程式語言 - The Fast Light Tool Kit (FLTK) - CPP - Dial



參考資訊:
https://www.fltk.org/doc-1.3/index.html

Dial種類


main.cpp

#include <iostream>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Dial.H>

void dial_callback(Fl_Widget* widget, void* data) {
    char buf[64] = { 0 };
    Fl_Dial* dial = (Fl_Dial*)widget;

    snprintf(buf, sizeof(buf), "Value: %.1f", dial->value());
    std::cout << buf << std::endl;
}

int main() {
    const int w = 320;
    const int h = 240;

    Fl_Window window(w, h, "main");
    Fl_Dial dial(110, 40, 100, 100, "Volume");

    dial.type(FL_NORMAL_DIAL);
    dial.minimum(0);
    dial.maximum(100);
    dial.value(50);
    dial.step(1);
    dial.callback(dial_callback);

    window.end();
    window.show();

    return Fl::run();
}

編譯、執行

$ g++ main.cpp -o main -lfltk
$ ./main