From 56c532adadf040438ab5ca26ba1c18b1af7727e9 Mon Sep 17 00:00:00 2001 From: EvanR Date: Tue, 6 Jan 2009 18:33:45 -0600 Subject: [PATCH] Windows untoggle the main panel button on close. --- src/ui.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++---------- src/ui.fl | 32 ++++++++++++++++++++------------ src/ui.h | 20 +++++++++++++++++--- 3 files changed, 79 insertions(+), 25 deletions(-) diff --git a/src/ui.cpp b/src/ui.cpp index 5becc95..e174357 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -257,7 +257,7 @@ void UI::cb_loop_toggle(fltk::Button* o, void* v) { ((UI*)(o->parent()->parent()->user_data()))->cb_loop_toggle_i(o,v); } -inline void UI::cb_conf_toggle_i(fltk::Button* o, void*) { +inline void UI::cb_conf_button_i(fltk::Button* o, void*) { if(o->state()){ ui->config_window->show(); } @@ -265,8 +265,8 @@ inline void UI::cb_conf_toggle_i(fltk::Button* o, void*) { ui->config_window->hide(); } ;} -void UI::cb_conf_toggle(fltk::Button* o, void* v) { - ((UI*)(o->parent()->parent()->user_data()))->cb_conf_toggle_i(o,v); +void UI::cb_conf_button(fltk::Button* o, void* v) { + ((UI*)(o->parent()->parent()->user_data()))->cb_conf_button_i(o,v); } inline void UI::cb_scope_button_i(fltk::Button* o, void*) { @@ -305,6 +305,14 @@ void UI::cb_help_button(fltk::Button* o, void* v) { ((UI*)(o->parent()->parent()->user_data()))->cb_help_button_i(o,v); } +inline void UI::cb_config_window_i(fltk::Window* o, void*) { + ui->conf_button->state(0); + o->hide(); +} +void UI::cb_config_window(fltk::Window* o, void* v) { + ((UI*)(o->user_data()))->cb_config_window_i(o,v); +} + inline void UI::cb_beats_per_measure_i(fltk::ValueInput* o, void*) { if(o->value() > o->maximum()) o->value(o->maximum()); @@ -455,6 +463,22 @@ void UI::cb_kg_l10(KeyGrabber* o, void* v) { ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_kg_l10_i(o,v); } +inline void UI::cb_help_window_i(fltk::Window* o, void*) { + ui->help_button->state(0); + o->hide(); +} +void UI::cb_help_window(fltk::Window* o, void* v) { + ((UI*)(o->user_data()))->cb_help_window_i(o,v); +} + +inline void UI::cb_action_window_i(fltk::Window* o, void*) { + ui->file_button->state(0); + o->hide(); +} +void UI::cb_action_window(fltk::Window* o, void* v) { + ((UI*)(o->user_data()))->cb_action_window_i(o,v); +} + inline void UI::cb_new1_i(fltk::Button*, void*) { reset_song(); } @@ -506,6 +530,14 @@ void UI::cb_export(fltk::Button* o, void* v) { ((UI*)(o->parent()->user_data()))->cb_export_i(o,v); } +inline void UI::cb_scope_window_i(fltk::Window* o, void*) { + ui->scope_button->state(0); + o->hide(); +} +void UI::cb_scope_window(fltk::Window* o, void* v) { + ((UI*)(o->user_data()))->cb_scope_window_i(o,v); +} + inline void UI::cb_on_i(fltk::Button* o, void*) { if(o->state()){ turnonscope(); @@ -771,8 +803,8 @@ UI::UI() { o->tooltip("toggle looping"); o->type(fltk::Button::TOGGLE); } - {fltk::Button* o = conf_toggle = new fltk::Button(520, 5, 25, 25); - o->callback((fltk::Callback*)cb_conf_toggle); + {fltk::Button* o = conf_button = new fltk::Button(520, 5, 25, 25); + o->callback((fltk::Callback*)cb_conf_button); o->tooltip("configuration"); o->type(fltk::Button::TOGGLE); } @@ -802,7 +834,7 @@ UI::UI() { } {fltk::Window* o = config_window = new fltk::Window(320, 285, "controls"); o->shortcut(0xff1b); - o->user_data((void*)(this)); + o->callback((fltk::Callback*)cb_config_window, (void*)(this)); o->begin(); {fltk::TabGroup* o = new fltk::TabGroup(0, 0, 320, 285); o->begin(); @@ -1066,7 +1098,7 @@ track."); } {fltk::Window* o = help_window = new fltk::Window(580, 370, "help"); o->shortcut(0xff1b); - o->user_data((void*)(this)); + o->callback((fltk::Callback*)cb_help_window, (void*)(this)); o->begin(); {fltk::TabGroup* o = new fltk::TabGroup(0, 0, 580, 370); o->begin(); @@ -1129,7 +1161,7 @@ track."); } {fltk::Window* o = action_window = new fltk::Window(100, 130, "menu"); o->shortcut(0xff1b); - o->user_data((void*)(this)); + o->callback((fltk::Callback*)cb_action_window, (void*)(this)); o->begin(); {fltk::Button* o = new fltk::Button(5, 5, 90, 20, "new"); o->callback((fltk::Callback*)cb_new1); @@ -1154,7 +1186,7 @@ track."); {fltk::Window* o = scope_window = new fltk::Window(425, 280, "scope"); w = o; o->shortcut(0xff1b); - o->user_data((void*)(this)); + o->callback((fltk::Callback*)cb_scope_window, (void*)(this)); o->begin(); {fltk::TextDisplay* o = scope = new fltk::TextDisplay(5, 5, 415, 245); o->textfont(fltk::COURIER); @@ -1177,7 +1209,7 @@ track."); o->resizable(o); } loop_toggle->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/loop.gif")); - conf_toggle->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/conf.gif")); + conf_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/conf.gif")); scope_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/scope.gif")); file_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/file.gif")); help_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/help.gif")); diff --git a/src/ui.fl b/src/ui.fl index 09e2906..0d6ee42 100644 --- a/src/ui.fl +++ b/src/ui.fl @@ -61,7 +61,7 @@ action_window->hide(); scope_window->hide(); o->hide(); -save_config();} open +save_config();} xywh {31 41 640 480} resizable extra_code {\#include @@ -75,7 +75,7 @@ o->resize(640,455);} visible {fltk::Group} {} { xywh {0 0 640 445} } { - {fltk::Group} song_edit {open + {fltk::Group} song_edit { xywh {0 0 640 445} } { {fltk::Group} {} { @@ -126,7 +126,7 @@ ui->arranger->scrollTo(dummy,target);} } } } - {fltk::Group} pattern_edit {open + {fltk::Group} pattern_edit { xywh {0 0 640 445} hide } { {fltk::Group} {} {open @@ -257,7 +257,7 @@ ui->event_edit->redraw();} } } } - {fltk::Group} {} {open selected + {fltk::Group} {} { xywh {0 445 640 35} box UP_BOX } { {fltk::Button} play_button { @@ -379,7 +379,7 @@ o->state(1);} xywh {490 5 25 25} extra_code {o->type(fltk::Button::TOGGLE);} } - {fltk::Button} conf_toggle { + {fltk::Button} conf_button { callback {if(o->state()){ ui->config_window->show(); } @@ -428,7 +428,9 @@ else{ } {fltk::Window} config_window { label controls - xywh {52 125 320 285} hide + callback {ui->conf_button->state(0); +o->hide();} + xywh {52 125 320 285} visible } { {fltk::TabGroup} {} {open xywh {0 0 320 285} @@ -802,10 +804,12 @@ set_defaultvelocity((int)o->value());} } {fltk::Window} help_window { label help - xywh {519 345 580 370} hide resizable - extra_code {o->size_range(580,370);} + callback {ui->help_button->state(0); +o->hide();} + xywh {519 345 580 370} resizable + extra_code {o->size_range(580,370);} visible } { - {fltk::TabGroup} {} {open + {fltk::TabGroup} {} {open selected xywh {0 0 580 370} } { {fltk::Group} {} { @@ -864,7 +868,9 @@ set_defaultvelocity((int)o->value());} } {fltk::Window} action_window { label menu - xywh {286 302 100 130} horizontal hide + callback {ui->file_button->state(0); +o->hide();} + xywh {286 302 100 130} horizontal visible } { {fltk::Button} {} { label new @@ -908,7 +914,9 @@ savesmf(fltk::file_chooser("export file",NULL,get_last_dir()));} } {fltk::Window} scope_window { label scope - xywh {647 310 425 280} hide resizable + callback {ui->scope_button->state(0); +o->hide();} open + xywh {647 310 425 280} resizable visible } { {fltk::TextDisplay} scope { xywh {5 5 415 245} textfont 4 color 0x280000 textcolor 0xff0000 @@ -934,7 +942,7 @@ else{ } } code {loop_toggle->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/loop.gif")); -conf_toggle->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/conf.gif")); +conf_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/conf.gif")); scope_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/scope.gif")); file_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/file.gif")); help_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/help.gif")); diff --git a/src/ui.h b/src/ui.h index c69824b..9612daa 100644 --- a/src/ui.h +++ b/src/ui.h @@ -186,10 +186,10 @@ private: inline void cb_loop_toggle_i(fltk::Button*, void*); static void cb_loop_toggle(fltk::Button*, void*); public: - fltk::Button *conf_toggle; + fltk::Button *conf_button; private: - inline void cb_conf_toggle_i(fltk::Button*, void*); - static void cb_conf_toggle(fltk::Button*, void*); + inline void cb_conf_button_i(fltk::Button*, void*); + static void cb_conf_button(fltk::Button*, void*); public: fltk::Button *scope_button; private: @@ -207,6 +207,10 @@ private: static void cb_help_button(fltk::Button*, void*); public: fltk::Window *config_window; +private: + inline void cb_config_window_i(fltk::Window*, void*); + static void cb_config_window(fltk::Window*, void*); +public: fltk::ValueInput *beats_per_measure; private: inline void cb_beats_per_measure_i(fltk::ValueInput*, void*); @@ -333,11 +337,17 @@ public: KeyGrabber *kg_ou; KeyGrabber *kg_od; fltk::Window *help_window; +private: + inline void cb_help_window_i(fltk::Window*, void*); + static void cb_help_window(fltk::Window*, void*); +public: fltk::Input *title_text; fltk::Input *author_text; fltk::TextEditor *info_text; fltk::Window *action_window; private: + inline void cb_action_window_i(fltk::Window*, void*); + static void cb_action_window(fltk::Window*, void*); inline void cb_new1_i(fltk::Button*, void*); static void cb_new1(fltk::Button*, void*); inline void cb_save_i(fltk::Button*, void*); @@ -352,6 +362,10 @@ private: static void cb_export(fltk::Button*, void*); public: fltk::Window *scope_window; +private: + inline void cb_scope_window_i(fltk::Window*, void*); + static void cb_scope_window(fltk::Window*, void*); +public: fltk::TextDisplay *scope; private: inline void cb_on_i(fltk::Button*, void*); -- 2.11.4.GIT