MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / resize

Method resize

Engine/source/gui/core/guiControl.cpp:1258–1313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1256//-----------------------------------------------------------------------------
1257
1258bool GuiControl::resize(const Point2I &newPosition, const Point2I &newExtent)
1259{
1260 const Point2I minExtent = getMinExtent();
1261 Point2I actualNewExtent = Point2I(getMax(minExtent.x, newExtent.x),
1262 getMax(minExtent.y, newExtent.y));
1263
1264 // only do the child control resizing stuff if you really need to.
1265 const RectI bounds = getBounds();
1266
1267 // If we didn't size anything, return false to indicate such
1268 bool extentChanged = (actualNewExtent != bounds.extent);
1269 bool positionChanged = (newPosition != bounds.point);
1270 if (!extentChanged && !positionChanged )
1271 return false;
1272
1273 // Update Position
1274 if ( positionChanged )
1275 mBounds.point = newPosition;
1276
1277 // Update Extent
1278 if( extentChanged )
1279 {
1280 //call set update both before and after
1281 setUpdate();
1282
1283 mBounds.extent = actualNewExtent;
1284
1285 // Obey the flag!
1286 // Could be set if we are resizing in response to a child resizing!
1287 if ( mNotifyChildrenResized )
1288 {
1289 iterator i;
1290 for(i = begin(); i != end(); i++)
1291 {
1292 GuiControl *ctrl = static_cast<GuiControl *>(*i);
1293 ctrl->parentResized(RectI(bounds.point, bounds.extent), RectI(newPosition,actualNewExtent));
1294 }
1295 }
1296
1297 GuiControl *parent = getParent();
1298 if (parent)
1299 parent->childResized(this);
1300 setUpdate();
1301 }
1302
1303 // We sized something
1304 if( extentChanged )
1305 return true;
1306
1307 // Note : We treat a repositioning as no sizing happening
1308 // because parent's should really not need to know when they
1309 // have moved, as it should not affect any child sizing since
1310 // all child bounds are relative to the parent's 0,0
1311 return false;
1312
1313}
1314
1315//-----------------------------------------------------------------------------

Callers 3

onMouseDownMethod · 0.45
maintainSizingMethod · 0.45
guiControl.cppFile · 0.45

Calls 9

getMinExtentFunction · 0.85
getMaxFunction · 0.85
getBoundsFunction · 0.85
beginFunction · 0.85
endFunction · 0.85
Point2IClass · 0.50
RectIClass · 0.50
parentResizedMethod · 0.45
childResizedMethod · 0.45

Tested by

no test coverage detected