GUI2/Styled Widget: enabled the virtual init function

I need this for some upcoming changes to the minimap widget that require an initialization
step on after canvas creation.
This commit is contained in:
Charles Dang 2017-07-24 15:15:20 +11:00
parent cc3c9be5b0
commit e550c1f67c
2 changed files with 6 additions and 8 deletions

View file

@ -347,9 +347,7 @@ void styled_widget::set_definition(const std::string& definition)
load_config();
assert(config());
#ifdef GUI2_EXPERIMENTAL_LISTBOX
init();
#endif
}
void styled_widget::set_label(const t_string& label)

View file

@ -461,18 +461,18 @@ protected:
std::string get_label_link(const gui2::point & position) const;
private:
#ifdef GUI2_EXPERIMENTAL_LISTBOX
/**
* Initializes the styled_widget.
* Allows derived classes to implement initialization steps after the config and
* canvases have been loaded.
*
* Not everything can be code in the constructor since virtual functions
* can't be used. So after construction this function needs to be called and
* only once, this happens when set_definition is called.
* Another area this is useful is for initialization making use of virtual functions,
* which can't be used in a constructor.
*
* This function should only be called once.
*/
virtual void init()
{
}
#endif
/**
* Gets the best size for a text.