summaryrefslogtreecommitdiff
path: root/src/Fl_Help_View.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2007-02-08 21:18:50 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2007-02-08 21:18:50 +0000
commit1b7589dacef37de05ffae181f802d60bff3e9afe (patch)
treec42b41a050bb9de69fa11cc65fdb6c2a0b3d631b /src/Fl_Help_View.cxx
parentc9a93b10f5d22a6fbcb57e602fe4f8e006836be2 (diff)
Fix flickering of Fl_Help_View - turns out we were drawing to the
window every time we checked for extension of the selection. The new code draws to a 1x1 off-screen buffer, which eliminates the flickering and runs much faster! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5681 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Help_View.cxx')
-rw-r--r--src/Fl_Help_View.cxx71
1 files changed, 53 insertions, 18 deletions
diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx
index 6623734e1..07c05035f 100644
--- a/src/Fl_Help_View.cxx
+++ b/src/Fl_Help_View.cxx
@@ -57,6 +57,7 @@
#include <FL/Fl_Help_View.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Pixmap.H>
+#include <FL/x.H>
#include <stdio.h>
#include <stdlib.h>
#include "flstring.h"
@@ -219,6 +220,9 @@ fl_line()
img->draw()
*/
+// We don't put the offscreen buffer in the help view class because
+// we'd need to include x.H in the header...
+static Fl_Offscreen fl_help_view_buffer;
int Fl_Help_View::selection_first = 0;
int Fl_Help_View::selection_last = 0;
int Fl_Help_View::selection_push_first = 0;
@@ -2625,34 +2629,67 @@ void Fl_Help_View::clear_global_selection()
char Fl_Help_View::begin_selection()
{
clear_global_selection();
- mouse_x = Fl::event_x(); mouse_y = Fl::event_y();
+
+ if (!fl_help_view_buffer) fl_help_view_buffer = fl_create_offscreen(1, 1);
+
+ mouse_x = Fl::event_x();
+ mouse_y = Fl::event_y();
draw_mode = 1;
- current_view = this;
- window()->make_current();
- draw();
+
+ current_view = this;
+ fl_begin_offscreen(fl_help_view_buffer);
+ draw();
+ fl_end_offscreen();
+
draw_mode = 0;
+
if (selection_push_last) return 1;
- return 0;
+ else return 0;
}
char Fl_Help_View::extend_selection()
{
if (Fl::event_is_click())
return 0;
- selected = 1;
+
+// printf("old selection_first=%d, selection_last=%d\n",
+// selection_first, selection_last);
+
int sf = selection_first, sl = selection_last;
- mouse_x = Fl::event_x(); mouse_y = Fl::event_y();
+
+ selected = 1;
+ mouse_x = Fl::event_x();
+ mouse_y = Fl::event_y();
draw_mode = 2;
- window()->make_current();
- draw();
+
+ fl_begin_offscreen(fl_help_view_buffer);
+ draw();
+ fl_end_offscreen();
+
draw_mode = 0;
- if (selection_push_first < selection_drag_first)
- selection_first = selection_push_first; else selection_first = selection_drag_first;
- if (selection_push_last > selection_drag_last)
- selection_last = selection_push_last; else selection_last = selection_drag_last;
- if (sf!=selection_first || sl!=selection_last)
+
+ if (selection_push_first < selection_drag_first) {
+ selection_first = selection_push_first;
+ } else {
+ selection_first = selection_drag_first;
+ }
+
+ if (selection_push_last > selection_drag_last) {
+ selection_last = selection_push_last;
+ } else {
+ selection_last = selection_drag_last;
+ }
+
+// printf("new selection_first=%d, selection_last=%d\n",
+// selection_first, selection_last);
+
+ if (sf!=selection_first || sl!=selection_last) {
+// puts("REDRAW!!!\n");
return 1;
- return 1;
+ } else {
+// puts("");
+ return 0;
+ }
}
// convert a command with up to four letters into an unsigned int
@@ -2811,9 +2848,7 @@ Fl_Help_View::handle(int event) // I - Event to handle
return 1;
}
if (current_view==this && selection_push_last) {
- if (extend_selection()) {
- redraw();
- }
+ if (extend_selection()) redraw();
fl_cursor(FL_CURSOR_INSERT);
return 1;
}