@@ -185,20 +185,22 @@ static EnumTable::Enums horzEnums[] =
185
185
{ GuiControl::horizResizeRight, " right" },
186
186
{ GuiControl::horizResizeWidth, " width" },
187
187
{ GuiControl::horizResizeLeft, " left" },
188
- { GuiControl::horizResizeCenter, " center" },
189
- { GuiControl::horizResizeRelative, " relative" }
188
+ { GuiControl::horizResizeCenter, " center" },
189
+ { GuiControl::horizResizeRelative, " relative" },
190
+ { GuiControl::horizResizeFill, " fill" }
190
191
};
191
- static EnumTable gHorizSizingTable (5 , &horzEnums[0 ]);
192
+ static EnumTable gHorizSizingTable (6 , &horzEnums[0 ]);
192
193
193
194
static EnumTable::Enums vertEnums[] =
194
195
{
195
196
{ GuiControl::vertResizeBottom, " bottom" },
196
197
{ GuiControl::vertResizeHeight, " height" },
197
198
{ GuiControl::vertResizeTop, " top" },
198
- { GuiControl::vertResizeCenter, " center" },
199
- { GuiControl::vertResizeRelative, " relative" }
199
+ { GuiControl::vertResizeCenter, " center" },
200
+ { GuiControl::vertResizeRelative, " relative" },
201
+ { GuiControl::vertResizeFill, " fill" }
200
202
};
201
- static EnumTable gVertSizingTable (5 , &vertEnums[0 ]);
203
+ static EnumTable gVertSizingTable (6 , &vertEnums[0 ]);
202
204
203
205
void GuiControl::initPersistFields ()
204
206
{
@@ -423,10 +425,20 @@ void GuiControl::resize(const Point2I &newPosition, const Point2I &newExtent)
423
425
{
424
426
actualNewPosition.x = (parentInnerExtent.x - actualNewExtent.x ) / 2 ;
425
427
}
428
+ else if (mHorizSizing == horizResizeFill)
429
+ {
430
+ actualNewPosition.x = 0 ;
431
+ actualNewExtent.x = parentInnerExtent.x ;
432
+ }
426
433
if (mVertSizing == vertResizeCenter)
427
434
{
428
435
actualNewPosition.y = (parentInnerExtent.y - actualNewExtent.y ) / 2 ;
429
436
}
437
+ else if (mVertSizing == vertResizeFill)
438
+ {
439
+ actualNewPosition.y = 0 ;
440
+ actualNewExtent.y = parentInnerExtent.y ;
441
+ }
430
442
}
431
443
432
444
// only do the child control resizing stuff if you really need to.
@@ -541,7 +553,8 @@ void GuiControl::parentResized(const Point2I &oldParentExtent, const Point2I &ne
541
553
// In the case of centering, we want to make doubly sure we are using the inner rect.
542
554
GuiControl* parent = getParent ();
543
555
Point2I parentInnerExt = Point2I (newParentExtent);
544
- if (mHorizSizing == horizResizeCenter || mVertSizing == vertResizeCenter)
556
+ if (mHorizSizing == horizResizeCenter || mVertSizing == vertResizeCenter ||
557
+ mHorizSizing == horizResizeFill || mVertSizing == vertResizeFill)
545
558
{
546
559
// This is based on the "new" outer extent of the parent.
547
560
parentInnerExt = parent->getInnerRect ().extent ;
@@ -553,6 +566,11 @@ void GuiControl::parentResized(const Point2I &oldParentExtent, const Point2I &ne
553
566
newExtent.x += deltaX;
554
567
else if (mHorizSizing == horizResizeLeft)
555
568
newPosition.x += deltaX;
569
+ else if (mHorizSizing == horizResizeFill)
570
+ {
571
+ newPosition.x = 0 ;
572
+ newExtent.x = parentInnerExt.x ;
573
+ }
556
574
else if (mHorizSizing == horizResizeRelative && oldParentExtent.x != 0 )
557
575
{
558
576
Point2F percent = relPosBatteryH (newPosition.x , newExtent.x , oldParentExtent.x );
@@ -569,6 +587,11 @@ void GuiControl::parentResized(const Point2I &oldParentExtent, const Point2I &ne
569
587
newExtent.y += deltaY;
570
588
else if (mVertSizing == vertResizeTop)
571
589
newPosition.y += deltaY;
590
+ else if (mVertSizing == vertResizeFill)
591
+ {
592
+ newPosition.y = 0 ;
593
+ newExtent.y = parentInnerExt.y ;
594
+ }
572
595
else if (mVertSizing == vertResizeRelative && oldParentExtent.y != 0 )
573
596
{
574
597
Point2F percent = relPosBatteryV (newPosition.y , newExtent.y , oldParentExtent.y );
@@ -584,6 +607,30 @@ void GuiControl::parentResized(const Point2I &oldParentExtent, const Point2I &ne
584
607
resize (newPosition, newExtent);
585
608
}
586
609
610
+ void GuiControl::preventResizeModeFill ()
611
+ {
612
+ if (getHorizSizing () == horizResizeFill)
613
+ {
614
+ setHorizSizing (horizResizeRight);
615
+ }
616
+ if (getVertSizing () == vertResizeFill)
617
+ {
618
+ setVertSizing (vertResizeBottom);
619
+ }
620
+ }
621
+
622
+ void GuiControl::preventResizeModeCenter ()
623
+ {
624
+ if (getHorizSizing () == horizResizeCenter)
625
+ {
626
+ setHorizSizing (horizResizeRight);
627
+ }
628
+ if (getVertSizing () == vertResizeCenter)
629
+ {
630
+ setVertSizing (vertResizeBottom);
631
+ }
632
+ }
633
+
587
634
Point2I GuiControl::extentBattery (Point2I &newExtent)
588
635
{
589
636
if (mMinExtent .x == 0 && mMinExtent .y == 0 )
@@ -936,7 +983,7 @@ bool GuiControl::renderTooltip(Point2I &cursorPos, const char* tipText )
936
983
return true ;
937
984
}
938
985
939
- void GuiControl::renderChildControls (Point2I offset, RectI content, const RectI & updateRect)
986
+ void GuiControl::renderChildControls (const Point2I& offset, const RectI& content, const RectI& updateRect)
940
987
{
941
988
// offset is the upper-left corner of this control in screen coordinates. It should almost always be the same offset passed into the onRender method.
942
989
// updateRect is the area that this control was allowed to draw in. It should almost always be the same as the value in onRender.
@@ -957,19 +1004,7 @@ void GuiControl::renderChildControls(Point2I offset, RectI content, const RectI
957
1004
}
958
1005
if (ctrl->mVisible )
959
1006
{
960
- ctrl->mRenderInsetLT = content.point - offset;
961
- ctrl->mRenderInsetRB = mBounds .extent - (ctrl->mRenderInsetLT + content.extent );
962
- Point2I childPosition = content.point + ctrl->getPosition ();
963
- RectI childClip (childPosition, ctrl->getExtent ());
964
-
965
- if (childClip.intersect (clipRect))
966
- {
967
- RectI old = dglGetClipRect ();
968
- dglSetClipRect (clipRect);
969
- glDisable (GL_CULL_FACE);
970
- ctrl->onRender (childPosition, RectI (childPosition, ctrl->getExtent ()));
971
- dglSetClipRect (old);
972
- }
1007
+ renderChild (ctrl, offset, content, clipRect);
973
1008
}
974
1009
size_cpy = objectList.size (); // CHRIS: i know its wierd but the size of the list changes sometimes during execution of this loop
975
1010
if (size != size_cpy)
@@ -981,6 +1016,23 @@ void GuiControl::renderChildControls(Point2I offset, RectI content, const RectI
981
1016
}
982
1017
}
983
1018
1019
+ void GuiControl::renderChild (GuiControl* ctrl, const Point2I& offset, const RectI& content, const RectI& clipRect)
1020
+ {
1021
+ ctrl->mRenderInsetLT = content.point - offset;
1022
+ ctrl->mRenderInsetRB = mBounds .extent - (ctrl->mRenderInsetLT + content.extent );
1023
+ Point2I childPosition = content.point + ctrl->getPosition ();
1024
+ RectI childClip (childPosition, ctrl->getExtent ());
1025
+
1026
+ if (childClip.intersect (clipRect))
1027
+ {
1028
+ RectI old = dglGetClipRect ();
1029
+ dglSetClipRect (clipRect);
1030
+ glDisable (GL_CULL_FACE);
1031
+ ctrl->onRender (childPosition, RectI (childPosition, ctrl->getExtent ()));
1032
+ dglSetClipRect (old);
1033
+ }
1034
+ }
1035
+
984
1036
void GuiControl::setUpdateRegion (Point2I pos, Point2I ext)
985
1037
{
986
1038
Point2I upos = localToGlobalCoord (pos);
0 commit comments