guiStackCtrl.h
Engine/source/gui/containers/guiStackCtrl.h
Classes:
class
A stack of GUI controls.
Public Typedefs
GuiHorizontalStackingType
GuiStackingType
GuiVerticalStackingType
Public Functions
Detailed Description
Public Typedefs
typedef GuiStackControl::HorizontalType GuiHorizontalStackingType
typedef GuiStackControl::StackingType GuiStackingType
typedef GuiStackControl::VerticalType GuiVerticalStackingType
Public Functions
DefineEnumType(GuiHorizontalStackingType )
DefineEnumType(GuiStackingType )
DefineEnumType(GuiVerticalStackingType )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _GUISTACKCTRL_H_ 25#define _GUISTACKCTRL_H_ 26 27#ifndef _GUICONTROL_H_ 28#include "gui/core/guiControl.h" 29#endif 30 31#include "gfx/gfxDevice.h" 32#include "console/console.h" 33#include "console/consoleTypes.h" 34 35/// A stack of GUI controls. 36/// 37/// This maintains a horizontal or vertical stack of GUI controls. If one is deleted, or 38/// resized, then the stack is resized to fit. The order of the stack is 39/// determined by the internal order of the children (ie, order of addition). 40class GuiStackControl : public GuiControl 41{ 42protected: 43 typedef GuiControl Parent; 44 bool mResizing; 45 S32 mPadding; 46 S32 mStackHorizSizing; ///< Set from horizSizingOptions. 47 S32 mStackVertSizing; ///< Set from vertSizingOptions. 48 S32 mStackingType; 49 bool mDynamicSize; ///< Resize this control along the stack axis to fit the summed extent of the children (width or height depends on the stack type) 50 bool mDynamicNonStackExtent; ///< Resize this control along the non-stack axis to fit the max extent of the children (width or height depends on the stack type) 51 bool mDynamicPos; ///< Reposition this control along the stack axis when it is resized (by mDynamicSize) (left or up depends on the stack type) 52 bool mChangeChildSizeToFit; ///< Does the child resize to fit i.e. should a horizontal stack resize its children's height to fit? 53 bool mChangeChildPosition; ///< Do we reset the child's position in the opposite direction we are stacking? 54 55public: 56 GuiStackControl(); 57 58 enum StackingType 59 { 60 stackingTypeVert, ///< Always stack vertically 61 stackingTypeHoriz, ///< Always stack horizontally 62 stackingTypeDyn ///< Dynamically switch based on width/height 63 }; 64 65 enum HorizontalType 66 { 67 horizStackLeft = 0,///< Stack from left to right when horizontal 68 horizStackRight, ///< Stack from right to left when horizontal 69 }; 70 71 enum VerticalType 72 { 73 vertStackTop, ///< Stack from top to bottom when vertical 74 vertStackBottom, ///< Stack from bottom to top when vertical 75 }; 76 77 bool resize(const Point2I &newPosition, const Point2I &newExtent); 78 void childResized(GuiControl *child); 79 bool isFrozen() { return mResizing; }; 80 /// prevent resizing. useful when adding many items. 81 void freeze(bool); 82 83 bool onWake(); 84 void onSleep(); 85 86 void updatePanes(); 87 88 virtual void stackVertical(bool fromTop); 89 virtual void stackHorizontal(bool fromLeft); 90 91 S32 getCount() { return size(); }; /// Returns the number of children in the stack 92 93 void addObject(SimObject *obj); 94 void removeObject(SimObject *obj); 95 96 bool reOrder(SimObject* obj, SimObject* target = 0); 97 98 static void initPersistFields(); 99 100 DECLARE_CONOBJECT(GuiStackControl); 101 DECLARE_CATEGORY( "Gui Containers" ); 102 DECLARE_DESCRIPTION( "A container that stacks its children horizontally or vertically." ); 103}; 104 105typedef GuiStackControl::StackingType GuiStackingType; 106typedef GuiStackControl::HorizontalType GuiHorizontalStackingType; 107typedef GuiStackControl::VerticalType GuiVerticalStackingType; 108 109DefineEnumType( GuiStackingType ); 110DefineEnumType( GuiHorizontalStackingType ); 111DefineEnumType( GuiVerticalStackingType ); 112 113#endif 114