Opened 2 years ago

Closed 2 years ago

#13432 closed bug (fixed)

Tracker volume icon usage bar not offset correctly for smaller icon sizes

Reported by: perelandra Owned by: perelandra
Priority: normal Milestone: Unscheduled
Component: Kits/libtracker.so Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

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.

Change History (3)

comment:1 Changed 2 years ago by waddlesplash

Makes sense to me.

comment:2 Changed 2 years ago by axeld

Just make sure to fix the coding style issue before (else goes on the same line as } from the if block) :-)

comment:3 Changed 2 years ago by perelandra

Resolution: fixed
Status: newclosed

Pushed in hrev51149

Note: See TracTickets for help on using tickets.