2019-09-04 18:26:26 +02:00
|
|
|
#pragma once
|
2022-06-14 16:45:45 +02:00
|
|
|
|
|
|
|
|
#include <FancyZonesLib/FancyZonesDataTypes.h>
|
2022-10-31 13:44:25 +02:00
|
|
|
#include <FancyZonesLib/Layout.h>
|
|
|
|
|
#include <FancyZonesLib/LayoutAssignedWindows.h>
|
2022-06-14 16:45:45 +02:00
|
|
|
|
|
|
|
|
class ZonesOverlay;
|
|
|
|
|
|
|
|
|
|
class WorkArea
|
2019-09-04 18:26:26 +02:00
|
|
|
{
|
2023-01-23 20:13:05 +03:00
|
|
|
WorkArea(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& uniqueId, const FancyZonesUtils::Rect& workAreaRect);
|
2022-06-14 16:45:45 +02:00
|
|
|
|
|
|
|
|
public:
|
2023-01-31 12:55:46 +03:00
|
|
|
~WorkArea();
|
|
|
|
|
|
|
|
|
|
static std::unique_ptr<WorkArea> Create(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& uniqueId, const FancyZonesDataTypes::WorkAreaId& parentUniqueId, const FancyZonesUtils::Rect& workAreaRect)
|
|
|
|
|
{
|
|
|
|
|
auto self = std::unique_ptr<WorkArea>(new WorkArea(hinstance, uniqueId, workAreaRect));
|
|
|
|
|
if (!self->Init(hinstance, parentUniqueId))
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-09 14:41:14 +00:00
|
|
|
inline bool Init([[maybe_unused]] HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& parentUniqueId)
|
2022-08-15 16:40:10 +03:00
|
|
|
{
|
|
|
|
|
#ifndef UNIT_TESTS
|
|
|
|
|
if (!InitWindow(hinstance))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
InitLayout(parentUniqueId);
|
2023-01-31 12:55:46 +03:00
|
|
|
InitSnappedWindows();
|
|
|
|
|
|
2022-08-15 16:40:10 +03:00
|
|
|
return true;
|
|
|
|
|
}
|
2023-01-31 12:55:46 +03:00
|
|
|
|
2022-07-01 17:29:02 +02:00
|
|
|
FancyZonesDataTypes::WorkAreaId UniqueId() const noexcept { return { m_uniqueId }; }
|
2022-10-31 13:44:25 +02:00
|
|
|
const std::unique_ptr<Layout>& GetLayout() const noexcept { return m_layout; }
|
|
|
|
|
const std::unique_ptr<LayoutAssignedWindows>& GetLayoutWindows() const noexcept { return m_layoutWindows; }
|
2023-01-30 19:39:46 +03:00
|
|
|
const HWND GetWorkAreaWindow() const noexcept { return m_window; }
|
2022-06-14 16:45:45 +02:00
|
|
|
|
2023-01-31 12:55:46 +03:00
|
|
|
ZoneIndexSet GetWindowZoneIndexes(HWND window) const;
|
|
|
|
|
|
|
|
|
|
void MoveWindowIntoZoneByIndex(HWND window, ZoneIndex index);
|
|
|
|
|
void MoveWindowIntoZoneByIndexSet(HWND window, const ZoneIndexSet& indexSet, bool updatePosition = true);
|
|
|
|
|
bool MoveWindowIntoZoneByDirectionAndIndex(HWND window, DWORD vkCode, bool cycle);
|
|
|
|
|
bool MoveWindowIntoZoneByDirectionAndPosition(HWND window, DWORD vkCode, bool cycle);
|
|
|
|
|
bool ExtendWindowByDirectionAndPosition(HWND window, DWORD vkCode);
|
2022-11-09 14:41:14 +00:00
|
|
|
|
2023-02-06 17:15:19 +01:00
|
|
|
void SnapWindow(HWND window, const ZoneIndexSet& zones, bool extend = false);
|
2023-01-31 12:55:46 +03:00
|
|
|
void UnsnapWindow(HWND window);
|
2022-11-09 14:41:14 +00:00
|
|
|
|
2023-01-31 12:55:46 +03:00
|
|
|
void UpdateActiveZoneSet();
|
2023-02-06 17:15:19 +01:00
|
|
|
void UpdateWindowPositions();
|
2022-06-14 16:45:45 +02:00
|
|
|
|
2023-01-30 19:39:46 +03:00
|
|
|
void ShowZonesOverlay(const ZoneIndexSet& highlight, HWND draggedWindow = nullptr);
|
|
|
|
|
void HideZonesOverlay();
|
|
|
|
|
void FlashZones();
|
2022-06-14 16:45:45 +02:00
|
|
|
|
2023-01-31 12:55:46 +03:00
|
|
|
void CycleWindows(HWND window, bool reverse);
|
2022-06-14 16:45:45 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
static LRESULT CALLBACK s_WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) noexcept;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-01-31 12:55:46 +03:00
|
|
|
bool InitWindow(HINSTANCE hinstance);
|
|
|
|
|
void InitLayout(const FancyZonesDataTypes::WorkAreaId& parentUniqueId);
|
|
|
|
|
void InitSnappedWindows();
|
|
|
|
|
|
|
|
|
|
void CalculateZoneSet();
|
2023-01-30 19:39:46 +03:00
|
|
|
void SetWorkAreaWindowAsTopmost(HWND draggedWindow) noexcept;
|
2022-06-14 16:45:45 +02:00
|
|
|
|
2023-01-31 12:55:46 +03:00
|
|
|
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept;
|
|
|
|
|
|
2023-01-23 20:13:05 +03:00
|
|
|
const FancyZonesUtils::Rect m_workAreaRect{};
|
2022-08-15 16:40:10 +03:00
|
|
|
const FancyZonesDataTypes::WorkAreaId m_uniqueId;
|
2022-06-14 16:45:45 +02:00
|
|
|
HWND m_window{}; // Hidden tool window used to represent current monitor desktop work area.
|
2022-10-31 13:44:25 +02:00
|
|
|
std::unique_ptr<Layout> m_layout;
|
|
|
|
|
std::unique_ptr<LayoutAssignedWindows> m_layoutWindows;
|
2022-06-14 16:45:45 +02:00
|
|
|
std::unique_ptr<ZonesOverlay> m_zonesOverlay;
|
2019-09-04 18:26:26 +02:00
|
|
|
};
|