3#include <cgv/defines/deprecated.h>
4#include <cgv/gui/event_handler.h>
5#include <cgv/gui/provider.h>
6#include <cgv/render/context.h>
7#include <cgv/render/drawable.h>
8#include <cgv/utils/pointer_test.h>
9#include <cgv_g2d/trect.h>
10#include <cgv_g2d/utils2d.h>
12#include <cgv/gui/key_event.h>
13#include <cgv/gui/mouse_event.h>
27 enum AlignmentOption {
51 bool captured_mouse_ =
false;
53 cgv::g2d::irect container_;
55 bool blocks_events_ =
false;
58 AlignmentOption horizontal_alignment_ = AlignmentOption::AO_START;
59 AlignmentOption vertical_alignment_ = AlignmentOption::AO_START;
60 StretchOption stretch_ = SO_NONE;
62 vec2 percentual_offset_ =
vec2(0.0f);
66 data::ref_ptr<cgv::gui::control<T>> add_layout_member_control(
const std::string& label, T& value,
const std::string& gui_type =
"",
const std::string& options =
"",
const std::string& align =
"\n") {
69 connect_copy(cp->value_change, cgv::signal::rebind(
this, &overlay::on_layout_change));
75 virtual void on_visibility_change();
78 virtual void on_layout_change();
88 std::string heading =
"";
90 bool create_default_tree_node =
true;
92 bool show_heading =
false;
94 bool show_layout_options =
true;
96 bool allow_alignment =
true;
98 bool allow_stretch =
true;
100 bool allow_margin =
true;
124 virtual void on_set(
void* member_ptr);
136 virtual ivec2 get_local_mouse_pos(
ivec2 mouse_pos)
const;
154 void set_alignment(AlignmentOption horizontal, AlignmentOption vertical,
vec2 percentual_offset =
vec2(-1.0f));
163 void set_stretch(StretchOption stretch,
vec2 percentual_size =
vec2(-1.0f));
169 void set_margin(
const ivec2& margin);
172 void set_size(
const ivec2& size);
175 void set_visibility(
bool visible);
178 void toggle_visibility();
193 virtual bool is_hit(
const ivec2& mouse_pos)
const;
196 bool begin_overlay_gui();
198 void end_overlay_gui();
201 void create_layout_gui();
233#include <cgv/config/lib_end.h>
virtual void stream_help(std::ostream &os)
overload to stream help information to the given output stream
cgv::g2d::irect get_rectangle() const
return the current rectangle area (in screen coordinates) of the overlay taking layout into account
virtual void handle_member_change(const cgv::utils::pointer_test &m)
implement to handle member changes
void blocks_events(bool flag)
set whether the overlay blocks events
vec2 get_percentual_offset() const
get the percentual alignment offset (only valid if get_horizontal_alignment() or get_vertical_alignme...
vec2 get_percentual_size() const
get the percentual stretch (only valid if get_stretch() returns StretchOption::SO_PERCENTUAL)
virtual bool self_reflect(cgv::reflect::reflection_handler &_rh)
overload to reflect members of derived classes
ivec2 get_margin() const
return the margin as set in the layout parameters
bool blocks_events() const
return whether this overlay blocks events, i.e. does not pass them to the next event handler
virtual bool handle_key_event(cgv::gui::key_event &e)
overload this method to handle key events
AlignmentOption get_horizontal_alignment() const
get the horizontal alignment
ivec2 get_viewport_size() const
return the current viewport size
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
gui_options_t gui_options
options for the GUI creation of this overlay (must be set before GUI creation)
AlignmentOption get_vertical_alignment() const
get the vertical alignment
virtual bool handle_mouse_event(cgv::gui::mouse_event &e, cgv::ivec2 local_mouse_pos)
overload this method to handle mouse events; local_mouse_pos is the mouse position in the local coord...
StretchOption get_stretch() const
get the stretch
virtual void create_gui_impl()
virtual method to implement the derived class gui creation
The node class keeps a pointer to its parent.
reference counted pointer, which can work together with types that are derived from ref_counted,...
interface for all classes that want to receive events
class to represent all possible keyboard events with the EID_KEY
class to represent all possible mouse events with the EID_MOUSE
derive from this class to provide a gui to the current viewer
static cgv::type::uint32_type size()
return number of elements
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
base class for all drawables, which is independent of the used rendering API.
base class for all drawables, which is independent of the used rendering API.