[Haiku-commits] r26443 - haiku/trunk/src/kits/interface
stippi at mail.berlios.de
stippi at mail.berlios.de
Wed Jul 16 17:15:26 CEST 2008
Author: stippi
Date: 2008-07-16 17:15:24 +0200 (Wed, 16 Jul 2008)
New Revision: 26443
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=26443&view=rev
Modified:
haiku/trunk/src/kits/interface/Slider.cpp
Log:
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.
Modified: haiku/trunk/src/kits/interface/Slider.cpp
===================================================================
--- haiku/trunk/src/kits/interface/Slider.cpp 2008-07-16 15:06:13 UTC (rev 26442)
+++ haiku/trunk/src/kits/interface/Slider.cpp 2008-07-16 15:15:24 UTC (rev 26443)
@@ -926,32 +926,36 @@
void
BSlider::DrawHashMarks()
{
+ if (fHashMarks == B_HASH_MARKS_NONE)
+ return;
+
BRect frame = HashMarksFrame();
- BView *view = OffscreenView();
+ BView* view = OffscreenView();
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color lightenmax;
rgb_color darken2;
if (IsEnabled()) {
- lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT);
- darken2 = tint_color(no_tint, B_DARKEN_2_TINT);
+ lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT);
+ darken2 = tint_color(no_tint, B_DARKEN_2_TINT);
} else {
- lightenmax = tint_color(no_tint, B_LIGHTEN_2_TINT);
- darken2 = tint_color(no_tint, B_DARKEN_1_TINT);
+ lightenmax = tint_color(no_tint, B_LIGHTEN_2_TINT);
+ darken2 = tint_color(no_tint, B_DARKEN_1_TINT);
}
float pos = _MinPosition();
- float factor = 0.0f;
- if (fHashMarkCount > 1)
- factor = (_MaxPosition() - pos) / (fHashMarkCount - 1);
+ int32 hashMarkCount = max_c(fHashMarkCount, 2);
+ // draw at least two hashmarks at min/max if
+ // 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) {
- for (int32 i = 0; i < fHashMarkCount; i++) {
+ for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(pos, frame.top),
BPoint(pos, frame.top + 5), darken2);
view->AddLine(BPoint(pos + 1, frame.top),
@@ -960,7 +964,7 @@
pos += factor;
}
} else {
- for (int32 i = 0; i < fHashMarkCount; i++) {
+ for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(frame.left, pos),
BPoint(frame.left + 5, pos), darken2);
view->AddLine(BPoint(frame.left, pos + 1),
@@ -975,11 +979,12 @@
pos = _MinPosition();
- if (fHashMarks & B_HASH_MARKS_BOTTOM && fHashMarkCount > 0) {
- view->BeginLineArray(fHashMarkCount * 2);
+ if (fHashMarks & B_HASH_MARKS_BOTTOM) {
+ view->BeginLineArray(hashMarkCount * 2);
+
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),
BPoint(pos, frame.bottom), darken2);
view->AddLine(BPoint(pos + 1, frame.bottom - 5),
@@ -988,7 +993,7 @@
pos += factor;
}
} else {
- for (int32 i = 0; i < fHashMarkCount; i++) {
+ for (int32 i = 0; i < hashMarkCount; i++) {
view->AddLine(BPoint(frame.right - 5, pos),
BPoint(frame.right, pos), darken2);
view->AddLine(BPoint(frame.right - 5, pos + 1),
More information about the Haiku-commits
mailing list