1.4 RC2 - guiInspector unreadable field captions
by Daan Broekhof · in Torque Game Engine · 09/11/2005 (8:10 am) · 11 replies
The new guiInspector has some nifty new features, but one major inconvenience as well: long field captions (names) are chopped off, with no way to resize the caption cell.
I peeked into the code and found that it had a fixed 35% width.
So here are some changes to alleviate the problem:
- Resizeable caption field with cursor change
- Minimum size of caption field or edit field is 20
- Standard size is 100
- Resizing one field caption resizes all in the current guiInspector
In guiInspector.h add:
After "SimObjectPtr mTarget;"
After "void registerEditControl( GuiControl *ctrl );"
Before "virtual bool onAdd();"
Remove
In guiInspector.cc add:
In function "GuiInspector::GuiInspector()" add
After function "void GuiInspector::clearGroups()"
In BOTH creator functions "GuiInspectorField::GuiInspectorField" add
After function "GuiInspectorField::registerEditControl" add
In functions "GuiInspectorField::onRender", "GuiInspectorField::onAdd", "GuiInspectorDynamicField::constructRenameControl", "GuiInspectorDynamicField::constructRenameControl", "GuiInspectorDynamicField::onRender", "GuiInspectorDynamicField::resize"
replace
Remove
I peeked into the code and found that it had a fixed 35% width.
So here are some changes to alleviate the problem:
- Resizeable caption field with cursor change
- Minimum size of caption field or edit field is 20
- Standard size is 100
- Resizing one field caption resizes all in the current guiInspector
In guiInspector.h add:
After "SimObjectPtr
S32 mCaptionWidth; void setCaptionWidth( S32 width, S32 maxWidth );
After "void registerEditControl( GuiControl *ctrl );"
GuiCursor *mLeftRightCursor; bool mResizingCaption; bool initCursors();
Before "virtual bool onAdd();"
virtual void onMouseDown(const GuiEvent &event); virtual void onMouseUp(const GuiEvent &event); virtual void onMouseDragged(const GuiEvent &event); virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
Remove
// Static Caption Width (in percentage) for all inspector fields static S32 smCaptionWidth;
In guiInspector.cc add:
In function "GuiInspector::GuiInspector()" add
mCaptionWidth = 100;
After function "void GuiInspector::clearGroups()"
void GuiInspector::setCaptionWidth( S32 width, S32 maxWidth )
{
mCaptionWidth = getMin(maxWidth-20, getMax(20, width));
setUpdate();
}In BOTH creator functions "GuiInspectorField::GuiInspectorField" add
mResizingCaption = false; mLeftRightCursor = NULL;
After function "GuiInspectorField::registerEditControl" add
bool GuiInspectorField::initCursors()
{
if (mLeftRightCursor == NULL)
{
SimObject *obj;
obj = Sim::findObject("LeftRightCursor");
mLeftRightCursor = dynamic_cast<GuiCursor*>(obj);
return(mLeftRightCursor != NULL );
}
else
return(true);
}
void GuiInspectorField::getCursor(GuiCursor *&cursor, bool &visible, const GuiEvent &event)
{
if ( initCursors() == true )
{
Point2I curMousePos = globalToLocalCoord(event.mousePoint);
cursor = NULL;
if ( mResizingCaption || (curMousePos.x > mParent->mParent->mCaptionWidth - 3 && curMousePos.x < mParent->mParent->mCaptionWidth + 3) )
cursor = mLeftRightCursor;
}
}
void GuiInspectorField::onMouseDown( const GuiEvent &event )
{
Point2I curMousePos = globalToLocalCoord(event.mousePoint);
if ( curMousePos.x > mParent->mParent->mCaptionWidth - 3 && curMousePos.x < mParent->mParent->mCaptionWidth + 3 )
{
mResizingCaption = true;
mouseLock();
setFirstResponder();
setUpdate();
}
}
void GuiInspectorField::onMouseUp( const GuiEvent &event )
{
if ( mResizingCaption )
{
mResizingCaption = false;
mouseUnlock();
setUpdate();
}
}
void GuiInspectorField::onMouseDragged(const GuiEvent &event)
{
if ( mResizingCaption )
{
Point2I curMousePos = globalToLocalCoord(event.mousePoint);
mParent->mParent->setCaptionWidth(curMousePos.x, mBounds.extent.x);
mParent->mParent->childResized(mParent); //FixMe? Other methods to force redraw didn't redraw edit controls in other groups
}
}In functions "GuiInspectorField::onRender", "GuiInspectorField::onAdd", "GuiInspectorDynamicField::constructRenameControl", "GuiInspectorDynamicField::constructRenameControl", "GuiInspectorDynamicField::onRender", "GuiInspectorDynamicField::resize"
replace
mFloor( mBounds.extent.x * (F32)( (F32)GuiInspectorField::smCaptionWidth / 100.0 ) )with
mParent->mParent->mCaptionWidth
Remove
// Caption width is in percentage of total width S32 GuiInspectorField::smCaptionWidth = 35;
#2
Think I'll open a resource for the total package of the changes. (patch file + full files)
09/11/2005 (5:49 pm)
I've ironed out some more kinks in the guiInspector (mosty rendering bugs) but the changes are a bit more extensive than the above.Think I'll open a resource for the total package of the changes. (patch file + full files)
#3
09/11/2005 (11:53 pm)
It's probably best to send them straight to Ben so they can get into CVS.
#4
09/12/2005 (2:47 am)
Tom's right; these are good fixes and I don't anticipate having any problems about getting them into CVS.
#5
09/12/2005 (9:14 am)
Ah then I will start spamming Ben ;)
#6
Very nice though, I was hoping someone would get around to this as, unfortunately I just didn't have time to do it :(
09/12/2005 (2:45 pm)
Daan : Those look like some nice changes that you've made. However, if I'm reading your code correctly it looks like you're setting the caption width in the inspector so that all fields then update their widths to match. If that is correct then I am a bit unsure why you didn't just set the GuiInspectorField::smCaptionWidth static member. I implemented it as a static member so that all GuiInspectorField controls would retain the same caption widths. Very nice though, I was hoping someone would get around to this as, unfortunately I just didn't have time to do it :(
#7
I considered that, but then it occured to me that multiple guiInspectors could be in use at the same time somewhere in the future. And having a global captionWidth would not allow different guiInspectors to have different settings.
09/12/2005 (2:48 pm)
@JustinI considered that, but then it occured to me that multiple guiInspectors could be in use at the same time somewhere in the future. And having a global captionWidth would not allow different guiInspectors to have different settings.
#8
-cheers!
09/12/2005 (3:02 pm)
Daan : I suppose that is true, always good to be looking out for the future!-cheers!
#10
(muhaha, now noone will be able to make sense of this thread!)
09/12/2005 (3:21 pm)
Unfortunatly I could find no images of elephants re-entering the atmosphere.. ;)(muhaha, now noone will be able to make sense of this thread!)
#11
09/12/2005 (3:32 pm)
Haha Daan, looks like someone already had that idea!
Torque 3D Owner Tom Bampton