-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDial.cpp
More file actions
55 lines (47 loc) · 1.63 KB
/
Dial.cpp
File metadata and controls
55 lines (47 loc) · 1.63 KB
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
48
49
50
51
52
53
54
55
#include <string>
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Dial.H>
#include <FL/Fl_Fill_Dial.H>
#include <FL/Fl_Line_Dial.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, "Dial example"} {
dial1.bounds(0, 1);
dial1.value(0.5);
dial1.callback(on_value_changed, &box1);
dial1.do_callback();
line_dial1.bounds(10, 11);
line_dial1.value(10);
line_dial1.callback(on_value_changed, &box2);
line_dial1.do_callback();
fill_dial1.bounds(0, 100);
fill_dial1.value(50);
fill_dial1.callback(on_value_changed, &box3);
fill_dial1.do_callback();
box1.align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
box2.align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
box3.align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
}
private:
static void on_value_changed(Fl_Widget* sender, void* box) noexcept {
static auto result = string(' ', 128);
static_cast<Fl_Valuator*>(sender)->format(result.data());
reinterpret_cast<Fl_Widget*>(box)->copy_label(result.c_str());
}
Fl_Dial dial1 {10, 10, 75, 75};
Fl_Box box1 {FL_DOWN_BOX, 95, 35, 90, 25, ""};
Fl_Line_Dial line_dial1 {10, 95, 75, 75};
Fl_Box box2 {FL_DOWN_BOX, 95, 120, 90, 25, ""};
Fl_Fill_Dial fill_dial1 {10, 180, 75, 75, ""};
Fl_Box box3 {FL_DOWN_BOX, 95, 205, 90, 25, ""};
};
}
auto main(int argc, char* argv[]) -> int {
auto window = Examples::Main_Window {};
window.show(argc, argv);
Fl::run();
}