3#include <cgv/data/informed_ptr.h>
4#include <cgv/defines/deprecated.h>
5#include <cgv/gui/event_handler.h>
6#include <cgv/gui/provider.h>
7#include <cgv/render/context.h>
8#include <cgv/render/drawable.h>
9#include <cgv_g2d/trect.h>
10#include <cgv_g2d/utils.h>
12#include <cgv/gui/key_event.h>
13#include <cgv/gui/mouse_event.h>
28enum class StretchMode {
44 std::string heading =
"";
46 bool create_default_tree_node =
true;
48 bool show_heading =
false;
50 bool show_layout_options =
true;
52 bool allow_alignment =
true;
54 bool allow_stretch =
true;
56 bool allow_margin =
true;
80 virtual void on_set(
void* member_ptr);
92 virtual ivec2 get_local_mouse_pos(
ivec2 mouse_pos)
const;
110 void set_alignment(Alignment horizontal, Alignment vertical,
vec2 percentual_offset =
vec2(-1.0f));
119 void set_stretch_mode(StretchMode stretch,
vec2 percentual_size =
vec2(-1.0f));
125 void set_margin(
const ivec2& margin);
128 void set_size(
const ivec2& size);
131 void set_visibility(
bool visible);
134 void toggle_visibility();
149 virtual bool is_hit(
const ivec2& mouse_pos)
const;
152 bool begin_overlay_gui();
154 void end_overlay_gui();
157 void create_layout_gui();
185 virtual void on_visibility_change();
188 virtual void on_layout_change();
191 void update_layout();
204 bool captured_mouse_ =
false;
206 cgv::g2d::irect container_;
208 bool blocks_events_ =
false;
211 Alignment horizontal_alignment_ = Alignment::kStart;
212 Alignment vertical_alignment_ = Alignment::kStart;
213 StretchMode stretch_ = StretchMode::kNone;
215 vec2 percentual_offset_ =
vec2(0.0f);
219 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") {
222 connect_copy(cp->value_change, cgv::signal::rebind(
this, &overlay::on_layout_change));
232#include <cgv/config/lib_end.h>
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 components
void blocks_events(bool flag)
set whether the overlay blocks events
virtual void handle_member_change(cgv::data::informed_ptr ptr)
implement to handle member changes
virtual void create_gui_impl()
virtual method to implement the derived class gui creation
virtual void stream_help(std::ostream &os)
overload to stream help information to the given output stream
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_mode() returns StretchMode::kPercentual)
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
bool blocks_events() const
return whether this overlay blocks events, i.e. does not pass them to the next event handler
Alignment get_vertical_alignment() const
get the vertical alignment
ivec2 get_margin() const
return the margin as set in the layout parameters
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...
cgv::g2d::irect get_rectangle() const
return the current rectangle area (in screen coordinates) of the overlay taking layout into account
virtual bool self_reflect(cgv::reflect::reflection_handler &_rh)
overload to reflect members of derived classes
StretchMode get_stretch_mode() const
get the stretch
gui_options_t gui_options
options for the GUI creation of this overlay (must be set before GUI creation)
virtual bool handle_key_event(cgv::gui::key_event &e)
overload this method to handle key events
ivec2 get_viewport_size() const
return the current viewport size
Alignment get_horizontal_alignment() const
get the horizontal alignment
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.
this header is dependency free