The window reports a PlatformInfo: operating system and version, device name, whether it is a desktop, tablet or phone, content scale, screen size, which input devices are present, and whether the window can be moved, resized or has window controls. WindowHost passes it to widgets. The menu bar hides the window buttons and ignores window drags where the platform has no such window, as on Android tablets and phones. The description is logged on Android at startup.
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "WindowHost.hpp"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace tp::ui {
|
|
|
|
class FakeWindowHost : public WindowHost {
|
|
public:
|
|
FakeWindowHost() {
|
|
platform.formFactor = FormFactor::Desktop;
|
|
platform.hasWindowControls = true;
|
|
platform.canMoveWindow = true;
|
|
platform.canResizeWindow = true;
|
|
}
|
|
|
|
[[nodiscard]] PlatformInfo platformInfo() const override { return platform; }
|
|
void minimizeWindow() override { minimizeCount++; }
|
|
void toggleMaximizeWindow() override {
|
|
toggleMaximizeCount++;
|
|
maximized = !maximized;
|
|
}
|
|
void closeWindow() override { closeCount++; }
|
|
[[nodiscard]] bool isWindowMaximized() const override { return maximized; }
|
|
void beginWindowMove() override { moveCount++; }
|
|
void showWindowMenu(Vec2F windowPoint) override {
|
|
windowMenuCount++;
|
|
windowMenuPoint = windowPoint;
|
|
}
|
|
void setCursor(CursorShape shape) override { cursors.push_back(shape); }
|
|
void setClipboardText(const std::string& text) override { clipboard = text; }
|
|
[[nodiscard]] std::string clipboardText() override { return clipboard; }
|
|
void setTextInputArea(const RectF* windowRect) override {
|
|
textInputEnabled = windowRect != nullptr;
|
|
if (windowRect) textInputRect = *windowRect;
|
|
}
|
|
|
|
PlatformInfo platform;
|
|
int minimizeCount = 0;
|
|
int toggleMaximizeCount = 0;
|
|
int closeCount = 0;
|
|
int moveCount = 0;
|
|
int windowMenuCount = 0;
|
|
Vec2F windowMenuPoint = { 0, 0 };
|
|
bool maximized = false;
|
|
std::vector<CursorShape> cursors;
|
|
std::string clipboard;
|
|
bool textInputEnabled = false;
|
|
RectF textInputRect = makeRect(0, 0, 0, 0);
|
|
};
|
|
}
|