From d85ee0843fbbd79a0a7d2ffa0aac57968e24f6d7 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 9 Feb 2017 13:00:36 -0700 Subject: [PATCH] textbox click policy prefs --- cinelerra-5.1/cinelerra/interfaceprefs.C | 36 +++++++++++++++++++----- cinelerra-5.1/cinelerra/interfaceprefs.h | 12 ++++++-- cinelerra-5.1/cinelerra/preferences.C | 2 +- cinelerra-5.1/guicast/bcresources.C | 2 +- cinelerra-5.1/guicast/bctextbox.C | 7 +++-- cinelerra-5.1/guicast/bcwindowbase.inc | 6 ++-- 6 files changed, 48 insertions(+), 17 deletions(-) diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.C b/cinelerra-5.1/cinelerra/interfaceprefs.C index 3789bc10..fb58b22e 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.C +++ b/cinelerra-5.1/cinelerra/interfaceprefs.C @@ -146,9 +146,12 @@ void InterfacePrefs::create_objects() PopupMenuBtnup *pop_win = new PopupMenuBtnup(pwindow, x1, y1); add_subwindow(pop_win); y1 += pop_win->get_h() + 5; - TextboxFocusPolicy *focus_policy = new TextboxFocusPolicy(pwindow, x1, y1); - add_subwindow(focus_policy); - y1 += focus_policy->get_h() + 5; + ActivateFocusPolicy *focus_activate = new ActivateFocusPolicy(pwindow, x1, y1); + add_subwindow(focus_activate); + y1 += focus_activate->get_h() + 5; + DeactivateFocusPolicy *focus_deactivate = new DeactivateFocusPolicy(pwindow, x1, y1); + add_subwindow(focus_deactivate); + y1 += focus_deactivate->get_h() + 5; if( y < y1 ) y = y1; y += 10; @@ -746,16 +749,35 @@ int PopupMenuBtnup::handle_event() return 1; } -TextboxFocusPolicy::TextboxFocusPolicy(PreferencesWindow *pwindow, int x, int y) - : BC_CheckBox(x, y, pwindow->thread->preferences->textbox_focus_policy, +ActivateFocusPolicy::ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y) + : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_ACTIVATE) != 0, + _("Click to activate text focus")) +{ + this->pwindow = pwindow; +} + +int ActivateFocusPolicy::handle_event() +{ + if( get_value() ) + pwindow->thread->preferences->textbox_focus_policy |= CLICK_ACTIVATE; + else + pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_ACTIVATE; + return 1; +} + +DeactivateFocusPolicy::DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y) + : BC_CheckBox(x, y, (pwindow->thread->preferences->textbox_focus_policy & CLICK_DEACTIVATE) != 0, _("Click to deactivate text focus")) { this->pwindow = pwindow; } -int TextboxFocusPolicy::handle_event() +int DeactivateFocusPolicy::handle_event() { - pwindow->thread->preferences->textbox_focus_policy = get_value(); + if( get_value() ) + pwindow->thread->preferences->textbox_focus_policy |= CLICK_DEACTIVATE; + else + pwindow->thread->preferences->textbox_focus_policy &= ~CLICK_DEACTIVATE; return 1; } diff --git a/cinelerra-5.1/cinelerra/interfaceprefs.h b/cinelerra-5.1/cinelerra/interfaceprefs.h index 17bf3508..a16cb750 100644 --- a/cinelerra-5.1/cinelerra/interfaceprefs.h +++ b/cinelerra-5.1/cinelerra/interfaceprefs.h @@ -335,10 +335,18 @@ public: PreferencesWindow *pwindow; }; -class TextboxFocusPolicy : public BC_CheckBox +class ActivateFocusPolicy : public BC_CheckBox { public: - TextboxFocusPolicy(PreferencesWindow *pwindow, int x, int y); + ActivateFocusPolicy(PreferencesWindow *pwindow, int x, int y); + int handle_event(); + PreferencesWindow *pwindow; +}; + +class DeactivateFocusPolicy : public BC_CheckBox +{ +public: + DeactivateFocusPolicy(PreferencesWindow *pwindow, int x, int y); int handle_event(); PreferencesWindow *pwindow; }; diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index 950ddfc2..4b7a92ae 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -83,7 +83,7 @@ Preferences::Preferences() warn_version = 1; bd_warn_root = 1; popupmenu_btnup = 1; - textbox_focus_policy = LEAVE_DEACTIVATE; + textbox_focus_policy = 0; dvd_yuv420p_interlace = 0; // Default brender asset diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C index cd56baaf..c97e802f 100644 --- a/cinelerra-5.1/guicast/bcresources.C +++ b/cinelerra-5.1/guicast/bcresources.C @@ -644,7 +644,7 @@ BC_Resources::BC_Resources() tooltip_delay = 1000; tooltip_bg_color = YELLOW; tooltips_enabled = 1; - textbox_focus_policy = LEAVE_DEACTIVATE; + textbox_focus_policy = 0; filebox_margin = 110; dirbox_margin = 90; diff --git a/cinelerra-5.1/guicast/bctextbox.C b/cinelerra-5.1/guicast/bctextbox.C index e5ac51c6..4eef5347 100644 --- a/cinelerra-5.1/guicast/bctextbox.C +++ b/cinelerra-5.1/guicast/bctextbox.C @@ -750,7 +750,8 @@ int BC_TextBox::focus_out_event() int BC_TextBox::cursor_enter_event() { - if(top_level->event_win == win && enabled) + if( top_level->event_win == win && enabled && + !(top_level->get_resources()->textbox_focus_policy & CLICK_ACTIVATE) ) { tooltip_done = 0; if( !active ) { @@ -777,7 +778,7 @@ int BC_TextBox::cursor_leave_event() flash(1); } if( !suggestions_popup && - top_level->get_resources()->textbox_focus_policy == LEAVE_DEACTIVATE ) + !(top_level->get_resources()->textbox_focus_policy & CLICK_DEACTIVATE) ) deactivate(); return 0; } @@ -901,7 +902,7 @@ int BC_TextBox::button_press_event() if( suggestions_popup->button_press_event() ) return suggestions_popup->handle_event(); } - else if( top_level->get_resources()->textbox_focus_policy == CLICK_DEACTIVATE ) + else if( (top_level->get_resources()->textbox_focus_policy & CLICK_DEACTIVATE) ) deactivate(); } diff --git a/cinelerra-5.1/guicast/bcwindowbase.inc b/cinelerra-5.1/guicast/bcwindowbase.inc index d6c4f495..c0bcff5a 100644 --- a/cinelerra-5.1/guicast/bcwindowbase.inc +++ b/cinelerra-5.1/guicast/bcwindowbase.inc @@ -45,9 +45,9 @@ class BC_WindowList; #define MIDDLE_BUTTON 2 #define RIGHT_BUTTON 3 -// textbox deactivate policy -#define LEAVE_DEACTIVATE 0 -#define CLICK_DEACTIVATE 1 +// textbox policy mask +#define CLICK_ACTIVATE 1 +#define CLICK_DEACTIVATE 2 // Use single thread for all windows. // This is a bad idea because it's very slow. Windows which share the same -- 2.26.2