* Further improved look.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32299 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -181,23 +181,36 @@ PowerStatusView::_DrawBattery(BRect rect)
|
|||||||
percent = 100;
|
percent = 100;
|
||||||
|
|
||||||
if (percent > 0) {
|
if (percent > 0) {
|
||||||
rgb_color base;
|
rect.InsetBy(gap, gap);
|
||||||
|
rgb_color base = {84, 84, 84, 255};
|
||||||
|
if (be_control_look != NULL) {
|
||||||
|
BRect empty = rect;
|
||||||
|
if (fHasBattery && percent > 0)
|
||||||
|
empty.left += empty.Width() * percent / 100.0;
|
||||||
|
|
||||||
|
be_control_look->DrawButtonBackground(this, empty, empty, base,
|
||||||
|
fHasBattery
|
||||||
|
? BControlLook::B_ACTIVATED : BControlLook::B_DISABLED,
|
||||||
|
fHasBattery && percent > 0
|
||||||
|
? (BControlLook::B_ALL_BORDERS
|
||||||
|
& ~BControlLook::B_LEFT_BORDER)
|
||||||
|
: BControlLook::B_ALL_BORDERS);
|
||||||
|
}
|
||||||
|
|
||||||
if (fHasBattery) {
|
if (fHasBattery) {
|
||||||
if (percent <= 15)
|
if (percent <= 15)
|
||||||
base.set_to(180, 0, 0);
|
base.set_to(180, 0, 0);
|
||||||
else
|
else
|
||||||
base.set_to(20, 180, 0);
|
base.set_to(20, 180, 0);
|
||||||
} else
|
|
||||||
base.set_to(84, 84, 84);
|
|
||||||
|
|
||||||
rect.InsetBy(gap, gap);
|
rect.right = rect.left + rect.Width() * percent / 100.0;
|
||||||
rect.right = rect.left + rect.Width() * percent / 100.0;
|
|
||||||
|
|
||||||
if (be_control_look != NULL) {
|
if (be_control_look != NULL) {
|
||||||
be_control_look->DrawButtonBackground(this, rect, rect, base,
|
be_control_look->DrawButtonBackground(this, rect, rect, base,
|
||||||
fHasBattery ? 0 : BControlLook::B_DISABLED);
|
fHasBattery ? 0 : BControlLook::B_DISABLED);
|
||||||
} else
|
} else
|
||||||
FillRect(rect);
|
FillRect(rect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
@@ -243,11 +256,7 @@ PowerStatusView::Draw(BRect updateRect)
|
|||||||
|
|
||||||
if (iconRect.Width() + 1 >= kMinIconWidth
|
if (iconRect.Width() + 1 >= kMinIconWidth
|
||||||
&& iconRect.Height() + 1 >= kMinIconHeight) {
|
&& iconRect.Height() + 1 >= kMinIconHeight) {
|
||||||
// TODO: have real icons
|
_DrawBattery(iconRect);
|
||||||
//if (!fOnline)
|
|
||||||
_DrawBattery(iconRect);
|
|
||||||
//else
|
|
||||||
// FillRect(iconRect);
|
|
||||||
} else {
|
} else {
|
||||||
// there is not enough space for the icon
|
// there is not enough space for the icon
|
||||||
iconRect.Set(0, 0, -1, -1);
|
iconRect.Set(0, 0, -1, -1);
|
||||||
@@ -346,9 +355,20 @@ PowerStatusView::Update(bool force)
|
|||||||
width += ceilf(StringWidth(text)) + 4;
|
width += ceilf(StringWidth(text)) + 4;
|
||||||
} else {
|
} else {
|
||||||
char text[256];
|
char text[256];
|
||||||
|
const char* open = "";
|
||||||
|
const char* close = "";
|
||||||
|
if (!fOnline) {
|
||||||
|
open = "(";
|
||||||
|
close = ")";
|
||||||
|
}
|
||||||
if (fHasBattery) {
|
if (fHasBattery) {
|
||||||
snprintf(text, sizeof(text), "%ld%%\n%ld:%02ld\n%s",
|
size_t length = snprintf(text, sizeof(text), "%s%ld%%%s\n",
|
||||||
fPercent, fTimeLeft / 3600, (fTimeLeft / 60) % 60,
|
open, fPercent, close);
|
||||||
|
if (fTimeLeft) {
|
||||||
|
length += snprintf(text + length, sizeof(text) - length,
|
||||||
|
"%ld:%02ld\n", fTimeLeft / 3600, (fTimeLeft / 60) % 60);
|
||||||
|
}
|
||||||
|
length += snprintf(text + length, sizeof(text) - length, "%s",
|
||||||
fOnline ? "charging" : "discharging");
|
fOnline ? "charging" : "discharging");
|
||||||
} else
|
} else
|
||||||
strcpy(text, "no battery");
|
strcpy(text, "no battery");
|
||||||
@@ -635,6 +655,8 @@ PowerStatusReplicant::_GetSettings(BFile& file, int mode)
|
|||||||
void
|
void
|
||||||
PowerStatusReplicant::_LoadSettings()
|
PowerStatusReplicant::_LoadSettings()
|
||||||
{
|
{
|
||||||
|
fShowLabel = false;
|
||||||
|
|
||||||
BFile file;
|
BFile file;
|
||||||
if (_GetSettings(file, B_READ_ONLY) != B_OK)
|
if (_GetSettings(file, B_READ_ONLY) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user