From ef8f59c95a8966d70e5c2ecb89f0f22ea82e1e28 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Sun, 5 Feb 2017 17:01:15 -0700 Subject: [PATCH] textbox focus policy preference --- cinelerra-5.1/cinelerra/interfaceprefs.C | 22 ++++++++++++++++++++- cinelerra-5.1/cinelerra/interfaceprefs.h | 8 ++++++++ cinelerra-5.1/cinelerra/preferences.C | 12 +++++------ cinelerra-5.1/cinelerra/preferences.h | 2 ++ cinelerra-5.1/cinelerra/preferencesthread.C | 1 + cinelerra-5.1/guicast/bcresources.C | 1 + cinelerra-5.1/guicast/bcresources.h | 1 + cinelerra-5.1/guicast/bctextbox.C | 14 ++++++++----- cinelerra-5.1/guicast/bcwindowbase.inc | 3 +++ 9 files changed, 51 insertions(+), 13 deletions(-) diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.C b/cinelerra-5.1/cinelerra/interfaceprefs.C index e25b1fd9..3789bc10 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.C +++ b/cinelerra-5.1/cinelerra/interfaceprefs.C @@ -145,7 +145,13 @@ void InterfacePrefs::create_objects() y1 += bdwr_win->get_h() + 5; PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1); add_subwindow(pop_win); - y1 += pop_win->get_h() + 25; + y1 += pop_win->get_h() + 5; + TextboxFocusPolicy *focus_policy = new TextboxFocusPolicy(pwindow, x1, y1); + add_subwindow(focus_policy); + y1 += focus_policy->get_h() + 5; + + if( y < y1 ) y = y1; + y += 10; add_subwindow(new BC_Bar(5, y, get_w() - 10)); y += 5; @@ -740,6 +746,20 @@ int PopupMenuBtnup::handle_event() return 1; } +TextboxFocusPolicy::TextboxFocusPolicy(PreferencesWindow *pwindow, int x, int y) + : BC_CheckBox(x, y, pwindow->thread->preferences->textbox_focus_policy, + _("Click to deactivate text focus")) +{ + this->pwindow = pwindow; +} + +int TextboxFocusPolicy::handle_event() +{ + pwindow->thread->preferences->textbox_focus_policy = get_value(); + return 1; +} + + ScanCommercials::ScanCommercials(PreferencesWindow *pwindow, int x, int y) : BC_CheckBox(x, diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.h b/cinelerra-5.1/cinelerra/interfaceprefs.h index 3005d446..17bf3508 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.h +++ b/cinelerra-5.1/cinelerra/interfaceprefs.h @@ -335,6 +335,14 @@ public: PreferencesWindow *pwindow; }; +class TextboxFocusPolicy : public BC_CheckBox +{ +public: + TextboxFocusPolicy(PreferencesWindow *pwindow, int x, int y); + int handle_event(); + PreferencesWindow *pwindow; +}; + class AndroidPIN : public BC_TextBox { public: diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index 97efba93..950ddfc2 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -83,6 +83,7 @@ Preferences::Preferences() warn_version = 1; bd_warn_root = 1; popupmenu_btnup = 1; + textbox_focus_policy = LEAVE_DEACTIVATE; dvd_yuv420p_interlace = 0; // Default brender asset @@ -192,6 +193,7 @@ void Preferences::copy_from(Preferences *that) warn_version = that->warn_version; bd_warn_root = that->bd_warn_root; popupmenu_btnup = that->popupmenu_btnup; + textbox_focus_policy = that->textbox_focus_policy; dvd_yuv420p_interlace = that->dvd_yuv420p_interlace; renderfarm_nodes.remove_all_objects(); renderfarm_ports.remove_all(); @@ -343,6 +345,7 @@ int Preferences::load_defaults(BC_Hash *defaults) warn_version = defaults->get("WARN_VERSION", warn_version); bd_warn_root = defaults->get("BD_WARN_ROOT", bd_warn_root); popupmenu_btnup = defaults->get("POPUPMENU_BTNUP", popupmenu_btnup); + textbox_focus_policy = defaults->get("TEXTBOX_FOCUS_POLICY", textbox_focus_policy); dvd_yuv420p_interlace = defaults->get("DVD_YUV420P_INTERLACE", dvd_yuv420p_interlace); use_brender = defaults->get("USE_BRENDER", use_brender); brender_fragment = defaults->get("BRENDER_FRAGMENT", brender_fragment); @@ -448,14 +451,9 @@ int Preferences::save_defaults(BC_Hash *defaults) defaults->update("WARN_VERSION", warn_version); defaults->update("BD_WARN_ROOT", bd_warn_root); defaults->update("POPUPMENU_BTNUP", popupmenu_btnup); + defaults->update("TEXTBOX_FOCUS_POLICY", textbox_focus_policy); defaults->update("DVD_YUV420P_INTERLACE", dvd_yuv420p_interlace); - brender_asset->save_defaults(defaults, - "BRENDER_", - 1, - 1, - 1, - 0, - 0); + brender_asset->save_defaults(defaults, "BRENDER_", 1, 1, 1, 0, 0); defaults->update("USE_BRENDER", use_brender); defaults->update("BRENDER_FRAGMENT", brender_fragment); defaults->update("USE_RENDERFARM", use_renderfarm); diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h index 3b2b221b..a54aa466 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -109,6 +109,8 @@ public: int bd_warn_root; // popup menus activate on button release int popupmenu_btnup; +// textbox focus policy: click, leave + int textbox_focus_policy; // use dvd yuv420p interlace format int dvd_yuv420p_interlace; diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 8e52a243..dd8e9c51 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -220,6 +220,7 @@ int PreferencesThread::apply_settings() BC_Signals::set_catch_segv(mwindow->preferences->trap_sigsegv); BC_Signals::set_catch_intr(mwindow->preferences->trap_sigintr); BC_WindowBase::get_resources()->popupmenu_btnup = mwindow->preferences->popupmenu_btnup; + BC_WindowBase::get_resources()->textbox_focus_policy = mwindow->preferences->textbox_focus_policy; if( mwindow->preferences->trap_sigsegv || mwindow->preferences->trap_sigintr ) { BC_Trace::enable_locks(); } diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C index fabb3d65..cd56baaf 100644 --- a/cinelerra-5.1/guicast/bcresources.C +++ b/cinelerra-5.1/guicast/bcresources.C @@ -644,6 +644,7 @@ BC_Resources::BC_Resources() tooltip_delay = 1000; tooltip_bg_color = YELLOW; tooltips_enabled = 1; + textbox_focus_policy = LEAVE_DEACTIVATE; filebox_margin = 110; dirbox_margin = 90; diff --git a/cinelerra-5.1/guicast/bcresources.h b/cinelerra-5.1/guicast/bcresources.h index 82a3c3be..e88e825b 100644 --- a/cinelerra-5.1/guicast/bcresources.h +++ b/cinelerra-5.1/guicast/bcresources.h @@ -153,6 +153,7 @@ public: int tooltip_delay; int tooltip_bg_color; int tooltips_enabled; + int textbox_focus_policy; int audiovideo_color; diff --git a/cinelerra-5.1/guicast/bctextbox.C b/cinelerra-5.1/guicast/bctextbox.C index f1d8f596..e5ac51c6 100644 --- a/cinelerra-5.1/guicast/bctextbox.C +++ b/cinelerra-5.1/guicast/bctextbox.C @@ -776,7 +776,8 @@ int BC_TextBox::cursor_leave_event() draw_border(); flash(1); } - if( !suggestions_popup ) + if( !suggestions_popup && + top_level->get_resources()->textbox_focus_policy == LEAVE_DEACTIVATE ) deactivate(); return 0; } @@ -895,10 +896,13 @@ int BC_TextBox::button_press_event() return 1; } else - if(active && suggestions_popup && (!yscroll || !yscroll->is_event_win())) - { - if( suggestions_popup->button_press_event() ) - return suggestions_popup->handle_event(); + if( active ) { + if( suggestions_popup && (!yscroll || !yscroll->is_event_win())) { + if( suggestions_popup->button_press_event() ) + return suggestions_popup->handle_event(); + } + else if( top_level->get_resources()->textbox_focus_policy == CLICK_DEACTIVATE ) + deactivate(); } return 0; diff --git a/cinelerra-5.1/guicast/bcwindowbase.inc b/cinelerra-5.1/guicast/bcwindowbase.inc index 16bb93e8..d6c4f495 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.inc +++ b/cinelerra-5.1/guicast/bcwindowbase.inc @@ -45,6 +45,9 @@ class BC_WindowList; #define MIDDLE_BUTTON 2 #define RIGHT_BUTTON 3 +// textbox deactivate policy +#define LEAVE_DEACTIVATE 0 +#define CLICK_DEACTIVATE 1 // Use single thread for all windows. // This is a bad idea because it's very slow. Windows which share the same -- 2.26.2