TDME2  1.9.200
GUITextureBaseNode.cpp
Go to the documentation of this file.
2 
3 #include <tdme/tdme.h>
4 #include <tdme/engine/Texture.h>
6 #include <tdme/engine/Engine.h>
16 #include <tdme/math/Matrix3x3.h>
17 #include <tdme/math/Vector2.h>
18 #include <tdme/utilities/Float.h>
20 
22 
39 
40 GUITextureBaseNode::GUITextureBaseNode(
41  GUIScreenNode* screenNode,
42  GUIParentNode* parentNode,
43  const string& id,
44  GUINode_Flow* flow,
45  const GUINode_Alignments& alignments,
46  const GUINode_RequestedConstraints& requestedConstraints,
47  const GUIColor& backgroundColor,
48  const string& backgroundImage,
49  const GUINode_Scale9Grid& backgroundImageScale9Grid,
50  const GUIColor& backgroundImageEffectColorMul,
51  const GUIColor& backgroundImageEffectColorAdd,
52  const GUINode_Border& border,
53  const GUINode_Padding& padding,
54  const GUINodeConditions& showOn,
55  const GUINodeConditions& hideOn,
56  const string& tooltip,
57  const RequestedDimensionConstraints& requestedDimensionConstraints,
58  bool mirrorX,
59  bool mirrorY,
60  const GUIColor& effectColorMul,
61  const GUIColor& effectColorAdd,
62  const GUINode_Scale9Grid& scale9Grid,
63  const GUINode_Clipping& clipping,
64  const string& mask,
65  float maskMaxValue):
66  GUINode(screenNode, parentNode, id, flow, alignments, requestedConstraints, backgroundColor, backgroundImage, backgroundImageScale9Grid, backgroundImageEffectColorMul, backgroundImageEffectColorAdd, border, padding, showOn, hideOn, tooltip)
67 {
68  this->requestedDimensionConstraints = requestedDimensionConstraints;
69  this->mirrorX = mirrorX;
70  this->mirrorY = mirrorY;
71  this->effectColorMul = effectColorMul;
72  this->effectColorAdd = effectColorAdd;
73  this->scale9Grid = scale9Grid;
74  this->textureMatrix.identity();
75  this->clipping = clipping;
76  this->setMask(mask);
77  this->maskMaxValue = maskMaxValue;
79  mirrorTextureMatrix.scale(Vector2(mirrorX == true?-1.0f:1.0f, mirrorY == true?-1.0f:1.0f));
80  mirrorTextureMatrix.setTranslation(Vector2(mirrorX == true?1.0f:0.0f, mirrorY == true?1.0f:0.0f));
82 }
83 
85 {
86  return true;
87 }
88 
90 {
93  } else {
95  }
96 }
97 
99 {
102  } else {
104  }
105 }
106 
108 {
109  if (maskTexture != nullptr) Engine::getInstance()->getTextureManager()->removeTexture(maskTexture->getId());
111 }
112 
114 {
115  if (shouldRender() == false) return;
116 
117  //
118  GUINode::render(guiRenderer);
119 
120  // on render
121  onRenderTexture();
122 
123  // clipping
124  {
125  auto renderOffsetXCurrent = guiRenderer->getRenderOffsetX();
126  auto renderOffsetYCurrent = guiRenderer->getRenderOffsetY();
127  auto screenWidth = screenNode->getScreenWidth();
128  auto screenHeight = screenNode->getScreenHeight();
133  auto renderAreaLeft = ((left) / (screenWidth / 2.0f)) - renderOffsetXCurrent - 1.0f;
134  auto renderAreaTop = ((screenHeight - top) / (screenHeight / 2.0f)) + renderOffsetYCurrent - 1.0f;
135  auto renderAreaRight = ((left + width) / (screenWidth / 2.0f)) - renderOffsetXCurrent - 1.0f;
136  auto renderAreaBottom = ((screenHeight - top - height) / (screenHeight / 2.0f)) + renderOffsetYCurrent - 1.0f;
137  guiRenderer->setSubRenderAreaLeft(renderAreaLeft);
138  guiRenderer->setSubRenderAreaTop(renderAreaTop);
139  guiRenderer->setSubRenderAreaRight(renderAreaRight);
140  guiRenderer->setSubRenderAreaBottom(renderAreaBottom);
141  }
142 
143  // render texture if required
144  if (textureId != 0) {
145  if (maskTextureId != 0) {
146  guiRenderer->setMaskMaxValue(maskMaxValue);
147  guiRenderer->bindMask(maskTextureId);
148  }
149  auto screenWidth = screenNode->getScreenWidth();
150  auto screenHeight = screenNode->getScreenHeight();
151  guiRenderer->bindTexture(textureId);
152  guiRenderer->setTexureMatrix(textureMatrix);
153  guiRenderer->setEffectColorMul(effectColorMul);
154  guiRenderer->setEffectColorAdd(effectColorAdd);
155  if (scale9Grid.left == 0 &&
156  scale9Grid.right == 0 &&
157  scale9Grid.top == 0 &&
158  scale9Grid.bottom == 0) {
161  float width = getContentWidth() - padding.left - padding.right;
162  float height = getContentHeight() - padding.top - padding.bottom;
163  guiRenderer->addQuad(
164  ((left) / (screenWidth / 2.0f)) - 1.0f,
165  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
166  1.0f, 1.0f, 1.0f, 1.0f,
167  0.0f,
168  0.0f,
169  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
170  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
171  1.0f, 1.0f, 1.0f, 1.0f,
172  1.0f,
173  0.0f,
174  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
175  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
176  1.0f, 1.0f, 1.0f, 1.0f,
177  1.0f,
178  1.0f,
179  ((left) / (screenWidth / 2.0f)) - 1.0f,
180  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
181  1.0f, 1.0f, 1.0f, 1.0f,
182  0.0f,
183  1.0f
184  );
185  } else {
186  // TODO: padding
187  auto scaleX = 1.0f;
188  auto scaleY = 1.0f;
189  // we have a scale here, because we have a axis without "scale9grid"
190  if (scale9Grid.top == 0 && scale9Grid.bottom == 0) {
191  scaleY = (float)getContentHeight() / (float)textureHeight;
192  scaleX = scaleY;
193  } else
194  // we have a scale here, because we have a axis without "scale9grid"
195  if (scale9Grid.left == 0 && scale9Grid.right == 0) {
196  scaleX = (float)getContentWidth() / (float)textureWidth;
197  scaleY = scaleX;
198  } else {
199  // scale Y if content height is too small to fit scale 9 top and bottom
201  scaleY = getContentHeight() < Math::EPSILON?0.0f:(float)getContentHeight() / (float)(scale9Grid.top + scale9Grid.bottom);
202  }
203  // scale X if content width is too small to fit scale 9 left and top
205  scaleX = getContentWidth() < Math::EPSILON?0.0f:(float)getContentWidth() / (float)(scale9Grid.left + scale9Grid.right);
206  }
207  }
208  // we have no certain scale, take original image size
209  GUINode_Scale9Grid scaledScale9Grid;
210  scaledScale9Grid.left = static_cast<int>(scale9Grid.left * scaleX);
211  scaledScale9Grid.right = static_cast<int>(scale9Grid.right * scaleX);
212  scaledScale9Grid.top = static_cast<int>(scale9Grid.top * scaleY);
213  scaledScale9Grid.bottom = static_cast<int>(scale9Grid.bottom * scaleY);
216  float imageScreenScale9Left = imageScreenLeft + scaledScale9Grid.left;
217  float imageScreenScale9Top = imageScreenTop + scaledScale9Grid.top;
218  float imageScreenWidth = getContentWidth();
219  float imageScreenHeight = getContentHeight();
220  float imageScreenScale9Right = imageScreenLeft + imageScreenWidth - scaledScale9Grid.right;
221  float imageScreenScale9Bottom = imageScreenTop + imageScreenHeight - scaledScale9Grid.bottom;
222  float imageTextureWidth = textureWidth;
223  float imageTextureHeight = textureHeight;
224  // left top
225  if (scaledScale9Grid.left > 0 && scaledScale9Grid.top > 0) {
226  float left = imageScreenLeft;
227  float top = imageScreenTop;
228  float width = scaledScale9Grid.left;
229  float height = scaledScale9Grid.top;
230  guiRenderer->addQuad(
231  ((left) / (screenWidth / 2.0f)) - 1.0f,
232  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
233  1.0f, 1.0f, 1.0f, 1.0f,
234  0.0f,
235  0.0f,
236  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
237  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
238  1.0f, 1.0f, 1.0f, 1.0f,
239  1.0f / imageTextureWidth * scale9Grid.left,
240  0.0f,
241  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
242  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
243  1.0f, 1.0f, 1.0f, 1.0f,
244  1.0f / imageTextureWidth * scale9Grid.left,
245  1.0f / imageTextureHeight * scale9Grid.top,
246  ((left) / (screenWidth / 2.0f)) - 1.0f,
247  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
248  1.0f, 1.0f, 1.0f, 1.0f,
249  0.0f,
250  1.0f / imageTextureHeight * scale9Grid.top
251  );
252  }
253  // middle top
254  if (scaledScale9Grid.top > 0) {
255  float left = imageScreenScale9Left;
256  float top = imageScreenTop;
257  float width = imageScreenWidth - scaledScale9Grid.left - scaledScale9Grid.right;
258  float height = scaledScale9Grid.top;
259  guiRenderer->addQuad(
260  ((left) / (screenWidth / 2.0f)) - 1.0f,
261  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
262  1.0f, 1.0f, 1.0f, 1.0f,
263  1.0f / imageTextureWidth * scale9Grid.left,
264  0.0f,
265  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
266  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
267  1.0f, 1.0f, 1.0f, 1.0f,
268  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
269  0.0f,
270  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
271  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
272  1.0f, 1.0f, 1.0f, 1.0f,
273  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
274  1.0f / imageTextureHeight * scale9Grid.top,
275  ((left) / (screenWidth / 2.0f)) - 1.0f,
276  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
277  1.0f, 1.0f, 1.0f, 1.0f,
278  1.0f / imageTextureWidth * scale9Grid.left,
279  1.0f / imageTextureHeight * scale9Grid.top
280  );
281  }
282  // right top
283  if (scaledScale9Grid.right > 0 && scaledScale9Grid.top > 0) {
284  float left = imageScreenScale9Right;
285  float top = imageScreenTop;
286  float width = scaledScale9Grid.right;
287  float height = scaledScale9Grid.top;
288  guiRenderer->addQuad(
289  ((left) / (screenWidth / 2.0f)) - 1.0f,
290  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
291  1.0f, 1.0f, 1.0f, 1.0f,
292  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
293  0.0f,
294  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
295  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
296  1.0f, 1.0f, 1.0f, 1.0f,
297  1.0f,
298  0.0f,
299  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
300  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
301  1.0f, 1.0f, 1.0f, 1.0f,
302  1.0f,
303  1.0f / imageTextureHeight * scale9Grid.top,
304  ((left) / (screenWidth / 2.0f)) - 1.0f,
305  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
306  1.0f, 1.0f, 1.0f, 1.0f,
307  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
308  1.0f / imageTextureHeight * scale9Grid.top
309  );
310  }
311  // right bottom
312  if (scaledScale9Grid.right > 0 && scaledScale9Grid.bottom > 0) {
313  float left = imageScreenScale9Right;
314  float top = imageScreenScale9Bottom;
315  float width = scaledScale9Grid.right;
316  float height = scaledScale9Grid.bottom;
317  guiRenderer->addQuad(
318  ((left) / (screenWidth / 2.0f)) - 1.0f,
319  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
320  1.0f, 1.0f, 1.0f, 1.0f,
321  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
322  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
323  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
324  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
325  1.0f, 1.0f, 1.0f, 1.0f,
326  1.0f,
327  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
328  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
329  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
330  1.0f, 1.0f, 1.0f, 1.0f,
331  1.0f,
332  1.0f,
333  ((left) / (screenWidth / 2.0f)) - 1.0f,
334  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
335  1.0f, 1.0f, 1.0f, 1.0f,
336  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
337  1.0f
338  );
339  }
340  // middle bottom
341  if (scaledScale9Grid.bottom > 0) {
342  float left = imageScreenScale9Left;
343  float top = imageScreenScale9Bottom;
344  float width = imageScreenWidth - scaledScale9Grid.left - scaledScale9Grid.right;
345  float height = scaledScale9Grid.bottom;
346  guiRenderer->addQuad(
347  ((left) / (screenWidth / 2.0f)) - 1.0f,
348  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
349  1.0f, 1.0f, 1.0f, 1.0f,
350  1.0f / imageTextureWidth * scale9Grid.left,
351  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
352  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
353  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
354  1.0f, 1.0f, 1.0f, 1.0f,
355  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
356  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
357  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
358  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
359  1.0f, 1.0f, 1.0f, 1.0f,
360  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
361  1.0f,
362  ((left) / (screenWidth / 2.0f)) - 1.0f,
363  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
364  1.0f, 1.0f, 1.0f, 1.0f,
365  1.0f / imageTextureWidth * scale9Grid.left,
366  1.0f
367  );
368  }
369  // left bottom
370  if (scaledScale9Grid.left > 0 && scaledScale9Grid.bottom > 0) {
371  float left = imageScreenLeft;
372  float top = imageScreenScale9Bottom;
373  float width = scaledScale9Grid.left;
374  float height = scaledScale9Grid.bottom;
375  guiRenderer->addQuad(
376  ((left) / (screenWidth / 2.0f)) - 1.0f,
377  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
378  1.0f, 1.0f, 1.0f, 1.0f,
379  0.0f,
380  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
381  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
382  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
383  1.0f, 1.0f, 1.0f, 1.0f,
384  1.0f / imageTextureWidth * scale9Grid.left,
385  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
386  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
387  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
388  1.0f, 1.0f, 1.0f, 1.0f,
389  1.0f / imageTextureWidth * scale9Grid.left,
390  1.0f,
391  ((left) / (screenWidth / 2.0f)) - 1.0f,
392  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
393  1.0f, 1.0f, 1.0f, 1.0f,
394  0.0f,
395  1.0f
396  );
397  }
398  // left middle
399  if (scaledScale9Grid.left > 0) {
400  float left = imageScreenLeft;
401  float top = imageScreenScale9Top;
402  float width = scaledScale9Grid.left;
403  float height = imageScreenHeight - scaledScale9Grid.top - scaledScale9Grid.bottom;
404  guiRenderer->addQuad(
405  ((left) / (screenWidth / 2.0f)) - 1.0f,
406  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
407  1.0f, 1.0f, 1.0f, 1.0f,
408  0.0f,
409  1.0f / imageTextureHeight * scale9Grid.top,
410  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
411  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
412  1.0f, 1.0f, 1.0f, 1.0f,
413  1.0f / imageTextureWidth * scale9Grid.left,
414  1.0f / imageTextureHeight * scale9Grid.top,
415  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
416  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
417  1.0f, 1.0f, 1.0f, 1.0f,
418  1.0f / imageTextureWidth * scale9Grid.left,
419  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
420  ((left) / (screenWidth / 2.0f)) - 1.0f,
421  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
422  1.0f, 1.0f, 1.0f, 1.0f,
423  0.0f,
424  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom)
425  );
426  }
427  // right middle
428  if (scaledScale9Grid.right > 0) {
429  float left = imageScreenScale9Right;
430  float top = imageScreenScale9Top;
431  float width = scaledScale9Grid.right;
432  float height = imageScreenHeight - scaledScale9Grid.top - scaledScale9Grid.bottom;
433  guiRenderer->addQuad(
434  ((left) / (screenWidth / 2.0f)) - 1.0f,
435  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
436  1.0f, 1.0f, 1.0f, 1.0f,
437  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
438  1.0f / imageTextureHeight * scale9Grid.top,
439  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
440  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
441  1.0f, 1.0f, 1.0f, 1.0f,
442  1.0f,
443  1.0f / imageTextureHeight * scale9Grid.top,
444  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
445  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
446  1.0f, 1.0f, 1.0f, 1.0f,
447  1.0f,
448  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
449  ((left) / (screenWidth / 2.0f)) - 1.0f,
450  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
451  1.0f, 1.0f, 1.0f, 1.0f,
452  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
453  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom)
454  );
455  }
456  // center
457  {
458  float left = imageScreenScale9Left;
459  float top = imageScreenScale9Top;
460  float width = imageScreenWidth - scaledScale9Grid.left - scaledScale9Grid.right;
461  float height = imageScreenHeight - scaledScale9Grid.top - scaledScale9Grid.bottom;
462  guiRenderer->addQuad(
463  ((left) / (screenWidth / 2.0f)) - 1.0f,
464  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
465  1.0f, 1.0f, 1.0f, 1.0f,
466  1.0f / imageTextureWidth * scale9Grid.left,
467  1.0f / imageTextureHeight * scale9Grid.top,
468  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
469  ((screenHeight - top) / (screenHeight / 2.0f)) - 1.0f,
470  1.0f, 1.0f, 1.0f, 1.0f,
471  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
472  1.0f / imageTextureHeight * scale9Grid.top,
473  ((left + width) / (screenWidth / 2.0f)) - 1.0f,
474  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
475  1.0f, 1.0f, 1.0f, 1.0f,
476  1.0f / imageTextureWidth * (imageTextureWidth - scale9Grid.right),
477  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom),
478  ((left) / (screenWidth / 2.0f)) - 1.0f,
479  ((screenHeight - top - height) / (screenHeight / 2.0f)) - 1.0f,
480  1.0f, 1.0f, 1.0f, 1.0f,
481  1.0f / imageTextureWidth * scale9Grid.left,
482  1.0f / imageTextureHeight * (imageTextureHeight - scale9Grid.bottom)
483  );
484  }
485  }
486  guiRenderer->render();
487  guiRenderer->bindTexture(0);
488  if (maskTextureId != 0) {
489  guiRenderer->setMaskMaxValue(1.0f);
490  guiRenderer->bindMask(0);
491  }
492  guiRenderer->setTexureMatrix((Matrix3x3()).identity());
493  }
494 }
495 
497  this->textureMatrix.set(mirrorTextureMatrix.multiply(textureMatrix));
498 }
499 
501  return effectColorMul;
502 }
503 
504 void GUITextureBaseNode::setEffectColorMul(const GUIColor& effectColorMul) {
505  this->effectColorMul = effectColorMul;
506 }
507 
509  return effectColorAdd;
510 }
511 
512 void GUITextureBaseNode::setEffectColorAdd(const GUIColor& effectColorAdd) {
513  this->effectColorAdd = effectColorAdd;
514 }
515 
517  return clipping;
518 }
519 
520 GUINode_Clipping GUITextureBaseNode::createClipping(const string& allClipping, const string& left, const string& top, const string& right, const string& bottom)
521 {
523  clipping.left = getRequestedPixelValue(allClipping, 0);
524  clipping.top = getRequestedPixelValue(allClipping, 0);
525  clipping.right = getRequestedPixelValue(allClipping, 0);
526  clipping.bottom = getRequestedPixelValue(allClipping, 0);
531  return clipping;
532 }
533 
535  return mask;
536 }
537 
538 void GUITextureBaseNode::setMask(const string& mask) {
539  if (maskTexture != nullptr) {
540  Engine::getInstance()->getTextureManager()->removeTexture(maskTexture->getId());
541  maskTexture = nullptr;
542  }
543  this->mask = mask;
544  this->maskTexture = mask.empty() == true?nullptr:screenNode->getImage(mask);
545  this->maskTextureId = maskTexture == nullptr?0:Engine::getInstance()->getTextureManager()->addTexture(maskTexture, 0);
546 }
547 
549  RequestedDimensionConstraints constraints;
550  if (width.empty() == false) {
551  if (StringTools::endsWith(width, "%")) {
552  constraints.horizontalScale = Float::parse(width.substr(0, width.length() - 1)) / 100.0f;
553  } else {
554  constraints.horizontalScale = Float::parse(width);
555  }
556  }
557  if (height.empty() == false) {
558  if (StringTools::endsWith(height, "%")) {
559  constraints.verticalScale = Float::parse(height.substr(0, height.length() - 1)) / 100.0f;
560  } else {
561  constraints.verticalScale = Float::parse(height);
562  }
563  }
564  return constraints;
565 }
566 
568  // no op
569 }
Engine main class.
Definition: Engine.h:131
Texture entity.
Definition: Texture.h:24
const string & getId() const
Definition: Texture.h:172
GUI element node conditions.
static STATIC_DLL_IMPEXT GUINode_RequestedConstraints_RequestedConstraintsType * AUTO
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
static int getRequestedPixelValue(const string &value, int defaultValue)
Get requested pixel value.
Definition: GUINode.cpp:324
GUINode_ComputedConstraints computedConstraints
Definition: GUINode.h:152
GUINode_Padding padding
Definition: GUINode.h:159
GUIScreenNode * screenNode
Definition: GUINode.h:147
GUINode_RequestedConstraints requestedConstraints
Definition: GUINode.h:151
bool shouldRender()
Returns if to render.
Definition: GUINode.h:302
virtual void dispose()
Dispose node.
Definition: GUINode.cpp:462
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
Texture * getImage(const string &fileName)
Get image.
static GUINode_Clipping createClipping(const string &allClipping, const string &left, const string &top, const string &right, const string &bottom)
Create clipping.
void setEffectColorMul(const GUIColor &effectColorMul)
Set effect color mul.
void dispose() override
Dispose node.
static RequestedDimensionConstraints createRequestedDimensionConstraints(const string &width, const string &height)
Create requested dimension constraints.
void setMask(const string &mask)
Set mask source.
virtual void onRenderTexture()
On render texture event.
RequestedDimensionConstraints requestedDimensionConstraints
void render(GUIRenderer *guiRenderer) override
Render.
void setEffectColorAdd(const GUIColor &effectColorAdd)
Set effect color add.
void setTextureMatrix(const Matrix3x3 &textureMatrix)
Set texture matrix.
void setSubRenderAreaBottom(float renderAreaBottom)
Set sub render area bottom.
Definition: GUIRenderer.h:340
void setMaskMaxValue(float maskMaxValue)
Set mask max value.
void setTexureMatrix(const Matrix3x3 &textureMatrix)
Set texture matrix.
void bindTexture(int32_t textureId)
Bind texture.
void setSubRenderAreaRight(float renderAreaRight)
Set sub render area right.
Definition: GUIRenderer.h:317
void setSubRenderAreaLeft(float renderAreaLeft)
Set sub render area left.
Definition: GUIRenderer.h:271
void setEffectColorAdd(const GUIColor &color)
Set effect color add.
Definition: GUIRenderer.h:192
void setSubRenderAreaTop(float renderAreaTop)
Set sub render area top.
Definition: GUIRenderer.h:294
void setEffectColorMul(const GUIColor &color)
Set effect color mul.
Definition: GUIRenderer.h:184
void bindMask(int32_t textureId)
Bind mask 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
Matrix3x3 class representing matrix3x3 mathematical structure and operations for 2d space.
Definition: Matrix3x3.h:20
Matrix3x3 & identity()
Creates identity matrix.
Definition: Matrix3x3.h:128
Matrix3x3 & set(float r0c0, float r0c1, float r0c2, float r1c0, float r1c1, float r1c2, float r2c0, float r2c1, float r2c2)
Sets this matrix by its components.
Definition: Matrix3x3.h:88
Matrix3x3 & setTranslation(const Vector2 &vector2)
Sets translation in matrix.
Definition: Matrix3x3.h:315
Matrix3x3 & scale(float scalar)
Scales by scalar.
Definition: Matrix3x3.h:146
Matrix3x3 & multiply(const Matrix3x3 &matrix)
Multiplies this matrix with given matrix.
Definition: Matrix3x3.h:176
Vector2 class representing vector2 mathematical structure and operations with x, y components.
Definition: Vector2.h:20
Float class.
Definition: Float.h:27
String tools class.
Definition: StringTools.h:22
GUI node border entity.
GUI node clipping entity.
GUI node padding entity.
GUINode_RequestedConstraints_RequestedConstraintsType * widthType
GUINode_RequestedConstraints_RequestedConstraintsType * heightType
GUI node scale 9 grid entity.