Optional custom widget config

Started by starkhorn, 06 April 2016, 00:58:49

starkhorn

Hi Texus,

I was wondering if you could advise if any of the below config is optional? As you can see I basically want the RGB and image to be the same for normal, hover and down events. I have alot of these widgets to create in the conf file so I was wondering if there was a way to remove optional parameters? i.e. if HoverImage isn't present will it use the normalImage by default etc?

Code (cpp) Select

Button.CustomButtonNonClickRomeHI {
    NormalImage  : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    HoverImage   : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    DownImage    : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(190, 190, 190);
    TextColorDown   : rgb(190, 190, 190);
}

starkhorn

Actually I should have just tested it before posting....sorry. :(

I had the below and it works fine.

Code (cpp) Select

Button.CustomButtonNonClickRomeHI {
    NormalImage  : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
}


I ensure when setting up the button to call the below to disable, disconnect etc and it works well.

Code (cpp) Select

gui.get(buttonText, true)->disconnectAll();
gui.get(buttonText, true)->disable();
gui.get<tgui::Button>(buttonText, true)->setText("");

texus

The last part shouldn't really be necessary unless you initialized the button earlier. The text is always empty by default and there is nothing to disconnect (other than perhaps internal things when a relative position or size is set) when it is just set up.
The disable call could help if you are planning on having signals connected which you don't want to activate yet, but when there is no hover or down image or signals, an enabled button will do exactly the same. Although calling disable would tell the button to ignore mouse events which could lead to a very small performance improvement with many buttons so that call still makes some sense.