Custom GUIPopupMenu -- HELP!
by Vern Jensen · in Torque Game Builder · 09/02/2009 (7:48 pm) · 10 replies
I am trying to make a custom GUI popup menu. That is, with custom graphics and colors. Everything works except for two things:
1) When the menu is open, the currently selected item always uses "gray" as a highlight color. I can't seem to change this.
2) As you move the mouse up and down through the menu's contents, it "hilights" those contents using pure black as the hilight color. (Not the text, but all around the text.) I can't seem to change this either.
Am I doing something wrong, or is this a bug in Torque? I noticed the default menus in TGB also use black as the highlight color. Problem is, the background of my custom menu is near-black, so using black as the highlight color does NOT work well.
My menu's profile is below, along with the colors I've been trying to set. Some of the ones with comments like "TEST" or "UNUSED?" are experiments I did that never seemed to make any difference on any part of the menu.
-Vern
1) When the menu is open, the currently selected item always uses "gray" as a highlight color. I can't seem to change this.
2) As you move the mouse up and down through the menu's contents, it "hilights" those contents using pure black as the hilight color. (Not the text, but all around the text.) I can't seem to change this either.
Am I doing something wrong, or is this a bug in Torque? I noticed the default menus in TGB also use black as the highlight color. Problem is, the background of my custom menu is near-black, so using black as the highlight color does NOT work well.
My menu's profile is below, along with the colors I've been trying to set. Some of the ones with comments like "TEST" or "UNUSED?" are experiments I did that never seemed to make any difference on any part of the menu.
-Vern
if(!isObject(GamePopUpMenuDefault)) new GuiControlProfile (GamePopUpMenuDefault : GuiDefaultProfile )
{
opaque = true;
mouseOverSelected = true;
textOffset = "3 3";
border = 4;
borderThickness = 2;
fixedExtent = true;
bitmap = "game/data/images/dialogGUI/dropDown";
hasBitmapArray = true;
profileForChildren = GamePopUpMenuDefault;
fontType = "Arial Black"; // TEST
fontSize = 16; // TEST
fillColor = "15 19 25 200"; // Background of menu when opened
fillColorHL = "0 0 255 255"; // Hilight color - BLUE
fillColorNA = "255 0 0 255"; // UNUSED?
fontColor = "57 181 255 255"; // Blue text
fontColorHL = "115 248 91 255"; // Green text (hilighted)
fontColorNA = "57 181 255 255"; // Font color when menu is opened, but item is not selected
fontColorSEL = "0 255 0 255";
borderColor = "81 103 125 200";
borderColorHL = "255 0 0 220";
borderColorNA = "0 255 0 255"; // TEST AGAIN
};
if(!isObject(GamePopUpMenuProfile)) new GuiControlProfile (GamePopUpMenuProfile : GamePopUpMenuDefault)
{
textOffset = "3 1"; // For the CONTENTS of the menu. Not the title text.
bitmap = "game/data/images/dialogGUI/dropDown";
hasBitmapArray = true;
border = -3;
profileForChildren = GamePopUpMenuDefault;
};
#2
09/02/2009 (8:21 pm)
As I suspected!// In GuiPopupTextListCtrl::onRenderCell, close to the top:
if(mouseOver)
{
// DAW: Render a background colour for the cell
RectI cellR(offset.x, offset.y, size.x, size.y);
ColorI color(0,0,0);
dglDrawRectFill(cellR, color);
} else if(selected)
{
// DAW: Render a background colour for the cell
RectI cellR(offset.x, offset.y, size.x, size.y);
ColorI color(128,128,128);
dglDrawRectFill(cellR, color);
}Change that to this:if(mouseOver)
{
// DAW: Render a background colour for the cell
RectI cellR(offset.x, offset.y, size.x, size.y);
dglDrawRectFill(cellR, mProfile->mFillColorHL);
} else if(selected)
{
// DAW: Render a background colour for the cell
RectI cellR(offset.x, offset.y, size.x, size.y);
// No mFillColorSE in TGB =(
// dglDrawRectFill(cellR, mProfile->mFillColorSEL);
dglDrawRectFill(cellR, mProfile->mFillColorNA);
}
#3
I had to actually take a break and walk away from the computer, I was getting so frustrated with it. And upon coming back, problem is solved. :-) Yeay!
For anyone else following, the file in question here is in:
Engine/source/gui/controls/guiPopUpCtrl.cc
09/02/2009 (9:40 pm)
Thanks so much, Phil!!! I had to actually take a break and walk away from the computer, I was getting so frustrated with it. And upon coming back, problem is solved. :-) Yeay!
For anyone else following, the file in question here is in:
Engine/source/gui/controls/guiPopUpCtrl.cc
#4
No worries Vern!
09/02/2009 (9:40 pm)
If you're using the Ex control, you'll have to make the changes there as well.No worries Vern!
#5
09/02/2009 (9:54 pm)
What does the Ex control do differently? Haven't looked at it yet, so have no idea what it does.
#6
09/02/2009 (9:56 pm)
The only place it is really used is for the Behavior List in TGB. It just adds categories and a few other things.
#7
dglDrawRectFill(cellR, mProfile->mFillColorNA);
as "mFillColorSEL" doesn't exist. Not sure if my choice is what it "should" be, but it works. :-)
[P.S. Just ran it -- OOOOOH! So much better! Whoohoo!]
09/02/2009 (9:59 pm)
Oh, also, I modified your code to use this for the second part:dglDrawRectFill(cellR, mProfile->mFillColorNA);
as "mFillColorSEL" doesn't exist. Not sure if my choice is what it "should" be, but it works. :-)
[P.S. Just ran it -- OOOOOH! So much better! Whoohoo!]
#8
09/02/2009 (10:01 pm)
Ahh, they must have added SEL to T3D, which is what it was changed it to over there. I'll update my post.
#9
textOffset = "3 3";
in the profile, that only changed the location of the text within the *body* of the popup menu (what you see once you click on it), not the text that's shown before you click.
If it requires extensive C++ changes it's not a big deal. Just wondering if there's a simple Profile fix, as I'm pretty new to all the GUI stuff.
09/02/2009 (10:13 pm)
BTW, while I have someone's attention, any idea if it's possible to re-position the text displayed in the popup menu *before* you click on it, by a few pixels? When I made the font larger, it rendered too low -- I want to move it up a pixel or two. But when I tried messing with:textOffset = "3 3";
in the profile, that only changed the location of the text within the *body* of the popup menu (what you see once you click on it), not the text that's shown before you click.
If it requires extensive C++ changes it's not a big deal. Just wondering if there's a simple Profile fix, as I'm pretty new to all the GUI stuff.
#10
09/02/2009 (10:23 pm)
Most controls behave differently, some use textOffset, some don't. You'd be best of trolling through the render code of the control and see if there are any hard coded text offsets in place or if the profile's offset is used.
Associate Phillip O'Shea
Violent Tulip