Add a linked widget feature in the configs.
This commit is contained in:
parent
006f19c087
commit
ba51a0e823
7 changed files with 38 additions and 0 deletions
|
@ -336,6 +336,7 @@ twindow_builder::tresolution::tresolution(const config& cfg) :
|
|||
tbuilder_grid::tbuilder_grid(const config& cfg) :
|
||||
tbuilder_widget(cfg),
|
||||
id(cfg["id"]),
|
||||
linked_group(cfg["linked_group"]),
|
||||
rows(0),
|
||||
cols(0),
|
||||
row_grow_factor(),
|
||||
|
@ -446,6 +447,7 @@ twidget* tbuilder_grid::build() const
|
|||
twidget* tbuilder_grid::build (tgrid* grid) const
|
||||
{
|
||||
grid->set_id(id);
|
||||
grid->set_linked_group(linked_group);
|
||||
grid->set_rows_cols(rows, cols);
|
||||
|
||||
log_scope2(log_gui_general, "Window builder: building grid");
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
tbuilder_grid(const config& cfg);
|
||||
|
||||
std::string id;
|
||||
std::string linked_group;
|
||||
unsigned rows;
|
||||
unsigned cols;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ tbuilder_control::tbuilder_control(const config& cfg) :
|
|||
tbuilder_widget(cfg),
|
||||
id(cfg["id"]),
|
||||
definition(cfg["definition"]),
|
||||
linked_group(cfg["linked_group"]),
|
||||
label(cfg["label"]),
|
||||
tooltip(cfg["tooltip"]),
|
||||
help(cfg["help"]),
|
||||
|
@ -49,6 +50,7 @@ void tbuilder_control::init_control(tcontrol* control) const
|
|||
|
||||
control->set_id(id);
|
||||
control->set_definition(definition);
|
||||
control->set_linked_group(linked_group);
|
||||
control->set_label(label);
|
||||
control->set_tooltip(tooltip);
|
||||
control->set_help_message(help);
|
||||
|
@ -83,6 +85,9 @@ void tbuilder_control::init_control(tcontrol* control) const
|
|||
* specific version of the widget eg a title
|
||||
* label when the label is used as title.
|
||||
*
|
||||
* linked_group(string = "") The linked group the control belongs
|
||||
* to.
|
||||
*
|
||||
* label (tstring = "") Most widgets have some text associated
|
||||
* with them, this field contain the value
|
||||
* of that text. Some widgets use this value
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
/** Parameters for the control. */
|
||||
std::string id;
|
||||
std::string definition;
|
||||
std::string linked_group;
|
||||
t_string label;
|
||||
t_string tooltip;
|
||||
t_string help;
|
||||
|
|
|
@ -48,6 +48,11 @@ void tcontrol::set_members(const string_map& data)
|
|||
set_id(itor->second);
|
||||
}
|
||||
|
||||
itor = data.find("linked_group");
|
||||
if(itor != data.end()) {
|
||||
set_linked_group(itor->second);
|
||||
}
|
||||
|
||||
itor = data.find("label");
|
||||
if(itor != data.end()) {
|
||||
set_label(itor->second);
|
||||
|
|
|
@ -21,8 +21,12 @@ namespace gui2 {
|
|||
void twidget::layout_init(const bool /*full_initialization*/)
|
||||
{
|
||||
assert(visible_ != INVISIBLE);
|
||||
assert(get_window());
|
||||
|
||||
layout_size_ = tpoint(0,0);
|
||||
if(!linked_group_.empty()) {
|
||||
get_window()->add_linked_widget(linked_group_, this);
|
||||
}
|
||||
}
|
||||
|
||||
tpoint twidget::get_best_size() const
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
, drawing_action_(DRAWN)
|
||||
, clip_rect_()
|
||||
, layout_size_(tpoint(0,0))
|
||||
, linked_group_()
|
||||
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
||||
, last_best_size_(tpoint(0,0))
|
||||
#endif
|
||||
|
@ -535,6 +536,13 @@ protected:
|
|||
void set_layout_size(const tpoint& size) { layout_size_ = size; }
|
||||
const tpoint& layout_size() const { return layout_size_; }
|
||||
|
||||
public:
|
||||
|
||||
void set_linked_group(const std::string& linked_group)
|
||||
{
|
||||
linked_group_ = linked_group;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The id is the unique name of the widget in a certain context. This is
|
||||
|
@ -598,6 +606,18 @@ private:
|
|||
*/
|
||||
tpoint layout_size_;
|
||||
|
||||
/**
|
||||
* The linked group the widget belongs to.
|
||||
*
|
||||
* @todo For now the linked group is initialized when the layout of the
|
||||
* widget is initialized. The best time to set it would be upon adding the
|
||||
* widget in the window. Need to look whether it's possible in a clean way.
|
||||
* Maybe a signal just prior to showing a window where the widget can do
|
||||
* some of it's on things, would also be nice for widgets that need a
|
||||
* finalizer function.
|
||||
*/
|
||||
std::string linked_group_;
|
||||
|
||||
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
|
||||
/**
|
||||
* Debug helper to store last value of get_best_size().
|
||||
|
|
Loading…
Add table
Reference in a new issue