aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/controls
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/ui/controls')
-rw-r--r--include/cru/ui/controls/Button.hpp4
-rw-r--r--include/cru/ui/controls/LayoutControl.hpp2
-rw-r--r--include/cru/ui/controls/TextHostControlService.hpp20
3 files changed, 26 insertions, 0 deletions
diff --git a/include/cru/ui/controls/Button.hpp b/include/cru/ui/controls/Button.hpp
index 9e324c62..e0335a39 100644
--- a/include/cru/ui/controls/Button.hpp
+++ b/include/cru/ui/controls/Button.hpp
@@ -39,6 +39,10 @@ class Button : public ContentControl,
return click_detector_.StateChangeEvent();
}
+ IEvent<helper::ClickEventArgs>* ClickEvent() {
+ return click_detector_.ClickEvent();
+ }
+
void ApplyBorderStyle(const style::ApplyBorderStyleInfo& style) override;
private:
diff --git a/include/cru/ui/controls/LayoutControl.hpp b/include/cru/ui/controls/LayoutControl.hpp
index 106dd94d..381df1df 100644
--- a/include/cru/ui/controls/LayoutControl.hpp
+++ b/include/cru/ui/controls/LayoutControl.hpp
@@ -18,6 +18,8 @@ class LayoutControl : public Control {
using Control::AddChild;
using Control::RemoveChild;
+ void ClearChildren();
+
protected:
// If container render object is not null. Render object of added or removed
// child control will automatically sync to the container render object.
diff --git a/include/cru/ui/controls/TextHostControlService.hpp b/include/cru/ui/controls/TextHostControlService.hpp
index 6ebe2a27..5216827b 100644
--- a/include/cru/ui/controls/TextHostControlService.hpp
+++ b/include/cru/ui/controls/TextHostControlService.hpp
@@ -15,6 +15,10 @@ class TextRenderObject;
class ScrollRenderObject;
} // namespace cru::ui::render
+namespace cru::ui::components {
+class PopupMenu;
+}
+
namespace cru::ui::controls {
constexpr int k_default_caret_blink_duration = 500;
@@ -86,6 +90,9 @@ class TextHostControlService : public Object {
bool IsEditable() { return this->editable_; }
void SetEditable(bool editable);
+ bool IsContextMenuEnabled() { return this->context_menu_enabled_; }
+ void SetContextMenuEnabled(bool enabled);
+
bool IsMultiLine() { return this->multi_line_; }
// If text contains line feed characters, it will be converted to space.
void SetMultiLine(bool multi_line);
@@ -169,6 +176,15 @@ class TextHostControlService : public Object {
void SetUpShortcuts();
+ enum ContextMenuItem : unsigned {
+ kSelectAll = 0b1,
+ kCut = 0b10,
+ kCopy = 0b100,
+ kPaste = 0b1000
+ };
+
+ void OpenContextMenu(const Point& position, ContextMenuItem items);
+
private:
gsl::not_null<Control*> control_;
gsl::not_null<ITextHostControl*> text_host_control_;
@@ -182,6 +198,7 @@ class TextHostControlService : public Object {
bool enable_ = false;
bool editable_ = false;
bool multi_line_ = false;
+ bool context_menu_enabled_ = true;
bool caret_visible_ = false;
platform::gui::TimerAutoCanceler caret_timer_canceler_;
@@ -191,5 +208,8 @@ class TextHostControlService : public Object {
// true if left mouse is down and selecting
bool mouse_move_selecting_ = false;
+
+ bool context_menu_dirty_ = true;
+ std::unique_ptr<components::PopupMenu> context_menu_;
};
} // namespace cru::ui::controls