Removed GuiFlexibleArrayControl.

This commit is contained in:
Daniel Buckmaster 2014-12-01 23:31:43 +11:00
parent 2ed175b52c
commit add9f990f7
4 changed files with 268 additions and 513 deletions

View file

@ -1,184 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 Daniel Buckmaster
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "console/engineAPI.h"
#include "platform/platform.h"
#include "gui/containers/guiFlexibleArrayCtrl.h"
#include "platform/types.h"
GuiFlexibleArrayControl::GuiFlexibleArrayControl()
{
mRows = 0;
mRowSpacing = 0;
mColSpacing = 0;
mIsContainer = true;
mResizing = false;
mFrozen = false;
mPadding.set(0, 0, 0, 0);
}
GuiFlexibleArrayControl::~GuiFlexibleArrayControl()
{
}
IMPLEMENT_CONOBJECT(GuiFlexibleArrayControl);
ConsoleDocClass( GuiFlexibleArrayControl,
"@brief A container that arranges children into a grid.\n\n"
"This container maintains a 2D grid of GUI controls. If one is added, deleted, "
"or resized, then the grid is updated. The insertion order into the grid is "
"determined by the internal order of the children (ie. the order of addition).<br>"
"Children are added to the grid by row or column until they fill the assocated "
"GuiFlexibleArrayControl extent (width or height). For example, a "
"GuiFlexibleArrayControl with 10 children, and <i>fillRowFirst</i> set to "
"true may be arranged as follows:\n\n"
"<pre>\n"
"1 2 ...3... 4\n"
"..5.. 6 7 .8.\n"
"9 ....10....\n"
"</pre>\n"
"@tsexample\n"
"new GuiFlexibleArrayControl()\n"
"{\n"
" colSpacing = \"2\";\n"
" rowSpacing = \"2\";\n"
" frozen = \"0\";\n"
" padding = \"0 0 0 0\";\n"
" //Properties not specific to this control have been omitted from this example.\n"
"};\n"
"@endtsexample\n\n"
"@see GuiDynamicCtrlArrayControl\n"
"@ingroup GuiContainers"
);
// ConsoleObject...
void GuiFlexibleArrayControl::initPersistFields()
{
addField("rowCount", TypeS32, Offset( mRows, GuiFlexibleArrayControl),
"Number of rows the child controls have been arranged into. This value "
"is calculated automatically when children are added, removed or resized; "
"writing it directly has no effect.");
addField("rowSpacing", TypeS32, Offset(mRowSpacing, GuiFlexibleArrayControl),
"Spacing between rows");
addField("colSpacing", TypeS32, Offset(mColSpacing, GuiFlexibleArrayControl),
"Spacing between columns");
addField("frozen", TypeBool, Offset(mFrozen, GuiFlexibleArrayControl),
"When true, the array will not update when new children are added or in "
"response to child resize events. This is useful to prevent unnecessary "
"resizing when adding, removing or resizing a number of child controls.");
addField("padding", TypeRectSpacingI, Offset(mPadding, GuiFlexibleArrayControl),
"Padding around the top, bottom, left, and right of this control. This "
"reduces the area available for child controls.");
Parent::initPersistFields();
}
void GuiFlexibleArrayControl::inspectPostApply()
{
resize(getPosition(), getExtent());
Parent::inspectPostApply();
}
void GuiFlexibleArrayControl::addObject(SimObject *obj)
{
Parent::addObject(obj);
if(!mFrozen)
refresh();
}
bool GuiFlexibleArrayControl::resize(const Point2I &newPosition, const Point2I &newExtent)
{
if(size() == 0)
return Parent::resize(newPosition, newExtent);
if(mResizing)
return false;
mResizing = true;
// Place each child.
S32 childcount = 0;
Point2I pos(mPadding.left, mPadding.top);
mRows = 0;
S32 rowHeight = 0;
for(S32 i = 0; i < size(); i++)
{
GuiControl *gc = dynamic_cast<GuiControl*>(operator [](i));
if(gc && gc->isVisible())
{
if(pos.x + gc->getWidth() > getExtent().x - mPadding.right)
{
pos.y += rowHeight + mRowSpacing;
pos.x = mPadding.left;
rowHeight = 0;
mRows++;
}
gc->setPosition(pos);
rowHeight = getMax(rowHeight, gc->getHeight());
pos.x += mColSpacing + gc->getWidth();
childcount++;
}
}
Point2I realExtent(newExtent);
realExtent.y = pos.y + rowHeight;
realExtent.y += mPadding.bottom;
mResizing = false;
return Parent::resize(newPosition, realExtent);
}
void GuiFlexibleArrayControl::childResized(GuiControl *child)
{
Parent::childResized(child);
if ( !mFrozen )
refresh();
}
void GuiFlexibleArrayControl::refresh()
{
resize(getPosition(), getExtent());
}
DefineEngineMethod( GuiFlexibleArrayControl, refresh, void, (),,
"Recalculates the position and size of this control and all its children." )
{
object->refresh();
}

View file

@ -1,67 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 Daniel Buckmaster
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _GUIFLEXIBLEARRAYCTRL_H_
#define _GUIFLEXIBLEARRAYCTRL_H_
#include "gui/core/guiControl.h"
class GuiFlexibleArrayControl : public GuiControl
{
typedef GuiControl Parent;
public:
GuiFlexibleArrayControl();
virtual ~GuiFlexibleArrayControl();
DECLARE_CONOBJECT(GuiFlexibleArrayControl);
DECLARE_CATEGORY( "Gui Containers" );
// ConsoleObject
static void initPersistFields();
// SimObject
void inspectPostApply();
// SimSet
void addObject(SimObject *obj);
// GuiControl
bool resize(const Point2I &newPosition, const Point2I &newExtent);
void childResized(GuiControl *child);
// GuiFlexibleArrayCtrl
void refresh();
protected:
S32 mRows;
S32 mRowSpacing;
S32 mColSpacing;
bool mResizing;
bool mFrozen;
RectSpacingI mPadding;
};
#endif // _GUIFLEXIBLEARRAYCTRL_H_

View file

@ -199,10 +199,8 @@
Extent = "86 18"; Extent = "86 18";
text = "Actions"; text = "Actions";
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "SelectActions"; internalName = "SelectActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -216,6 +214,11 @@
text = "Build NavMesh"; text = "Build NavMesh";
command = "NavEditorGui.buildSelectedMeshes();"; command = "NavEditorGui.buildSelectedMeshes();";
}; };
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "182 20";
position = "0 20";
new GuiCheckboxCtrl() { new GuiCheckboxCtrl() {
internalName = "BackgroundBuildButton"; internalName = "BackgroundBuildButton";
text = "Background"; text = "Background";
@ -227,7 +230,7 @@
profile = "GuiCheckBoxProfile"; profile = "GuiCheckBoxProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
variable = "$Nav::Editor::backgroundBuild"; variable = "NavEditorGui.backgroundBuild";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
@ -235,6 +238,7 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiCheckboxCtrl() { new GuiCheckboxCtrl() {
position = "75 0";
internalName = "SaveIntermediatesButton"; internalName = "SaveIntermediatesButton";
text = "Keep intermediates"; text = "Keep intermediates";
groupNum = "-1"; groupNum = "-1";
@ -244,13 +248,14 @@
profile = "GuiCheckBoxProfile"; profile = "GuiCheckBoxProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
variable = "$Nav::Editor::saveIntermediates"; variable = "NavEditorGui.saveIntermediates";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
canSave = "1"; canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
};
new GuiCheckboxCtrl() { new GuiCheckboxCtrl() {
internalName = "BuildSoundButton"; internalName = "BuildSoundButton";
text = "Play sound when done"; text = "Play sound when done";
@ -262,7 +267,7 @@
profile = "GuiCheckBoxProfile"; profile = "GuiCheckBoxProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
variable = "$Nav::Editor::playSoundWhenDone"; variable = "NavEditorGui.playSoundWhenDone";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
@ -270,10 +275,8 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "LinkActions"; internalName = "LinkActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -288,10 +291,8 @@
command = "NavEditorGui.buildLinks();"; command = "NavEditorGui.buildLinks();";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "CoverActions"; internalName = "CoverActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -315,10 +316,8 @@
command = "NavEditorGui.deleteCoverPoints();"; command = "NavEditorGui.deleteCoverPoints();";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "TileActions"; internalName = "TileActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -333,10 +332,8 @@
command = "NavEditorGui.buildTile();"; command = "NavEditorGui.buildTile();";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "TestActions"; internalName = "TestActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -350,6 +347,10 @@
text = "Spawn"; text = "Spawn";
command = "NavEditorGui.spawnPlayer();"; command = "NavEditorGui.spawnPlayer();";
}; };
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 18";
new GuiButtonCtrl() { new GuiButtonCtrl() {
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
@ -360,6 +361,7 @@
command = "NavEditorGui.getPlayer().delete();"; command = "NavEditorGui.getPlayer().delete();";
}; };
new GuiButtonCtrl() { new GuiButtonCtrl() {
position = "100 0";
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
HorizSizing = "right"; HorizSizing = "right";
@ -368,6 +370,11 @@
text = "Find cover"; text = "Find cover";
command = "NavEditorGui.findCover();"; command = "NavEditorGui.findCover();";
}; };
};
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 18";
new GuiButtonCtrl() { new GuiButtonCtrl() {
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
@ -378,6 +385,7 @@
command = "NavEditorGui.followObject();"; command = "NavEditorGui.followObject();";
}; };
new GuiButtonCtrl() { new GuiButtonCtrl() {
position = "100 0";
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
HorizSizing = "right"; HorizSizing = "right";
@ -388,6 +396,7 @@
}; };
}; };
}; };
};
new GuiContainer(){ new GuiContainer(){
isContainer = "1"; isContainer = "1";
Profile = "inspectorStyleRolloutDarkProfile"; Profile = "inspectorStyleRolloutDarkProfile";
@ -460,9 +469,7 @@
dividerMargin = "5"; dividerMargin = "5";
}; };
new GuiFlexibleArrayControl() { new GuiStackControl() {
colSpacing = 2;
rowSpacing = 2;
internalName = "LinkProperties"; internalName = "LinkProperties";
position = "7 21"; position = "7 21";
extent = "186 64"; extent = "186 64";
@ -589,9 +596,7 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
}; };
new GuiFlexibleArrayControl() { new GuiStackControl() {
colSpacing = 2;
rowSpacing = 2;
internalName = "TileProperties"; internalName = "TileProperties";
position = "7 21"; position = "7 21";
extent = "186 64"; extent = "186 64";
@ -634,9 +639,7 @@
variable = "$Nav::Editor::renderVoxels"; variable = "$Nav::Editor::renderVoxels";
}; };
}; };
new GuiFlexibleArrayControl() { new GuiStackControl() {
colSpacing = 2;
rowSpacing = 2;
internalName = "TestProperties"; internalName = "TestProperties";
position = "7 21"; position = "7 21";
extent = "186 64"; extent = "186 64";

View file

@ -199,10 +199,8 @@
Extent = "86 18"; Extent = "86 18";
text = "Actions"; text = "Actions";
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "SelectActions"; internalName = "SelectActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -216,6 +214,11 @@
text = "Build NavMesh"; text = "Build NavMesh";
command = "NavEditorGui.buildSelectedMeshes();"; command = "NavEditorGui.buildSelectedMeshes();";
}; };
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "182 20";
position = "0 20";
new GuiCheckboxCtrl() { new GuiCheckboxCtrl() {
internalName = "BackgroundBuildButton"; internalName = "BackgroundBuildButton";
text = "Background"; text = "Background";
@ -227,7 +230,7 @@
profile = "GuiCheckBoxProfile"; profile = "GuiCheckBoxProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
variable = "$Nav::Editor::backgroundBuild"; variable = "NavEditorGui.backgroundBuild";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
@ -235,6 +238,7 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
new GuiCheckboxCtrl() { new GuiCheckboxCtrl() {
position = "75 0";
internalName = "SaveIntermediatesButton"; internalName = "SaveIntermediatesButton";
text = "Keep intermediates"; text = "Keep intermediates";
groupNum = "-1"; groupNum = "-1";
@ -244,13 +248,14 @@
profile = "GuiCheckBoxProfile"; profile = "GuiCheckBoxProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
variable = "$Nav::Editor::saveIntermediates"; variable = "NavEditorGui.saveIntermediates";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
canSave = "1"; canSave = "1";
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
};
new GuiCheckboxCtrl() { new GuiCheckboxCtrl() {
internalName = "BuildSoundButton"; internalName = "BuildSoundButton";
text = "Play sound when done"; text = "Play sound when done";
@ -262,7 +267,7 @@
profile = "GuiCheckBoxProfile"; profile = "GuiCheckBoxProfile";
visible = "1"; visible = "1";
active = "1"; active = "1";
variable = "$Nav::Editor::playSoundWhenDone"; variable = "NavEditorGui.playSoundWhenDone";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000"; hovertime = "1000";
isContainer = "0"; isContainer = "0";
@ -270,10 +275,8 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "LinkActions"; internalName = "LinkActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -288,10 +291,8 @@
command = "NavEditorGui.buildLinks();"; command = "NavEditorGui.buildLinks();";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "CoverActions"; internalName = "CoverActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -315,10 +316,8 @@
command = "NavEditorGui.deleteCoverPoints();"; command = "NavEditorGui.deleteCoverPoints();";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "TileActions"; internalName = "TileActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -333,10 +332,8 @@
command = "NavEditorGui.buildTile();"; command = "NavEditorGui.buildTile();";
}; };
}; };
new GuiFlexibleArrayControl() new GuiStackControl()
{ {
colSpacing = 2;
rowSpacing = 2;
internalName = "TestActions"; internalName = "TestActions";
position = "7 21"; position = "7 21";
extent = "190 64"; extent = "190 64";
@ -350,6 +347,10 @@
text = "Spawn"; text = "Spawn";
command = "NavEditorGui.spawnPlayer();"; command = "NavEditorGui.spawnPlayer();";
}; };
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 18";
new GuiButtonCtrl() { new GuiButtonCtrl() {
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
@ -360,6 +361,7 @@
command = "NavEditorGui.getPlayer().delete();"; command = "NavEditorGui.getPlayer().delete();";
}; };
new GuiButtonCtrl() { new GuiButtonCtrl() {
position = "100 0";
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
HorizSizing = "right"; HorizSizing = "right";
@ -368,6 +370,11 @@
text = "Find cover"; text = "Find cover";
command = "NavEditorGui.findCover();"; command = "NavEditorGui.findCover();";
}; };
};
new GuiControl() {
profile = "GuiDefaultProfile";
Extent = "190 18";
new GuiButtonCtrl() { new GuiButtonCtrl() {
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
@ -378,6 +385,7 @@
command = "NavEditorGui.followObject();"; command = "NavEditorGui.followObject();";
}; };
new GuiButtonCtrl() { new GuiButtonCtrl() {
position = "100 0";
Profile = "GuiButtonProfile"; Profile = "GuiButtonProfile";
buttonType = "PushButton"; buttonType = "PushButton";
HorizSizing = "right"; HorizSizing = "right";
@ -388,6 +396,7 @@
}; };
}; };
}; };
};
new GuiContainer(){ new GuiContainer(){
isContainer = "1"; isContainer = "1";
Profile = "inspectorStyleRolloutDarkProfile"; Profile = "inspectorStyleRolloutDarkProfile";
@ -460,9 +469,7 @@
dividerMargin = "5"; dividerMargin = "5";
}; };
new GuiFlexibleArrayControl() { new GuiStackControl() {
colSpacing = 2;
rowSpacing = 2;
internalName = "LinkProperties"; internalName = "LinkProperties";
position = "7 21"; position = "7 21";
extent = "186 64"; extent = "186 64";
@ -589,9 +596,7 @@
canSaveDynamicFields = "0"; canSaveDynamicFields = "0";
}; };
}; };
new GuiFlexibleArrayControl() { new GuiStackControl() {
colSpacing = 2;
rowSpacing = 2;
internalName = "TileProperties"; internalName = "TileProperties";
position = "7 21"; position = "7 21";
extent = "186 64"; extent = "186 64";
@ -634,9 +639,7 @@
variable = "$Nav::Editor::renderVoxels"; variable = "$Nav::Editor::renderVoxels";
}; };
}; };
new GuiFlexibleArrayControl() { new GuiStackControl() {
colSpacing = 2;
rowSpacing = 2;
internalName = "TestProperties"; internalName = "TestProperties";
position = "7 21"; position = "7 21";
extent = "186 64"; extent = "186 64";