bWidgets
Core widget toolkit designed for Blender
bwTextBox.h
Go to the documentation of this file.
1#pragma once
2
3#include "bwWidget.h"
4#include "bwWidgetBaseStyle.h"
5
6namespace bWidgets {
7
8class bwTextBox : public bwWidget {
9 friend class bwTextBoxHandler;
10
11 public:
12 bwTextBox(std::optional<unsigned int> width_hint = std::nullopt,
13 std::optional<unsigned int> height_hint = std::nullopt);
14
15 auto getTypeIdentifier() const -> std::string_view override;
16
17 void draw(class bwStyle& style) override;
18 void registerProperties() override;
19
20 auto setText(const std::string& value) -> bwTextBox&;
21 auto getLabel() const -> const std::string* override;
22
23 bool canAlign() const override;
24
25 auto createHandler() -> std::unique_ptr<bwScreenGraph::EventHandler> override;
26
28
29 protected:
30 std::string text;
31 bool is_text_editing = false;
32
33 public:
35 base_style; // XXX public for setWidgetStyle. Should only be temporarily needed.
36};
37
38class bwTextBoxHandler : public bwScreenGraph::EventHandler {
39 public:
41 virtual ~bwTextBoxHandler() = default;
42
43 void onMouseEnter(bwEvent&) override;
44 void onMouseLeave(bwEvent&) override;
45 void onMousePress(bwMouseButtonEvent&) override;
46
47 protected:
48 void startTextEditing();
49 void endTextEditing();
50
52 bool is_dragging = false;
53};
54
55} // namespace bWidgets
Definition: bwEvent.h:8
Definition: bwEvent.h:24
Definition: bwStyle.h:10
Definition: bwTextBox.h:38
bwTextBox & textbox
Definition: bwTextBox.h:51
virtual ~bwTextBoxHandler()=default
Definition: bwTextBox.h:8
bwTextBox(std::optional< unsigned int > width_hint=std::nullopt, std::optional< unsigned int > height_hint=std::nullopt)
Definition: bwTextBox.cc:9
auto createHandler() -> std::unique_ptr< bwScreenGraph::EventHandler > override
Definition: bwTextBox.cc:65
auto setText(const std::string &value) -> bwTextBox &
Definition: bwTextBox.cc:47
std::string text
Definition: bwTextBox.h:30
bwRectanglePixel selection_rectangle
Definition: bwTextBox.h:27
auto getLabel() const -> const std::string *override
Definition: bwTextBox.cc:53
auto getTypeIdentifier() const -> std::string_view override
Definition: bwTextBox.cc:16
void draw(class bwStyle &style) override
Definition: bwTextBox.cc:21
bool is_text_editing
Definition: bwTextBox.h:31
void registerProperties() override
Definition: bwTextBox.cc:42
bwWidgetBaseStyle base_style
Definition: bwTextBox.h:35
friend class bwTextBoxHandler
Definition: bwTextBox.h:9
bool canAlign() const override
Definition: bwTextBox.cc:58
Properties for typical widgets with roundbox corners.
Definition: bwWidgetBaseStyle.h:14
Abstract base class that all widgets derive from.
Definition: bwWidget.h:22
unsigned int height_hint
Definition: bwWidget.h:68
unsigned int width_hint
Definition: bwWidget.h:68
Definition: bwContext.h:3