STR 1183: swapping two items in an Fl_Browser_ widget would corrupt redrawing if either item was "top". This fix swaps the top_ variable correctly, and also swaps the selection flag as the user would expect.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4879 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2006-03-28 23:27:20 +00:00
parent 8fcdb4beba
commit b8bc24764e
3 changed files with 11 additions and 2 deletions

View File

@ -88,6 +88,7 @@ protected:
void new_list(); // completely clobber all data, as though list replaced
void deleting(void *a); // get rid of any pointers to a
void replacing(void *a,void *b); // change a pointers to b
void swapping(void *a,void *b); // exchange pointers a and b
void inserting(void *a,void *b); // insert b near a
int displayed(void *) const ; // true if this line is visible
void redraw_line(void *); // minimal update, no change in size

View File

@ -503,6 +503,7 @@ int Fl_Browser::value() const {
void Fl_Browser::swap(FL_BLINE *a, FL_BLINE *b) {
if ( a == b || !a || !b) return; // nothing to do
swapping(a, b);
FL_BLINE *aprev = a->prev;
FL_BLINE *anext = a->next;
FL_BLINE *bprev = b->prev;
@ -535,8 +536,6 @@ void Fl_Browser::swap(FL_BLINE *a, FL_BLINE *b) {
}
// Disable cache -- we played around with positions
cacheline = 0;
// Redraw modified lines
redraw_lines();
}
void Fl_Browser::swap(int ai, int bi) {

View File

@ -470,6 +470,15 @@ void Fl_Browser_::replacing(void* a, void* b) {
if (a == max_width_item) {max_width_item = 0; max_width = 0;}
}
void Fl_Browser_::swapping(void* a, void* b) {
redraw_line(a);
redraw_line(b);
if (a == selection_) selection_ = b;
else if (b == selection_) selection_ = a;
if (a == top_) top_ = b;
else if (b == top_) top_ = a;
}
void Fl_Browser_::inserting(void* a, void* b) {
if (displayed(a)) redraw_lines();
if (a == top_) top_ = b;