GUI2: removed unused offset parameters from drawing functions
These were added in8f945cf235
, but since the "new" listbox implementation never came to be, these have just been unused clutter. There was one place they were used as parameters in a manual call to calculate_blitting_rectangle, but that was refactored out in3332ae9757
. This also removes an overload of widget::draw_debug_border, since without the offsets, both functions now did the same thing. This affects: * widget::draw_background * widget::draw_children * widget::draw_foreground * widget::impl_draw_background (offset overload removed) * widget::impl_draw_children * widget::impl_draw_foreground * widget::calculate_blitting_rectangle * widget::calculate_clipping_rectangle * widget::draw_debug_border
This commit is contained in:
parent
eecc46f02f
commit
b2fc0f25e0
29 changed files with 77 additions and 137 deletions
|
@ -194,12 +194,12 @@ void container_base::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
grid_.set_visible_rectangle(rectangle);
|
grid_.set_visible_rectangle(rectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void container_base::impl_draw_children(int x_offset, int y_offset)
|
void container_base::impl_draw_children()
|
||||||
{
|
{
|
||||||
assert(get_visible() == widget::visibility::visible
|
assert(get_visible() == widget::visibility::visible
|
||||||
&& grid_.get_visible() == widget::visibility::visible);
|
&& grid_.get_visible() == widget::visibility::visible);
|
||||||
|
|
||||||
grid_.draw_children(x_offset, y_offset);
|
grid_.draw_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void container_base::layout_children()
|
void container_base::layout_children()
|
||||||
|
|
|
@ -107,7 +107,7 @@ public:
|
||||||
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** See @ref widget::layout_children. */
|
/** See @ref widget::layout_children. */
|
||||||
|
|
|
@ -279,7 +279,7 @@ public:
|
||||||
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override = 0;
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override = 0;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override = 0;
|
virtual void impl_draw_children() override = 0;
|
||||||
|
|
||||||
/** See @ref widget::find_at. */
|
/** See @ref widget::find_at. */
|
||||||
virtual widget* find_at(const point& coordinate,
|
virtual widget* find_at(const point& coordinate,
|
||||||
|
|
|
@ -826,7 +826,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override
|
virtual void impl_draw_children() override
|
||||||
{
|
{
|
||||||
assert(this->get_visible() == widget::visibility::visible);
|
assert(this->get_visible() == widget::visibility::visible);
|
||||||
|
|
||||||
|
@ -836,7 +836,7 @@ public:
|
||||||
child* item = items_[index].get();
|
child* item = items_[index].get();
|
||||||
|
|
||||||
if(item->child_grid.get_visible() == widget::visibility::visible && item->shown) {
|
if(item->child_grid.get_visible() == widget::visibility::visible && item->shown) {
|
||||||
item->child_grid.draw_children(x_offset, y_offset);
|
item->child_grid.draw_children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -975,7 +975,7 @@ void grid::layout(const point& origin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void grid::impl_draw_children(int x_offset, int y_offset)
|
void grid::impl_draw_children()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The call to SDL_PumpEvents seems a bit like black magic.
|
* The call to SDL_PumpEvents seems a bit like black magic.
|
||||||
|
@ -1003,9 +1003,9 @@ void grid::impl_draw_children(int x_offset, int y_offset)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget->draw_background(x_offset, y_offset);
|
widget->draw_background();
|
||||||
widget->draw_children(x_offset, y_offset);
|
widget->draw_children();
|
||||||
widget->draw_foreground(x_offset, y_offset);
|
widget->draw_foreground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -547,7 +547,7 @@ private:
|
||||||
void layout(const point& origin);
|
void layout(const point& origin);
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,10 +111,9 @@ void matrix::layout_initialize(const bool full_initialization)
|
||||||
content_.layout_initialize(full_initialization);
|
content_.layout_initialize(full_initialization);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void matrix::impl_draw_children()
|
||||||
matrix::impl_draw_children(int x_offset, int y_offset)
|
|
||||||
{
|
{
|
||||||
content_.draw_children(x_offset, y_offset);
|
content_.draw_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix::layout_children()
|
void matrix::layout_children()
|
||||||
|
|
|
@ -121,7 +121,7 @@ public:
|
||||||
virtual void layout_initialize(const bool full_initialization) override;
|
virtual void layout_initialize(const bool full_initialization) override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
|
|
||||||
/** See @ref widget::layout_children. */
|
/** See @ref widget::layout_children. */
|
||||||
virtual void layout_children() override;
|
virtual void layout_children() override;
|
||||||
|
|
|
@ -144,7 +144,7 @@ void multi_page::finalize(const std::vector<string_map>& page_data)
|
||||||
swap_grid(nullptr, &get_grid(), generator_, "_content_grid");
|
swap_grid(nullptr, &get_grid(), generator_, "_content_grid");
|
||||||
}
|
}
|
||||||
|
|
||||||
void multi_page::impl_draw_background(int /*x_offset*/, int /*y_offset*/)
|
void multi_page::impl_draw_background()
|
||||||
{
|
{
|
||||||
/* DO NOTHING */
|
/* DO NOTHING */
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ private:
|
||||||
std::map<std::string, builder_grid_const_ptr> page_builders_;
|
std::map<std::string, builder_grid_const_ptr> page_builders_;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_background. */
|
/** See @ref widget::impl_draw_background. */
|
||||||
virtual void impl_draw_background(int x_offset, int y_offset) override;
|
virtual void impl_draw_background() override;
|
||||||
|
|
||||||
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
||||||
virtual const std::string& get_control_type() const override;
|
virtual const std::string& get_control_type() const override;
|
||||||
|
|
|
@ -186,14 +186,14 @@ void pane::layout_initialize(const bool full_initialization)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pane::impl_draw_children(int x_offset, int y_offset)
|
pane::impl_draw_children()
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER << '\n';
|
DBG_GUI_D << LOG_HEADER << '\n';
|
||||||
|
|
||||||
for(auto & item : items_)
|
for(auto & item : items_)
|
||||||
{
|
{
|
||||||
if(item.item_grid->get_visible() != widget::visibility::invisible) {
|
if(item.item_grid->get_visible() != widget::visibility::invisible) {
|
||||||
item.item_grid->draw_children(x_offset, y_offset);
|
item.item_grid->draw_children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
virtual void layout_initialize(const bool full_initialization) override;
|
virtual void layout_initialize(const bool full_initialization) override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
|
|
||||||
/** See @ref widget::request_reduce_width. */
|
/** See @ref widget::request_reduce_width. */
|
||||||
virtual void request_reduce_width(const unsigned maximum_width) override;
|
virtual void request_reduce_width(const unsigned maximum_width) override;
|
||||||
|
|
|
@ -64,14 +64,14 @@ unsigned panel::get_state() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void panel::impl_draw_background(int /*x_offset*/, int /*y_offset*/)
|
void panel::impl_draw_background()
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER << " size " << get_rectangle() << ".\n";
|
DBG_GUI_D << LOG_HEADER << " size " << get_rectangle() << ".\n";
|
||||||
|
|
||||||
get_canvas(0).render();
|
get_canvas(0).render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void panel::impl_draw_foreground(int /*x_offset*/, int /*y_offset*/)
|
void panel::impl_draw_foreground()
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER << " size " << get_rectangle() << ".\n";
|
DBG_GUI_D << LOG_HEADER << " size " << get_rectangle() << ".\n";
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** See @ref widget::impl_draw_background. */
|
/** See @ref widget::impl_draw_background. */
|
||||||
virtual void impl_draw_background(int x_offset, int y_offset) override;
|
virtual void impl_draw_background() override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_foreground. */
|
/** See @ref widget::impl_draw_foreground. */
|
||||||
virtual void impl_draw_foreground(int x_offset, int y_offset) override;
|
virtual void impl_draw_foreground() override;
|
||||||
|
|
||||||
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
||||||
virtual const std::string& get_control_type() const override;
|
virtual const std::string& get_control_type() const override;
|
||||||
|
|
|
@ -785,14 +785,14 @@ void scrollbar_container::set_horizontal_scrollbar_mode(const scrollbar_mode scr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollbar_container::impl_draw_children(int x_offset, int y_offset)
|
void scrollbar_container::impl_draw_children()
|
||||||
{
|
{
|
||||||
assert(get_visible() == widget::visibility::visible && content_grid_->get_visible() == widget::visibility::visible);
|
assert(get_visible() == widget::visibility::visible && content_grid_->get_visible() == widget::visibility::visible);
|
||||||
|
|
||||||
// Inherited.
|
// Inherited.
|
||||||
container_base::impl_draw_children(x_offset, y_offset);
|
container_base::impl_draw_children();
|
||||||
|
|
||||||
content_grid_->draw_children( x_offset, y_offset);
|
content_grid_->draw_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollbar_container::layout_children()
|
void scrollbar_container::layout_children()
|
||||||
|
|
|
@ -506,7 +506,7 @@ private:
|
||||||
virtual void layout_children() override;
|
virtual void layout_children() override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the size of the content grid.
|
* Sets the size of the content grid.
|
||||||
|
|
|
@ -96,7 +96,7 @@ bool spacer::disable_click_dismiss() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spacer::impl_draw_background(int /*x_offset*/, int /*y_offset*/)
|
void spacer::impl_draw_background()
|
||||||
{
|
{
|
||||||
/* DO NOTHING */
|
/* DO NOTHING */
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ private:
|
||||||
bool fills_available_space();
|
bool fills_available_space();
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_background. */
|
/** See @ref widget::impl_draw_background. */
|
||||||
virtual void impl_draw_background(int x_offset, int y_offset) override;
|
virtual void impl_draw_background() override;
|
||||||
|
|
||||||
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
||||||
virtual const std::string& get_control_type() const override;
|
virtual const std::string& get_control_type() const override;
|
||||||
|
|
|
@ -407,7 +407,7 @@ int styled_widget::get_text_maximum_height() const
|
||||||
return get_height() - config_->text_extra_height;
|
return get_height() - config_->text_extra_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void styled_widget::impl_draw_background(int /*x_offset*/, int /*y_offset*/)
|
void styled_widget::impl_draw_background()
|
||||||
{
|
{
|
||||||
DBG_GUI_D << LOG_HEADER << " label '" << debug_truncate(label_) << "' size "
|
DBG_GUI_D << LOG_HEADER << " label '" << debug_truncate(label_) << "' size "
|
||||||
<< get_rectangle() << ".\n";
|
<< get_rectangle() << ".\n";
|
||||||
|
@ -415,7 +415,7 @@ void styled_widget::impl_draw_background(int /*x_offset*/, int /*y_offset*/)
|
||||||
get_canvas(get_state()).render();
|
get_canvas(get_state()).render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void styled_widget::impl_draw_foreground(int /*x_offset*/, int /*y_offset*/)
|
void styled_widget::impl_draw_foreground()
|
||||||
{
|
{
|
||||||
/* DO NOTHING */
|
/* DO NOTHING */
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,10 +412,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** See @ref widget::impl_draw_background. */
|
/** See @ref widget::impl_draw_background. */
|
||||||
virtual void impl_draw_background(int x_offset, int y_offset) override;
|
virtual void impl_draw_background() override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_foreground. */
|
/** See @ref widget::impl_draw_foreground. */
|
||||||
virtual void impl_draw_foreground(int x_offset, int y_offset) override;
|
virtual void impl_draw_foreground() override;
|
||||||
|
|
||||||
/** Exposes font::pango_text::get_token, for the text label of this styled_widget */
|
/** Exposes font::pango_text::get_token, for the text label of this styled_widget */
|
||||||
std::string get_label_token(const point & position, const char * delimiters = " \n\r\t") const;
|
std::string get_label_token(const point & position, const char * delimiters = " \n\r\t") const;
|
||||||
|
|
|
@ -191,18 +191,18 @@ void toggle_panel::set_state(const state_t state)
|
||||||
assert(conf);
|
assert(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_panel::impl_draw_background(int x_offset, int y_offset)
|
void toggle_panel::impl_draw_background()
|
||||||
{
|
{
|
||||||
// We don't have a fore and background and need to draw depending on
|
// We don't have a fore and background and need to draw depending on
|
||||||
// our state, like a styled_widget. So we use the styled_widget's drawing method.
|
// our state, like a styled_widget. So we use the styled_widget's drawing method.
|
||||||
styled_widget::impl_draw_background(x_offset, y_offset);
|
styled_widget::impl_draw_background();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_panel::impl_draw_foreground(int x_offset, int y_offset)
|
void toggle_panel::impl_draw_foreground()
|
||||||
{
|
{
|
||||||
// We don't have a fore and background and need to draw depending on
|
// We don't have a fore and background and need to draw depending on
|
||||||
// our state, like a styled_widget. So we use the styled_widget's drawing method.
|
// our state, like a styled_widget. So we use the styled_widget's drawing method.
|
||||||
styled_widget::impl_draw_foreground(x_offset, y_offset);
|
styled_widget::impl_draw_foreground();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle_panel::signal_handler_mouse_enter(const event::ui_event event,
|
void toggle_panel::signal_handler_mouse_enter(const event::ui_event event,
|
||||||
|
|
|
@ -148,10 +148,10 @@ private:
|
||||||
std::function<void(widget&)> callback_mouse_left_double_click_;
|
std::function<void(widget&)> callback_mouse_left_double_click_;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_background. */
|
/** See @ref widget::impl_draw_background. */
|
||||||
virtual void impl_draw_background(int x_offset, int y_offset) override;
|
virtual void impl_draw_background() override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_foreground. */
|
/** See @ref widget::impl_draw_foreground. */
|
||||||
virtual void impl_draw_foreground(int x_offset, int y_offset) override;
|
virtual void impl_draw_foreground() override;
|
||||||
|
|
||||||
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
|
||||||
virtual const std::string& get_control_type() const override;
|
virtual const std::string& get_control_type() const override;
|
||||||
|
|
|
@ -549,16 +549,16 @@ void tree_view_node::set_visible_rectangle(const SDL_Rect& rectangle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tree_view_node::impl_draw_children(int x_offset, int y_offset)
|
void tree_view_node::impl_draw_children()
|
||||||
{
|
{
|
||||||
grid_.draw_children(x_offset, y_offset);
|
grid_.draw_children();
|
||||||
|
|
||||||
if(is_folded()) {
|
if(is_folded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto & node : children_) {
|
for(auto & node : children_) {
|
||||||
node->impl_draw_children(x_offset, y_offset);
|
node->impl_draw_children();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ private:
|
||||||
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;
|
virtual void set_visible_rectangle(const SDL_Rect& rectangle) override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
|
|
||||||
// FIXME rename to icon
|
// FIXME rename to icon
|
||||||
void signal_handler_left_button_click(const event::ui_event event);
|
void signal_handler_left_button_click(const event::ui_event event);
|
||||||
|
|
|
@ -120,16 +120,12 @@ void viewport::layout_initialize(const bool full_initialization)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void viewport::impl_draw_children()
|
||||||
viewport::impl_draw_children(int x_offset, int y_offset)
|
|
||||||
{
|
{
|
||||||
x_offset += get_x();
|
|
||||||
y_offset += get_y();
|
|
||||||
|
|
||||||
if(widget_.get_visible() != widget::visibility::invisible) {
|
if(widget_.get_visible() != widget::visibility::invisible) {
|
||||||
widget_.draw_background(x_offset, y_offset);
|
widget_.draw_background();
|
||||||
widget_.draw_children(x_offset, y_offset);
|
widget_.draw_children();
|
||||||
widget_.draw_foreground(x_offset, y_offset);
|
widget_.draw_foreground();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
virtual void layout_initialize(const bool full_initialization) override;
|
virtual void layout_initialize(const bool full_initialization) override;
|
||||||
|
|
||||||
/** See @ref widget::impl_draw_children. */
|
/** See @ref widget::impl_draw_children. */
|
||||||
virtual void impl_draw_children(int x_offset, int y_offset) override;
|
virtual void impl_draw_children() override;
|
||||||
|
|
||||||
/** See @ref widget::request_reduce_width. */
|
/** See @ref widget::request_reduce_width. */
|
||||||
virtual void request_reduce_width(const unsigned maximum_width) override;
|
virtual void request_reduce_width(const unsigned maximum_width) override;
|
||||||
|
|
|
@ -341,20 +341,14 @@ void widget::set_linked_group(const std::string& linked_group)
|
||||||
|
|
||||||
/***** ***** ***** ***** Drawing functions. ***** ***** ***** *****/
|
/***** ***** ***** ***** Drawing functions. ***** ***** ***** *****/
|
||||||
|
|
||||||
SDL_Rect widget::calculate_blitting_rectangle(const int x_offset, const int y_offset) const
|
SDL_Rect widget::calculate_blitting_rectangle() const
|
||||||
{
|
{
|
||||||
SDL_Rect result = get_rectangle();
|
return get_rectangle();
|
||||||
result.x += x_offset;
|
|
||||||
result.y += y_offset;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect widget::calculate_clipping_rectangle(const int x_offset, const int y_offset) const
|
SDL_Rect widget::calculate_clipping_rectangle() const
|
||||||
{
|
{
|
||||||
SDL_Rect result = clipping_rectangle_;
|
return clipping_rectangle_;
|
||||||
result.x += x_offset;
|
|
||||||
result.y += y_offset;
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -365,11 +359,11 @@ namespace
|
||||||
class viewport_and_clip_rect_setter
|
class viewport_and_clip_rect_setter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
viewport_and_clip_rect_setter(const widget& widget, int x_offset, int y_offset)
|
explicit viewport_and_clip_rect_setter(const widget& widget)
|
||||||
: renderer_(CVideo::get_singleton().get_renderer())
|
: renderer_(CVideo::get_singleton().get_renderer())
|
||||||
{
|
{
|
||||||
// Set viewport.
|
// Set viewport.
|
||||||
const SDL_Rect dst_rect = widget.calculate_blitting_rectangle(x_offset, y_offset);
|
const SDL_Rect dst_rect = widget.calculate_blitting_rectangle();
|
||||||
SDL_RenderSetViewport(renderer_, &dst_rect);
|
SDL_RenderSetViewport(renderer_, &dst_rect);
|
||||||
|
|
||||||
// Set clip rect, if appropriate.
|
// Set clip rect, if appropriate.
|
||||||
|
@ -377,7 +371,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect clip_rect = widget.calculate_clipping_rectangle(x_offset, y_offset);
|
SDL_Rect clip_rect = widget.calculate_clipping_rectangle();
|
||||||
|
|
||||||
// Adjust clip rect origin to match the viewport origin. Currently, the both rects are mapped to
|
// Adjust clip rect origin to match the viewport origin. Currently, the both rects are mapped to
|
||||||
// absolute screen coordinates. However, setting the viewport essentially moves the screen origin,
|
// absolute screen coordinates. However, setting the viewport essentially moves the screen origin,
|
||||||
|
@ -406,32 +400,32 @@ private:
|
||||||
* Currently they're only needed by the minimap.
|
* Currently they're only needed by the minimap.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void widget::draw_background(int x_offset, int y_offset)
|
void widget::draw_background()
|
||||||
{
|
{
|
||||||
assert(visible_ == visibility::visible);
|
assert(visible_ == visibility::visible);
|
||||||
|
|
||||||
viewport_and_clip_rect_setter setter(*this, x_offset, y_offset);
|
viewport_and_clip_rect_setter setter(*this);
|
||||||
|
|
||||||
draw_debug_border(x_offset, y_offset);
|
draw_debug_border();
|
||||||
impl_draw_background(x_offset, y_offset);
|
impl_draw_background();
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget::draw_children(int x_offset, int y_offset)
|
void widget::draw_children()
|
||||||
{
|
{
|
||||||
assert(visible_ == visibility::visible);
|
assert(visible_ == visibility::visible);
|
||||||
|
|
||||||
viewport_and_clip_rect_setter setter(*this, x_offset, y_offset);
|
viewport_and_clip_rect_setter setter(*this);
|
||||||
|
|
||||||
impl_draw_children(x_offset, y_offset);
|
impl_draw_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget::draw_foreground(int x_offset, int y_offset)
|
void widget::draw_foreground()
|
||||||
{
|
{
|
||||||
assert(visible_ == visibility::visible);
|
assert(visible_ == visibility::visible);
|
||||||
|
|
||||||
viewport_and_clip_rect_setter setter(*this, x_offset, y_offset);
|
viewport_and_clip_rect_setter setter(*this);
|
||||||
|
|
||||||
impl_draw_foreground(x_offset, y_offset);
|
impl_draw_foreground();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect widget::get_dirty_rectangle() const
|
SDL_Rect widget::get_dirty_rectangle() const
|
||||||
|
@ -500,33 +494,10 @@ void widget::set_debug_border_color(const color_t debug_border_color)
|
||||||
}
|
}
|
||||||
|
|
||||||
void widget::draw_debug_border()
|
void widget::draw_debug_border()
|
||||||
{
|
|
||||||
SDL_Rect r = redraw_action_ == redraw_action::partly ? clipping_rectangle_
|
|
||||||
: get_rectangle();
|
|
||||||
|
|
||||||
switch(debug_border_mode_) {
|
|
||||||
case 0:
|
|
||||||
/* DO NOTHING */
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
sdl::draw_rectangle(r, debug_border_color_);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
sdl::fill_rectangle(r, debug_border_color_);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
widget::draw_debug_border(int x_offset, int y_offset)
|
|
||||||
{
|
{
|
||||||
SDL_Rect r = redraw_action_ == redraw_action::partly
|
SDL_Rect r = redraw_action_ == redraw_action::partly
|
||||||
? calculate_clipping_rectangle(x_offset, y_offset)
|
? calculate_clipping_rectangle()
|
||||||
: calculate_blitting_rectangle(x_offset, y_offset);
|
: calculate_blitting_rectangle();
|
||||||
|
|
||||||
switch(debug_border_mode_) {
|
switch(debug_border_mode_) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -508,12 +508,9 @@ public:
|
||||||
* The blitting rectangle is the entire widget rectangle, but offsetted for
|
* The blitting rectangle is the entire widget rectangle, but offsetted for
|
||||||
* drawing position.
|
* drawing position.
|
||||||
*
|
*
|
||||||
* @param x_offset The offset in the x-direction when drawn.
|
|
||||||
* @param y_offset The offset in the y-direction when drawn.
|
|
||||||
*
|
|
||||||
* @returns The drawing rectangle.
|
* @returns The drawing rectangle.
|
||||||
*/
|
*/
|
||||||
SDL_Rect calculate_blitting_rectangle(const int x_offset, const int y_offset) const;
|
SDL_Rect calculate_blitting_rectangle() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the clipping rectangle of the widget.
|
* Calculates the clipping rectangle of the widget.
|
||||||
|
@ -522,25 +519,17 @@ public:
|
||||||
* @ref redraw_action::partly. Since the drawing can be offsetted it also
|
* @ref redraw_action::partly. Since the drawing can be offsetted it also
|
||||||
* needs offset parameters.
|
* needs offset parameters.
|
||||||
*
|
*
|
||||||
* @param x_offset The offset in the x-direction when drawn.
|
|
||||||
* @param y_offset The offset in the y-direction when drawn.
|
|
||||||
*
|
|
||||||
* @returns The clipping rectangle.
|
* @returns The clipping rectangle.
|
||||||
*/
|
*/
|
||||||
SDL_Rect calculate_clipping_rectangle(const int x_offset, const int y_offset) const;
|
SDL_Rect calculate_clipping_rectangle() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the background of a widget.
|
* Draws the background of a widget.
|
||||||
*
|
*
|
||||||
* Derived should override @ref impl_draw_background instead of changing
|
* Derived should override @ref impl_draw_background instead of changing
|
||||||
* this function.
|
* this function.
|
||||||
*
|
|
||||||
* @param x_offset The offset in the x-direction in the
|
|
||||||
* @p frame_buffer to draw.
|
|
||||||
* @param y_offset The offset in the y-direction in the
|
|
||||||
* @p frame_buffer to draw.
|
|
||||||
*/
|
*/
|
||||||
void draw_background(int x_offset, int y_offset);
|
void draw_background();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the children of a widget.
|
* Draws the children of a widget.
|
||||||
|
@ -549,13 +538,8 @@ public:
|
||||||
*
|
*
|
||||||
* Derived should override @ref impl_draw_children instead of changing
|
* Derived should override @ref impl_draw_children instead of changing
|
||||||
* this function.
|
* this function.
|
||||||
*
|
|
||||||
* @param x_offset The offset in the x-direction in the
|
|
||||||
* @p frame_buffer to draw.
|
|
||||||
* @param y_offset The offset in the y-direction in the
|
|
||||||
* @p frame_buffer to draw.
|
|
||||||
*/
|
*/
|
||||||
void draw_children(int x_offset, int y_offset);
|
void draw_children();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the foreground of the widget.
|
* Draws the foreground of the widget.
|
||||||
|
@ -565,13 +549,8 @@ public:
|
||||||
*
|
*
|
||||||
* Derived should override @ref impl_draw_foreground instead of changing
|
* Derived should override @ref impl_draw_foreground instead of changing
|
||||||
* this function.
|
* this function.
|
||||||
*
|
|
||||||
* @param x_offset The offset in the x-direction in the
|
|
||||||
* @p frame_buffer to draw.
|
|
||||||
* @param y_offset The offset in the y-direction in the
|
|
||||||
* @p frame_buffer to draw.
|
|
||||||
*/
|
*/
|
||||||
void draw_foreground(int x_offset, int y_offset);
|
void draw_foreground();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** See @ref draw_background. */
|
/** See @ref draw_background. */
|
||||||
|
@ -579,17 +558,13 @@ private:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void impl_draw_background(int /*x_offset*/, int /*y_offset*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/** See @ref draw_children. */
|
/** See @ref draw_children. */
|
||||||
virtual void impl_draw_children(int /*x_offset*/, int /*y_offset*/)
|
virtual void impl_draw_children()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** See @ref draw_foreground. */
|
/** See @ref draw_foreground. */
|
||||||
virtual void impl_draw_foreground(int /*x_offset*/, int /*y_offset*/)
|
virtual void impl_draw_foreground()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +629,6 @@ private:
|
||||||
color_t debug_border_color_;
|
color_t debug_border_color_;
|
||||||
|
|
||||||
void draw_debug_border();
|
void draw_debug_border();
|
||||||
void draw_debug_border(int x_offset, int y_offset);
|
|
||||||
|
|
||||||
/***** ***** ***** ***** Query functions ***** ***** ***** *****/
|
/***** ***** ***** ***** Query functions ***** ***** ***** *****/
|
||||||
|
|
||||||
|
|
|
@ -582,13 +582,13 @@ void window::draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw background.
|
// Draw background.
|
||||||
this->draw_background(0, 0);
|
this->draw_background();
|
||||||
|
|
||||||
// Draw children.
|
// Draw children.
|
||||||
this->draw_children(0, 0);
|
this->draw_children();
|
||||||
|
|
||||||
// Draw foreground.
|
// Draw foreground.
|
||||||
this->draw_foreground(0, 0);
|
this->draw_foreground();
|
||||||
|
|
||||||
|
|
||||||
if(callback_next_draw_ != nullptr) {
|
if(callback_next_draw_ != nullptr) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue