Skip to content

Commit

Permalink
GUI2: allow REGISTER_WIDGET to implement get_control_type overrides
Browse files Browse the repository at this point in the history
This is similar to what REGISER_WINDOW does with window_id().

Excludes the following class instances since they are not registered with REGISTER_WIDGET:
* tree_view_node
* scrollbar_container
* password_box (uses REGISTER_WIDGET3)
  • Loading branch information
Vultraz committed Aug 25, 2017
1 parent f9c2dbe commit 3b4b7b9
Show file tree
Hide file tree
Showing 59 changed files with 39 additions and 209 deletions.
8 changes: 7 additions & 1 deletion src/gui/core/register_widget.hpp
Expand Up @@ -55,4 +55,10 @@
*
* "Calls" REGISTER_WIDGET3(id_definition, id, nullptr)
*/
#define REGISTER_WIDGET(id) REGISTER_WIDGET3(id##_definition, id, nullptr)
#define REGISTER_WIDGET(id) REGISTER_WIDGET3(id##_definition, id, nullptr) \
\
const std::string& id::get_control_type() const \
{ \
static const std::string result(#id); \
return result; \
}
8 changes: 2 additions & 6 deletions src/gui/widgets/addon_list.hpp
Expand Up @@ -159,12 +159,8 @@ class addon_list : public container_base
/** Needed because otherwise the add-on with the first ID would be initially selected. */
void select_first_addon();

/** See @ref control::get_control_type. */
const std::string& get_control_type() const override
{
static const std::string control_type = "addon_list";
return control_type;
}
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/** See @ref container_::set_self_active. */
void set_self_active(const bool) override
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/button.cpp
Expand Up @@ -84,12 +84,6 @@ void button::set_state(const state_t state)
}
}

const std::string& button::get_control_type() const
{
static const std::string type = "button";
return type;
}

void button::signal_handler_mouse_enter(const event::ui_event event,
bool& handled)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/button.hpp
Expand Up @@ -97,7 +97,7 @@ class button : public styled_widget, public clickable_item
*/
int retval_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/chatbox.cpp
Expand Up @@ -214,12 +214,6 @@ bool chatbox::get_active() const
return true;
}

const std::string& chatbox::get_control_type() const
{
static const std::string type = "chatbox";
return type;
}

void chatbox::set_self_active(const bool /*active*/)
{
/* DO NOTHING */
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/chatbox.hpp
Expand Up @@ -131,7 +131,7 @@ class chatbox : public container_base, public events::chat_handler

wesnothd_connection* wesnothd_connection_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/** See @ref container_base::set_self_active. */
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/drawing.cpp
Expand Up @@ -81,12 +81,6 @@ bool drawing::disable_click_dismiss() const
return false;
}

const std::string& drawing::get_control_type() const
{
static const std::string type = "drawing";
return type;
}

// }---------- DEFINITION ---------{

drawing_definition::drawing_definition(const config& cfg)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/drawing.hpp
Expand Up @@ -103,7 +103,7 @@ class drawing : public styled_widget
/** When we're used as a fixed size item, this holds the best size. */
point best_size_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
};

Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/horizontal_scrollbar.cpp
Expand Up @@ -104,12 +104,6 @@ bool horizontal_scrollbar::in_orthogonal_range(const point& coordinate) const
return static_cast<size_t>(coordinate.x) < get_width();
}

const std::string& horizontal_scrollbar::get_control_type() const
{
static const std::string type = "horizontal_scrollbar";
return type;
}

// }---------- DEFINITION ---------{

horizontal_scrollbar_definition::horizontal_scrollbar_definition(
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/horizontal_scrollbar.hpp
Expand Up @@ -70,7 +70,7 @@ class horizontal_scrollbar : public scrollbar_base
return current.x - original.x;
}

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
};

Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/image.cpp
Expand Up @@ -95,12 +95,6 @@ bool image::disable_click_dismiss() const
return false;
}

const std::string& image::get_control_type() const
{
static const std::string type = "image";
return type;
}

// }---------- DEFINITION ---------{

image_definition::image_definition(const config& cfg)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/image.hpp
Expand Up @@ -93,7 +93,7 @@ class image : public styled_widget
ENABLED,
};

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
};

Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/label.cpp
Expand Up @@ -141,12 +141,6 @@ void label::set_state(const state_t state)
}
}

const std::string& label::get_control_type() const
{
static const std::string type = "label";
return type;
}

void label::signal_handler_left_button_click(const event::ui_event /* event */, bool & handled)
{
DBG_GUI_E << "label click" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/label.hpp
Expand Up @@ -134,7 +134,7 @@ class label : public styled_widget
return can_shrink_;
}

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/list.cpp
Expand Up @@ -379,12 +379,6 @@ void list_view::set_self_active(const bool active)
/* DO NOTHING */
}

const std::string& list_view::get_control_type() const
{
static const std::string type = "list";
return type;
}

void list_view::signal_handler_left_button_down(const event::ui_event event)
{
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/list.hpp
Expand Up @@ -271,7 +271,7 @@ class list_view : public container_base
/** See @ref container_base::set_self_active. */
virtual void set_self_active(const bool active) override;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/listbox.cpp
Expand Up @@ -700,12 +700,6 @@ void listbox::layout_children(const bool force)
}
}

const std::string& listbox::get_control_type() const
{
static const std::string type = "listbox";
return type;
}

// }---------- DEFINITION ---------{

listbox_definition::listbox_definition(const config& cfg)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/listbox.hpp
Expand Up @@ -419,7 +419,7 @@ class listbox : public scrollbar_container
/** Inherited from scrollbar_container. */
virtual void set_content_size(const point& origin, const point& size) override;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

void order_by_column(unsigned column, widget& widget);
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/matrix.cpp
Expand Up @@ -183,12 +183,6 @@ iteration::walker_base* matrix::create_walker()
return nullptr;
}

const std::string& matrix::get_control_type() const
{
static const std::string type = "matrix";
return type;
}

// }---------- DEFINITION ---------{

/*WIKI
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/matrix.hpp
Expand Up @@ -224,7 +224,7 @@ class matrix : public tbase
*/
pane* pane_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
};

Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/menu_button.cpp
Expand Up @@ -87,12 +87,6 @@ void menu_button::set_state(const state_t state)
}
}

const std::string& menu_button::get_control_type() const
{
static const std::string type = "menu_button";
return type;
}

void menu_button::signal_handler_mouse_enter(const event::ui_event event, bool& handled)
{
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/menu_button.hpp
Expand Up @@ -145,7 +145,7 @@ class menu_button : public styled_widget, public selectable_item
/** See selectable_item::set_callback_state_change. */
std::function<void(widget&)> callback_state_change_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/minimap.cpp
Expand Up @@ -255,12 +255,6 @@ void minimap::impl_draw_background(surface& frame_buffer,
}
}

const std::string& minimap::get_control_type() const
{
static const std::string type = "minimap";
return type;
}

// }---------- DEFINITION ---------{

minimap_definition::minimap_definition(const config& cfg)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/minimap.hpp
Expand Up @@ -106,7 +106,7 @@ class minimap : public styled_widget
int x_offset,
int y_offset) override;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
};

Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/multi_page.cpp
Expand Up @@ -153,12 +153,6 @@ void multi_page::impl_draw_background(surface& /*frame_buffer*/
/* DO NOTHING */
}

const std::string& multi_page::get_control_type() const
{
static const std::string type = "multi_page";
return type;
}

void multi_page::set_self_active(const bool /*active*/)
{
/* DO NOTHING */
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/multi_page.hpp
Expand Up @@ -205,7 +205,7 @@ class multi_page : public container_base
int x_offset,
int y_offset) override;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/** See @ref container_base::set_self_active. */
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/multimenu_button.cpp
Expand Up @@ -87,12 +87,6 @@ void multimenu_button::set_state(const state_t state)
}
}

const std::string& multimenu_button::get_control_type() const
{
static const std::string type = "multimenu_button";
return type;
}

void multimenu_button::signal_handler_mouse_enter(const event::ui_event event, bool& handled)
{
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/multimenu_button.hpp
Expand Up @@ -196,7 +196,7 @@ class multimenu_button : public styled_widget
void update_config_from_toggle_states();
void update_label();

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/panel.cpp
Expand Up @@ -88,12 +88,6 @@ point panel::border_space() const
return point(conf->left_border + conf->right_border, conf->top_border + conf->bottom_border);
}

const std::string& panel::get_control_type() const
{
static const std::string type = "panel";
return type;
}

void panel::set_self_active(const bool /*active*/)
{
/* DO NOTHING */
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/panel.hpp
Expand Up @@ -62,7 +62,7 @@ class panel : public container_base
int x_offset,
int y_offset) override;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/** See @ref container_base::border_space. */
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/progress_bar.cpp
Expand Up @@ -76,12 +76,6 @@ bool progress_bar::disable_click_dismiss() const
return false;
}

const std::string& progress_bar::get_control_type() const
{
static const std::string type = "progress_bar";
return type;
}

// }---------- DEFINITION ---------{

progress_bar_definition::progress_bar_definition(const config& cfg)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/progress_bar.hpp
Expand Up @@ -69,7 +69,7 @@ class progress_bar : public styled_widget
/** The percentage done. */
unsigned percentage_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
};

Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/repeating_button.cpp
Expand Up @@ -101,12 +101,6 @@ void repeating_button::set_state(const state_t state)
}
}

const std::string& repeating_button::get_control_type() const
{
static const std::string type = "repeating_button";
return type;
}

void repeating_button::signal_handler_mouse_enter(const event::ui_event event,
bool& handled)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/repeating_button.hpp
Expand Up @@ -102,7 +102,7 @@ class repeating_button : public styled_widget, public clickable_item
/** The timer for the repeating events. */
size_t repeat_timer_;

/** See @ref styled_widget::get_control_type. */
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;

/***** ***** ***** signal handlers ***** ****** *****/
Expand Down
6 changes: 0 additions & 6 deletions src/gui/widgets/scroll_label.cpp
Expand Up @@ -150,12 +150,6 @@ bool scroll_label::can_wrap() const
return wrap_on_;
}

const std::string& scroll_label::get_control_type() const
{
static const std::string type = "scroll_label";
return type;
}

void scroll_label::signal_handler_left_button_down(const event::ui_event event)
{
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
Expand Down

0 comments on commit 3b4b7b9

Please sign in to comment.