The block selection is now drawn incrementally if possible which removes flicker.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10380 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-12-09 02:34:35 +00:00
parent d72c6cc87b
commit 247c75991c
2 changed files with 53 additions and 23 deletions
+44 -15
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
@@ -544,7 +544,7 @@ DataView::DrawSelectionFrame(view_focus which)
void void
DataView::DrawSelectionBlock(view_focus which) DataView::DrawSelectionBlock(view_focus which, int32 blockStart, int32 blockEnd)
{ {
if (fFileSize == 0) if (fFileSize == 0)
return; return;
@@ -553,10 +553,10 @@ DataView::DrawSelectionBlock(view_focus which)
SetDrawingMode(B_OP_INVERT); SetDrawingMode(B_OP_INVERT);
int32 start = fStart % kBlockSize; int32 start = blockStart % kBlockSize;
int32 first = (fStart / kBlockSize) * kBlockSize; int32 first = (blockStart / kBlockSize) * kBlockSize;
int32 end = fEnd; int32 end = blockEnd;
if (end > first + (int32)kBlockSize - 1) if (end > first + (int32)kBlockSize - 1)
end = first + kBlockSize - 1; end = first + kBlockSize - 1;
@@ -565,8 +565,8 @@ DataView::DrawSelectionBlock(view_focus which)
// draw block (and last line) if necessary // draw block (and last line) if necessary
end = fEnd % kBlockSize; end = blockEnd % kBlockSize;
int32 last = (fEnd / kBlockSize) * kBlockSize; int32 last = (blockEnd / kBlockSize) * kBlockSize;
if (last >= first) { if (last >= first) {
if (end == kBlockSize - 1) if (end == kBlockSize - 1)
@@ -583,9 +583,17 @@ DataView::DrawSelectionBlock(view_focus which)
void void
DataView::DrawSelection() DataView::DrawSelectionBlock(view_focus which)
{
DrawSelectionBlock(which, fStart, fEnd);
}
void
DataView::DrawSelection(bool frameOnly)
{ {
if (IsFocus() && fIsActive) { if (IsFocus() && fIsActive) {
if (!frameOnly)
DrawSelectionBlock(fFocus); DrawSelectionBlock(fFocus);
DrawSelectionFrame(fFocus == kHexFocus ? kAsciiFocus : kHexFocus); DrawSelectionFrame(fFocus == kHexFocus ? kAsciiFocus : kHexFocus);
} else { } else {
@@ -633,18 +641,39 @@ DataView::SetSelection(int32 start, int32 end, view_focus focus)
update.AddInt64("end", end); update.AddInt64("end", end);
SendNotices(kDataViewSelection, &update); SendNotices(kDataViewSelection, &update);
// remove old selection // Update selection - first, we need to remove the old selection, then
// ToDo: this could be drastically improved if only the changed // we redraw the selection with the current values.
// parts are drawn! Of course, this would only work for the
// selection block, not the frame. DrawSelection(focus == kNoFocus);
DrawSelection(); // From the block selection, only the parts that need updating are
// actually updated, if there is no focus change.
if (IsFocus() && fIsActive && focus == kNoFocus) {
// Update the selection block incrementally
if (start > fStart) {
// remove from the top
DrawSelectionBlock(fFocus, fStart, start - 1);
} else if (start < fStart) {
// add to the top
DrawSelectionBlock(fFocus, start, fStart - 1);
}
if (end < fEnd) {
// remove from bottom
DrawSelectionBlock(fFocus, end + 1, fEnd);
} else if (end > fEnd) {
// add to the bottom
DrawSelectionBlock(fFocus, fEnd + 1, end);
}
}
if (focus != kNoFocus) if (focus != kNoFocus)
fFocus = focus; fFocus = focus;
fStart = start; fStart = start;
fEnd = end; fEnd = end;
DrawSelection(); DrawSelection(focus == kNoFocus);
fBitPosition = 0; fBitPosition = 0;
} }
+4 -3
View File
@@ -1,6 +1,6 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
#ifndef DATA_VIEW_H #ifndef DATA_VIEW_H
#define DATA_VIEW_H #define DATA_VIEW_H
@@ -68,8 +68,9 @@ class DataView : public BView {
int32 PositionAt(view_focus focus, BPoint point, view_focus *_newFocus = NULL); int32 PositionAt(view_focus focus, BPoint point, view_focus *_newFocus = NULL);
void DrawSelectionFrame(view_focus which); void DrawSelectionFrame(view_focus which);
void DrawSelectionBlock(view_focus which, int32 start, int32 end);
void DrawSelectionBlock(view_focus which); void DrawSelectionBlock(view_focus which);
void DrawSelection(); void DrawSelection(bool frameOnly = false);
void SetActive(bool active); void SetActive(bool active);
void SetFocus(view_focus which); void SetFocus(view_focus which);