* Changing the icon size will now work more like simply scaling/zooming the
view. BPose converts the scale in SetLocation() and Location(), which does _not_ affect performance for list mode, BTW. So that should be fine. * The center of the pose view is now locked when changing the icon size. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29974 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+70
-30
@@ -195,7 +195,7 @@ OneMouseUp(BTextWidget *widget, BPose *pose, BPoseView *poseView, BColumn *colum
|
|||||||
if (poseView->ViewMode() == kListMode)
|
if (poseView->ViewMode() == kListMode)
|
||||||
rect = widget->CalcClickRect(poseLoc, column, poseView);
|
rect = widget->CalcClickRect(poseLoc, column, poseView);
|
||||||
else
|
else
|
||||||
rect = widget->CalcClickRect(pose->Location(), 0, poseView);
|
rect = widget->CalcClickRect(pose->Location(poseView), 0, poseView);
|
||||||
|
|
||||||
if (rect.Contains(where)) {
|
if (rect.Contains(where)) {
|
||||||
widget->MouseUp(rect, poseView, pose, where, pose->DelayedEdit());
|
widget->MouseUp(rect, poseView, pose, where, pose->DelayedEdit());
|
||||||
@@ -224,7 +224,7 @@ void
|
|||||||
BPose::UpdateAllWidgets(int32, BPoint poseLoc, BPoseView *poseView)
|
BPose::UpdateAllWidgets(int32, BPoint poseLoc, BPoseView *poseView)
|
||||||
{
|
{
|
||||||
if (poseView->ViewMode() != kListMode)
|
if (poseView->ViewMode() != kListMode)
|
||||||
poseLoc = fLocation;
|
poseLoc = Location(poseView);
|
||||||
|
|
||||||
ASSERT(fModel->IsNodeOpen());
|
ASSERT(fModel->IsNodeOpen());
|
||||||
EachTextWidget(this, poseView, OneCheckAndUpdate, poseLoc);
|
EachTextWidget(this, poseView, OneCheckAndUpdate, poseLoc);
|
||||||
@@ -236,7 +236,7 @@ BPose::UpdateWidgetAndModel(Model *resolvedModel, const char *attrName,
|
|||||||
uint32 attrType, int32, BPoint poseLoc, BPoseView *poseView)
|
uint32 attrType, int32, BPoint poseLoc, BPoseView *poseView)
|
||||||
{
|
{
|
||||||
if (poseView->ViewMode() != kListMode)
|
if (poseView->ViewMode() != kListMode)
|
||||||
poseLoc = fLocation;
|
poseLoc = Location(poseView);
|
||||||
|
|
||||||
ASSERT(!resolvedModel || resolvedModel->IsNodeOpen());
|
ASSERT(!resolvedModel || resolvedModel->IsNodeOpen());
|
||||||
|
|
||||||
@@ -330,18 +330,20 @@ BPose::UpdateIcon(BPoint poseLoc, BPoseView *poseView)
|
|||||||
{
|
{
|
||||||
IconCache::sIconCache->IconChanged(ResolvedModel());
|
IconCache::sIconCache->IconChanged(ResolvedModel());
|
||||||
|
|
||||||
|
int32 iconSize = poseView->IconSizeInt();
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
if (poseView->ViewMode() == kListMode) {
|
if (poseView->ViewMode() == kListMode) {
|
||||||
rect = CalcRect(poseLoc, poseView);
|
rect = CalcRect(poseLoc, poseView);
|
||||||
rect.left += kListOffset;
|
rect.left += kListOffset;
|
||||||
// TODO: make this depend on IconSizeInt() as well?
|
rect.right = rect.left + iconSize;
|
||||||
rect.right = rect.left + B_MINI_ICON;
|
rect.top = rect.bottom - iconSize;
|
||||||
rect.top = rect.bottom - B_MINI_ICON;
|
|
||||||
} else {
|
} else {
|
||||||
rect.left = fLocation.x;
|
BPoint location = Location(poseView);
|
||||||
rect.top = fLocation.y;
|
rect.left = location.x;
|
||||||
rect.right = rect.left + poseView->IconSizeInt();
|
rect.top = location.y;
|
||||||
rect.bottom = rect.top + poseView->IconSizeInt();
|
rect.right = rect.left + iconSize;
|
||||||
|
rect.bottom = rect.top + iconSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
poseView->Invalidate(rect);
|
poseView->Invalidate(rect);
|
||||||
@@ -390,7 +392,7 @@ BPose::EditFirstWidget(BPoint poseLoc, BPoseView *poseView)
|
|||||||
if (poseView->ViewMode() == kListMode)
|
if (poseView->ViewMode() == kListMode)
|
||||||
bounds = widget->CalcRect(poseLoc, column, poseView);
|
bounds = widget->CalcRect(poseLoc, column, poseView);
|
||||||
else
|
else
|
||||||
bounds = widget->CalcRect(fLocation, NULL, poseView);
|
bounds = widget->CalcRect(Location(poseView), NULL, poseView);
|
||||||
widget->StartEdit(bounds, poseView, this);
|
widget->StartEdit(bounds, poseView, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -422,7 +424,7 @@ BPose::EditPreviousNextWidgetCommon(BPoseView *poseView, bool next)
|
|||||||
BPoint poseLoc(0, poseIndex * poseView->ListElemHeight());
|
BPoint poseLoc(0, poseIndex * poseView->ListElemHeight());
|
||||||
bounds = widget->CalcRect(poseLoc, column, poseView);
|
bounds = widget->CalcRect(poseLoc, column, poseView);
|
||||||
} else
|
} else
|
||||||
bounds = widget->CalcRect(fLocation, 0, poseView);
|
bounds = widget->CalcRect(Location(poseView), 0, poseView);
|
||||||
|
|
||||||
widget->StartEdit(bounds, poseView, this);
|
widget->StartEdit(bounds, poseView, this);
|
||||||
break;
|
break;
|
||||||
@@ -450,14 +452,16 @@ BPose::PointInPose(const BPoseView *poseView, BPoint where) const
|
|||||||
{
|
{
|
||||||
ASSERT(poseView->ViewMode() != kListMode);
|
ASSERT(poseView->ViewMode() != kListMode);
|
||||||
|
|
||||||
|
BPoint location = Location(poseView);
|
||||||
|
|
||||||
if (poseView->ViewMode() == kIconMode) {
|
if (poseView->ViewMode() == kIconMode) {
|
||||||
// check icon rect, then actual icon pixel
|
// check icon rect, then actual icon pixel
|
||||||
BRect rect(fLocation, fLocation);
|
BRect rect(location, location);
|
||||||
rect.right += poseView->IconSizeInt() - 1;
|
rect.right += poseView->IconSizeInt() - 1;
|
||||||
rect.bottom += poseView->IconSizeInt() - 1;
|
rect.bottom += poseView->IconSizeInt() - 1;
|
||||||
|
|
||||||
if (rect.Contains(where))
|
if (rect.Contains(where))
|
||||||
return IconCache::sIconCache->IconHitTest(where - fLocation,
|
return IconCache::sIconCache->IconHitTest(where - location,
|
||||||
ResolvedModel(),
|
ResolvedModel(),
|
||||||
kNormalIcon,
|
kNormalIcon,
|
||||||
poseView->IconSize());
|
poseView->IconSize());
|
||||||
@@ -469,14 +473,14 @@ BPose::PointInPose(const BPoseView *poseView, BPoint where) const
|
|||||||
rect.right = rect.left + textWidth;
|
rect.right = rect.left + textWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.top = fLocation.y + poseView->IconSizeInt();
|
rect.top = location.y + poseView->IconSizeInt();
|
||||||
rect.bottom = rect.top + poseView->FontHeight();
|
rect.bottom = rect.top + poseView->FontHeight();
|
||||||
|
|
||||||
return rect.Contains(where);
|
return rect.Contains(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MINI_ICON_MODE rect calc
|
// MINI_ICON_MODE rect calc
|
||||||
BRect rect(fLocation, fLocation);
|
BRect rect(location, location);
|
||||||
rect.right += B_MINI_ICON + kMiniIconSeparator;
|
rect.right += B_MINI_ICON + kMiniIconSeparator;
|
||||||
rect.bottom += poseView->IconPoseHeight();
|
rect.bottom += poseView->IconPoseHeight();
|
||||||
BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
||||||
@@ -612,7 +616,7 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
|||||||
if (updateRgn && !updateRgn->Intersects(rect))
|
if (updateRgn && !updateRgn->Intersects(rect))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BPoint iconOrigin(fLocation);
|
BPoint iconOrigin(Location(poseView));
|
||||||
iconOrigin += offset;
|
iconOrigin += offset;
|
||||||
|
|
||||||
DrawIcon(iconOrigin, drawView, poseView->IconSize(), directDraw,
|
DrawIcon(iconOrigin, drawView, poseView->IconSize(), directDraw,
|
||||||
@@ -626,7 +630,7 @@ BPose::Draw(BRect rect, BPoseView *poseView, BView *drawView, bool fullDraw,
|
|||||||
if (!widget || !widget->IsVisible())
|
if (!widget || !widget->IsVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rect = widget->CalcRect(fLocation, 0, poseView);
|
rect = widget->CalcRect(Location(poseView), 0, poseView);
|
||||||
|
|
||||||
bool selectDuringDraw = directDraw && selected
|
bool selectDuringDraw = directDraw && selected
|
||||||
&& (poseView->IsDesktopWindow() || windowActive);
|
&& (poseView->IsDesktopWindow() || windowActive);
|
||||||
@@ -664,11 +668,13 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView *poseView)
|
|||||||
ASSERT(poseView->ViewMode() != kListMode);
|
ASSERT(poseView->ViewMode() != kListMode);
|
||||||
ASSERT(!IsSelected());
|
ASSERT(!IsSelected());
|
||||||
|
|
||||||
|
BPoint location(Location(poseView));
|
||||||
|
|
||||||
// draw icon directly
|
// draw icon directly
|
||||||
if (fPercent == -1)
|
if (fPercent == -1)
|
||||||
DrawIcon(fLocation, poseView, poseView->IconSize(), true);
|
DrawIcon(location, poseView, poseView->IconSize(), true);
|
||||||
else
|
else
|
||||||
UpdateIcon(fLocation, poseView);
|
UpdateIcon(location, poseView);
|
||||||
|
|
||||||
BColumn *column = poseView->FirstColumn();
|
BColumn *column = poseView->FirstColumn();
|
||||||
if (!column)
|
if (!column)
|
||||||
@@ -679,7 +685,7 @@ BPose::DeselectWithoutErasingBackground(BRect, BPoseView *poseView)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// just invalidate the background, don't draw anything
|
// just invalidate the background, don't draw anything
|
||||||
poseView->Invalidate(widget->CalcRect(fLocation, 0, poseView));
|
poseView->Invalidate(widget->CalcRect(location, 0, poseView));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -691,8 +697,10 @@ BPose::MoveTo(BPoint point, BPoseView *poseView, bool inval)
|
|||||||
|
|
||||||
BRect oldBounds;
|
BRect oldBounds;
|
||||||
|
|
||||||
|
BPoint oldLocation = Location(poseView);
|
||||||
|
|
||||||
ASSERT(poseView->ViewMode() != kListMode);
|
ASSERT(poseView->ViewMode() != kListMode);
|
||||||
if (point == fLocation || poseView->ViewMode() == kListMode)
|
if (point == oldLocation || poseView->ViewMode() == kListMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (inval)
|
if (inval)
|
||||||
@@ -702,10 +710,16 @@ BPose::MoveTo(BPoint point, BPoseView *poseView, bool inval)
|
|||||||
if (poseView->ActivePose() == this) {
|
if (poseView->ActivePose() == this) {
|
||||||
BView *border_view = poseView->FindView("BorderView");
|
BView *border_view = poseView->FindView("BorderView");
|
||||||
if (border_view)
|
if (border_view)
|
||||||
border_view->MoveBy(point.x - fLocation.x, point.y - fLocation.y);
|
border_view->MoveBy(point.x - oldLocation.x, point.y - oldLocation.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
fLocation = point;
|
float scale = 1.0;
|
||||||
|
if (poseView->ViewMode() == kIconMode) {
|
||||||
|
scale = poseView->IconSize() / 32.0;
|
||||||
|
}
|
||||||
|
fLocation.x = point.x / scale;
|
||||||
|
fLocation.y = point.y / scale;
|
||||||
|
|
||||||
fHasLocation = true;
|
fHasLocation = true;
|
||||||
fNeedsSaveLocation = true;
|
fNeedsSaveLocation = true;
|
||||||
|
|
||||||
@@ -851,6 +865,31 @@ BPose::DrawToggleSwitch(BRect, BPoseView *)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BPoint
|
||||||
|
BPose::Location(const BPoseView *poseView) const
|
||||||
|
{
|
||||||
|
float scale = 1.0;
|
||||||
|
if (poseView->ViewMode() == kIconMode)
|
||||||
|
scale = poseView->IconSize() / 32.0;
|
||||||
|
|
||||||
|
return BPoint(fLocation.x * scale, fLocation.y * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPose::SetLocation(BPoint point, const BPoseView *poseView)
|
||||||
|
{
|
||||||
|
float scale = 1.0;
|
||||||
|
if (poseView->ViewMode() == kIconMode)
|
||||||
|
scale = poseView->IconSize() / 32.0;
|
||||||
|
|
||||||
|
fLocation = BPoint(floorf(point.x / scale), floorf(point.y / scale));
|
||||||
|
if (isinff(fLocation.x) || isinff(fLocation.y))
|
||||||
|
debugger("BPose::SetLocation() - infinite location");
|
||||||
|
fHasLocation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BPose::CalcRect(BPoint loc, const BPoseView *poseView, bool minimalRect)
|
BPose::CalcRect(BPoint loc, const BPoseView *poseView, bool minimalRect)
|
||||||
{
|
{
|
||||||
@@ -879,8 +918,9 @@ BPose::CalcRect(const BPoseView *poseView)
|
|||||||
ASSERT(poseView->ViewMode() != kListMode);
|
ASSERT(poseView->ViewMode() != kListMode);
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
|
BPoint location = Location(poseView);
|
||||||
if (poseView->ViewMode() == kIconMode) {
|
if (poseView->ViewMode() == kIconMode) {
|
||||||
rect.left = fLocation.x;
|
rect.left = location.x;
|
||||||
rect.right = rect.left + poseView->IconSizeInt();
|
rect.right = rect.left + poseView->IconSizeInt();
|
||||||
|
|
||||||
BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
||||||
@@ -892,12 +932,12 @@ BPose::CalcRect(const BPoseView *poseView)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.top = fLocation.y;
|
rect.top = location.y;
|
||||||
rect.bottom = rect.top + poseView->IconPoseHeight();
|
rect.bottom = rect.top + poseView->IconPoseHeight();
|
||||||
} else {
|
} else {
|
||||||
// MINI_ICON_MODE rect calc
|
// MINI_ICON_MODE rect calc
|
||||||
rect.left = fLocation.x;
|
rect.left = location.x;
|
||||||
rect.top = fLocation.y;
|
rect.top = location.y;
|
||||||
rect.right = rect.left + B_MINI_ICON + kMiniIconSeparator;
|
rect.right = rect.left + B_MINI_ICON + kMiniIconSeparator;
|
||||||
rect.bottom = rect.top + poseView->IconPoseHeight();
|
rect.bottom = rect.top + poseView->IconPoseHeight();
|
||||||
BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
BTextWidget *widget = WidgetFor(poseView->FirstColumn()->AttrHash());
|
||||||
@@ -927,8 +967,8 @@ BPose::PrintToStream()
|
|||||||
}
|
}
|
||||||
PRINT(("%sselected\n", IsSelected() ? "" : "not "));
|
PRINT(("%sselected\n", IsSelected() ? "" : "not "));
|
||||||
PRINT(("location %s x:%f y:%f\n", HasLocation() ? "" : "unknown ",
|
PRINT(("location %s x:%f y:%f\n", HasLocation() ? "" : "unknown ",
|
||||||
HasLocation() ? Location().x : 0,
|
HasLocation() ? fLocation.x : 0,
|
||||||
HasLocation() ? Location().y : 0));
|
HasLocation() ? fLocation.y : 0));
|
||||||
PRINT(("%s autoplaced \n", WasAutoPlaced() ? "was" : "not"));
|
PRINT(("%s autoplaced \n", WasAutoPlaced() ? "was" : "not"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-19
@@ -60,7 +60,7 @@ class BPose {
|
|||||||
BTextWidget *AddWidget(BPoseView *, BColumn *);
|
BTextWidget *AddWidget(BPoseView *, BColumn *);
|
||||||
BTextWidget *AddWidget(BPoseView *, BColumn *, ModelNodeLazyOpener &opener);
|
BTextWidget *AddWidget(BPoseView *, BColumn *, ModelNodeLazyOpener &opener);
|
||||||
void RemoveWidget(BPoseView *, BColumn *);
|
void RemoveWidget(BPoseView *, BColumn *);
|
||||||
void SetLocation(BPoint);
|
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, BPoseView *, bool fullDraw = true,
|
||||||
@@ -108,7 +108,7 @@ class BPose {
|
|||||||
void EditNextWidget(BPoseView *);
|
void EditNextWidget(BPoseView *);
|
||||||
void EditPreviousWidget(BPoseView *);
|
void EditPreviousWidget(BPoseView *);
|
||||||
|
|
||||||
BPoint Location() const;
|
BPoint Location(const BPoseView *poseView) const;
|
||||||
bool DelayedEdit() const;
|
bool DelayedEdit() const;
|
||||||
void SetDelayedEdit(bool delay);
|
void SetDelayedEdit(bool delay);
|
||||||
bool ListModeInited() const;
|
bool ListModeInited() const;
|
||||||
@@ -234,23 +234,6 @@ BPose::HasLocation() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline BPoint
|
|
||||||
BPose::Location() const
|
|
||||||
{
|
|
||||||
return fLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void
|
|
||||||
BPose::SetLocation(BPoint point)
|
|
||||||
{
|
|
||||||
fLocation = BPoint(floorf(point.x), floorf(point.y));
|
|
||||||
if (isinff(fLocation.x) || isinff(fLocation.y))
|
|
||||||
debugger("BPose::SetLocation() - infinite location");
|
|
||||||
fHasLocation = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
BPose::Draw(BRect rect, BPoseView *view, bool fullDraw,
|
BPose::Draw(BRect rect, BPoseView *view, bool fullDraw,
|
||||||
const BRegion *updateRgn)
|
const BRegion *updateRgn)
|
||||||
|
|||||||
@@ -714,7 +714,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop)
|
|||||||
else
|
else
|
||||||
poseInfo.fInitedDirectory = model->EntryRef()->directory;
|
poseInfo.fInitedDirectory = model->EntryRef()->directory;
|
||||||
|
|
||||||
poseInfo.fLocation = pose->Location();
|
poseInfo.fLocation = pose->Location(this);
|
||||||
|
|
||||||
ExtendedPoseInfo *extendedPoseInfo = NULL;
|
ExtendedPoseInfo *extendedPoseInfo = NULL;
|
||||||
size_t extendedPoseInfoSize = 0;
|
size_t extendedPoseInfoSize = 0;
|
||||||
@@ -740,7 +740,7 @@ BPoseView::SavePoseLocations(BRect *frameIfDesktop)
|
|||||||
}
|
}
|
||||||
ASSERT(extendedPoseInfo);
|
ASSERT(extendedPoseInfo);
|
||||||
|
|
||||||
extendedPoseInfo->SetLocationForFrame(pose->Location(),
|
extendedPoseInfo->SetLocationForFrame(pose->Location(this),
|
||||||
*frameIfDesktop);
|
*frameIfDesktop);
|
||||||
extendedPoseInfoSize = extendedPoseInfo->Size();
|
extendedPoseInfoSize = extendedPoseInfo->Size();
|
||||||
}
|
}
|
||||||
@@ -1016,7 +1016,7 @@ BPoseView::CommitActivePose(bool saveChanges)
|
|||||||
int32 index = fPoseList->IndexOf(ActivePose());
|
int32 index = fPoseList->IndexOf(ActivePose());
|
||||||
BPoint loc(0, index * fListElemHeight);
|
BPoint loc(0, index * fListElemHeight);
|
||||||
if (ViewMode() != kListMode)
|
if (ViewMode() != kListMode)
|
||||||
loc = ActivePose()->Location();
|
loc = ActivePose()->Location(this);
|
||||||
|
|
||||||
ActivePose()->Commit(saveChanges, loc, this, index);
|
ActivePose()->Commit(saveChanges, loc, this, index);
|
||||||
fActivePose = NULL;
|
fActivePose = NULL;
|
||||||
@@ -1652,7 +1652,7 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
|
|||||||
// set location from poseinfo if saved loc was for this dir
|
// set location from poseinfo if saved loc was for this dir
|
||||||
if (poseInfo->fInitedDirectory != -1LL) {
|
if (poseInfo->fInitedDirectory != -1LL) {
|
||||||
PinPointToValidRange(poseInfo->fLocation);
|
PinPointToValidRange(poseInfo->fLocation);
|
||||||
pose->SetLocation(poseInfo->fLocation);
|
pose->SetLocation(poseInfo->fLocation, this);
|
||||||
AddToVSList(pose);
|
AddToVSList(pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1743,9 +1743,9 @@ BPoseView::CreatePoses(Model **models, PoseInfo *poseInfoArray, int32 count,
|
|||||||
if (fEnsurePosesVisible && !viewBounds.Intersects(poseBounds)) {
|
if (fEnsurePosesVisible && !viewBounds.Intersects(poseBounds)) {
|
||||||
viewBounds.InsetBy(20, 20);
|
viewBounds.InsetBy(20, 20);
|
||||||
RemoveFromVSList(pose);
|
RemoveFromVSList(pose);
|
||||||
BPoint loc(pose->Location());
|
BPoint loc(pose->Location(this));
|
||||||
loc.ConstrainTo(viewBounds);
|
loc.ConstrainTo(viewBounds);
|
||||||
pose->SetLocation(loc);
|
pose->SetLocation(loc, this);
|
||||||
pose->SetSaveLocation();
|
pose->SetSaveLocation();
|
||||||
AddToVSList(pose);
|
AddToVSList(pose);
|
||||||
poseBounds = pose->CalcRect(this);
|
poseBounds = pose->CalcRect(this);
|
||||||
@@ -2741,6 +2741,24 @@ BPoseView::SetViewMode(uint32 newMode)
|
|||||||
|
|
||||||
fViewState->SetViewMode(newMode);
|
fViewState->SetViewMode(newMode);
|
||||||
|
|
||||||
|
// try to lock the center of the pose view when scaling icons
|
||||||
|
BPoint scaleOffset(0, 0);
|
||||||
|
if (newMode == kIconMode && oldMode == kIconMode) {
|
||||||
|
// definitely changing the icon size, so we will need to scroll
|
||||||
|
BRect bounds(Bounds());
|
||||||
|
BPoint center(bounds.LeftTop());
|
||||||
|
center.x += bounds.Width() / 2.0;
|
||||||
|
center.y += bounds.Height() / 2.0;
|
||||||
|
// convert the center into "unscaled icon placement" space
|
||||||
|
float oldScale = lastIconSize / 32.0;
|
||||||
|
BPoint unscaledCenter(center.x / oldScale, center.y / oldScale);
|
||||||
|
// get the new center in "scaled icon placement" place
|
||||||
|
float newScale = fViewState->IconSize() / 32.0;
|
||||||
|
BPoint newCenter(unscaledCenter.x * newScale,
|
||||||
|
unscaledCenter.y * newScale);
|
||||||
|
scaleOffset = newCenter - center;
|
||||||
|
}
|
||||||
|
|
||||||
// toggle view layout between listmode and non-listmode, if necessary
|
// toggle view layout between listmode and non-listmode, if necessary
|
||||||
BContainerWindow *window = ContainerWindow();
|
BContainerWindow *window = ContainerWindow();
|
||||||
if (oldMode == kListMode) {
|
if (oldMode == kListMode) {
|
||||||
@@ -2801,7 +2819,7 @@ BPoseView::SetViewMode(uint32 newMode)
|
|||||||
if (newMode == kListMode)
|
if (newMode == kListMode)
|
||||||
newOrigin = fViewState->ListOrigin();
|
newOrigin = fViewState->ListOrigin();
|
||||||
else
|
else
|
||||||
newOrigin = fViewState->IconOrigin();
|
newOrigin = fViewState->IconOrigin() + scaleOffset;
|
||||||
|
|
||||||
PinPointToValidRange(newOrigin);
|
PinPointToValidRange(newOrigin);
|
||||||
|
|
||||||
@@ -2837,8 +2855,8 @@ BPoseView::MapToNewIconMode(BPose *pose, BPoint oldGrid, BPoint oldOffset)
|
|||||||
BPoint delta;
|
BPoint delta;
|
||||||
BPoint poseLoc;
|
BPoint poseLoc;
|
||||||
|
|
||||||
poseLoc = PinToGrid(pose->Location(), oldGrid, oldOffset);
|
poseLoc = PinToGrid(pose->Location(this), oldGrid, oldOffset);
|
||||||
delta = pose->Location() - poseLoc;
|
delta = pose->Location(this) - poseLoc;
|
||||||
poseLoc -= oldOffset;
|
poseLoc -= oldOffset;
|
||||||
|
|
||||||
if (poseLoc.x >= 0)
|
if (poseLoc.x >= 0)
|
||||||
@@ -2866,7 +2884,7 @@ BPoseView::MapToNewIconMode(BPose *pose, BPoint oldGrid, BPoint oldOffset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
poseLoc += fOffset;
|
poseLoc += fOffset;
|
||||||
pose->SetLocation(poseLoc);
|
pose->SetLocation(poseLoc, this);
|
||||||
pose->SetSaveLocation();
|
pose->SetSaveLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3156,7 +3174,7 @@ BPoseView::Cleanup(bool doAll)
|
|||||||
int32 count = fPoseList->CountItems();
|
int32 count = fPoseList->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
BPoint location(pose->Location());
|
BPoint location(pose->Location(this));
|
||||||
BPoint newLocation(PinToGrid(location, fGrid, fOffset));
|
BPoint newLocation(PinToGrid(location, fGrid, fOffset));
|
||||||
|
|
||||||
// do we need to move pose to a grid location?
|
// do we need to move pose to a grid location?
|
||||||
@@ -3191,7 +3209,7 @@ void
|
|||||||
BPoseView::PlacePose(BPose *pose, BRect &viewBounds)
|
BPoseView::PlacePose(BPose *pose, BRect &viewBounds)
|
||||||
{
|
{
|
||||||
// move pose to probable location
|
// move pose to probable location
|
||||||
pose->SetLocation(fHintLocation);
|
pose->SetLocation(fHintLocation, this);
|
||||||
BRect rect(pose->CalcRect(this));
|
BRect rect(pose->CalcRect(this));
|
||||||
BPoint deltaFromBounds(fHintLocation - rect.LeftTop());
|
BPoint deltaFromBounds(fHintLocation - rect.LeftTop());
|
||||||
|
|
||||||
@@ -3214,9 +3232,9 @@ BPoseView::PlacePose(BPose *pose, BRect &viewBounds)
|
|||||||
|
|
||||||
rect.InsetBy(3, 0);
|
rect.InsetBy(3, 0);
|
||||||
|
|
||||||
fHintLocation = pose->Location() + BPoint(fGrid.x, 0);
|
fHintLocation = pose->Location(this) + BPoint(fGrid.x, 0);
|
||||||
|
|
||||||
pose->SetLocation(rect.LeftTop() + deltaFromBounds);
|
pose->SetLocation(rect.LeftTop() + deltaFromBounds, this);
|
||||||
pose->SetSaveLocation();
|
pose->SetSaveLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3251,7 +3269,7 @@ BPoseView::CheckAutoPlacedPoses()
|
|||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
if (pose->WasAutoPlaced()) {
|
if (pose->WasAutoPlaced()) {
|
||||||
RemoveFromVSList(pose);
|
RemoveFromVSList(pose);
|
||||||
fHintLocation = pose->Location();
|
fHintLocation = pose->Location(this);
|
||||||
BRect oldBounds(pose->CalcRect(this));
|
BRect oldBounds(pose->CalcRect(this));
|
||||||
PlacePose(pose, viewBounds);
|
PlacePose(pose, viewBounds);
|
||||||
|
|
||||||
@@ -3286,7 +3304,7 @@ BPoseView::CheckPoseVisibility(BRect *newFrame)
|
|||||||
int32 count = fPoseList->CountItems();
|
int32 count = fPoseList->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
BPose *pose = fPoseList->ItemAt(index);
|
BPose *pose = fPoseList->ItemAt(index);
|
||||||
BPoint newLocation(pose->Location());
|
BPoint newLocation(pose->Location(this));
|
||||||
bool locationNeedsUpdating = false;
|
bool locationNeedsUpdating = false;
|
||||||
|
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
@@ -3303,7 +3321,7 @@ BPoseView::CheckPoseVisibility(BRect *newFrame)
|
|||||||
Invalidate(pose->CalcRect(this));
|
Invalidate(pose->CalcRect(this));
|
||||||
// make sure the old icon gets erased
|
// make sure the old icon gets erased
|
||||||
RemoveFromVSList(pose);
|
RemoveFromVSList(pose);
|
||||||
pose->SetLocation(newLocation);
|
pose->SetLocation(newLocation, this);
|
||||||
// set the new location
|
// set the new location
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3319,11 +3337,11 @@ BPoseView::CheckPoseVisibility(BRect *newFrame)
|
|||||||
Invalidate(rect);
|
Invalidate(rect);
|
||||||
RemoveFromVSList(pose);
|
RemoveFromVSList(pose);
|
||||||
}
|
}
|
||||||
BPoint loc(pose->Location());
|
BPoint loc(pose->Location(this));
|
||||||
loc.ConstrainTo(bounds);
|
loc.ConstrainTo(bounds);
|
||||||
// place it onscreen
|
// place it onscreen
|
||||||
|
|
||||||
pose->SetLocation(loc);
|
pose->SetLocation(loc, this);
|
||||||
// set the new location
|
// set the new location
|
||||||
locationNeedsUpdating = true;
|
locationNeedsUpdating = true;
|
||||||
}
|
}
|
||||||
@@ -3359,7 +3377,7 @@ BPoseView::SlotOccupied(BRect poseRect, BRect viewBounds) const
|
|||||||
int32 index = FirstIndexAtOrBelow((int32)(poseRect.top - IconPoseHeight()));
|
int32 index = FirstIndexAtOrBelow((int32)(poseRect.top - IconPoseHeight()));
|
||||||
int32 numPoses = fVSPoseList->CountItems();
|
int32 numPoses = fVSPoseList->CountItems();
|
||||||
|
|
||||||
while (index < numPoses && fVSPoseList->ItemAt(index)->Location().y
|
while (index < numPoses && fVSPoseList->ItemAt(index)->Location(this).y
|
||||||
< poseRect.bottom) {
|
< poseRect.bottom) {
|
||||||
|
|
||||||
BRect rect(fVSPoseList->ItemAt(index)->CalcRect(this));
|
BRect rect(fVSPoseList->ItemAt(index)->CalcRect(this));
|
||||||
@@ -3384,7 +3402,7 @@ BPoseView::NextSlot(BPose *pose, BRect &poseRect, BRect viewBounds)
|
|||||||
fHintLocation.y += fGrid.y;
|
fHintLocation.y += fGrid.y;
|
||||||
fHintLocation.x = viewBounds.left + fOffset.x;
|
fHintLocation.x = viewBounds.left + fOffset.x;
|
||||||
fHintLocation = PinToGrid(fHintLocation, fGrid, fOffset);
|
fHintLocation = PinToGrid(fHintLocation, fGrid, fOffset);
|
||||||
pose->SetLocation(fHintLocation);
|
pose->SetLocation(fHintLocation, this);
|
||||||
poseRect = pose->CalcRect(this);
|
poseRect = pose->CalcRect(this);
|
||||||
poseRect.InsetBy(-3, 0);
|
poseRect.InsetBy(-3, 0);
|
||||||
}
|
}
|
||||||
@@ -3404,7 +3422,7 @@ BPoseView::FirstIndexAtOrBelow(int32 y, bool constrainIndex) const
|
|||||||
|
|
||||||
while (l <= r) {
|
while (l <= r) {
|
||||||
index = (l + r) >> 1;
|
index = (l + r) >> 1;
|
||||||
int32 result = (int32)(y - fVSPoseList->ItemAt(index)->Location().y);
|
int32 result = (int32)(y - fVSPoseList->ItemAt(index)->Location(this).y);
|
||||||
|
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
r = index - 1;
|
r = index - 1;
|
||||||
@@ -3413,7 +3431,7 @@ BPoseView::FirstIndexAtOrBelow(int32 y, bool constrainIndex) const
|
|||||||
else {
|
else {
|
||||||
// compare turned out equal, find first pose
|
// compare turned out equal, find first pose
|
||||||
while (index > 0
|
while (index > 0
|
||||||
&& y == fVSPoseList->ItemAt(index - 1)->Location().y)
|
&& y == fVSPoseList->ItemAt(index - 1)->Location(this).y)
|
||||||
index--;
|
index--;
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
@@ -3421,7 +3439,7 @@ BPoseView::FirstIndexAtOrBelow(int32 y, bool constrainIndex) const
|
|||||||
|
|
||||||
// didn't find pose AT location y - bump index to proper insert point
|
// didn't find pose AT location y - bump index to proper insert point
|
||||||
while (index < fVSPoseList->CountItems()
|
while (index < fVSPoseList->CountItems()
|
||||||
&& fVSPoseList->ItemAt(index)->Location().y <= y)
|
&& fVSPoseList->ItemAt(index)->Location(this).y <= y)
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
// if flag is true then constrain index to legal value since this
|
// if flag is true then constrain index to legal value since this
|
||||||
@@ -3437,7 +3455,7 @@ BPoseView::FirstIndexAtOrBelow(int32 y, bool constrainIndex) const
|
|||||||
void
|
void
|
||||||
BPoseView::AddToVSList(BPose *pose)
|
BPoseView::AddToVSList(BPose *pose)
|
||||||
{
|
{
|
||||||
int32 index = FirstIndexAtOrBelow((int32)pose->Location().y, false);
|
int32 index = FirstIndexAtOrBelow((int32)pose->Location(this).y, false);
|
||||||
fVSPoseList->AddItem(pose, index);
|
fVSPoseList->AddItem(pose, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3445,7 +3463,7 @@ BPoseView::AddToVSList(BPose *pose)
|
|||||||
int32
|
int32
|
||||||
BPoseView::RemoveFromVSList(const BPose *pose)
|
BPoseView::RemoveFromVSList(const BPose *pose)
|
||||||
{
|
{
|
||||||
int32 index = FirstIndexAtOrBelow((int32)pose->Location().y);
|
int32 index = FirstIndexAtOrBelow((int32)pose->Location(this).y);
|
||||||
|
|
||||||
int32 count = fVSPoseList->CountItems();
|
int32 count = fVSPoseList->CountItems();
|
||||||
for (; index < count; index++) {
|
for (; index < count; index++) {
|
||||||
@@ -4498,7 +4516,7 @@ BPoseView::MoveSelectionInto(Model *destFolder, BContainerWindow *srcWindow,
|
|||||||
// need to do this because bsearch uses top of pose
|
// need to do this because bsearch uses top of pose
|
||||||
// to locate pose to remove
|
// to locate pose to remove
|
||||||
targetView->RemoveFromVSList(pose);
|
targetView->RemoveFromVSList(pose);
|
||||||
BPoint location (pose->Location() + delta);
|
BPoint location (pose->Location(targetView) + delta);
|
||||||
BRect oldBounds(pose->CalcRect(targetView));
|
BRect oldBounds(pose->CalcRect(targetView));
|
||||||
if (dropOnGrid)
|
if (dropOnGrid)
|
||||||
location = targetView->PinToGrid(location, targetView->fGrid, targetView->fOffset);
|
location = targetView->PinToGrid(location, targetView->fGrid, targetView->fOffset);
|
||||||
@@ -5270,7 +5288,7 @@ BPoseView::GetDropPointList(BPoint dropStart, BPoint dropEnd, const PoseList *po
|
|||||||
if (sourceInListMode)
|
if (sourceInListMode)
|
||||||
poseLoc = dropEnd + BPoint(0, index * (IconPoseHeight() + 3));
|
poseLoc = dropEnd + BPoint(0, index * (IconPoseHeight() + 3));
|
||||||
else
|
else
|
||||||
poseLoc = dropEnd + (pose->Location() - dropStart);
|
poseLoc = dropEnd + (pose->Location(this) - dropStart);
|
||||||
|
|
||||||
if (dropOnGrid)
|
if (dropOnGrid)
|
||||||
poseLoc = PinToGrid(poseLoc, fGrid, fOffset);
|
poseLoc = PinToGrid(poseLoc, fGrid, fOffset);
|
||||||
@@ -6756,7 +6774,7 @@ BPoseView::GetDragRect(int32 clickedPoseIndex)
|
|||||||
if (pose->IsSelected())
|
if (pose->IsSelected())
|
||||||
result = result | pose->CalcRect(this);
|
result = result | pose->CalcRect(this);
|
||||||
|
|
||||||
if (pose->Location().y > bounds.bottom)
|
if (pose->Location(this).y > bounds.bottom)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7010,7 +7028,7 @@ BPoseView::SelectPosesIconMode(BRect selectionRect, BList **oldList)
|
|||||||
fSelectionPivotPose = pose;
|
fSelectionPivotPose = pose;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pose->Location().y > selectionRect.bottom)
|
if (pose->Location(this).y > selectionRect.bottom)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7079,7 +7097,7 @@ BPoseView::AddRemoveSelectionRange(BPoint where, bool extendSelection, BPose *po
|
|||||||
AddRemovePoseFromSelection(fPoseList->ItemAt(i), i, select);
|
AddRemovePoseFromSelection(fPoseList->ItemAt(i), i, select);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
BRect selection(where, fSelectionPivotPose->Location());
|
BRect selection(where, fSelectionPivotPose->Location(this));
|
||||||
|
|
||||||
// Things will get odd if we don't 'fix' the selection rect.
|
// Things will get odd if we don't 'fix' the selection rect.
|
||||||
if (selection.left > selection.right) {
|
if (selection.left > selection.right) {
|
||||||
@@ -7812,7 +7830,7 @@ BPoseView::ClearSelection()
|
|||||||
Invalidate(pose->CalcRect(this));
|
Invalidate(pose->CalcRect(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pose->Location().y > bounds.bottom)
|
if (pose->Location(this).y > bounds.bottom)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7872,7 +7890,7 @@ BPoseView::ShowSelection(bool show)
|
|||||||
Invalidate(pose->CalcRect(this));
|
Invalidate(pose->CalcRect(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pose->Location().y > bounds.bottom)
|
if (pose->Location(this).y > bounds.bottom)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8837,7 +8855,8 @@ BPoseView::FrameForPose(BPose *targetpose, bool convert, BRect *poseRect)
|
|||||||
returnvalue = false;
|
returnvalue = false;
|
||||||
}
|
}
|
||||||
} 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++) {
|
||||||
@@ -8849,7 +8868,7 @@ BPoseView::FrameForPose(BPose *targetpose, bool convert, BRect *poseRect)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pose->Location().y > bounds.bottom) {
|
if (pose->Location(this).y > bounds.bottom) {
|
||||||
returnvalue = false;
|
returnvalue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -8999,7 +9018,7 @@ BPoseView::HiliteDropTarget(bool hiliteState)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pose->Location().y > bounds.bottom)
|
if (pose->Location(this).y > bounds.bottom)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user