From 8d552439c716ae15e1f392ca88f3bdebf85ae607 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 4 Oct 2002 15:59:29 +0000 Subject: New Fl_Widget::redraw_label() method to cleanly redraw the label of a widget (this should eliminate the extra flicker some users have complained about...) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2652 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 3 +++ FL/Fl_Widget.H | 7 ++++--- documentation/Fl_Widget.html | 7 +++++++ documentation/common.html | 11 +++++++---- src/Fl.cxx | 11 +++++++++-- src/Fl_Widget.cxx | 7 +++++-- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 1b712d949..2238b1b07 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ CHANGES IN FLTK 1.1.0 - Documentation updates. + - Added a Fl_Widget::redraw_label() method which flags a + redraw of the appropriate area. This helps to + eliminate flicker when updating the value of a widget. - Fl_Wizard::value() now resets the mouse cursor to the window's default cursor. - Fl_File_Chooser::type() didn't enable/disable the new diff --git a/FL/Fl_Widget.H b/FL/Fl_Widget.H index 22ed0253f..1637b69c2 100644 --- a/FL/Fl_Widget.H +++ b/FL/Fl_Widget.H @@ -1,5 +1,5 @@ // -// "$Id: Fl_Widget.H,v 1.6.2.4.2.18 2002/08/14 17:05:38 easysw Exp $" +// "$Id: Fl_Widget.H,v 1.6.2.4.2.19 2002/10/04 15:59:28 easysw Exp $" // // Widget header file for the Fast Light Tool Kit (FLTK). // @@ -131,7 +131,7 @@ public: void selection_color(unsigned a) {color2_ = a;} void color(unsigned a, unsigned b) {color_=a; color2_=b;} const char* label() const {return label_.value;} - void label(const char* a) {label_.value=a;} + void label(const char* a) {label_.value=a; redraw_label();} void label(Fl_Labeltype a,const char* b) {label_.type = a; label_.value = b;} Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;} void labeltype(Fl_Labeltype a) {label_.type = a;} @@ -194,6 +194,7 @@ public: int inside(const Fl_Widget* o) const {return o ? o->contains(this) : 0;} void redraw(); + void redraw_label(); uchar damage() const {return damage_;} void clear_damage(uchar c = 0) {damage_ = c;} void damage(uchar c); @@ -216,5 +217,5 @@ public: #endif // -// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.18 2002/08/14 17:05:38 easysw Exp $". +// End of "$Id: Fl_Widget.H,v 1.6.2.4.2.19 2002/10/04 15:59:28 easysw Exp $". // diff --git a/documentation/Fl_Widget.html b/documentation/Fl_Widget.html index 19cb3dced..3b6a1cf58 100644 --- a/documentation/Fl_Widget.html +++ b/documentation/Fl_Widget.html @@ -75,6 +75,7 @@ to call redraw() after these.

  • parent
  • position
  • redraw
  • +
  • redraw_label
  • resize
  • selection_color
  • set_changed
  • @@ -386,6 +387,12 @@ HREF="Fl_Window.html#Fl_Window">Fl_Window. Returns HREF="subclassing.html#draw">draw() routine called. +

    void Fl_Widget::redraw_label()

    + +

    Marks the widget or the parent as needing a redraw for the +label area of a widget. + +

    virtual void Fl_Widget::resize(int x, int y, int w, int h)
    void Fl_Widget::position(short x, short y) diff --git a/documentation/common.html b/documentation/common.html index 6659c85b4..7a7a85066 100644 --- a/documentation/common.html +++ b/documentation/common.html @@ -332,7 +332,7 @@ sign. Figure 3-4 shows the available symbols.

    Figure 3-4: FLTK label symbols

    The @ sign may also be followed by the following optional -"formatting" characters, in this order:

    +"formatting" characters, in this order:

    +

    Thus, to show a very large arrow pointing downward you would use the +label string "@+92->". +

    align()

    The align() method positions the label. The following diff --git a/src/Fl.cxx b/src/Fl.cxx index aa01b3251..ae635ba53 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.53 2002/09/20 17:56:56 easysw Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.54 2002/10/04 15:59:28 easysw Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -855,7 +855,9 @@ void Fl::paste(Fl_Widget &receiver) { void Fl_Widget::redraw() { damage(FL_DAMAGE_ALL); +} +void Fl_Widget::redraw_label() { if (window()) { if (box() == FL_NO_BOX) { // Widgets with the FL_NO_BOX boxtype need a parent to @@ -880,7 +882,12 @@ void Fl_Widget::redraw() { window()->damage(FL_DAMAGE_EXPOSE, x() - W, y(), W, h()); } else if (align() & FL_ALIGN_RIGHT) { window()->damage(FL_DAMAGE_EXPOSE, x() + w(), y(), W, h()); + } else { + damage(FL_DAMAGE_ALL); } + } else { + // The label is inside the widget, so just redraw the widget itself... + damage(FL_DAMAGE_ALL); } } } @@ -960,5 +967,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.53 2002/09/20 17:56:56 easysw Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.54 2002/10/04 15:59:28 easysw Exp $". // diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 7d396eac7..b237adb10 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.19 2002/07/23 15:07:33 easysw Exp $" +// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.20 2002/10/04 15:59:29 easysw Exp $" // // Base widget class for the Fast Light Tool Kit (FLTK). // @@ -182,6 +182,7 @@ void Fl_Widget::activate() { clear_flag(INACTIVE); if (active_r()) { redraw(); + redraw_label(); handle(FL_ACTIVATE); if (inside(Fl::focus())) Fl::focus()->take_focus(); } @@ -192,6 +193,7 @@ void Fl_Widget::deactivate() { if (active_r()) { set_flag(INACTIVE); redraw(); + redraw_label(); handle(FL_DEACTIVATE); fl_throw_focus(this); } else { @@ -210,6 +212,7 @@ void Fl_Widget::show() { clear_flag(INVISIBLE); if (visible_r()) { redraw(); + redraw_label(); handle(FL_SHOW); if (inside(Fl::focus())) Fl::focus()->take_focus(); } @@ -242,5 +245,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const { } // -// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.19 2002/07/23 15:07:33 easysw Exp $". +// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.20 2002/10/04 15:59:29 easysw Exp $". // -- cgit v1.2.3