[haiku-commits] BRANCH looncraz-github.setviewuicolor [61b325bf4621] src/kits/interface src/apps/bootmanager src/servers/app src/apps/aboutsystem headers/os/interface

  • From: looncraz-github.setviewuicolor <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 28 Sep 2015 23:32:04 +0200 (CEST)

added 2 changesets to branch 'refs/remotes/looncraz-github/setviewuicolor'
old head: f68a3bb52ec4ec03b9a78e72ce55d11a0af16dc0
new head: 61b325bf462167f7df5ab8eae61b30643a141a54
overview: https://github.com/looncraz/haiku/compare/f68a3bb52ec4...61b325bf4621

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

38b8458e58e8: AboutSystem, BootManager

AboutSystem
Some issue is preventing the tinting to work right until after the
window is visible, so I did a quick kludge to make it look right.

BootManager
Wow, what a disaster this was with large fonts and dark color scheme!
Text colors properly adjusted for panel colors, though no live
updates - low priority, ATM.
Window was also super small, so it now adjutss based on font size.

61b325bf4621: DelayedInvalidate, Better Layout Color Handling

Added DelayedInvalidate support - seems to work perfectly.

The layout process makes it very difficult to propagate
colors to children, so I figured defaulting the color of
attaching children to B_PANEL_BACKGROUND_COLOR would cover
90% of all use cases, and the other 10% will just require
some TLC. BTW, I'm aware it isn't in the right place...
... relative to when AttachedToWindow is called on the
child. I'll get around to it.

[ looncraz <looncraz@xxxxxxxxxxxx> ]

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

8 files changed, 104 insertions(+), 18 deletions(-)
headers/os/interface/View.h | 3 ++
headers/private/app/ServerProtocol.h | 1 +
src/apps/aboutsystem/AboutSystem.cpp | 27 +++++++++++++----
src/apps/bootmanager/BootManagerWindow.cpp | 8 ++++-
src/apps/bootmanager/WizardPageView.cpp | 20 +++++++++----
src/kits/interface/View.cpp | 41 +++++++++++++++++++++-----
src/servers/app/ProfileMessageSupport.cpp | 1 +
src/servers/app/ServerWindow.cpp | 21 +++++++++++++

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

Commit: 38b8458e58e8f4e96ef1b05f3700c18fd7759fb1
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Mon Sep 28 19:54:43 2015 UTC

AboutSystem, BootManager

AboutSystem
Some issue is preventing the tinting to work right until after the
window is visible, so I did a quick kludge to make it look right.

BootManager
Wow, what a disaster this was with large fonts and dark color scheme!
Text colors properly adjusted for panel colors, though no live
updates - low priority, ATM.
Window was also super small, so it now adjutss based on font size.

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

diff --git a/src/apps/aboutsystem/AboutSystem.cpp
b/src/apps/aboutsystem/AboutSystem.cpp
index 0541217..715851a 100644
--- a/src/apps/aboutsystem/AboutSystem.cpp
+++ b/src/apps/aboutsystem/AboutSystem.cpp
@@ -144,11 +144,16 @@ public:
};


+class AboutView;
+
class AboutWindow : public BWindow {
public:
AboutWindow();

+ virtual void Show();
virtual bool QuitRequested();
+
+ AboutView* fAboutView;
};


@@ -208,11 +213,11 @@ public:
void PickRandomHaiku();


+ void _AdjustTextColors();
private:
typedef std::map<std::string, PackageCredit*> PackageCreditMap;

private:
- void _AdjustTextColors();
BView* _CreateLabel(const char* name,
const char* label);
BView* _CreateCreditsView();
status_t _GetLicensePath(const char*
license,
@@ -272,7 +277,8 @@ AboutWindow::AboutWindow()
B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
{
SetLayout(new BGroupLayout(B_VERTICAL));
- AddChild(new AboutView());
+ fAboutView = new AboutView();
+ AddChild(fAboutView);

// Make sure we take the minimal window size into account when centering
BSize size = GetLayout()->MinSize();
@@ -283,6 +289,17 @@ AboutWindow::AboutWindow()
}


+void
+AboutWindow::Show()
+{
+ // A horrible kludge...
+ BWindow::Show();
+ fAboutView->LockLooper();
+ fAboutView->_AdjustTextColors();
+ fAboutView->UnlockLooper();
+}
+
+
bool
AboutWindow::QuitRequested()
{
@@ -595,8 +612,6 @@ AboutView::AboutView()

float min = fMemView->MinSize().width * 1.1f;
fCreditsView->SetExplicitMinSize(BSize(min, min));
-
- _AdjustTextColors();
}


@@ -619,6 +634,7 @@ AboutView::AttachedToWindow()
Window()->SetPulseRate(500000);
SetEventMask(B_POINTER_EVENTS);
DoLayout();
+ _AdjustTextColors();
}


@@ -850,6 +866,7 @@ AboutView::_AdjustTextColors()
for (int32 index = 0; index < fSubTextViews.CountItems(); ++index) {
view = fSubTextViews.ItemAt(index);
view->SetHighUIColor(B_PANEL_TEXT_COLOR, tint);
+ view->Invalidate();
}

// Labels
@@ -857,8 +874,8 @@ AboutView::_AdjustTextColors()
for (int32 index = 0; index < fTextViews.CountItems(); ++index) {
view = fTextViews.ItemAt(index);
view->SetHighUIColor(B_PANEL_TEXT_COLOR, tint);
+ view->Invalidate();
}
-
}


diff --git a/src/apps/bootmanager/BootManagerWindow.cpp
b/src/apps/bootmanager/BootManagerWindow.cpp
index 813f985..f472fde 100644
--- a/src/apps/bootmanager/BootManagerWindow.cpp
+++ b/src/apps/bootmanager/BootManagerWindow.cpp
@@ -34,7 +34,13 @@ BootManagerWindow::BootManagerWindow()
{
float minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
- SetSizeLimits(250, maxWidth, 250, maxHeight);
+
+ // Use font to determine necessary size of window:
+ const BFont* font = be_plain_font;
+ minWidth = 400 * ((double)font->Size()/12.0f);
+ minHeight = 250 * ((double)font->Size()/12.0f);
+
+ SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);

fWizardView = new WizardView("wizard");
BLayoutBuilder::Group<>(this)
diff --git a/src/apps/bootmanager/WizardPageView.cpp
b/src/apps/bootmanager/WizardPageView.cpp
index 59fe46e..25b6419 100644
--- a/src/apps/bootmanager/WizardPageView.cpp
+++ b/src/apps/bootmanager/WizardPageView.cpp
@@ -21,7 +21,7 @@ WizardPageView::WizardPageView(BMessage* settings, BRect
frame,
BView(frame, name, resizingMode, flags),
fSettings(settings)
{
- SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
}


@@ -30,7 +30,7 @@ WizardPageView::WizardPageView(BMessage* settings, const
char* name)
BView(name, B_WILL_DRAW),
fSettings(settings)
{
- SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
+ SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
}


@@ -54,9 +54,10 @@ WizardPageView::CreateDescription(BRect frame, const char*
name,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS);
view->MakeEditable(false);
- view->SetViewColor(ViewColor());
+ view->SetViewUIColor(ViewUIColor());
view->SetStylable(true);
view->SetText(description);
+
return view;
}

@@ -67,9 +68,10 @@ WizardPageView::CreateDescription(const char* name,
{
BTextView* view = new BTextView("text");
view->MakeEditable(false);
- view->SetViewColor(ViewColor());
+ view->SetViewUIColor(ViewUIColor());
view->SetStylable(true);
view->SetText(description);
+
return view;
}

@@ -84,7 +86,15 @@ WizardPageView::MakeHeading(BTextView* view)
BFont font;
view->GetFont(&font);
font.SetFace(B_BOLD_FACE);
- view->SetFontAndColor(0, indexFirstLineEnd, &font);
+ font.SetSize(font.Size() + 1);
+ rgb_color color = ui_color(B_PANEL_TEXT_COLOR);
+ view->SetFontAndColor(0, indexFirstLineEnd, &font, B_FONT_ALL,
+ &color);
+
+ font.SetFace(B_REGULAR_FACE);
+ font.SetSize(font.Size() - 1);
+ view->SetFontAndColor(indexFirstLineEnd + 1, view->TextLength(),
+ &font, B_FONT_ALL, &color);
}
}


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

Commit: 61b325bf462167f7df5ab8eae61b30643a141a54
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Mon Sep 28 21:15:36 2015 UTC

DelayedInvalidate, Better Layout Color Handling

Added DelayedInvalidate support - seems to work perfectly.

The layout process makes it very difficult to propagate
colors to children, so I figured defaulting the color of
attaching children to B_PANEL_BACKGROUND_COLOR would cover
90% of all use cases, and the other 10% will just require
some TLC. BTW, I'm aware it isn't in the right place...
... relative to when AttachedToWindow is called on the
child. I'll get around to it.

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

diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h
index 0e55cc3..c1381e1 100644
--- a/headers/os/interface/View.h
+++ b/headers/os/interface/View.h
@@ -497,6 +497,9 @@ public:
void Invalidate(BRect
invalRect);
void Invalidate(const
BRegion* invalRegion);
void Invalidate();
+ void
DelayedInvalidate(bigtime_t delay);
+ void
DelayedInvalidate(bigtime_t delay,
+ BRect
invalRect);

void SetDiskMode(char*
filename, long offset);

diff --git a/headers/private/app/ServerProtocol.h
b/headers/private/app/ServerProtocol.h
index 952a611..d791f15 100644
--- a/headers/private/app/ServerProtocol.h
+++ b/headers/private/app/ServerProtocol.h
@@ -309,6 +309,7 @@ enum {
AS_VIEW_COPY_BITS,
AS_VIEW_DRAW_PICTURE,
AS_VIEW_INVALIDATE_RECT,
+ AS_VIEW_DELAYED_INVALIDATE_RECT,
AS_VIEW_INVALIDATE_REGION,
AS_VIEW_INVERT_RECT,
AS_VIEW_MOVE_TO,
diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp
index 5a79d10..ec1bc92 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -4182,6 +4182,35 @@ BView::Invalidate()


void
+BView::DelayedInvalidate(bigtime_t delay)
+{
+ DelayedInvalidate(delay, Bounds());
+}
+
+
+void
+BView::DelayedInvalidate(bigtime_t delay, BRect invalRect)
+{
+ if (fOwner == NULL)
+ return;
+
+ invalRect.left = (int)invalRect.left;
+ invalRect.top = (int)invalRect.top;
+ invalRect.right = (int)invalRect.right;
+ invalRect.bottom = (int)invalRect.bottom;
+ if (!invalRect.IsValid())
+ return;
+
+ _CheckLockAndSwitchCurrent();
+
+ fOwner->fLink->StartMessage(AS_VIEW_DELAYED_INVALIDATE_RECT);
+ fOwner->fLink->Attach<bigtime_t>(delay);
+ fOwner->fLink->Attach<BRect>(invalRect);
+ fOwner->fLink->Flush();
+}
+
+
+void
BView::InvertRect(BRect rect)
{
if (fOwner) {
@@ -4259,6 +4288,9 @@ BView::_AddChild(BView* child, BView* before)
child->_CreateSelf();
child->_Attach();

+ if (fLayoutData->fLayout != NULL)
+ child->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
+
if (lockedOwner)
fOwner->Unlock();
}
@@ -5674,17 +5706,12 @@ BView::_Activate(bool active)
void
BView::_Attach()
{
- // Synchronous colors in case they have changed since this view
- // was previously attached. This is needed for BTabView to
- // update view properly since BTabView, for some reason, removes
- // the views that are not in the current tab, for some reason...
- // Not sure why Be made that choice, Haiku is just stuck with it.
- // For now. (i.e. remove this when that is fixed :p)
+ AttachedToWindow();
+
if (fOwner != NULL
&& !fOwner->IsOffscreenWindow())
_UpdateUIColor(kAllColors);

- AttachedToWindow();
fAttached = true;

// after giving the view a chance to do this itself,
diff --git a/src/servers/app/ProfileMessageSupport.cpp
b/src/servers/app/ProfileMessageSupport.cpp
index 1dbb357..1a5e01e 100644
--- a/src/servers/app/ProfileMessageSupport.cpp
+++ b/src/servers/app/ProfileMessageSupport.cpp
@@ -292,6 +292,7 @@ string_for_message_code(uint32 code, BString& string)
CODE(AS_VIEW_COPY_BITS);
CODE(AS_VIEW_DRAW_PICTURE);
CODE(AS_VIEW_INVALIDATE_RECT);
+ CODE(AS_VIEW_DELAYED_INVALIDATE_RECT);
CODE(AS_VIEW_INVALIDATE_REGION);
CODE(AS_VIEW_INVERT_RECT);
CODE(AS_VIEW_MOVE_TO);
diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp
index 577a47a..410074d 100644
--- a/src/servers/app/ServerWindow.cpp
+++ b/src/servers/app/ServerWindow.cpp
@@ -2058,6 +2058,27 @@ fDesktop->LockSingleWindow();
}
break;
}
+
+ case AS_VIEW_DELAYED_INVALIDATE_RECT:
+ {
+ bigtime_t delay = 0;
+ BRect invalidRect;
+ if (link.Read<bigtime_t>(&delay) == B_OK
+ && link.Read<BRect>(&invalidRect) == B_OK) {
+ DTRACE(("ServerWindow %s: Message
AS_VIEW_DELAYED_INVALIDATE_RECT: "
+ "View: %s -> BRect(%.1f, %.1f, %.1f,
%.1f) in %llu us\n", Title(),
+ fCurrentView->Name(), invalidRect.left,
invalidRect.top,
+ invalidRect.right, invalidRect.bottom,
delay));
+
+ DelayedMessage delayed(AS_VIEW_INVALIDATE_RECT,
delay,
+ DM_MERGE_DUPLICATES);
+
+ if (delayed.Attach<BRect>(invalidRect) == B_OK)
+ ScheduleMessage(delayed);
+ }
+ break;
+ }
+
case AS_VIEW_INVALIDATE_REGION:
{
// NOTE: looks like this call is NOT affected by origin
and scale


Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.setviewuicolor [61b325bf4621] src/kits/interface src/apps/bootmanager src/servers/app src/apps/aboutsystem headers/os/interface - looncraz-github . setviewuicolor