2019-09-05 00:26:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Zone.h"
|
2020-07-22 16:39:13 +08:00
|
|
|
|
|
|
|
namespace FancyZonesDataTypes
|
|
|
|
{
|
|
|
|
enum class ZoneSetLayoutType;
|
|
|
|
}
|
2019-09-05 00:26:26 +08:00
|
|
|
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Class representing single zone layout. ZoneSet is responsible for actual calculation of rectangle coordinates
|
|
|
|
* (whether is grid or canvas layout) and moving windows through them.
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : public IUnknown
|
|
|
|
{
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* @returns Unique identifier of zone layout.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(GUID, Id)() const = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* @returns Type of the zone layout. Layout type can be focus, columns, rows, grid, priority grid or custom.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(FancyZonesDataTypes::ZoneSetLayoutType, LayoutType)() const = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Add zone to the zone layout.
|
|
|
|
*
|
|
|
|
* @param zone Zone object (defining coordinates of the zone).
|
|
|
|
*/
|
2019-11-19 07:29:42 +08:00
|
|
|
IFACEMETHOD(AddZone)(winrt::com_ptr<IZone> zone) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
2020-04-10 22:09:08 +08:00
|
|
|
* Get zones from cursor coordinates.
|
2020-03-10 02:22:53 +08:00
|
|
|
*
|
|
|
|
* @param pt Cursor coordinates.
|
2020-04-10 22:09:08 +08:00
|
|
|
* @returns Vector of indices, corresponding to the current set of zones - the zones considered active.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(std::vector<size_t>, ZonesFromPoint)(POINT pt) const = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
2020-05-26 22:01:12 +08:00
|
|
|
* Get index set of the zones to which the window was assigned.
|
2020-03-10 02:22:53 +08:00
|
|
|
*
|
2020-05-26 22:01:12 +08:00
|
|
|
* @param window Handle of the window.
|
2020-10-16 21:25:30 +08:00
|
|
|
* @returns A vector of size_t, 0-based index set.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(std::vector<size_t>, GetZoneIndexSetFromWindow)
|
|
|
|
(HWND window) const = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* @returns Array of zone objects (defining coordinates of the zone) inside this zone layout.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(std::vector<winrt::com_ptr<IZone>>, GetZones)() const = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Assign window to the zone based on zone index inside zone layout.
|
|
|
|
*
|
2020-10-16 21:25:30 +08:00
|
|
|
* @param window Handle of window which should be assigned to zone.
|
|
|
|
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
|
|
|
|
* current monitor desktop work area.
|
|
|
|
* @param index Zone index within zone layout.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)
|
|
|
|
(HWND window, HWND workAreaWindow, size_t index) = 0;
|
2020-04-10 22:09:08 +08:00
|
|
|
/**
|
|
|
|
* Assign window to the zones based on the set of zone indices inside zone layout.
|
|
|
|
*
|
2020-10-16 21:25:30 +08:00
|
|
|
* @param window Handle of window which should be assigned to zone.
|
|
|
|
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
|
|
|
|
* current monitor desktop work area.
|
|
|
|
* @param indexSet The set of zone indices within zone layout.
|
2020-04-10 22:09:08 +08:00
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet)
|
|
|
|
(HWND window, HWND workAreaWindow, const std::vector<size_t>& indexSet) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
2020-08-21 18:53:03 +08:00
|
|
|
* Assign window to the zone based on direction (using WIN + LEFT/RIGHT arrow), based on zone index numbers,
|
|
|
|
* not their on-screen position.
|
2020-03-10 02:22:53 +08:00
|
|
|
*
|
2020-10-16 21:25:30 +08:00
|
|
|
* @param window Handle of window which should be assigned to zone.
|
|
|
|
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
|
|
|
|
* current monitor desktop work area.
|
|
|
|
* @param vkCode Pressed arrow key.
|
|
|
|
* @param cycle Whether we should move window to the first zone if we reached last zone in layout.
|
2020-03-25 01:50:26 +08:00
|
|
|
*
|
|
|
|
* @returns Boolean which is always true if cycle argument is set, otherwise indicating if there is more
|
|
|
|
* zones left in the zone layout in which window can move.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirectionAndIndex)
|
|
|
|
(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) = 0;
|
2020-08-21 18:53:03 +08:00
|
|
|
/**
|
|
|
|
* Assign window to the zone based on direction (using WIN + LEFT/RIGHT/UP/DOWN arrow), based on
|
|
|
|
* their on-screen position.
|
|
|
|
*
|
2020-10-16 21:25:30 +08:00
|
|
|
* @param window Handle of window which should be assigned to zone.
|
|
|
|
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
|
|
|
|
* current monitor desktop work area.
|
|
|
|
* @param vkCode Pressed arrow key.
|
|
|
|
* @param cycle Whether we should move window to the first zone if we reached last zone in layout.
|
2020-08-21 18:53:03 +08:00
|
|
|
*
|
|
|
|
* @returns Boolean which is always true if cycle argument is set, otherwise indicating if there is more
|
|
|
|
* zones left in the zone layout in which window can move.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirectionAndPosition)
|
|
|
|
(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) = 0;
|
2020-09-11 17:32:45 +08:00
|
|
|
/**
|
|
|
|
* Extend or shrink the window to an adjacent zone based on direction (using CTRL+WIN+ALT + LEFT/RIGHT/UP/DOWN arrow), based on
|
|
|
|
* their on-screen position.
|
|
|
|
*
|
2020-10-16 21:25:30 +08:00
|
|
|
* @param window Handle of window which should be assigned to zone.
|
|
|
|
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
|
|
|
|
* current monitor desktop work area.
|
|
|
|
* @param vkCode Pressed arrow key.
|
2020-09-11 17:32:45 +08:00
|
|
|
*
|
|
|
|
* @returns Boolean indicating whether the window was rezoned. False could be returned when there are no more
|
|
|
|
* zones available in the given direction.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(bool, ExtendWindowByDirectionAndPosition)
|
|
|
|
(HWND window, HWND workAreaWindow, DWORD vkCode) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Assign window to the zone based on cursor coordinates.
|
|
|
|
*
|
2020-10-16 21:25:30 +08:00
|
|
|
* @param window Handle of window which should be assigned to zone.
|
|
|
|
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
|
|
|
|
* current monitor desktop work area.
|
|
|
|
* @param pt Cursor coordinates.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(void, MoveWindowIntoZoneByPoint)
|
|
|
|
(HWND window, HWND workAreaWindow, POINT ptClient) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
2020-10-16 21:25:30 +08:00
|
|
|
* Calculate zone coordinates within zone layout based on number of zones and spacing.
|
2020-03-10 02:22:53 +08:00
|
|
|
*
|
2020-08-07 16:06:25 +08:00
|
|
|
* @param workAreaRect The rectangular area on the screen on which the zone layout is applied.
|
|
|
|
* @param zoneCount Number of zones inside zone layout.
|
|
|
|
* @param spacing Spacing between zones in pixels.
|
2020-03-25 01:50:26 +08:00
|
|
|
*
|
|
|
|
* @returns Boolean indicating if calculation was successful.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-08-07 16:06:25 +08:00
|
|
|
IFACEMETHOD_(bool, CalculateZones)(RECT workAreaRect, int zoneCount, int spacing) = 0;
|
2020-05-26 22:01:12 +08:00
|
|
|
/**
|
2020-10-16 21:25:30 +08:00
|
|
|
* Check if the zone with the specified index is empty. Returns true if the zone with passed zoneIndex does not exist.
|
2020-05-26 22:01:12 +08:00
|
|
|
*
|
|
|
|
* @param zoneIndex The index of of the zone within this zone set.
|
|
|
|
*
|
|
|
|
* @returns Boolean indicating whether the zone is empty.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(bool, IsZoneEmpty)(int zoneIndex) const = 0;
|
2020-09-11 17:32:45 +08:00
|
|
|
/**
|
|
|
|
* Returns all zones spanned by the minimum bounding rectangle containing the two given zone index sets.
|
|
|
|
*
|
|
|
|
* @param initialZones The indices of the first chosen zone (the anchor).
|
|
|
|
* @param finalZones The indices of the last chosen zone (the current window position).
|
|
|
|
*
|
|
|
|
* @returns A vector indicating describing the chosen zone index set.
|
|
|
|
*/
|
2020-10-16 21:25:30 +08:00
|
|
|
IFACEMETHOD_(std::vector<size_t>, GetCombinedZoneRange)(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) const = 0;
|
2019-09-05 00:26:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ZoneSetConfig
|
|
|
|
{
|
|
|
|
ZoneSetConfig(
|
|
|
|
GUID id,
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::ZoneSetLayoutType layoutType,
|
2020-09-18 15:16:06 +08:00
|
|
|
HMONITOR monitor,
|
|
|
|
int sensitivityRadius) noexcept :
|
2019-09-05 00:26:26 +08:00
|
|
|
Id(id),
|
2020-02-10 21:59:51 +08:00
|
|
|
LayoutType(layoutType),
|
2020-09-18 15:16:06 +08:00
|
|
|
Monitor(monitor),
|
|
|
|
SensitivityRadius(sensitivityRadius)
|
2019-09-05 00:26:26 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GUID Id{};
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::ZoneSetLayoutType LayoutType{};
|
2019-09-05 00:26:26 +08:00
|
|
|
HMONITOR Monitor{};
|
2020-09-18 15:16:06 +08:00
|
|
|
int SensitivityRadius;
|
2019-09-05 00:26:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
winrt::com_ptr<IZoneSet> MakeZoneSet(ZoneSetConfig const& config) noexcept;
|