* Don't draw/clear the background if the parent view draws on children.
* Make use of the BControlLook method to draw labels. Both fix ticket #4875. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35261 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
#include <binary_compatibility/Interface.h>
|
#include <binary_compatibility/Interface.h>
|
||||||
|
|
||||||
|
|
||||||
#define USE_OFF_SCREEN_VIEW 1
|
#define USE_OFF_SCREEN_VIEW 0
|
||||||
|
|
||||||
|
|
||||||
BSlider::BSlider(BRect frame, const char* name, const char* label,
|
BSlider::BSlider(BRect frame, const char* name, const char* label,
|
||||||
@@ -799,6 +799,12 @@ BSlider::Draw(BRect updateRect)
|
|||||||
// clear out background
|
// clear out background
|
||||||
BRegion background(updateRect);
|
BRegion background(updateRect);
|
||||||
background.Exclude(BarFrame());
|
background.Exclude(BarFrame());
|
||||||
|
bool drawBackground = true;
|
||||||
|
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
|
||||||
|
// This view is embedded somewhere, most likely the Tracker Desktop
|
||||||
|
// shelf.
|
||||||
|
drawBackground = false;
|
||||||
|
}
|
||||||
|
|
||||||
// ToDo: the triangle thumb doesn't delete its background, so we still have
|
// ToDo: the triangle thumb doesn't delete its background, so we still have
|
||||||
// to do it Note, this also creates a different behaviour for subclasses,
|
// to do it Note, this also creates a different behaviour for subclasses,
|
||||||
@@ -824,7 +830,7 @@ BSlider::Draw(BRect updateRect)
|
|||||||
fOffScreenView->SetLowColor(ViewColor());
|
fOffScreenView->SetLowColor(ViewColor());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (background.Frame().IsValid())
|
if (drawBackground && background.Frame().IsValid())
|
||||||
OffscreenView()->FillRegion(&background, B_SOLID_LOW);
|
OffscreenView()->FillRegion(&background, B_SOLID_LOW);
|
||||||
|
|
||||||
#if USE_OFF_SCREEN_VIEW
|
#if USE_OFF_SCREEN_VIEW
|
||||||
@@ -1133,33 +1139,62 @@ BSlider::DrawText()
|
|||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
BView *view = OffscreenView();
|
BView *view = OffscreenView();
|
||||||
|
|
||||||
if (IsEnabled()) {
|
rgb_color base = LowColor();
|
||||||
view->SetHighColor(0, 0, 0);
|
uint32 flags = 0;
|
||||||
} else {
|
if (be_control_look == NULL) {
|
||||||
view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT));
|
if (IsEnabled()) {
|
||||||
}
|
view->SetHighColor(0, 0, 0);
|
||||||
|
} else {
|
||||||
|
view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
flags = be_control_look->Flags(this);
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
GetFontHeight(&fontHeight);
|
GetFontHeight(&fontHeight);
|
||||||
if (Orientation() == B_HORIZONTAL) {
|
if (Orientation() == B_HORIZONTAL) {
|
||||||
if (Label())
|
if (Label()) {
|
||||||
view->DrawString(Label(), BPoint(0.0, ceilf(fontHeight.ascent)));
|
if (be_control_look == NULL) {
|
||||||
|
view->DrawString(Label(),
|
||||||
|
BPoint(0.0, ceilf(fontHeight.ascent)));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, Label(), base, flags,
|
||||||
|
BPoint(0.0, ceilf(fontHeight.ascent)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// the update text is updated in SetValue() only
|
// the update text is updated in SetValue() only
|
||||||
if (fUpdateText != NULL) {
|
if (fUpdateText != NULL) {
|
||||||
view->DrawString(fUpdateText, BPoint(bounds.right
|
if (be_control_look == NULL) {
|
||||||
- StringWidth(fUpdateText), ceilf(fontHeight.ascent)));
|
view->DrawString(fUpdateText, BPoint(bounds.right
|
||||||
|
- StringWidth(fUpdateText), ceilf(fontHeight.ascent)));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, fUpdateText, base, flags,
|
||||||
|
BPoint(bounds.right - StringWidth(fUpdateText),
|
||||||
|
ceilf(fontHeight.ascent)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fMinLimitLabel) {
|
if (fMinLimitLabel) {
|
||||||
view->DrawString(fMinLimitLabel, BPoint(0.0, bounds.bottom
|
if (be_control_look == NULL) {
|
||||||
- fontHeight.descent));
|
view->DrawString(fMinLimitLabel, BPoint(0.0, bounds.bottom
|
||||||
|
- fontHeight.descent));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
|
||||||
|
BPoint(0.0, bounds.bottom - fontHeight.descent));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fMaxLimitLabel) {
|
if (fMaxLimitLabel) {
|
||||||
view->DrawString(fMaxLimitLabel, BPoint(bounds.right
|
if (be_control_look == NULL) {
|
||||||
- StringWidth(fMaxLimitLabel), bounds.bottom
|
view->DrawString(fMaxLimitLabel, BPoint(bounds.right
|
||||||
- fontHeight.descent));
|
- StringWidth(fMaxLimitLabel), bounds.bottom
|
||||||
|
- fontHeight.descent));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
|
||||||
|
BPoint(bounds.right - StringWidth(fMaxLimitLabel),
|
||||||
|
bounds.bottom - fontHeight.descent));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
float lineHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)
|
float lineHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)
|
||||||
@@ -1167,27 +1202,51 @@ BSlider::DrawText()
|
|||||||
float baseLine = ceilf(fontHeight.ascent);
|
float baseLine = ceilf(fontHeight.ascent);
|
||||||
|
|
||||||
if (Label()) {
|
if (Label()) {
|
||||||
view->DrawString(Label(), BPoint((bounds.Width()
|
if (be_control_look == NULL) {
|
||||||
- StringWidth(Label())) / 2.0, baseLine));
|
view->DrawString(Label(), BPoint((bounds.Width()
|
||||||
|
- StringWidth(Label())) / 2.0, baseLine));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, Label(), base, flags,
|
||||||
|
BPoint((bounds.Width() - StringWidth(Label())) / 2.0,
|
||||||
|
baseLine));
|
||||||
|
}
|
||||||
baseLine += lineHeight;
|
baseLine += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fMaxLimitLabel) {
|
if (fMaxLimitLabel) {
|
||||||
view->DrawString(fMaxLimitLabel, BPoint((bounds.Width()
|
if (be_control_look == NULL) {
|
||||||
- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
|
view->DrawString(fMaxLimitLabel, BPoint((bounds.Width()
|
||||||
|
- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
|
||||||
|
BPoint((bounds.Width()
|
||||||
|
- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baseLine = bounds.bottom - ceilf(fontHeight.descent);
|
baseLine = bounds.bottom - ceilf(fontHeight.descent);
|
||||||
|
|
||||||
if (fMinLimitLabel) {
|
if (fMinLimitLabel) {
|
||||||
view->DrawString(fMinLimitLabel, BPoint((bounds.Width()
|
if (be_control_look == NULL) {
|
||||||
- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
|
view->DrawString(fMinLimitLabel, BPoint((bounds.Width()
|
||||||
|
- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
|
||||||
|
BPoint((bounds.Width()
|
||||||
|
- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
|
||||||
|
}
|
||||||
baseLine -= lineHeight;
|
baseLine -= lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fUpdateText != NULL) {
|
if (fUpdateText != NULL) {
|
||||||
view->DrawString(fUpdateText, BPoint((bounds.Width()
|
if (be_control_look == NULL) {
|
||||||
- StringWidth(fUpdateText)) / 2.0, baseLine));
|
view->DrawString(fUpdateText, BPoint((bounds.Width()
|
||||||
|
- StringWidth(fUpdateText)) / 2.0, baseLine));
|
||||||
|
} else {
|
||||||
|
be_control_look->DrawLabel(view, fUpdateText, base, flags,
|
||||||
|
BPoint((bounds.Width()
|
||||||
|
- StringWidth(fUpdateText)) / 2.0, baseLine));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user