#pragma once
#include <nbind/api.h>
#include <nbind/nbind.h>
#include "TaskbarThread.h"

class TakbarInstance
{
	friend class Taskbar;

	void AddReference();
	void RemoveReference();

	std::unique_ptr<TaskbarThread> m_Thread = nullptr; // TODO: To constructor
	int m_References = 0;
};

// All values in here are thread safe
class Taskbar
{
public:
	Taskbar();
	~Taskbar();

	std::vector<App> getAllApps(bool grouped = false);

	void bringAppToTop(UINT hwndRaw) {
		HWND hwnd = (HWND)hwndRaw;
		SwitchToThisWindow(hwnd, true);
        SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
	}

	// Non-copyable
	Taskbar(Taskbar const&) = delete;
	void operator=(Taskbar const&) = delete;

private:
	static TakbarInstance& GetTaskbarInstance();
};

NBIND_CLASS(Taskbar) {
	construct();
	method(getAllApps);
	method(bringAppToTop);
}