Add a helper function to generate an unique id.
This function will be needed later when a widget without an id needs to do some registration in new window functions.
This commit is contained in:
parent
e393e1228e
commit
9b8c0550fd
2 changed files with 20 additions and 0 deletions
|
@ -170,5 +170,15 @@ t_string missing_widget(const std::string& id)
|
|||
return t_string(vgettext("Mandatory widget '$id' hasn't been defined.", symbols));
|
||||
}
|
||||
|
||||
std::string get_uid()
|
||||
{
|
||||
static unsigned id = 0;
|
||||
++id;
|
||||
assert(id); // avoid wrapping.
|
||||
|
||||
return "____" + lexical_cast<std::string>(id);
|
||||
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
|
|
|
@ -132,6 +132,16 @@ void restore_background(const surface& restorer,
|
|||
*/
|
||||
t_string missing_widget(const std::string& id);
|
||||
|
||||
/**
|
||||
* Gets an unique id for a widget.
|
||||
*
|
||||
* The id will have extra leading underscores so it's in the private range and
|
||||
* can't collide with user defined ids.
|
||||
*
|
||||
* @returns The id.
|
||||
*/
|
||||
std::string get_uid();
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue