cgv
Loading...
Searching...
No Matches
help_message.h
1#pragma once
2
3#include <cgv/gui/dialog.h>
4#include <cgv/gui/provider.h>
5
6namespace cgv {
7namespace gui {
8
10protected:
11 std::string message = "";
12
13public:
14 void clear() {
15
16 message.clear();
17 }
18
19 void add_line(const std::string& line) {
20
21 if(!message.empty())
22 message += "\n";
23
24 message += line;
25 }
26
27 void add_bullet_point(const std::string& line) {
28
29 add_line(" -\t" + line);
30 }
31
32 void show() const {
33
35 }
36
37 void create_gui(cgv::gui::provider* p) const {
38
39 cgv::gui::button_ptr btn = p->add_button("?", "w=0;font_style='bold'", "");
40
41 int x = btn->get<int>("x");
42 int y = btn->get<int>("y");
43
44 cgv::base::group_ptr group = btn->get_parent() ? btn->get_parent()->get_group() : nullptr;
45
46 if(group->get_nr_children() > 1) {
47 cgv::base::base_ptr last_child = group->get_child(group->get_nr_children() - 2);
48
49 int last_x = last_child->get<int>("x");
50 int last_y = last_child->get<int>("y");
51 int last_w = last_child->get<int>("w");
52 int last_h = last_child->get<int>("h");
53
54 x = last_x + (last_w > 200 ? last_w - 20 : 180);
55 y = last_y;
56
57 } else {
58 x += 180;
59 }
60
61 btn->set("x", x);
62 btn->set("y", y);
63 btn->set("w", 20);
64
65 connect_copy(btn->click, cgv::signal::rebind(this, &help_message::show));
66 }
67};
68
69}
70}
reference counted pointer, which can work together with types that are derived from ref_counted,...
Definition ref_ptr.h:160
derive from this class to provide a gui to the current viewer
Definition provider.h:64
button_ptr add_button(const std::string &label, const std::string &options="", const std::string &align="\n")
use the current gui driver to append a new button with the given label
Definition provider.cxx:176
void message(const std::string &_message)
tell the user something with a message box
Definition dialog.cxx:14
the cgv namespace
Definition print.h:11