Sorry for mixing some cleanups into this patch...
* When changing icon sizes, invalidate before scrolling. This causes silent scrolling in app_server and avoids a visual jerk. Everything needs to be re-drawn at the new icon size anyways. * Removed the fUpdateRegion member from BPoseView. It was supposed to make drawing quicker, but it only made it slower. Checking for intersection with the update rect passed to Draw() should be much more straight forward and does not involve app_server communication... * Refactored some misnamed methods, ScrollIntoView() would always draw and only sometimes scroll - I couldn't agree with that. * There is a very confusing mix of "fullDraw" and "minimalRect" booleans which seem to be used with wrong semantics. The minimalRect flag passed to BPose:: CalcRect() means to get the pose rect for the icon and the first column only, not all columns. Contrary to that, some pose rect calculation happens with minimalRect == fullDraw... I tried to fix some of that. * The visible changes of this patch are when adding poses. The SynchronousUpate() wasn't working so well, I made it work reliably by invoking Invalidate() and Window()->UpdateIfNeeded(), which also takes care of any drawing that the app_server has to do for the background. And it's flicker free in double buffered mode... -> This fixes poses being drawn multiple times and the text getting darker. * And there was another bug when adding poses. The extent (bottom of last item in list view for example) can be just above the current view bounds. When the next item is added above the view bounds, then the extent scrolls into view, but there is nothing to be scrolled in this case. srcRect is still invalid and so is dstRect. But destRect should be valid in this case. -> This fixes some poses being cut off at the bottom when opening Tracker windows. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30033 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -524,8 +524,8 @@ BPose::PointInPose(BPoint loc, const BPoseView *poseView, BPoint where,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
BPose::Draw(BRect rect, const BRect& updateRect, BPoseView *poseView, BView *drawView,
|
||||||
const BRegion *updateRgn, BPoint offset, bool selected)
|
bool fullDraw, BPoint offset, bool selected)
|
||||||
{
|
{
|
||||||
// If the background wasn't cleared and Draw() is not called after
|
// If the background wasn't cleared and Draw() is not called after
|
||||||
// having edited a name or similar (with fullDraw)
|
// having edited a name or similar (with fullDraw)
|
||||||
@@ -550,7 +550,7 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
|||||||
iconRect.left += kListOffset;
|
iconRect.left += kListOffset;
|
||||||
iconRect.right = iconRect.left + size;
|
iconRect.right = iconRect.left + size;
|
||||||
iconRect.top = iconRect.bottom - size;
|
iconRect.top = iconRect.bottom - size;
|
||||||
if (!updateRgn || updateRgn->Intersects(iconRect)) {
|
if (updateRect.Intersects(iconRect)) {
|
||||||
DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(), directDraw,
|
DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(), directDraw,
|
||||||
!windowActive && !showSelectionWhenInactive);
|
!windowActive && !showSelectionWhenInactive);
|
||||||
}
|
}
|
||||||
@@ -572,7 +572,7 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
|||||||
BRect widgetRect(widget->ColumnRect(rect.LeftTop(), column,
|
BRect widgetRect(widget->ColumnRect(rect.LeftTop(), column,
|
||||||
poseView));
|
poseView));
|
||||||
|
|
||||||
if (!updateRgn || updateRgn->Intersects(widgetRect)) {
|
if (updateRect.Intersects(widgetRect)) {
|
||||||
BRect widgetTextRect(widget->CalcRect(rect.LeftTop(), column,
|
BRect widgetTextRect(widget->CalcRect(rect.LeftTop(), column,
|
||||||
poseView));
|
poseView));
|
||||||
|
|
||||||
@@ -613,10 +613,8 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
// draw in icon mode
|
// draw in icon mode
|
||||||
if (updateRgn && !updateRgn->Intersects(rect))
|
BPoint location(Location(poseView));
|
||||||
return;
|
BPoint iconOrigin(location);
|
||||||
|
|
||||||
BPoint iconOrigin(Location(poseView));
|
|
||||||
iconOrigin += offset;
|
iconOrigin += offset;
|
||||||
|
|
||||||
DrawIcon(iconOrigin, drawView, poseView->IconSize(), directDraw,
|
DrawIcon(iconOrigin, drawView, poseView->IconSize(), directDraw,
|
||||||
@@ -630,7 +628,7 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
|||||||
if (!widget || !widget->IsVisible())
|
if (!widget || !widget->IsVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rect = widget->CalcRect(Location(poseView), 0, poseView);
|
rect = widget->CalcRect(location, 0, poseView);
|
||||||
|
|
||||||
bool selectDuringDraw = directDraw && selected
|
bool selectDuringDraw = directDraw && selected
|
||||||
&& (poseView->IsDesktopWindow() || windowActive);
|
&& (poseView->IsDesktopWindow() || windowActive);
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ class BPose {
|
|||||||
void SetLocation(BPoint, const BPoseView *);
|
void SetLocation(BPoint, const BPoseView *);
|
||||||
void MoveTo(BPoint, BPoseView *, bool inval = true);
|
void MoveTo(BPoint, BPoseView *, bool inval = true);
|
||||||
|
|
||||||
void Draw(BRect, BPoseView *, bool fullDraw = true,
|
void Draw(BRect poseRect, const BRect& updateRect, BPoseView *,
|
||||||
const BRegion * = 0);
|
bool fullDraw = true);
|
||||||
void Draw(BRect, BPoseView *, BView *drawView, bool fullDraw,
|
void Draw(BRect poseRect, const BRect& updateRect, BPoseView *,
|
||||||
const BRegion *, BPoint offset, bool selected);
|
BView *drawView, bool fullDraw, BPoint offset, bool selected);
|
||||||
void DeselectWithoutErasingBackground(BRect rect, BPoseView *poseView);
|
void DeselectWithoutErasingBackground(BRect rect, BPoseView *poseView);
|
||||||
// special purpose draw call for deselecting over a textured
|
// special purpose draw call for deselecting over a textured
|
||||||
// background
|
// background
|
||||||
@@ -236,10 +236,10 @@ BPose::HasLocation() const
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BPose::Draw(BRect rect, BPoseView *view, bool fullDraw,
|
BPose::Draw(BRect poseRect, const BRect& updateRect, BPoseView *view,
|
||||||
const BRegion *updateRgn)
|
bool fullDraw)
|
||||||
{
|
{
|
||||||
Draw(rect, view, (BView *)view, fullDraw, updateRgn, BPoint(0, 0),
|
Draw(poseRect, updateRect, view, (BView *)view, fullDraw, BPoint(0, 0),
|
||||||
IsSelected());
|
IsSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+140
-88
@@ -206,7 +206,6 @@ BPoseView::BPoseView(Model *model, BRect bounds, uint32 viewMode, uint32 resizeM
|
|||||||
fViewState(new BViewState),
|
fViewState(new BViewState),
|
||||||
fStateNeedsSaving(false),
|
fStateNeedsSaving(false),
|
||||||
fCountView(NULL),
|
fCountView(NULL),
|
||||||
fUpdateRegion(new BRegion), // does this need to be allocated ??
|
|
||||||
fDropTarget(NULL),
|
fDropTarget(NULL),
|
||||||
fAlreadySelectedDropTarget(NULL),
|
fAlreadySelectedDropTarget(NULL),
|
||||||
fSelectionHandler(be_app),
|
fSelectionHandler(be_app),
|
||||||
@@ -257,7 +256,6 @@ BPoseView::~BPoseView()
|
|||||||
delete fSelectionList;
|
delete fSelectionList;
|
||||||
delete fMimeTypeList;
|
delete fMimeTypeList;
|
||||||
delete fZombieList;
|
delete fZombieList;
|
||||||
delete fUpdateRegion;
|
|
||||||
delete fViewState;
|
delete fViewState;
|
||||||
delete fModel;
|
delete fModel;
|
||||||
delete fKeyRunner;
|
delete fKeyRunner;
|
||||||
@@ -1122,8 +1120,8 @@ BPoseView::AddPoses(Model *model)
|
|||||||
if (model)
|
if (model)
|
||||||
params->ref = *model->EntryRef();
|
params->ref = *model->EntryRef();
|
||||||
|
|
||||||
thread_id addPosesThread = spawn_thread(&BPoseView::AddPosesTask, "add poses",
|
thread_id addPosesThread = spawn_thread(&BPoseView::AddPosesTask,
|
||||||
B_DISPLAY_PRIORITY, params);
|
"add poses", B_DISPLAY_PRIORITY, params);
|
||||||
|
|
||||||
if (addPosesThread >= B_OK) {
|
if (addPosesThread >= B_OK) {
|
||||||
fAddPosesThreads.insert(addPosesThread);
|
fAddPosesThreads.insert(addPosesThread);
|
||||||
@@ -1308,8 +1306,8 @@ BPoseView::AddPosesTask(void *castToParams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!view->IsValidAddPosesThread(threadID)) {
|
if (!view->IsValidAddPosesThread(threadID)) {
|
||||||
// this handles the case of a file panel when the directory is switched
|
// this handles the case of a file panel when the directory is
|
||||||
// and and old AddPosesTask needs to die.
|
// switched and and old AddPosesTask needs to die.
|
||||||
// we might no longer be the current async thread
|
// we might no longer be the current async thread
|
||||||
// for this view - if not then we're done
|
// for this view - if not then we're done
|
||||||
view->HideBarberPole();
|
view->HideBarberPole();
|
||||||
@@ -1320,20 +1318,24 @@ BPoseView::AddPosesTask(void *castToParams)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
// try to watch the model, no matter what
|
// try to watch the model, no matter what
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
// failed to init pose, model is a zombie, add to zombie list
|
// failed to init pose, model is a zombie, add to zombie
|
||||||
PRINT(("1 adding model %s to zombie list, error %s\n", model->Name(),
|
// list
|
||||||
strerror(model->InitCheck())));
|
PRINT(("1 adding model %s to zombie list, error %s\n",
|
||||||
|
model->Name(), strerror(model->InitCheck())));
|
||||||
view->fZombieList->AddItem(model);
|
view->fZombieList->AddItem(model);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
view->ReadPoseInfo(model, &(posesResult->fPoseInfos[modelChunkIndex]));
|
view->ReadPoseInfo(model,
|
||||||
if (!view->ShouldShowPose(model, &(posesResult->fPoseInfos[modelChunkIndex]))
|
&(posesResult->fPoseInfos[modelChunkIndex]));
|
||||||
|
if (!view->ShouldShowPose(model,
|
||||||
|
&(posesResult->fPoseInfos[modelChunkIndex]))
|
||||||
// filter out models we do not want to show
|
// filter out models we do not want to show
|
||||||
|| model->IsSymLink() && !view->CreateSymlinkPoseTarget(model)) {
|
|| model->IsSymLink()
|
||||||
|
&& !view->CreateSymlinkPoseTarget(model)) {
|
||||||
// filter out symlinks whose target models we do not
|
// filter out symlinks whose target models we do not
|
||||||
// want to show
|
// want to show
|
||||||
|
|
||||||
@@ -1352,7 +1354,8 @@ BPoseView::AddPosesTask(void *castToParams)
|
|||||||
|
|
||||||
bigtime_t now = system_time();
|
bigtime_t now = system_time();
|
||||||
|
|
||||||
if (!count || modelChunkIndex >= kMaxAddPosesChunk || now > nextChunkTime) {
|
if (!count || modelChunkIndex >= kMaxAddPosesChunk
|
||||||
|
|| now > nextChunkTime) {
|
||||||
// keep getting models until we get <kMaxAddPosesChunk> of them
|
// keep getting models until we get <kMaxAddPosesChunk> of them
|
||||||
// or until 300000 runs out
|
// or until 300000 runs out
|
||||||
|
|
||||||
@@ -1579,18 +1582,22 @@ BPoseView::CreatePose(Model *model, PoseInfo *poseInfo, bool insertionSort,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::FinishPendingScroll(float &listViewScrollBy, BRect bounds)
|
BPoseView::FinishPendingScroll(float &listViewScrollBy, BRect srcRect)
|
||||||
{
|
{
|
||||||
if (!listViewScrollBy)
|
if (listViewScrollBy == 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect srcRect(bounds);
|
// copy top contents to bottom and
|
||||||
BRect dstRect = srcRect;
|
// redraw from top to top of part that could be copied
|
||||||
srcRect.bottom -= listViewScrollBy;
|
|
||||||
dstRect.top += listViewScrollBy;
|
if (srcRect.Width() > listViewScrollBy) {
|
||||||
CopyBits(srcRect, dstRect);
|
BRect dstRect = srcRect;
|
||||||
listViewScrollBy = 0;
|
srcRect.bottom -= listViewScrollBy;
|
||||||
srcRect.bottom = dstRect.top;
|
dstRect.top += listViewScrollBy;
|
||||||
|
CopyBits(srcRect, dstRect);
|
||||||
|
listViewScrollBy = 0;
|
||||||
|
srcRect.bottom = dstRect.top;
|
||||||
|
}
|
||||||
SynchronousUpdate(srcRect);
|
SynchronousUpdate(srcRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1636,7 +1643,7 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
|
|||||||
fInsertedNodes.insert(*(model->NodeRef()));
|
fInsertedNodes.insert(*(model->NodeRef()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((clipboardMode = FSClipboardFindNodeMode(model,false,true)) != 0
|
if ((clipboardMode = FSClipboardFindNodeMode(model, false, true)) != 0
|
||||||
&& !HasPosesInClipboard()) {
|
&& !HasPosesInClipboard()) {
|
||||||
SetHasPosesInClipboard(true);
|
SetHasPosesInClipboard(true);
|
||||||
}
|
}
|
||||||
@@ -1672,22 +1679,40 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
|
|||||||
if (orientation == kInsertAfter)
|
if (orientation == kInsertAfter)
|
||||||
poseIndex++;
|
poseIndex++;
|
||||||
|
|
||||||
poseBounds = CalcPoseRect(pose, poseIndex);
|
poseBounds = CalcPoseRectList(pose, poseIndex);
|
||||||
havePoseBounds = true;
|
havePoseBounds = true;
|
||||||
BRect srcRect(Extent());
|
BRect srcRect(Extent());
|
||||||
srcRect.top = poseBounds.top;
|
srcRect.top = poseBounds.top;
|
||||||
srcRect = srcRect & viewBounds;
|
srcRect = srcRect & viewBounds;
|
||||||
BRect destRect(srcRect);
|
BRect destRect(srcRect);
|
||||||
destRect.OffsetBy(0, fListElemHeight);
|
destRect.OffsetBy(0, fListElemHeight);
|
||||||
|
// special case the addition of a pose that scrolls
|
||||||
|
// the extent into the view for the first time:
|
||||||
|
if (destRect.bottom > viewBounds.top
|
||||||
|
&& destRect.top > destRect.bottom) {
|
||||||
|
// make destRect valid
|
||||||
|
destRect.top = viewBounds.top;
|
||||||
|
}
|
||||||
|
|
||||||
if (srcRect.Intersects(viewBounds)
|
if (srcRect.Intersects(viewBounds)
|
||||||
|| destRect.Intersects(viewBounds)) {
|
|| destRect.Intersects(viewBounds)) {
|
||||||
|
// The visual area is affected by the insertion.
|
||||||
|
// If items have been added above the visual area,
|
||||||
|
// delay the scrolling. srcRect.bottom holds the
|
||||||
|
// current Extent(). So if the bottom is still above
|
||||||
|
// the viewBounds top, it means the view is scrolled
|
||||||
|
// to show the area below the items that have already
|
||||||
|
// been added.
|
||||||
if (srcRect.top == viewBounds.top
|
if (srcRect.top == viewBounds.top
|
||||||
&& srcRect.bottom == viewBounds.bottom) {
|
&& srcRect.bottom >= viewBounds.top) {
|
||||||
// if new pose above current view bounds, cache up
|
// if new pose above current view bounds, cache up
|
||||||
// the draw and do it later
|
// the draw and do it later
|
||||||
listViewScrollBy += fListElemHeight;
|
listViewScrollBy += fListElemHeight;
|
||||||
forceDraw = false;
|
forceDraw = false;
|
||||||
|
} else if (!srcRect.IsValid()) {
|
||||||
|
// nothing to be scrolled, but extent became
|
||||||
|
// visible
|
||||||
|
SynchronousUpdate(destRect);
|
||||||
} else {
|
} else {
|
||||||
FinishPendingScroll(listViewScrollBy, viewBounds);
|
FinishPendingScroll(listViewScrollBy, viewBounds);
|
||||||
fPoseList->AddItem(pose, poseIndex);
|
fPoseList->AddItem(pose, poseIndex);
|
||||||
@@ -1696,8 +1721,7 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
|
|||||||
CopyBits(srcRect, destRect);
|
CopyBits(srcRect, destRect);
|
||||||
srcRect.bottom = destRect.top;
|
srcRect.bottom = destRect.top;
|
||||||
|
|
||||||
//SynchronousUpdate(srcRect);
|
SynchronousUpdate(srcRect);
|
||||||
Invalidate(srcRect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1708,7 +1732,7 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
|
|||||||
|
|
||||||
if (forceDraw) {
|
if (forceDraw) {
|
||||||
if (!havePoseBounds)
|
if (!havePoseBounds)
|
||||||
poseBounds = CalcPoseRect(pose, poseIndex);
|
poseBounds = CalcPoseRectList(pose, poseIndex);
|
||||||
if (viewBounds.Intersects(poseBounds))
|
if (viewBounds.Intersects(poseBounds))
|
||||||
Invalidate(poseBounds);
|
Invalidate(poseBounds);
|
||||||
}
|
}
|
||||||
@@ -1862,7 +1886,7 @@ BPoseView::InsertPoseAfter(BPose *pose, int32 *index, int32 orientation,
|
|||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
// copy the good bits in the list
|
// copy the good bits in the list
|
||||||
BRect srcRect(Extent());
|
BRect srcRect(Extent());
|
||||||
srcRect.top = CalcPoseRect(pose, *index).top;
|
srcRect.top = CalcPoseRectList(pose, *index).top;
|
||||||
srcRect = srcRect & bounds;
|
srcRect = srcRect & bounds;
|
||||||
BRect destRect(srcRect);
|
BRect destRect(srcRect);
|
||||||
destRect.OffsetBy(0, fListElemHeight);
|
destRect.OffsetBy(0, fListElemHeight);
|
||||||
@@ -1992,11 +2016,13 @@ BPoseView::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
AddPosesResult *currentPoses;
|
AddPosesResult *currentPoses;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
message->FindPointer("currentPoses", reinterpret_cast<void **>(¤tPoses));
|
message->FindPointer("currentPoses",
|
||||||
|
reinterpret_cast<void **>(¤tPoses));
|
||||||
message->FindRef("ref", &ref);
|
message->FindRef("ref", &ref);
|
||||||
|
|
||||||
// check if CreatePoses should be called (abort if dir has been switched
|
// check if CreatePoses should be called (abort if dir has been
|
||||||
// under normal circumstances, ignore in several special cases
|
// switched under normal circumstances, ignore in several special
|
||||||
|
// cases
|
||||||
if (AddPosesThreadValid(&ref)) {
|
if (AddPosesThreadValid(&ref)) {
|
||||||
CreatePoses(currentPoses->fModels, currentPoses->fPoseInfos,
|
CreatePoses(currentPoses->fModels, currentPoses->fPoseInfos,
|
||||||
currentPoses->fCount, NULL, true, 0, 0, true);
|
currentPoses->fCount, NULL, true, 0, 0, true);
|
||||||
@@ -2829,6 +2855,11 @@ BPoseView::SetViewMode(uint32 newMode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// invalidate before anything else to avoid flickering, especially when
|
||||||
|
// scrolling is also performed (invalidating before scrolling will cause
|
||||||
|
// app_server to scroll silently, ie not visibly)
|
||||||
|
Invalidate();
|
||||||
|
|
||||||
// update origin in case of a list <-> icon mode transition
|
// update origin in case of a list <-> icon mode transition
|
||||||
BPoint newOrigin;
|
BPoint newOrigin;
|
||||||
if (newMode == kListMode)
|
if (newMode == kListMode)
|
||||||
@@ -2860,7 +2891,6 @@ BPoseView::SetViewMode(uint32 newMode)
|
|||||||
SetScrollBarsTo(newOrigin);
|
SetScrollBarsTo(newOrigin);
|
||||||
EnableScrollBars();
|
EnableScrollBars();
|
||||||
ContainerWindow()->ViewModeChanged(oldMode, newMode);
|
ContainerWindow()->ViewModeChanged(oldMode, newMode);
|
||||||
Invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3607,30 +3637,27 @@ BPoseView::SelectPoses(int32 start, int32 end)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::ScrollIntoView(BPose *pose, int32 index, bool drawOnly)
|
BPoseView::ScrollIntoView(BPose *pose, int32 index)
|
||||||
{
|
{
|
||||||
BRect poseRect;
|
ScrollIntoView(CalcPoseRect(pose, index, true));
|
||||||
|
}
|
||||||
|
|
||||||
if (ViewMode() == kListMode)
|
|
||||||
poseRect = CalcPoseRect(pose, index);
|
|
||||||
else
|
|
||||||
poseRect = pose->CalcRect(this);
|
|
||||||
|
|
||||||
if (!IsDesktopWindow() && !drawOnly) {
|
void
|
||||||
BRect testRect(poseRect);
|
BPoseView::ScrollIntoView(BRect poseRect)
|
||||||
|
{
|
||||||
|
if (IsDesktopWindow())
|
||||||
|
return;
|
||||||
|
|
||||||
if (ViewMode() == kListMode) {
|
if (ViewMode() == kListMode) {
|
||||||
// if we're in list view then we only care that the entire
|
// if we're in list view then we only care that the entire
|
||||||
// pose is visible vertically, not horizontally
|
// pose is visible vertically, not horizontally
|
||||||
testRect.left = 0;
|
poseRect.left = 0;
|
||||||
testRect.right = testRect.left + 1;
|
poseRect.right = poseRect.left + 1;
|
||||||
}
|
|
||||||
if (!Bounds().Contains(testRect))
|
|
||||||
SetScrollBarsTo(testRect.LeftTop());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bounds().Intersects(poseRect))
|
if (!Bounds().Contains(poseRect))
|
||||||
pose->Draw(poseRect, this, false);
|
SetScrollBarsTo(poseRect.LeftTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3652,7 +3679,11 @@ BPoseView::AddPoseToSelection(BPose *pose, int32 index, bool scrollIntoView)
|
|||||||
pose->Select(true);
|
pose->Select(true);
|
||||||
fSelectionList->AddItem(pose);
|
fSelectionList->AddItem(pose);
|
||||||
|
|
||||||
ScrollIntoView(pose, index, !scrollIntoView);
|
BRect poseRect = CalcPoseRect(pose, index);
|
||||||
|
Invalidate(poseRect);
|
||||||
|
|
||||||
|
if (scrollIntoView)
|
||||||
|
ScrollIntoView(poseRect);
|
||||||
|
|
||||||
if (fSelectionChangedHook)
|
if (fSelectionChangedHook)
|
||||||
ContainerWindow()->SelectionChanged();
|
ContainerWindow()->SelectionChanged();
|
||||||
@@ -5738,7 +5769,7 @@ BPoseView::SelectAll()
|
|||||||
poseRect = pose->CalcRect(loc, this);
|
poseRect = pose->CalcRect(loc, this);
|
||||||
|
|
||||||
if (bounds.Intersects(poseRect)) {
|
if (bounds.Intersects(poseRect)) {
|
||||||
pose->Draw(poseRect, this, false);
|
pose->Draw(poseRect, bounds, this, false);
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5843,8 +5874,8 @@ BPoseView::SelectMatchingEntries(const BMessage *message)
|
|||||||
|
|
||||||
// There is room for optimizations here: If regexp-type match, the Matches()
|
// There is room for optimizations here: If regexp-type match, the Matches()
|
||||||
// function compiles the expression for every entry. One could use
|
// function compiles the expression for every entry. One could use
|
||||||
// TrackerString::CompileRegExp and reuse the expression. However, then we have
|
// TrackerString::CompileRegExp and reuse the expression. However, then we
|
||||||
// to take care of the case sensitivity ourselves.
|
// have to take care of the case sensitivity ourselves.
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
name = pose->TargetModel()->Name();
|
name = pose->TargetModel()->Name();
|
||||||
@@ -5890,7 +5921,7 @@ BPoseView::KeyDown(const char *bytes, int32 count)
|
|||||||
if (pose->IsSelected()) {
|
if (pose->IsSelected()) {
|
||||||
RemovePoseFromSelection(fSelectionList->LastItem());
|
RemovePoseFromSelection(fSelectionList->LastItem());
|
||||||
fSelectionPivotPose = pose;
|
fSelectionPivotPose = pose;
|
||||||
ScrollIntoView(pose, index, false);
|
ScrollIntoView(pose, index);
|
||||||
} else
|
} else
|
||||||
AddPoseToSelection(pose, index, true);
|
AddPoseToSelection(pose, index, true);
|
||||||
} else
|
} else
|
||||||
@@ -6333,7 +6364,8 @@ BPoseView::ShowContextMenu(BPoint where)
|
|||||||
|
|
||||||
window->Activate();
|
window->Activate();
|
||||||
window->UpdateIfNeeded();
|
window->UpdateIfNeeded();
|
||||||
window->ShowContextMenu(where, pose ? pose->TargetModel()->EntryRef() : 0, this);
|
window->ShowContextMenu(where, pose ? pose->TargetModel()->EntryRef() : 0,
|
||||||
|
this);
|
||||||
|
|
||||||
if (fSelectionChangedHook)
|
if (fSelectionChangedHook)
|
||||||
window->SelectionChanged();
|
window->SelectionChanged();
|
||||||
@@ -6745,7 +6777,8 @@ BPoseView::MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPose
|
|||||||
BRect poseRect(pose->CalcRect(loc, this, true));
|
BRect poseRect(pose->CalcRect(loc, this, true));
|
||||||
if (poseRect.Intersects(inner)) {
|
if (poseRect.Intersects(inner)) {
|
||||||
BPoint offsetBy(-inner.LeftTop().x, -inner.LeftTop().y);
|
BPoint offsetBy(-inner.LeftTop().x, -inner.LeftTop().y);
|
||||||
pose->Draw(poseRect, this, view, true, 0, offsetBy, false);
|
pose->Draw(poseRect, poseRect, this, view, true, offsetBy,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loc.y += fListElemHeight;
|
loc.y += fListElemHeight;
|
||||||
@@ -6765,7 +6798,8 @@ BPoseView::MakeDragBitmap(BRect dragRect, BPoint clickedPoint, int32 clickedPose
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
BPoint offsetBy(-inner.LeftTop().x, -inner.LeftTop().y);
|
BPoint offsetBy(-inner.LeftTop().x, -inner.LeftTop().y);
|
||||||
pose->Draw(poseRect, this, view, true, 0, offsetBy, false);
|
pose->Draw(poseRect, poseRect, this, view, true, offsetBy,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6804,7 +6838,7 @@ BPoseView::GetDragRect(int32 clickedPoseIndex)
|
|||||||
BPose *pose = fPoseList->ItemAt(clickedPoseIndex);
|
BPose *pose = fPoseList->ItemAt(clickedPoseIndex);
|
||||||
if (ViewMode() == kListMode) {
|
if (ViewMode() == kListMode) {
|
||||||
// get starting rect of clicked pose
|
// get starting rect of clicked pose
|
||||||
result = CalcPoseRect(pose, clickedPoseIndex, true);
|
result = CalcPoseRectList(pose, clickedPoseIndex, true);
|
||||||
|
|
||||||
// add rects for visible poses only
|
// add rects for visible poses only
|
||||||
int32 count = fPoseList->CountItems();
|
int32 count = fPoseList->CountItems();
|
||||||
@@ -7309,7 +7343,7 @@ BPoseView::DeletePose(const node_ref *itemNode, BPose *pose, int32 index)
|
|||||||
|
|
||||||
BRect invalidRect;
|
BRect invalidRect;
|
||||||
if (ViewMode() == kListMode)
|
if (ViewMode() == kListMode)
|
||||||
invalidRect = CalcPoseRect(pose, index);
|
invalidRect = CalcPoseRectList(pose, index);
|
||||||
else
|
else
|
||||||
invalidRect = pose->CalcRect(this);
|
invalidRect = pose->CalcRect(this);
|
||||||
|
|
||||||
@@ -7479,7 +7513,7 @@ BPoseView::OpenSelectionCommon(BPose *clickedPose, int32 *poseIndex,
|
|||||||
if (clickedPose) {
|
if (clickedPose) {
|
||||||
ASSERT(poseIndex);
|
ASSERT(poseIndex);
|
||||||
if (ViewMode() == kListMode)
|
if (ViewMode() == kListMode)
|
||||||
DrawOpenAnimation(CalcPoseRect(clickedPose, *poseIndex, true));
|
DrawOpenAnimation(CalcPoseRectList(clickedPose, *poseIndex, true));
|
||||||
else
|
else
|
||||||
DrawOpenAnimation(clickedPose->CalcRect(this));
|
DrawOpenAnimation(clickedPose->CalcRect(this));
|
||||||
}
|
}
|
||||||
@@ -7929,7 +7963,8 @@ BPoseView::ShowSelection(bool show)
|
|||||||
if (pose->IsSelected() != show || fShowSelectionWhenInactive) {
|
if (pose->IsSelected() != show || fShowSelectionWhenInactive) {
|
||||||
if (!fShowSelectionWhenInactive)
|
if (!fShowSelectionWhenInactive)
|
||||||
pose->Select(show);
|
pose->Select(show);
|
||||||
pose->Draw(BRect(pose->CalcRect(loc, this, false)), this, false);
|
pose->Draw(BRect(pose->CalcRect(loc, this, false)),
|
||||||
|
bounds, this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
loc.y += fListElemHeight;
|
loc.y += fListElemHeight;
|
||||||
@@ -7937,7 +7972,8 @@ BPoseView::ShowSelection(bool show)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32 startIndex = FirstIndexAtOrBelow((int32)(bounds.top - IconPoseHeight()), true);
|
int32 startIndex = FirstIndexAtOrBelow(
|
||||||
|
(int32)(bounds.top - IconPoseHeight()), true);
|
||||||
int32 count = fVSPoseList->CountItems();
|
int32 count = fVSPoseList->CountItems();
|
||||||
for (int32 index = startIndex; index < count; index++) {
|
for (int32 index = startIndex; index < count; index++) {
|
||||||
BPose *pose = fVSPoseList->ItemAt(index);
|
BPose *pose = fVSPoseList->ItemAt(index);
|
||||||
@@ -8157,16 +8193,13 @@ BPoseView::UpdateScrollRange()
|
|||||||
void
|
void
|
||||||
BPoseView::DrawPose(BPose *pose, int32 index, bool fullDraw)
|
BPoseView::DrawPose(BPose *pose, int32 index, bool fullDraw)
|
||||||
{
|
{
|
||||||
BRect rect;
|
BRect rect = CalcPoseRect(pose, index, fullDraw);
|
||||||
if (ViewMode() == kListMode)
|
|
||||||
rect = pose->CalcRect(BPoint(0, index * fListElemHeight), this, fullDraw);
|
|
||||||
else
|
|
||||||
rect = pose->CalcRect(this);
|
|
||||||
|
|
||||||
if (TrackerSettings().ShowVolumeSpaceBar() && pose->TargetModel()->IsVolume())
|
if (TrackerSettings().ShowVolumeSpaceBar()
|
||||||
|
&& pose->TargetModel()->IsVolume()) {
|
||||||
Invalidate(rect);
|
Invalidate(rect);
|
||||||
else
|
} else
|
||||||
pose->Draw(rect, this, fullDraw);
|
pose->Draw(rect, rect, this, fullDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -8265,19 +8298,17 @@ BPoseView::SynchronousUpdate(BRect updateRect, bool clip)
|
|||||||
ConstrainClippingRegion(&updateRegion);
|
ConstrainClippingRegion(&updateRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
FillRect(updateRect, B_SOLID_LOW);
|
Invalidate(updateRect);
|
||||||
DrawViewCommon(updateRect);
|
Window()->UpdateIfNeeded();
|
||||||
|
|
||||||
if (clip)
|
if (clip)
|
||||||
ConstrainClippingRegion(0);
|
ConstrainClippingRegion(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPoseView::DrawViewCommon(const BRect &updateRect)
|
BPoseView::DrawViewCommon(const BRect &updateRect)
|
||||||
{
|
{
|
||||||
GetClippingRegion(fUpdateRegion);
|
|
||||||
|
|
||||||
int32 count = fPoseList->CountItems();
|
int32 count = fPoseList->CountItems();
|
||||||
if (ViewMode() == kListMode) {
|
if (ViewMode() == kListMode) {
|
||||||
int32 startIndex = (int32)((updateRect.top - fListElemHeight) / fListElemHeight);
|
int32 startIndex = (int32)((updateRect.top - fListElemHeight) / fListElemHeight);
|
||||||
@@ -8289,7 +8320,7 @@ BPoseView::DrawViewCommon(const BRect &updateRect)
|
|||||||
for (int32 index = startIndex; index < count; index++) {
|
for (int32 index = startIndex; index < count; index++) {
|
||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
BRect poseRect(pose->CalcRect(loc, this, true));
|
BRect poseRect(pose->CalcRect(loc, this, true));
|
||||||
pose->Draw(poseRect, this, true, fUpdateRegion);
|
pose->Draw(poseRect, updateRect, this, true);
|
||||||
loc.y += fListElemHeight;
|
loc.y += fListElemHeight;
|
||||||
if (loc.y >= updateRect.bottom)
|
if (loc.y >= updateRect.bottom)
|
||||||
break;
|
break;
|
||||||
@@ -8298,8 +8329,8 @@ BPoseView::DrawViewCommon(const BRect &updateRect)
|
|||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
BRect poseRect(pose->CalcRect(this));
|
BRect poseRect(pose->CalcRect(this));
|
||||||
if (fUpdateRegion->Intersects(poseRect))
|
if (updateRect.Intersects(poseRect))
|
||||||
pose->Draw(poseRect, this, true, fUpdateRegion);
|
pose->Draw(poseRect, updateRect, this, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8347,7 +8378,7 @@ BPoseView::ColumnRedraw(BRect updateRect)
|
|||||||
dstRect.OffsetTo(loc);
|
dstRect.OffsetTo(loc);
|
||||||
|
|
||||||
BPoint offsetBy(0, -(index * ListElemHeight()));
|
BPoint offsetBy(0, -(index * ListElemHeight()));
|
||||||
pose->Draw(dstRect, this, offscreenView, true, &updateRegion,
|
pose->Draw(dstRect, updateRect, this, offscreenView, true,
|
||||||
offsetBy, pose->IsSelected());
|
offsetBy, pose->IsSelected());
|
||||||
|
|
||||||
offscreenView->Sync();
|
offscreenView->Sync();
|
||||||
@@ -8409,7 +8440,7 @@ BPoseView::CheckPoseSortOrder(BPose *pose, int32 oldIndex)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect invalidRect(CalcPoseRect(pose, oldIndex));
|
BRect invalidRect(CalcPoseRectList(pose, oldIndex));
|
||||||
CloseGapInList(&invalidRect);
|
CloseGapInList(&invalidRect);
|
||||||
Invalidate(invalidRect);
|
Invalidate(invalidRect);
|
||||||
// need to invalidate for the last item in the list
|
// need to invalidate for the last item in the list
|
||||||
@@ -9050,7 +9081,7 @@ BPoseView::HiliteDropTarget(bool hiliteState)
|
|||||||
for (int32 index = startIndex; index < count; index++) {
|
for (int32 index = startIndex; index < count; index++) {
|
||||||
if (fDropTarget == fPoseList->ItemAt(index)) {
|
if (fDropTarget == fPoseList->ItemAt(index)) {
|
||||||
BRect poseRect = fDropTarget->CalcRect(loc, this, false);
|
BRect poseRect = fDropTarget->CalcRect(loc, this, false);
|
||||||
fDropTarget->Draw(poseRect, this, false);
|
fDropTarget->Draw(poseRect, poseRect, this, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9066,14 +9097,15 @@ BPoseView::HiliteDropTarget(bool hiliteState)
|
|||||||
BPose *pose = fVSPoseList->ItemAt(index);
|
BPose *pose = fVSPoseList->ItemAt(index);
|
||||||
if (pose) {
|
if (pose) {
|
||||||
if (pose == fDropTarget) {
|
if (pose == fDropTarget) {
|
||||||
|
BRect poseRect = pose->CalcRect(this);
|
||||||
// TODO: maybe leave just the else part
|
// TODO: maybe leave just the else part
|
||||||
if (!hiliteState)
|
if (!hiliteState)
|
||||||
// deselecting an icon with widget drawn over background
|
// deselecting an icon with widget drawn over background
|
||||||
// have to be a little tricky here - draw just the icon,
|
// have to be a little tricky here - draw just the icon,
|
||||||
// invalidate the widget
|
// invalidate the widget
|
||||||
pose->DeselectWithoutErasingBackground(pose->CalcRect(this), this);
|
pose->DeselectWithoutErasingBackground(poseRect, this);
|
||||||
else
|
else
|
||||||
pose->Draw(pose->CalcRect(this), this, false);
|
pose->Draw(poseRect, poseRect, this, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9254,9 +9286,29 @@ BPoseView::HandleAutoScroll()
|
|||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BPoseView::CalcPoseRect(BPose *pose, int32 index, bool min) const
|
BPoseView::CalcPoseRect(const BPose *pose, int32 index,
|
||||||
|
bool firstColumnOnly) const
|
||||||
{
|
{
|
||||||
return pose->CalcRect(BPoint(0, index * fListElemHeight), this, min);
|
if (ViewMode() == kListMode)
|
||||||
|
return CalcPoseRectList(pose, index, firstColumnOnly);
|
||||||
|
else
|
||||||
|
return CalcPoseRectIcon(pose);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BPoseView::CalcPoseRectIcon(const BPose *pose) const
|
||||||
|
{
|
||||||
|
return pose->CalcRect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BPoseView::CalcPoseRectList(const BPose *pose, int32 index,
|
||||||
|
bool firstColumnOnly) const
|
||||||
|
{
|
||||||
|
return pose->CalcRect(BPoint(0, index * fListElemHeight), this,
|
||||||
|
firstColumnOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class BPoseView : public BView {
|
|||||||
virtual void RestoreColumnState(AttributeStreamNode *);
|
virtual void RestoreColumnState(AttributeStreamNode *);
|
||||||
void AddColumnList(BObjectList<BColumn> *list);
|
void AddColumnList(BObjectList<BColumn> *list);
|
||||||
virtual void SaveColumnState(AttributeStreamNode *);
|
virtual void SaveColumnState(AttributeStreamNode *);
|
||||||
virtual void SavePoseLocations(BRect *frameIfDesktop = 0);
|
virtual void SavePoseLocations(BRect *frameIfDesktop = NULL);
|
||||||
void DisableSaveLocation();
|
void DisableSaveLocation();
|
||||||
|
|
||||||
virtual void SaveState(BMessage &) const;
|
virtual void SaveState(BMessage &) const;
|
||||||
@@ -146,7 +146,8 @@ class BPoseView : public BView {
|
|||||||
uint32 ViewMode() const;
|
uint32 ViewMode() const;
|
||||||
|
|
||||||
// re-use the pose view for a new directory
|
// re-use the pose view for a new directory
|
||||||
virtual void SwitchDir(const entry_ref *, AttributeStreamNode *node = 0);
|
virtual void SwitchDir(const entry_ref *,
|
||||||
|
AttributeStreamNode *node = NULL);
|
||||||
|
|
||||||
// in the rare cases where a pose view needs to be explicitly refreshed
|
// in the rare cases where a pose view needs to be explicitly refreshed
|
||||||
// (for instance in a query window with a dynamic date query), this is
|
// (for instance in a query window with a dynamic date query), this is
|
||||||
@@ -308,13 +309,15 @@ class BPoseView : public BView {
|
|||||||
|
|
||||||
// pose selection
|
// pose selection
|
||||||
void SelectPose(BPose *, int32 index, bool scrollIntoView = true);
|
void SelectPose(BPose *, int32 index, bool scrollIntoView = true);
|
||||||
void AddPoseToSelection(BPose *, int32 index, bool scrollIntoView = true);
|
void AddPoseToSelection(BPose *, int32 index,
|
||||||
|
bool scrollIntoView = true);
|
||||||
void RemovePoseFromSelection(BPose *);
|
void RemovePoseFromSelection(BPose *);
|
||||||
void SelectPoseAtLocation(BPoint);
|
void SelectPoseAtLocation(BPoint);
|
||||||
void SelectPoses(int32 start, int32 end);
|
void SelectPoses(int32 start, int32 end);
|
||||||
|
|
||||||
// pose handling
|
// pose handling
|
||||||
void ScrollIntoView(BPose *pose, int32 index, bool drawOnly = false);
|
void ScrollIntoView(BPose *pose, int32 index);
|
||||||
|
void ScrollIntoView(BRect poseRect);
|
||||||
void SetActivePose(BPose *);
|
void SetActivePose(BPose *);
|
||||||
BPose *ActivePose() const;
|
BPose *ActivePose() const;
|
||||||
void CommitActivePose(bool saveChanges = true);
|
void CommitActivePose(bool saveChanges = true);
|
||||||
@@ -492,7 +495,11 @@ class BPoseView : public BView {
|
|||||||
BPose *ConvertZombieToPose(Model *zombie, int32 index);
|
BPose *ConvertZombieToPose(Model *zombie, int32 index);
|
||||||
|
|
||||||
// pose handling
|
// pose handling
|
||||||
BRect CalcPoseRect(BPose *, int32 index, bool minimal = false) const;
|
BRect CalcPoseRect(const BPose *, int32 index,
|
||||||
|
bool firstColumnOnly = false) const;
|
||||||
|
BRect CalcPoseRectIcon(const BPose *) const;
|
||||||
|
BRect CalcPoseRectList(const BPose *, int32 index,
|
||||||
|
bool firstColumnOnly = false) const;
|
||||||
void DrawPose(BPose *, int32 index, bool fullDraw = true);
|
void DrawPose(BPose *, int32 index, bool fullDraw = true);
|
||||||
void DrawViewCommon(const BRect &updateRect);
|
void DrawViewCommon(const BRect &updateRect);
|
||||||
|
|
||||||
@@ -637,7 +644,6 @@ class BPoseView : public BView {
|
|||||||
BCountView *fCountView;
|
BCountView *fCountView;
|
||||||
float fListElemHeight;
|
float fListElemHeight;
|
||||||
float fIconPoseHeight;
|
float fIconPoseHeight;
|
||||||
BRegion *fUpdateRegion;
|
|
||||||
BPose *fDropTarget;
|
BPose *fDropTarget;
|
||||||
BPose *fAlreadySelectedDropTarget;
|
BPose *fAlreadySelectedDropTarget;
|
||||||
BLooper *fSelectionHandler;
|
BLooper *fSelectionHandler;
|
||||||
|
|||||||
Reference in New Issue
Block a user