Skip to content

Commit

Permalink
GUI2: get rid of all the magic canvas count numbers
Browse files Browse the repository at this point in the history
These were unnecessary since the canvas vector was automatically resized the match the
available number of canvases when a styled_widget was constructed.
  • Loading branch information
Vultraz committed May 26, 2017
1 parent da248a8 commit fc83e20
Show file tree
Hide file tree
Showing 42 changed files with 49 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/gui/widgets/addon_list.hpp
Expand Up @@ -39,7 +39,7 @@ class addon_list : public container_base

public:
addon_list()
: container_base(1)
: container_base()
, addon_vector_()
, install_status_visibility_(visibility::visible)
, install_buttons_visibility_(visibility::invisible)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/button.cpp
Expand Up @@ -40,7 +40,7 @@ namespace gui2

REGISTER_WIDGET(button)

button::button() : styled_widget(COUNT), clickable_item(), state_(ENABLED), retval_(0)
button::button() : styled_widget(), clickable_item(), state_(ENABLED), retval_(0)
{
connect_signal<event::MOUSE_ENTER>(
std::bind(&button::signal_handler_mouse_enter, this, _2, _3));
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/button.hpp
Expand Up @@ -74,7 +74,6 @@ class button : public styled_widget, public clickable_item
DISABLED,
PRESSED,
FOCUSED,
COUNT
};

void set_state(const state_t state);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/chatbox.cpp
Expand Up @@ -53,7 +53,7 @@ namespace gui2
REGISTER_WIDGET(chatbox)

chatbox::chatbox()
: container_base(1)
: container_base()
, roomlistbox_(nullptr)
, chat_log_container_(nullptr)
, chat_input_(nullptr)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/widgets/container_base.cpp
Expand Up @@ -28,8 +28,8 @@
namespace gui2
{

container_base::container_base(const unsigned canvas_count)
: styled_widget(canvas_count), grid_()
container_base::container_base()
: styled_widget(), grid_()
{
grid_.set_parent(this);
connect_signal<event::REQUEST_PLACEMENT>(
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/container_base.hpp
Expand Up @@ -33,7 +33,7 @@ class container_base : public styled_widget
friend class debug_layout_graph;

public:
explicit container_base(const unsigned canvas_count);
container_base();

/**
* Returns the client rect.
Expand Down
3 changes: 1 addition & 2 deletions src/gui/widgets/drawing.hpp
Expand Up @@ -35,7 +35,7 @@ namespace gui2
class drawing : public styled_widget
{
public:
drawing() : styled_widget(COUNT), best_size_(0, 0)
drawing() : styled_widget(), best_size_(0, 0)
{
}

Expand Down Expand Up @@ -97,7 +97,6 @@ class drawing : public styled_widget
*/
enum state_t {
ENABLED,
COUNT
};

/** When we're used as a fixed size item, this holds the best size. */
Expand Down
3 changes: 1 addition & 2 deletions src/gui/widgets/image.hpp
Expand Up @@ -28,7 +28,7 @@ namespace gui2
class image : public styled_widget
{
public:
image() : styled_widget(COUNT)
image() : styled_widget()
{
}

Expand Down Expand Up @@ -89,7 +89,6 @@ class image : public styled_widget
*/
enum state_t {
ENABLED,
COUNT
};

/** See @ref styled_widget::get_control_type. */
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/label.cpp
Expand Up @@ -41,7 +41,7 @@ namespace gui2
REGISTER_WIDGET(label)

label::label()
: styled_widget(COUNT)
: styled_widget()
, state_(ENABLED)
, can_wrap_(false)
, characters_per_line_(0)
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/label.hpp
Expand Up @@ -85,7 +85,6 @@ class label : public styled_widget
enum state_t {
ENABLED,
DISABLED,
COUNT
};

void set_state(const state_t state);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/list.cpp
Expand Up @@ -43,7 +43,7 @@ list_view::list_view(const bool has_minimum,
const generator_base::tplacement placement,
const bool select,
const builder_grid_const_ptr list_builder)
: container_base(2) // FIXME magic number
: container_base()
, state_(ENABLED)
, generator_(nullptr)
, list_builder_(list_builder)
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/list.hpp
Expand Up @@ -219,7 +219,6 @@ class list_view : public container_base
enum state_t {
ENABLED,
DISABLED,
COUNT
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/listbox.cpp
Expand Up @@ -64,7 +64,7 @@ listbox::listbox(const bool has_minimum,
const bool has_maximum,
const generator_base::placement placement,
const bool select)
: scrollbar_container(2) // FIXME magic number
: scrollbar_container()
, generator_(generator_base::build(has_minimum, has_maximum, placement, select))
, is_horizonal_(placement == generator_base::horizontal_list)
, list_builder_(nullptr)
Expand Down
3 changes: 1 addition & 2 deletions src/gui/widgets/matrix.hpp
Expand Up @@ -51,7 +51,6 @@ class state_default
enum state_t {
ENABLED,
DISABLED,
COUNT
};

private:
Expand All @@ -70,7 +69,7 @@ class control_NEW : public styled_widget, public STATE
public:
control_NEW(const implementation::builder_styled_widget& builder,
const std::string& control_type)
: styled_widget(builder, STATE::COUNT, control_type)
: styled_widget(builder, control_type)

{
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/menu_button.cpp
Expand Up @@ -38,7 +38,7 @@ namespace gui2
REGISTER_WIDGET(menu_button)

menu_button::menu_button()
: styled_widget(COUNT)
: styled_widget()
, selectable_item()
, state_(ENABLED)
, retval_(0)
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/menu_button.hpp
Expand Up @@ -110,7 +110,6 @@ class menu_button : public styled_widget, public selectable_item
DISABLED,
PRESSED,
FOCUSED,
COUNT
};

void set_state(const state_t state);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/minimap.hpp
Expand Up @@ -35,7 +35,7 @@ namespace gui2
class minimap : public styled_widget
{
public:
minimap() : styled_widget(1), map_data_(), terrain_(nullptr)
minimap() : styled_widget(), map_data_(), terrain_(nullptr)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/multi_page.cpp
Expand Up @@ -33,7 +33,7 @@ namespace gui2

REGISTER_WIDGET(multi_page)
multi_page::multi_page()
: container_base(0)
: container_base()
, generator_(
generator_base::build(true, true, generator_base::independent, false))
, page_builders_()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/multimenu_button.cpp
Expand Up @@ -40,7 +40,7 @@ namespace gui2
REGISTER_WIDGET(multimenu_button)

multimenu_button::multimenu_button()
: styled_widget(COUNT)
: styled_widget()
, state_(ENABLED)
, retval_(0)
, values_()
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/multimenu_button.hpp
Expand Up @@ -156,7 +156,6 @@ class multimenu_button : public styled_widget
DISABLED,
PRESSED,
FOCUSED,
COUNT
};

void set_state(const state_t state);
Expand Down
4 changes: 1 addition & 3 deletions src/gui/widgets/panel.hpp
Expand Up @@ -36,10 +36,8 @@ class panel : public container_base
public:
/**
* Constructor.
*
* @param canvas_count The canvas count for styled_widget.
*/
explicit panel(const unsigned canvas_count = 2) : container_base(canvas_count)
panel() : container_base()
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/gui/widgets/progress_bar.hpp
Expand Up @@ -27,7 +27,7 @@ namespace gui2
class progress_bar : public styled_widget
{
public:
progress_bar() : styled_widget(COUNT), percentage_(static_cast<unsigned>(-1))
progress_bar() : styled_widget(), percentage_(static_cast<unsigned>(-1))
{
// Force canvas update
set_percentage(0);
Expand Down Expand Up @@ -64,7 +64,6 @@ class progress_bar : public styled_widget
*/
enum state_t {
ENABLED,
COUNT
};

/** The percentage done. */
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/repeating_button.cpp
Expand Up @@ -36,7 +36,7 @@ namespace gui2
REGISTER_WIDGET(repeating_button)

repeating_button::repeating_button()
: styled_widget(COUNT), clickable_item(), state_(ENABLED), repeat_timer_(0)
: styled_widget(), clickable_item(), state_(ENABLED), repeat_timer_(0)
{
connect_signal<event::MOUSE_ENTER>(std::bind(
&repeating_button::signal_handler_mouse_enter, this, _2, _3));
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/repeating_button.hpp
Expand Up @@ -84,7 +84,6 @@ class repeating_button : public styled_widget, public clickable_item
DISABLED,
PRESSED,
FOCUSED,
COUNT
};

void set_state(const state_t state);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/scroll_label.cpp
Expand Up @@ -40,7 +40,7 @@ namespace gui2
REGISTER_WIDGET(scroll_label)

scroll_label::scroll_label(bool wrap, const PangoAlignment text_alignment)
: scrollbar_container(COUNT)
: scrollbar_container()
, state_(ENABLED)
, wrap_on_(wrap)
, text_alignment_(text_alignment)
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/scroll_label.hpp
Expand Up @@ -80,7 +80,6 @@ class scroll_label : public scrollbar_container
enum state_t {
ENABLED,
DISABLED,
COUNT
};

// It's not needed for now so keep it disabled, no definition exists yet.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/scrollbar.cpp
Expand Up @@ -28,7 +28,7 @@ namespace gui2
{

scrollbar_base::scrollbar_base()
: styled_widget(COUNT)
: styled_widget()
, state_(ENABLED)
, item_count_(0)
, item_position_(0)
Expand Down
1 change: 0 additions & 1 deletion src/gui/widgets/scrollbar.hpp
Expand Up @@ -120,7 +120,6 @@ class scrollbar_base : public styled_widget
DISABLED,
PRESSED,
FOCUSED,
COUNT
};

/***** ***** ***** setters / getters for members ***** ****** *****/
Expand Down
4 changes: 2 additions & 2 deletions src/gui/widgets/scrollbar_container.cpp
Expand Up @@ -66,8 +66,8 @@ const std::map<std::string, scrollbar_base::scroll_mode>& scroll_lookup()

} // namespace

scrollbar_container::scrollbar_container(const unsigned canvas_count)
: container_base(canvas_count)
scrollbar_container::scrollbar_container()
: container_base()
, state_(ENABLED)
, vertical_scrollbar_mode_(AUTO_VISIBLE_FIRST_RUN)
, horizontal_scrollbar_mode_(AUTO_VISIBLE_FIRST_RUN)
Expand Down
3 changes: 1 addition & 2 deletions src/gui/widgets/scrollbar_container.hpp
Expand Up @@ -50,7 +50,7 @@ class scrollbar_container : public container_base
friend struct scrollbar_container_implementation;

public:
explicit scrollbar_container(const unsigned canvas_count);
scrollbar_container();

~scrollbar_container()
{
Expand Down Expand Up @@ -455,7 +455,6 @@ class scrollbar_container : public container_base
enum state_t {
ENABLED,
DISABLED,
COUNT
};

/**
Expand Down
6 changes: 2 additions & 4 deletions src/gui/widgets/scrollbar_panel.hpp
Expand Up @@ -42,11 +42,9 @@ class scrollbar_panel : public scrollbar_container
public:
/**
* Constructor.
*
* @param canvas_count The canvas count for styled_widget.
*/
explicit scrollbar_panel(const unsigned canvas_count = 2)
: scrollbar_container(canvas_count)
scrollbar_panel()
: scrollbar_container()
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/size_lock.hpp
Expand Up @@ -37,7 +37,7 @@ class size_lock : public container_base

public:
size_lock() :
container_base(1),
container_base(),
widget_(nullptr)
{}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/spacer.hpp
Expand Up @@ -38,7 +38,7 @@ class spacer : public styled_widget
{
public:
spacer(const std::string& w = "0", const std::string& h = "0")
: styled_widget(0)
: styled_widget()
, width_(w)
, height_(h)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/stacked_widget.cpp
Expand Up @@ -34,7 +34,7 @@ namespace gui2
REGISTER_WIDGET(stacked_widget)

stacked_widget::stacked_widget()
: container_base(1)
: container_base()
, generator_(generator_base::build(false, false, generator_base::independent, false))
, selected_layer_(-1)
{
Expand Down

0 comments on commit fc83e20

Please sign in to comment.