]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/entry.cpp
Refactor all slider logic into the Slider class
[libs/gltk.git] / source / entry.cpp
index 606f447b68c99ffdf8da7fce0495ed4709a73610..83ed563298b793b919d31d1a7bc442b0d3b24e2d 100644 (file)
@@ -5,8 +5,8 @@
 #include "entry.h"
 #include "graphic.h"
 #include "part.h"
+#include "slider.h"
 #include "style.h"
-#include "vslider.h"
 
 using namespace std;
 
@@ -84,7 +84,7 @@ void Entry::insert(unsigned pos, const string &t)
        if(multiline)
                check_view_range();
 
-       rebuild();
+       mark_rebuild();
 }
 
 void Entry::erase(unsigned pos, unsigned len)
@@ -114,7 +114,7 @@ void Entry::erase(unsigned pos, unsigned len)
        if(multiline)
                check_view_range();
 
-       rebuild();
+       mark_rebuild();
 }
 
 bool Entry::get_selection(unsigned &start, unsigned &end) const
@@ -158,7 +158,7 @@ void Entry::set_multiline(bool m)
                        add(*slider);
                        slider->set_step(1);
                        slider->signal_value_changed.connect(sigc::mem_fun(this, &Entry::slider_value_changed));
-                       rebuild();
+                       mark_rebuild();
                }
                check_view_range();
        }
@@ -366,10 +366,10 @@ bool Entry::navigate(Navigation nav)
 void Entry::animate(const Time::TimeDelta &)
 {
        cursor_blink = !cursor_blink;
-       rebuild();
+       mark_rebuild();
 }
 
-void Entry::on_geometry_change()
+void Entry::on_size_change()
 {
        if(multiline)
                check_view_range();
@@ -429,7 +429,7 @@ void Entry::set_edit_position(unsigned ep, bool select)
 
        if(multiline)
                check_view_range();
-       rebuild();
+       mark_rebuild();
 }
 
 void Entry::erase_selection(bool emit_change)
@@ -446,18 +446,21 @@ void Entry::erase_selection(bool emit_change)
 
 void Entry::check_cursor_blink()
 {
+       const Part *cursor_part = style->get_part("cursor");
+       bool has_blink = (cursor_part && cursor_part->get_graphic(ACTIVE|FOCUS)!=cursor_part->get_graphic(NORMAL|FOCUS));
+
        cursor_blink = (state&FOCUS);
-       if((state&FOCUS) && style)
+       if((state&FOCUS) && style && has_blink)
        {
-               const Part *cursor_part = style->get_part("cursor");
-               if(cursor_part && cursor_part->get_graphic(ACTIVE|FOCUS)!=cursor_part->get_graphic(NORMAL|FOCUS))
-               {
-                       set_animation_interval(Time::sec/2);
-                       return;
-               }
+               set_animation_interval(Time::sec/2);
+               mark_rebuild();
+       }
+       else
+       {
+               if(has_blink)
+                       mark_rebuild();
+               stop_animation();
        }
-
-       stop_animation();
 }
 
 void Entry::check_view_range()
@@ -495,6 +498,7 @@ void Entry::slider_value_changed(double value)
                first_row = text.get_n_lines()-visible_rows-static_cast<unsigned>(value);
                if(first_row!=old_first_row)
                        signal_scroll_position_changed.emit(first_row);
+               mark_rebuild();
        }
 }