[haiku-commits] BRANCH looncraz-github.setviewuicolor [906559597eb0] in src: tests/kits/game/chart preferences/keymap servers/app kits/interface bin/desklink

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 3 Oct 2015 19:02:53 +0200 (CEST)

added 5 changesets to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: ca107fa4852a8c37996670523994a4d78663dbc0
new head: 906559597eb03c6effa06dcd991f42317256ea76
overview: https://github.com/looncraz/haiku/compare/ca107fa4852a...906559597eb0

----------------------------------------------------------------------------

c6028b728b8b: Adapt Media Control Replicant

Gotta love AdoptParentColors() ;-)

70571bbd24ac: Improve Compatibility

Identify colors not found in app_server appearance settings on load
and mark as transparent. The first client to pull in the UI color
will read the default value instead of an invalid value, creating
a seamless addition of new color constants and maintaining
compatibility with previous appearance settings, if any.

0270c0c2f1f7: IconButton

Do not default to a low color, full adoption only.

c8fb3716b928: Keymap

Force key color to be black, as the key color does not change.

906559597eb0: Adapt Chart

Colors update, more font awareness and intelligent placement and
window sizing.

This app could use some more love in this regard.

[ looncraz <looncraz@xxxxxxxxxxxx> ]

----------------------------------------------------------------------------

6 files changed, 38 insertions(+), 19 deletions(-)
src/bin/desklink/MediaReplicant.cpp | 4 +--
src/kits/interface/InterfaceDefs.cpp | 7 ++++-
src/kits/shared/IconButton.cpp | 2 --
src/preferences/keymap/KeyboardLayoutView.cpp | 5 ++--
src/servers/app/DesktopSettings.cpp | 5 +++-
src/tests/kits/game/chart/ChartWindow.cpp | 34 ++++++++++++++++-------

############################################################################

Commit: c6028b728b8b4bc80a9ee630d3dfb09acf29fb4d
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sat Oct 3 15:39:44 2015 UTC

Adapt Media Control Replicant

Gotta love AdoptParentColors() ;-)

----------------------------------------------------------------------------

diff --git a/src/bin/desklink/MediaReplicant.cpp
b/src/bin/desklink/MediaReplicant.cpp
index 2b8d18e..7853531 100644
--- a/src/bin/desklink/MediaReplicant.cpp
+++ b/src/bin/desklink/MediaReplicant.cpp
@@ -211,9 +211,7 @@ MediaReplicant::Archive(BMessage* data, bool deep) const
void
MediaReplicant::AttachedToWindow()
{
- BView* parent = Parent();
- if (parent)
- SetViewColor(parent->ViewColor());
+ AdoptParentColors();

BView::AttachedToWindow();
}

############################################################################

Commit: 70571bbd24ac9dba50612d65d1b7aa0b4a93cba4
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sat Oct 3 17:01:50 2015 UTC

Improve Compatibility

Identify colors not found in app_server appearance settings on load
and mark as transparent. The first client to pull in the UI color
will read the default value instead of an invalid value, creating
a seamless addition of new color constants and maintaining
compatibility with previous appearance settings, if any.

----------------------------------------------------------------------------

diff --git a/src/kits/interface/InterfaceDefs.cpp
b/src/kits/interface/InterfaceDefs.cpp
index 05c9ba0..7063139 100644
--- a/src/kits/interface/InterfaceDefs.cpp
+++ b/src/kits/interface/InterfaceDefs.cpp
@@ -1083,8 +1083,13 @@ ui_color(color_which which)
if (be_app != NULL) {
server_read_only_memory* shared
= BApplication::Private::ServerReadOnlyMemory();
- if (shared != NULL)
+ if (shared != NULL) {
+ // check for unset colors
+ if (shared->colors[index] == B_TRANSPARENT_COLOR)
+ shared->colors[index] = kDefaultColors[index];
+
return shared->colors[index];
+ }
}

return kDefaultColors[index];
diff --git a/src/servers/app/DesktopSettings.cpp
b/src/servers/app/DesktopSettings.cpp
index c1081ae..8e88d56 100644
--- a/src/servers/app/DesktopSettings.cpp
+++ b/src/servers/app/DesktopSettings.cpp
@@ -297,7 +297,10 @@ DesktopSettingsPrivate::_Load()
snprintf(colorName, sizeof(colorName), "color%"
B_PRId32,
(int32)index_to_color_which(i));

- settings.FindInt32(colorName,
(int32*)&fShared.colors[i]);
+ if (settings.FindInt32(colorName,
(int32*)&fShared.colors[i]) != B_OK) {
+ // Set obviously bad value so the
Appearance app can detect it
+ fShared.colors[i] = B_TRANSPARENT_COLOR;
+ }
}
}
}

############################################################################

Commit: 0270c0c2f1f769d9d0805c2a4a64544e8e7d7eaa
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sat Oct 3 17:10:54 2015 UTC

IconButton

Do not default to a low color, full adoption only.

----------------------------------------------------------------------------

diff --git a/src/kits/shared/IconButton.cpp b/src/kits/shared/IconButton.cpp
index 6e69385..0000f1d 100644
--- a/src/kits/shared/IconButton.cpp
+++ b/src/kits/shared/IconButton.cpp
@@ -83,8 +83,6 @@ BIconButton::AttachedToWindow()

if (ViewUIColor() != B_NO_COLOR)
SetLowUIColor(ViewUIColor());
- else
- SetLowUIColor(B_PANEL_BACKGROUND_COLOR);

SetTarget(fTargetCache);
if (!Target())

############################################################################

Commit: c8fb3716b928d43600c1d2b27e19e97ea574f8cb
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sat Oct 3 17:16:16 2015 UTC

Keymap

Force key color to be black, as the key color does not change.

----------------------------------------------------------------------------

diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp
b/src/preferences/keymap/KeyboardLayoutView.cpp
index 0eec89a..74e901a 100644
--- a/src/preferences/keymap/KeyboardLayoutView.cpp
+++ b/src/preferences/keymap/KeyboardLayoutView.cpp
@@ -765,6 +765,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect,
const Key* key,
{
rgb_color base = key->dark ? kDarkColor : kBrightColor;
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
+ rgb_color keyLabelColor = make_color(0, 0, 0, 255);
key_kind keyKind = kNormalKey;
int32 deadKey = 0;
bool secondDeadKey = false;
@@ -795,7 +796,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect,
const Key* key,

_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text,
sizeof(text));
be_control_look->DrawLabel(view, text, rect, updateRect,
- base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
+ base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE),
&keyLabelColor);
} else if (key->shape == kEnterKeyShape) {
BRect topLeft = rect;
BRect topRight = rect;
@@ -875,7 +876,7 @@ KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect,
const Key* key,

// draw the button label
be_control_look->DrawLabel(view, text, rect, updateRect,
- base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
+ base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE),
&keyLabelColor);

// reset the clipping region
view->ConstrainClippingRegion(NULL);

############################################################################

Commit: 906559597eb03c6effa06dcd991f42317256ea76
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Sat Oct 3 17:47:46 2015 UTC

Adapt Chart

Colors update, more font awareness and intelligent placement and
window sizing.

This app could use some more love in this regard.

----------------------------------------------------------------------------

diff --git a/src/tests/kits/game/chart/ChartWindow.cpp
b/src/tests/kits/game/chart/ChartWindow.cpp
index 0606c6e..a07ae39 100644
--- a/src/tests/kits/game/chart/ChartWindow.cpp
+++ b/src/tests/kits/game/chart/ChartWindow.cpp
@@ -66,7 +66,6 @@ enum {
SPACE_LABEL = 40,
SPACE_POPUP = 53,
INSTANT_LOAD = 205,
- LEFT_WIDTH = 96,
LEFT_OFFSET = 2,
STATUS_BOX = 98,
STATUS_LABEL = 13,
@@ -90,6 +89,10 @@ enum {
REFRESH_RATE_V = 34
};

+
+int32 LEFT_WIDTH = 96;
+
+
/* min, max and standard setting of the star count, also
called starfield density. */
enum {
@@ -143,9 +146,6 @@ enum {
/* no comments (almost :-) */
#define abs(x) (((x)>0)?(x):-(x))

-/* default background color for the UI. */
-rgb_color background_color = { 216, 216, 216, 255 };
-
/* the 7 colors for stars. */
static rgb_color color_list[7] = {
{ 255, 160, 160, 255 }, /* red */
@@ -476,9 +476,15 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* top line background */
r.Set(0.0, 0.0, frame.right, TOP_LEFT_LIMIT - 1);
fTopView = new BView(r, "top view", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
- fTopView->SetViewColor(background_color);
+ fTopView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
AddChild(fTopView);

+ LEFT_WIDTH = (int32)fTopView->StringWidth(B_TRANSLATE("Full screen"))
+ + 22 + H_BORDER;
+
+ if (LEFT_WIDTH < 96)
+ LEFT_WIDTH = 96;
+
h = 2;
v = V_BORDER;

@@ -628,7 +634,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* left column gray background */
r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH - 1, frame.bottom);
fLeftView = new BView(r, "top view", B_FOLLOW_LEFT |
B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW);
- fLeftView->SetViewColor(background_color);
+ fLeftView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
AddChild(fLeftView);

h2 = LEFT_OFFSET;
@@ -722,7 +728,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
boxWidth = max_c(width + r.left, boxWidth);
fLeftView->AddChild(button);

- v2 += AUTO_DEMO+LEFT_OFFSET*2;
+ v2 += button->Frame().Height()+LEFT_OFFSET*2;
h = h2;
v = v2;

@@ -894,6 +900,14 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
fChartView->SetViewColor(0, 0, 0);
AddChild(fChartView);

+ /*Resize Window Height to fit contents, if needed*/
+ r = Bounds();
+ r.bottom = fSpecialBox->Frame().bottom + H_BORDER*2 + 20;
+
+ if (r.Height() > Bounds().Height())
+ ResizeTo(r.Width(), r.Height());
+
+
/* allocate the semaphores */
fDrawingLock = create_sem(1, "chart locker");
fSecondThreadLock = create_sem(0, "chart second locker");
@@ -1206,7 +1220,7 @@ ChartWindow::OpenColorPalette(BPoint here)
point.Set(0, 0);
BColorControl *colorControl = new ChartColorControl(point,
new BMessage(COLOR_PALETTE_MSG));
- colorControl->SetViewColor(background_color);
+ colorControl->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
colorControl->SetTarget(NULL, this);
colorControl->SetValue(fCurrentSettings.back_color);
colorControl->ResizeToPreferred();
@@ -1234,7 +1248,7 @@ ChartWindow::OpenStarDensity(BPoint here)
frame.OffsetTo(0.0, 0.0);
BSlider *slider = new BSlider(frame, "", NULL, new
BMessage(STAR_DENSITY_MSG),
STAR_DENSITY_MIN,
STAR_DENSITY_MAX);
- slider->SetViewColor(background_color);
+ slider->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
slider->SetTarget(NULL, this);
slider->SetValue(fCurrentSettings.star_density);
slider->SetModificationMessage(new BMessage(STAR_DENSITY_MSG));
@@ -1264,7 +1278,7 @@ ChartWindow::OpenRefresh(BPoint here)
B_NOT_RESIZABLE |
B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK);
frame.OffsetTo(0.0, 0.0);
BSlider *slider = new BSlider(frame, "", NULL, new
BMessage(REFRESH_RATE_MSG), 0, 1000);
- slider->SetViewColor(background_color);
+ slider->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
slider->SetTarget(NULL, this);
slider->SetValue((int32)(1000 *
log(fCurrentSettings.refresh_rate / REFRESH_RATE_MIN) /

log(REFRESH_RATE_MAX/REFRESH_RATE_MIN)));


Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.setviewuicolor [906559597eb0] in src: tests/kits/game/chart preferences/keymap servers/app kits/interface bin/desklink - looncraz-github . setviewuicolor