If the user specified a hashmark location other than B_HASH_MARKS_NONE, draw

at least two hash marks, even if the hash mark count has never been configured.
Also means the minimum hashmark count is 2 instead of 1 as before. I think this
behavior is more what one would expect, I turned on hashmarks and wondered
why nothing happened until I realized I needed to configure the count as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26443 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-07-16 15:15:24 +00:00
parent 58ecd48c0f
commit f898f8af47
+16 -11
View File
@@ -926,6 +926,9 @@ BSlider::DrawBar()
void void
BSlider::DrawHashMarks() BSlider::DrawHashMarks()
{ {
if (fHashMarks == B_HASH_MARKS_NONE)
return;
BRect frame = HashMarksFrame(); BRect frame = HashMarksFrame();
BView* view = OffscreenView(); BView* view = OffscreenView();
@@ -942,16 +945,17 @@ BSlider::DrawHashMarks()
} }
float pos = _MinPosition(); float pos = _MinPosition();
float factor = 0.0f; int32 hashMarkCount = max_c(fHashMarkCount, 2);
if (fHashMarkCount > 1) // draw at least two hashmarks at min/max if
factor = (_MaxPosition() - pos) / (fHashMarkCount - 1); // fHashMarks != B_HASH_MARKS_NONE
float factor = (_MaxPosition() - pos) / (hashMarkCount - 1);
if (fHashMarks & B_HASH_MARKS_TOP && fHashMarkCount > 0) { if (fHashMarks & B_HASH_MARKS_TOP) {
view->BeginLineArray(fHashMarkCount * 2); view->BeginLineArray(hashMarkCount * 2);
if (fOrientation == B_HORIZONTAL) { if (fOrientation == B_HORIZONTAL) {
for (int32 i = 0; i < fHashMarkCount; i++) { for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(pos, frame.top), view->AddLine(BPoint(pos, frame.top),
BPoint(pos, frame.top + 5), darken2); BPoint(pos, frame.top + 5), darken2);
view->AddLine(BPoint(pos + 1, frame.top), view->AddLine(BPoint(pos + 1, frame.top),
@@ -960,7 +964,7 @@ BSlider::DrawHashMarks()
pos += factor; pos += factor;
} }
} else { } else {
for (int32 i = 0; i < fHashMarkCount; i++) { for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(frame.left, pos), view->AddLine(BPoint(frame.left, pos),
BPoint(frame.left + 5, pos), darken2); BPoint(frame.left + 5, pos), darken2);
view->AddLine(BPoint(frame.left, pos + 1), view->AddLine(BPoint(frame.left, pos + 1),
@@ -975,11 +979,12 @@ BSlider::DrawHashMarks()
pos = _MinPosition(); pos = _MinPosition();
if (fHashMarks & B_HASH_MARKS_BOTTOM && fHashMarkCount > 0) { if (fHashMarks & B_HASH_MARKS_BOTTOM) {
view->BeginLineArray(fHashMarkCount * 2);
view->BeginLineArray(hashMarkCount * 2);
if (fOrientation == B_HORIZONTAL) { if (fOrientation == B_HORIZONTAL) {
for (int32 i = 0; i < fHashMarkCount; i++) { for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(pos, frame.bottom - 5), view->AddLine(BPoint(pos, frame.bottom - 5),
BPoint(pos, frame.bottom), darken2); BPoint(pos, frame.bottom), darken2);
view->AddLine(BPoint(pos + 1, frame.bottom - 5), view->AddLine(BPoint(pos + 1, frame.bottom - 5),
@@ -988,7 +993,7 @@ BSlider::DrawHashMarks()
pos += factor; pos += factor;
} }
} else { } else {
for (int32 i = 0; i < fHashMarkCount; i++) { for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(frame.right - 5, pos), view->AddLine(BPoint(frame.right - 5, pos),
BPoint(frame.right, pos), darken2); BPoint(frame.right, pos), darken2);
view->AddLine(BPoint(frame.right - 5, pos + 1), view->AddLine(BPoint(frame.right - 5, pos + 1),