21 cgv::g2d::irect border_rect;
22 cgv::g2d::irect color_rect;
23 cgv::g2d::irect hue_rect;
24 cgv::g2d::irect opacity_rect;
25 cgv::g2d::irect preview_rect;
27 cgv::g2d::irect hue_constraint;
28 cgv::g2d::irect opacity_constraint;
33 bool is_rectangular =
false;
37 position_is_center =
true;
38 constraint_reference = CR_CENTER;
43 const cgv::g2d::irect& c = *constraint;
44 vec2 p = position -
static_cast<vec2>(c.position);
46 val = p /
static_cast<vec2>(size);
47 if(size.x() == 0) val.
x() = 0.0f;
48 if(size.y() == 0) val.
y() = 0.0f;
49 val = cgv::math::clamp(val, 0.0f, 1.0f);
55 const cgv::g2d::irect& c = *constraint;
56 val = cgv::math::clamp(val, 0.0f, 1.0f);
57 position =
static_cast<vec2>(c.position) + val * c.
size;
61 bool contains(
const vec2& mp)
const override {
63 return draggable::contains(mp);
65 const auto dist = length(mp - center());
66 return dist <= 0.5f*size.x();
71 bool has_opacity =
false;
72 bool auto_show =
true;
74 std::vector<std::string> texts;
75 cgv::g2d::msdf_text_geometry text_geometry;
77 cgv::g2d::shape2d_style border_style, color_texture_style, hue_texture_style, opacity_color_style, color_handle_style, hue_handle_style;
78 cgv::g2d::text2d_style text_style;
79 cgv::g2d::grid2d_style opacity_bg_style;
81 cgv::g2d::draggable_collection<selector_handle> selector_handles;
89 void update_layout(
const ivec2& parent_size);
91 void init_styles()
override;
93 void update_color_texture();
97 void handle_selector_drag(cgv::g2d::DragAction action);
99 void set_color(
rgba color,
bool opacity,
bool init =
false);
101 std::function<void(
rgb)> on_change_rgb_callback;
102 std::function<void(
rgba)> on_change_rgba_callback;
104 void create_gui_impl()
override;
122 void set_rgb_color(
rgb color);
123 void set_rgba_color(
rgba color);
124 rgb get_rgb_color()
const {
return rgb_color; }
125 rgba get_rgba_color()
const {
return rgba_color; }
127 void set_on_change_rgb_callback(std::function<
void(rgb)> cb) { on_change_rgb_callback = cb; }
128 void set_on_change_rgba_callback(std::function<
void(rgba)> cb) { on_change_rgba_callback = cb; }
base class for all drawables, which is independent of the used rendering API.
the texture class encapsulates all functionality independent of the rendering api.