TDME2  1.9.200
GUIHorizontalScrollbarInternalNode.cpp
Go to the documentation of this file.
2 
3 #include <array>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
15 #include <tdme/gui/GUI.h>
16 
17 using std::array;
18 using std::vector;
19 
22 using tdme::gui::nodes::GUIHorizontalScrollbarInternalController_State;
30 using tdme::gui::GUI;
31 
32 GUIHorizontalScrollbarInternalNode::GUIHorizontalScrollbarInternalNode(
33  GUIScreenNode* screenNode,
34  GUIParentNode* parentNode, const
35  string& id,
36  GUINode_Flow* flow,
37  const GUINode_Alignments& alignments,
38  const GUINode_RequestedConstraints& requestedConstraints,
39  const GUIColor& backgroundColor,
40  const string& backgroundImage,
41  const GUINode_Scale9Grid& backgroundImageScale9Grid,
42  const GUIColor& backgroundImageEffectColorMul,
43  const GUIColor& backgroundImageEffectColorAdd,
44  const GUINode_Border& border,
45  const GUINode_Padding& padding,
46  const GUINodeConditions& showOn,
47  const GUINodeConditions& hideOn,
48  const string& tooltip,
49  const GUIColor& barColorNone,
50  const GUIColor& barColorMouseOver,
51  const GUIColor& barColorDragging
52  ):
53  GUINode(screenNode, parentNode, id, flow, alignments, requestedConstraints, backgroundColor, backgroundImage, backgroundImageScale9Grid, backgroundImageEffectColorMul, backgroundImageEffectColorAdd, border, padding, showOn, hideOn, tooltip)
54 {
56  controller->initialize();
58  //
59  this->barColorNone = barColorNone;
60  this->barColorMouseOver = barColorMouseOver;
61  this->barColorDragging = barColorDragging;
62 }
63 
65 {
66  return "scrollbar";
67 }
68 
70 {
71  return false;
72 }
73 
75 {
77 }
78 
80 {
82 }
83 
85 {
86  if (shouldRender() == false) return;
87 
88  GUINode::render(guiRenderer);
89  auto screenWidth = screenNode->getScreenWidth();
90  auto screenHeight = screenNode->getScreenHeight();
91  auto controller = required_dynamic_cast<GUIHorizontalScrollbarInternalController*>(this->getController());
92  auto barWidth = controller->getBarWidth();
93  auto barLeft = controller->getBarLeft();
94  auto left = barLeft;
96  auto width = barWidth;
97  float height = computedConstraints.height - border.top - border.bottom;
98  array<float, 4> barColorArray;
99  {
100  auto state = controller->getState();
102  barColorArray = barColorNone.getArray();
103  } else
105  barColorArray = barColorMouseOver.getArray();
106  } else
108  barColorArray = barColorDragging.getArray();
109  }
110  }
111  guiRenderer->bindTexture(0);
112  guiRenderer->addQuad(
113  ((left) / (screenWidth / 2.0f)) - 1.0f,
114  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
115  barColorArray[0],
116  barColorArray[1],
117  barColorArray[2],
118  barColorArray[3],
119  0.0f,
120  1.0f,
121  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
122  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
123  barColorArray[0],
124  barColorArray[1],
125  barColorArray[2],
126  barColorArray[3],
127  1.0f,
128  1.0f,
129  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
130  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
131  barColorArray[0],
132  barColorArray[1],
133  barColorArray[2],
134  barColorArray[3],
135  1.0f,
136  0.0f,
137  ((left) / (screenWidth / 2.0f)) - 1.0f,
138  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
139  barColorArray[0],
140  barColorArray[1],
141  barColorArray[2],
142  barColorArray[3],
143  0.0f,
144  0.0f
145  );
146  guiRenderer->render();
147 }
148 
const array< float, 4 > & getArray() const
Definition: Color4.h:262
GUI module class.
Definition: GUI.h:64
GUI element node conditions.
GUI node controller base class.
GUI node base class.
Definition: GUINode.h:64
GUINode_Border border
Definition: GUINode.h:160
virtual void render(GUIRenderer *guiRenderer)
Render.
Definition: GUINode.cpp:509
unique_ptr< GUINodeController > controller
Definition: GUINode.h:163
GUINode_ComputedConstraints computedConstraints
Definition: GUINode.h:152
GUINodeController * getController()
Definition: GUINode.h:661
GUIScreenNode * screenNode
Definition: GUINode.h:147
bool shouldRender()
Returns if to render.
Definition: GUINode.h:302
void setController(GUINodeController *controller)
Set up node controller.
Definition: GUINode.cpp:1046
friend class GUIHorizontalScrollbarInternalController
Definition: GUINode.h:75
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:42
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
void bindTexture(int32_t textureId)
Bind texture.
void addQuad(float x1, float y1, float colorR1, float colorG1, float colorB1, float colorA1, float tu1, float tv1, float x2, float y2, float colorR2, float colorG2, float colorB2, float colorA2, float tu2, float tv2, float x3, float y3, float colorR3, float colorG3, float colorB3, float colorA3, float tu3, float tv3, float x4, float y4, float colorR4, float colorG4, float colorB4, float colorA4, float tu4, float tv4, bool solidColor=false, bool rotated=false)
Add quad Note: quad vertices order 1 2 +-—+ | | | | +-—+ 4 3.
Definition: GUIRenderer.h:507
GUI node border entity.
GUI node padding entity.
GUI node scale 9 grid entity.