From 46dd7d5077c0ef26d079ae007f158abdec06de83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 9 Sep 2015 20:37:22 +0200 Subject: [PATCH] Tracker: Fixed vertical list icon position. * Instead of drawing it at the bottom of the line, draw it in the middle of it. --- src/kits/tracker/Pose.cpp | 25 +++++++++++++++---------- src/kits/tracker/Pose.h | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/kits/tracker/Pose.cpp b/src/kits/tracker/Pose.cpp index 6171bc3a0b..d28ad5ac05 100644 --- a/src/kits/tracker/Pose.cpp +++ b/src/kits/tracker/Pose.cpp @@ -524,11 +524,7 @@ BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where, *hitWidget = NULL; // check intersection with icon - BRect rect; - rect.left = loc.x + kListOffset; - rect.right = rect.left + B_MINI_ICON; - rect.bottom = loc.y + poseView->ListElemHeight(); - rect.top = rect.bottom - B_MINI_ICON; + BRect rect = _IconRect(poseView, loc); if (rect.Contains(where)) return true; @@ -572,11 +568,7 @@ BPose::Draw(BRect rect, const BRect& updateRect, BPoseView* poseView, ModelNodeLazyOpener modelOpener(fModel); if (poseView->ViewMode() == kListMode) { - uint32 size = poseView->IconSizeInt(); - BRect iconRect(rect); - iconRect.left += kListOffset; - iconRect.right = iconRect.left + size; - iconRect.top = iconRect.bottom - size; + BRect iconRect = _IconRect(poseView, rect.LeftTop()); if (updateRect.Intersects(iconRect)) { iconRect.OffsetBy(offset); DrawIcon(iconRect.LeftTop(), drawView, poseView->IconSize(), @@ -992,6 +984,19 @@ BPose::CalcRect(const BPoseView* poseView) const } +BRect +BPose::_IconRect(const BPoseView* poseView, BPoint location) const +{ + uint32 size = poseView->IconSizeInt(); + BRect rect; + rect.left = location.x + kListOffset; + rect.right = rect.left + size; + rect.top = location.y + (poseView->ListElemHeight() - size) / 2.f; + rect.bottom = rect.top + size; + return rect; +} + + #if DEBUG void BPose::PrintToStream() diff --git a/src/kits/tracker/Pose.h b/src/kits/tracker/Pose.h index 2d831e1880..665abd7a75 100644 --- a/src/kits/tracker/Pose.h +++ b/src/kits/tracker/Pose.h @@ -137,6 +137,8 @@ private: void EditPreviousNextWidgetCommon(BPoseView* poseView, bool next); void CreateWidgets(BPoseView*); bool TestLargeIconPixel(BPoint) const; + BRect _IconRect(const BPoseView* poseView, + BPoint location) const; Model* fModel; BObjectList fWidgetList;