Rose
TestWidget.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include "Button.h"
11 #include "Visual.h"
12 
13 namespace rose {
14 
19  class TestWidget : public Widget {
20  protected:
21  color::RGBA mColor;
22  ButtonSemantics mButtonSemantics;
23 
24  public:
25  TestWidget() : mButtonSemantics(static_cast<Widget&>(*this)) {
26  mButtonSemantics.setButtonDisplayCallback([](ButtonDisplayState buttonDisplayState){
27  switch (buttonDisplayState) {
29  std::cout << __PRETTY_FUNCTION__ << " Active\n";
30  break;
32  std::cout << __PRETTY_FUNCTION__ << " Inactive\n";
33  break;
35  std::cout << __PRETTY_FUNCTION__ << " Pressed Inactive\n";
36  break;
38  std::cout << __PRETTY_FUNCTION__ << " Pressed Active\n";
39  break;
40  }
41  });
42  }
43 
44  ~TestWidget() override = default;
45 
46  TestWidget(const TestWidget &) = delete;
47 
48  TestWidget(TestWidget &&) = delete;
49 
50  TestWidget &operator=(const TestWidget &) = delete;
51 
52  TestWidget &operator=(TestWidget &&) = delete;
53 
54  explicit TestWidget(color::RGBA c) : TestWidget() {
55  mSemanticGesture = SemanticGesture::Key | SemanticGesture::Click | SemanticGesture::Scroll | SemanticGesture::Drag;
56  mColor = c;
57  }
58 
59  TestWidget(Size size, color::RGBA c) : TestWidget() {
60  mSemanticGesture = SemanticGesture::Key | SemanticGesture::Click | SemanticGesture::Scroll | SemanticGesture::Drag;
61  mPreferredSize = size;
62  mColor = c;
63  }
64 
65  static constexpr std::string_view id = "TestWidget";
66  std::string_view nodeId() const noexcept override {
67  return id;
68  }
69 
71  void draw(gm::Context &context, const Position<int>& containerPosition) override {
72  Rectangle dst{containerPosition + mPos, mSize};
73  context.fillRect(dst, mColor);
74  }
75 
77  Rectangle layout(rose::gm::Context &context, const Rectangle &screenRect) override {
79  }
80  };
81 
82 }
83 
int fillRect(Rectangle rect, color::RGBA color)
Render a filled Rectangle.
Definition: GraphicsModel.cpp:113
Red Green Blue Alpha representation of a color.
Definition: Color.h:64
Position< int > mPos
Position relative to the container, arrived at by layout.
Definition: Visual.h:134
Interpret interaction events to drive button operation semantics.
Definition: PointerInteractions.h:31
Rectangle layout(rose::gm::Context &context, const Rectangle &screenRect) override
Layout the visual.
Definition: TestWidget.h:77
ButtonDisplayState
The visible state a button is in.
Definition: Callbacks.h:21
Context
Definition: GraphicsModel.h:76
Definition: TestWidget.h:19
User pressed the button in the Active state.
User pressed the button in the Inactive state.
void setButtonDisplayCallback(ButtonDisplayCallback buttonDisplayCallback)
Set the ButtonDisplayCallback function.
Definition: PointerInteractions.h:79
A composite of a Position and a Size.
Definition: Types.h:307
An element of the application user interface.
Definition: Visual.h:451
A size in integer dimensions.
Definition: Types.h:230
Button is active (pushed, toggled on, etc).
Size mSize
The size on screen, arrived at by layout.
Definition: Visual.h:135
void draw(gm::Context &context, const Position< int > &containerPosition) override
Draw the visual.
Definition: TestWidget.h:71
Size mPreferredSize
The preferred size.
Definition: Visual.h:137
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13
User Interface Visual types.
Button is inactive (not pushed, toggled off, etc).
Position< int > mPreferredPos
The preferred position.
Definition: Visual.h:136