titler rework, some code cleanup and fixes
[goodguy/history.git] / cinelerra-5.1 / guicast / bctextbox.C
index 52aa85d3e28f54c77cdb0abc6763f6e73e24ccb5..e8cb09ced1fc35afb853cea90382e99766229cd8 100644 (file)
@@ -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 ) {
@@ -772,10 +773,12 @@ int BC_TextBox::cursor_leave_event()
        if(highlighted)
        {
                highlighted = 0;
-               draw_border();
                hide_tooltip();
+               draw_border();
+               flash(1);
        }
-       if( !suggestions_popup )
+       if( !suggestions_popup &&
+           !(top_level->get_resources()->textbox_focus_policy & CLICK_DEACTIVATE) )
                deactivate();
        return 0;
 }
@@ -894,10 +897,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;
@@ -990,6 +996,7 @@ int BC_TextBox::deactivate()
 {
        if( active ) {
                active = 0;
+               text_selected = word_selected = line_selected = 0;
                top_level->set_active_subwindow(0);
                top_level->unset_repeat(top_level->get_resources()->blink_rate);
        }
@@ -2159,46 +2166,18 @@ void BC_ScrollTextBox::create_objects()
        set_text_row(0);
 }
 
-int BC_ScrollTextBox::handle_event()
-{
-       return 1;
-}
-
-int BC_ScrollTextBox::get_x()
-{
-       return x;
-}
-
-int BC_ScrollTextBox::get_y()
-{
-       return y;
-}
+int BC_ScrollTextBox::handle_event() { return 1; }
+int BC_ScrollTextBox::button_press_event() { return text->BC_TextBox::button_press_event(); }
+int BC_ScrollTextBox::button_release_event() { return text->BC_TextBox::button_release_event(); }
+int BC_ScrollTextBox::get_buttonpress() { return text->BC_TextBox::get_buttonpress(); };
+int BC_ScrollTextBox::get_x() { return x; }
+int BC_ScrollTextBox::get_y() { return y; }
+int BC_ScrollTextBox::get_w() { return w; }
+int BC_ScrollTextBox::get_h() { return text->get_h(); }
+int BC_ScrollTextBox::get_rows() { return rows; }
 
-int BC_ScrollTextBox::get_w()
-{
-       return w;
-}
-
-int BC_ScrollTextBox::get_h()
-{
-       return this->text->get_h();
-}
-
-int BC_ScrollTextBox::get_rows()
-{
-       return rows;
-}
-
-
-const char* BC_ScrollTextBox::get_text()
-{
-       return text->get_text();
-}
-
-const wchar_t* BC_ScrollTextBox::get_wtext()
-{
-       return text->get_wtext();
-}
+const char* BC_ScrollTextBox::get_text() { return text->get_text(); }
+const wchar_t* BC_ScrollTextBox::get_wtext() { return text->get_wtext(); }
 
 void BC_ScrollTextBox::set_text(char *text, int isz)
 {
@@ -2319,7 +2298,6 @@ int BC_ScrollTextBoxText::motion_event()
        return 1;
 }
 
-
 BC_ScrollTextBoxYScroll::BC_ScrollTextBoxYScroll(BC_ScrollTextBox *gui)
  : BC_ScrollBar(gui->x +
                        gui->w -
@@ -2522,22 +2500,14 @@ void BC_PopupTextBox::reposition_window(int x, int y)
 
 
 BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
-       int64_t default_value,
-       int64_t min,
-       int64_t max,
-       int x,
-       int y)
+       int64_t default_value, int x, int y)
  : BC_TextBox(x, y, popup->text_w, 1, default_value)
 {
        this->popup = popup;
 }
 
 BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
-       float default_value,
-       float min,
-       float max,
-       int x,
-       int y)
+       float default_value, int x, int y)
  : BC_TextBox(x, y, popup->text_w, 1, default_value)
 {
        this->popup = popup;
@@ -2693,20 +2663,12 @@ int BC_TumbleTextBox::create_objects()
        if(use_float)
        {
                parent_window->add_subwindow(textbox = new BC_TumbleTextBoxText(this,
-                       default_value_f,
-                       min_f,
-                       max_f,
-                       x,
-                       y));
+                       default_value_f, x, y));
                textbox->set_precision(precision);
        }
        else
                parent_window->add_subwindow(textbox = new BC_TumbleTextBoxText(this,
-                       default_value,
-                       min,
-                       max,
-                       x,
-                       y));
+                       default_value, x, y));
 
        x += textbox->get_w();
 
@@ -2781,17 +2743,23 @@ int BC_TumbleTextBox::get_h()
        return textbox->get_h();
 }
 
-void BC_TumbleTextBox::disable()
+void BC_TumbleTextBox::disable(int hide_text)
 {
+       if( hide_text && !textbox->is_hidden() )
+               textbox->hide_window(0);
+       if( !tumbler->is_hidden() )
+               tumbler->hide_window(0);
        if( !get_enabled() ) return;
-       tumbler->hide_window(0);
        return textbox->disable();
 }
 
 void BC_TumbleTextBox::enable()
 {
+       if( textbox->is_hidden() )
+               textbox->show_window(0);
+       if( tumbler->is_hidden() )
+               tumbler->show_window(0);
        if( get_enabled() ) return;
-       tumbler->show_window(0);
        return textbox->enable();
 }