Optional custom widget config
« on: 06 April 2016, 00:58:49 »
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?

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);

Re: Optional custom widget config
« Reply #1 on: 06 April 2016, 01:06:49 »
Actually I should have just tested it before posting....sorry. :(

I had the below and it works fine.

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.

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



  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Optional custom widget config
« Reply #2 on: 06 April 2016, 10:52:00 »
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.