[haiku-bugs] [Haiku] #13432: Tracker volume icon usage bar not offset correctly for smaller icon sizes

  • From: "perelandra" <trac@xxxxxxxxxxxx>
  • Date: Sun, 16 Apr 2017 12:08:41 -0000

#13432: Tracker volume icon usage bar not offset correctly for smaller icon 
sizes
--------------------------------+------------------------------
 Reporter:  perelandra          |        Owner:  perelandra
     Type:  bug                 |       Status:  new
 Priority:  normal              |    Milestone:  Unscheduled
Component:  Kits/libtracker.so  |      Version:  R1/Development
 Keywords:                      |   Blocked By:
 Blocking:                      |  Has a Patch:  0
 Platform:  All                 |
--------------------------------+------------------------------
 By copying the Tracker's BPose:DrawBar code into the draw code of one of
 my projects, I discovered and issue with the x offset calulation of the
 used space bar for icon size between B_MINI_ICON and B_LARGE_ICON.  The
 bar should be drawn over the very right part of the icon.  However for
 icon sizes less than B_LARGE_ICON the "size" variable is set to
 B_MINI_ICON (which is 16).  This throws off the offset for an icon of for
 example 20 pixles and will draw the bar farther to the left than it
 should.

 Referenced code is here:
 http://cgit.haiku-os.org/haiku/tree/src/kits/tracker/Pose.cpp#n841

 I don't think this has been noticed because in Tracker, you cannot select
 an icon size between B_MINI_ICON (16) and B_LARGE_ICON (32) but this bug
 could be revealed in the future if that changes.

 I fixed this by replacing the code starting that above reference with
 this:

 {{{
 int32 yOffset;
 int32 size = which - 1;
 int32 barWidth = (int32)(7.0f / 32.0f * (float)which);
 if (barWidth < 4) {
         barWidth = 4;
         yOffset = 0;
 }
 else
         yOffset = 2;
 int32 barHeight = size - 4 - 2 * yOffset;
 }}}

 Any thoughts or problems anyone sees with this solution?

 Also with this line:
 {{{
 int32 barHeight = size - 4 - 2 * yOffset;
 }}}

 This causes the green part of the bar to start as one pixel high at 0
 percent used space, and start 2 pixels high at any amount more than 0.
 Maybe this was as intended to provide a larger visual clue about there
 being some files on the volume even at very low total usage.  For things
 like download percentage complete the 4 must be replaced with a 3 to be
 visually accurate.  However we can leave it at 4 if visually starting at
 always having more than one pixel in the usage bar is desired.

 If there are no objections in a few days I will push the above code
 change.

--
Ticket URL: <https://dev.haiku-os.org/ticket/13432>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: