HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
ButtonWidget.hpp
1// Copyright 2019 Pokitec
2// All rights reserved.
3
4#pragma once
5
6#include "TTauri/Widgets/Widget.hpp"
7#include <rhea/constraint.hpp>
8#include <memory>
9#include <string>
10#include <array>
11#include <optional>
12#include <future>
13
14namespace tt {
15
16class ButtonWidget : public Widget {
17protected:
18 bool value = false;
19 bool pressed = false;
20
21 std::string label = "<unknown>";
22
23 ShapedText labelShapedText;
24 mat::T textTranslate;
25public:
26
27 ButtonWidget(Window &window, Widget *parent, std::string const label) noexcept;
29
30 ButtonWidget(const ButtonWidget &) = delete;
31 ButtonWidget &operator=(const ButtonWidget &) = delete;
32 ButtonWidget(ButtonWidget&&) = delete;
33 ButtonWidget &operator=(ButtonWidget &&) = delete;
34
35 void layout(hires_utc_clock::time_point displayTimePoint) noexcept override;
36
37 void draw(DrawContext const &drawContext, hires_utc_clock::time_point displayTimePoint) noexcept override;
38
39 void handleMouseEvent(MouseEvent const &event) noexcept override;
40 void handleCommand(string_ltag command) noexcept override;
41
42 [[nodiscard]] HitBox hitBoxTest(vec position) const noexcept override;
43 [[nodiscard]] bool acceptsFocus() const noexcept override {
44 return *enabled;
45 }
46
47};
48
49}
Optimized translate matrix.
Definition mat.hpp:119
A 4D vector.
Definition vec.hpp:37
Draw context for drawing using the TTauri shaders.
Definition DrawContext.hpp:30
Definition HitBox.hpp:12
Definition MouseEvent.hpp:12
Definition Window_vulkan_win32.hpp:15
ShapedText represent a piece of text shaped to be displayed.
Definition ShapedText.hpp:21
Definition ButtonWidget.hpp:16
bool acceptsFocus() const noexcept override
Check if the widget will accept keyboard focus.
Definition ButtonWidget.hpp:43
HitBox hitBoxTest(vec position) const noexcept override
Find the widget that is under the mouse cursor.
void handleCommand(string_ltag command) noexcept override
Handle command.
void layout(hires_utc_clock::time_point displayTimePoint) noexcept override
Layout the widget.
void draw(DrawContext const &drawContext, hires_utc_clock::time_point displayTimePoint) noexcept override
Draw widget.
void handleMouseEvent(MouseEvent const &event) noexcept override
Definition Widget.hpp:64
observable< bool > enabled
The widget is enabled.
Definition Widget.hpp:150