-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathAdjuster.cpp
47 lines (40 loc) · 1.33 KB
/
Adjuster.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <string>
#include <FL/Fl.H>
#include <FL/Fl_Adjuster.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Window.H>
using namespace std;
namespace Examples {
class Main_Window : public Fl_Window {
public:
Main_Window() : Fl_Window {200, 100, 300, 300, "Adjuster example"} {
adjuster1.bounds(0, 1);
adjuster1.value(0.5);
adjuster1.soft(false);
adjuster1.callback(on_value_changed, &box1);
adjuster1.do_callback();
adjuster2.bounds(10, 11);
adjuster2.value(10);
adjuster2.soft(false);
adjuster2.callback(on_value_changed, &box2);
adjuster2.do_callback();
box1.align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
box2.align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
}
private:
static void on_value_changed(Fl_Widget* sender, void* box) {
static auto result = string(' ', 128);
dynamic_cast<Fl_Valuator*>(sender)->format(result.data());
reinterpret_cast<Fl_Widget*>(box)->copy_label(result.c_str());
}
Fl_Adjuster adjuster1 {10, 10, 75, 25};
Fl_Adjuster adjuster2 {60, 50, 25, 75};
Fl_Box box1 {FL_DOWN_BOX, 95, 10, 75, 25, ""};
Fl_Box box2 {FL_DOWN_BOX, 95, 75, 75, 25, ""};
};
}
auto main(int argc, char* argv[]) -> int {
auto window = Examples::Main_Window {};
window.show(argc, argv);
Fl::run();
}