cgv
Loading...
Searching...
No Matches
themed_canvas_overlay.cxx
1#include "themed_canvas_overlay.h"
2
3namespace cgv {
4namespace app {
5
7 const auto& theme = cgv::gui::theme_info::instance();
8 init_container_style(theme);
9 set_margin(cgv::ivec2(-theme.spacing()));
10}
11
13 register_shader("rectangle", cgv::g2d::shaders::rectangle);
14 return canvas_overlay::init(ctx);
15}
16
17void themed_canvas_overlay::begin_content(cgv::render::context& ctx, bool clear_frame_buffer) {
18 canvas_overlay::begin_content(ctx, clear_frame_buffer);
19
21 content_canvas.enable_shader(ctx, "rectangle");
22 content_canvas.set_style(ctx, container_style_);
23 content_canvas.draw_shape(ctx, get_local_rectangle());
24 content_canvas.disable_current_shader(ctx);
25 }
26}
27
29 init_container_style(theme);
30 init_styles();
31 post_damage();
32}
33
34void themed_canvas_overlay::init_container_style(const cgv::gui::theme_info& theme) {
35 // configure style for the container background
36 container_style_.fill_color = theme.group();
37 container_style_.border_color = theme.background();
38 container_style_.border_width = static_cast<float>(theme.spacing());
39 container_style_.feather_width = 0.0f;
40}
41
43 auto rectangle = get_local_rectangle();
44 rectangle.scale(-padding_);
45 return rectangle;
46}
47
48void themed_canvas_overlay::set_background_visible(bool flag) {
51}
52
53}
54}
virtual void on_set(void *member_ptr) override
default implementation of that calls handle_member_change and afterwards upates the member in the gui...
bool init(cgv::render::context &ctx) override
this method is called after creation or recreation of the context, return whether all necessary funct...
void set_margin(const ivec2 &margin)
set the overlay margin
Definition overlay.cxx:103
cgv::g2d::irect get_local_rectangle() const
return the current rectangle area of the overlay in local space, i.e. with position set to zero
Definition overlay.h:142
virtual void handle_theme_change(const cgv::gui::theme_info &theme) override
override in your class to handle theme changes
cgv::g2d::irect get_content_rectangle() const
return the current rectangle area of the themed_overlay content
bool init(cgv::render::context &ctx) override
this method is called after creation or recreation of the context, return whether all necessary funct...
bool background_visible_
whether the background is visible (true by default)
themed_canvas_overlay()
creates an overlay in the bottom left corner with zero size using a canvas for 2d drawing
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
the cgv namespace
Definition print.h:11