textbox focus policy preference
authorGood Guy <[email protected]>
Mon, 6 Feb 2017 00:01:15 +0000 (17:01 -0700)
committerGood Guy <[email protected]>
Mon, 6 Feb 2017 00:01:15 +0000 (17:01 -0700)
cinelerra-5.1/cinelerra/interfaceprefs.C
cinelerra-5.1/cinelerra/interfaceprefs.h
cinelerra-5.1/cinelerra/preferences.C
cinelerra-5.1/cinelerra/preferences.h
cinelerra-5.1/cinelerra/preferencesthread.C
cinelerra-5.1/guicast/bcresources.C
cinelerra-5.1/guicast/bcresources.h
cinelerra-5.1/guicast/bctextbox.C
cinelerra-5.1/guicast/bcwindowbase.inc

index e25b1fd90f6a014a46bae8ec3a2da42dc0bfd6a0..3789bc1042bd941fc227c2118481c9a631060db8 100644 (file)
@@ -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,
index 3005d4461d1a9867e9ae9e24e658fc61593675dd..17bf3508caf07f0ba7772445cf174aab27164005 100644 (file)
@@ -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:
index 97efba935a3eb743fa7ab846307226e187db8d9b..950ddfc26eebcd398e84b2efa38775824ac07389 100644 (file)
@@ -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);
index 3b2b221b9522dd3fdc2306b29021bba848e2bb41..a54aa4662fb666dc3ec66712ce49973594c02973 100644 (file)
@@ -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;
 
index 8e52a243701b30fee149ce077113b64c496a843c..dd8e9c5182ee8dfdf3f004cf3102c1921f3e065d 100644 (file)
@@ -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();
        }
index fabb3d65e75d7255eea3af2ce30f6983ceae8323..cd56baaf31158ad5913374206bba6e0253cb29c4 100644 (file)
@@ -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;
index 82a3c3be65ad5e36a3359e20d0f3c6e51111399d..e88e825b4c401f1de94fd05031c96e5a7ccbbfe2 100644 (file)
@@ -153,6 +153,7 @@ public:
        int tooltip_delay;
        int tooltip_bg_color;
        int tooltips_enabled;
+       int textbox_focus_policy;
 
        int audiovideo_color;
 
index f1d8f596f486aa590193b034781724ffd76022df..e5ac51c652993ded444722e15c5d7ed9b80602f9 100644 (file)
@@ -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;
index 16bb93e8bd24a3b5ec85c2e9eee9148aa55211b2..d6c4f4951d13a56920fad770be7dbcc3fe4fe7b9 100644 (file)
@@ -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