GUI2:Canvas: remove custom drawing function interface

This was only needed for the minimap since each canvas had its own texture, and the
minimap widget's canvas texture needed to be passed to image::render_minimap (that
function operated on the current render target, in this case, the canvas texture).
As of 02858f2259 we render directly to the screen instead,
so this isn't needed anymore.
This commit is contained in:
Charles Dang 2018-05-22 22:14:34 +11:00
parent b2fc0f25e0
commit 2819f549a1
4 changed files with 4 additions and 23 deletions

View file

@ -1354,7 +1354,6 @@ void text_shape::draw(
canvas::canvas()
: shapes_()
, draw_func_(nullptr)
, blur_depth_(0)
, w_(0)
, h_(0)
@ -1367,7 +1366,6 @@ canvas::canvas()
canvas::canvas(canvas&& c)
: shapes_(std::move(c.shapes_))
, draw_func_(c.draw_func_)
, blur_depth_(c.blur_depth_)
, w_(c.w_)
, h_(c.h_)
@ -1392,12 +1390,6 @@ void canvas::draw()
variables_.add("height", wfl::variant(h_));
}
// If we have a custom drawing function, call it now and exit.
if(draw_func_) {
draw_func_(w_, h_);
return;
}
// Draw shapes.
for(auto& shape : shapes_) {
lg::scope_logger inner_scope_logging_object__(log_gui_draw, "Canvas: draw shape.");

View file

@ -93,8 +93,6 @@ public:
~canvas();
using draw_func_t = std::function<void(unsigned, unsigned)>;
/**
* Draws the canvas.
*/
@ -108,11 +106,6 @@ public:
*/
void render();
void set_draw_function(draw_func_t func)
{
draw_func_ = func;
}
/**
* Sets the config.
*
@ -161,9 +154,6 @@ private:
/** Vector with the shapes to draw. */
std::vector<shape_ptr> shapes_;
/** Optional custom drawing function. */
draw_func_t draw_func_;
/**
* The depth of the blur to use in the pre committing.
*

View file

@ -54,7 +54,6 @@ minimap::minimap(const implementation::builder_minimap& builder)
, terrain_(nullptr)
, map_(nullptr)
{
get_canvas(0).set_draw_function(std::bind(&minimap::canvas_draw_background, this, _1, _2));
}
void minimap::set_active(const bool /*active*/)
@ -93,10 +92,10 @@ void minimap::set_map_data(const std::string& map_data)
}
}
void minimap::canvas_draw_background(unsigned dst_w, unsigned dst_h)
void minimap::impl_draw_background()
{
if(map_) {
image::render_minimap(dst_w, dst_h, *map_, nullptr, nullptr, nullptr, true);
image::render_minimap(get_width(), get_height(), *map_, nullptr, nullptr, nullptr, true);
}
}

View file

@ -89,8 +89,8 @@ private:
/** Game map generated from the provided data. */
std::unique_ptr<gamemap> map_;
/** Drawing function passed to the background canvas. */
void canvas_draw_background(unsigned dst_w, unsigned dst_h);
/** See @ref widget::impl_draw_background. */
virtual void impl_draw_background() override;
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;