差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| fltk:example-app-countdown_timer [2025/05/27 17:15] – [スクリーンショット] Upload anmated gif freemikan | fltk:example-app-countdown_timer [2025/06/12 11:45] (現在) – [スクリーンショット] Remove imagebox freemikan | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== | + | ====== |
| - | {{: | + | [[fltk:|{{: |
| ===== スクリーンショット ===== | ===== スクリーンショット ===== | ||
| - | + | {{ : | |
| - | {{ : | + | |
| ===== プロジェクトレイアウト ===== | ===== プロジェクトレイアウト ===== | ||
| 行 44: | 行 43: | ||
| #include < | #include < | ||
| - | #include <array> | + | #include <format> |
| - | #include <cstdio> | + | #include <string> |
| struct AppContext { | struct AppContext { | ||
| int start = 10; | int start = 10; | ||
| int count = 0; | int count = 0; | ||
| - | Fl_Box *countdown_digits; | + | Fl_Box *digits; |
| Fl_Button *start_button; | Fl_Button *start_button; | ||
| Fl_Button *reset_button; | Fl_Button *reset_button; | ||
| - | std::array< | + | std::string sbuf; |
| }; | }; | ||
| AppContext *as_app_context(void *ptr) { return static_cast< | AppContext *as_app_context(void *ptr) { return static_cast< | ||
| - | void update_countdown_digits_label(AppContext *ctx) { | + | void update_digits_label(AppContext *ctx) { |
| - | | + | ctx->sbuf.clear(); |
| - | ctx->countdown_digits-> | + | std:: |
| + | ctx->digits-> | ||
| } | } | ||
| 行 67: | 行 67: | ||
| if (ctx-> | if (ctx-> | ||
| - | ctx-> | + | |
| + | | ||
| return; | return; | ||
| } | } | ||
| 行 73: | 行 74: | ||
| --ctx-> | --ctx-> | ||
| - | | + | |
| Fl:: | Fl:: | ||
| 行 79: | 行 80: | ||
| void start_button_cb(Fl_Widget *w, void *data) { | void start_button_cb(Fl_Widget *w, void *data) { | ||
| - | Fl:: | + | |
| - | w->deactivate(); | + | // Start button pressed |
| + | | ||
| + | w-> | ||
| + | | ||
| + | // Pause button pressed | ||
| + | Fl:: | ||
| + | | ||
| + | } | ||
| } | } | ||
| 行 86: | 行 94: | ||
| auto ctx = as_app_context(data); | auto ctx = as_app_context(data); | ||
| ctx-> | ctx-> | ||
| - | | + | |
| } | } | ||
| int main() { | int main() { | ||
| - | auto window = new Fl_Window(600, 600, " | + | auto window = new Fl_Window(300, 300, "Countdown |
| - | auto countdown_digits | + | auto digits |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | auto start_button = new Fl_Button(210, 420, 80, 30, " | + | auto start_button = new Fl_Button(10, 260, 140, 30, " |
| - | auto reset_button = new Fl_Button(310, 420, 80, 30, " | + | auto reset_button = new Fl_Button(150, 260, 140, 30, " |
| int const countdown_start = 10; | int const countdown_start = 10; | ||
| 行 106: | 行 114: | ||
| .start = countdown_start, | .start = countdown_start, | ||
| .count = countdown_start, | .count = countdown_start, | ||
| - | .countdown_digits | + | .digits |
| .start_button = start_button, | .start_button = start_button, | ||
| .reset_button = reset_button, | .reset_button = reset_button, | ||
| }; | }; | ||
| - | | + | |
| start_button-> | start_button-> | ||
| reset_button-> | reset_button-> | ||
