[haiku-commits] BRANCH looncraz-github.fontaware [d98da8d56289] src/kits/app headers/os/app src/kits/interface headers/os/interface

  • From: looncraz-github.fontaware <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 30 Oct 2015 21:17:01 +0100 (CET)

added 1 changeset to branch 'refs/remotes/looncraz-github/fontaware'
old head: 0ca86935494e6719cfa61610456e43aefd727d6a
new head: d98da8d56289ec4994721e718c63f2aad45a15b3
overview: https://github.com/looncraz/haiku/compare/0ca86935494e...d98da8d56289

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

d98da8d56289: Get rid of B_FONT_AWARE

BWindow gets B_NO_FONT_UPDATES
BApplication receives the initial facilities to control the fonts and
colors in use by the application. This will be externally accessible
to permit applications to use the system frameworks for color and font
handling and updates with the utmost of freedom as well as to enable
a blacklist of applications which will use a predefined font or color
scheme (i.e., closed source apps that do not behave well with large
fonts or custom colors can be forced to use the expected values).

[ looncraz <looncraz@xxxxxxxxxxxx> ]

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

Commit: d98da8d56289ec4994721e718c63f2aad45a15b3
Author: looncraz <looncraz@xxxxxxxxxxxx>
Date: Fri Oct 30 20:00:52 2015 UTC

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

6 files changed, 89 insertions(+), 20 deletions(-)
headers/os/app/Application.h | 11 ++++-
headers/os/interface/View.h | 1 -
headers/os/interface/Window.h | 3 +-
src/kits/app/Application.cpp | 87 ++++++++++++++++++++++++++++++++-------
src/kits/interface/View.cpp | 4 +-
src/kits/interface/Window.cpp | 3 ++

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

diff --git a/headers/os/app/Application.h b/headers/os/app/Application.h
index 898960f..3a0d770 100644
--- a/headers/os/app/Application.h
+++ b/headers/os/app/Application.h
@@ -14,7 +14,9 @@
#include <Rect.h>


+class BColorMap;
class BCursor;
+class BFont;
class BList;
class BLocker;
class BMessageRunner;
@@ -85,13 +87,19 @@ public:

BHandler* handler);
void SetPulseRate(bigtime_t
rate);

- // Application-wide font/color update options
+ // Application-wide font handling
void
SetFontUpdatesEnabled(bool enabled);
bool FontUpdatesEnabled()
const;

+ void SetAppFont(font_which
which,
+ const
BFont* font);
+
+ // Application-wide color handling
void
SetColorUpdatesEnabled(bool enabled);
bool ColorUpdatesEnabled()
const;

+ void SetAppColors(const
BColorMap* colors);
+
// More scripting
virtual status_t GetSupportedSuites(BMessage*
data);

@@ -129,6 +137,7 @@ private:
void _InitData(const char*
signature, bool initGUI,

status_t* error);
port_id _GetPort(const char*
signature);
+ void
_BroadcastMessage(BMessage* message);
void BeginRectTracking(BRect
r, bool trackWhole);
void EndRectTracking();
status_t _SetupServerAllocator();
diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h
index 0aafae1..1574ba3 100644
--- a/headers/os/interface/View.h
+++ b/headers/os/interface/View.h
@@ -80,7 +80,6 @@ const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL;
/* 23 */
const uint32 _B_RESERVED7_ = 0x00200000UL; /* 22 */
const uint32 B_SUPPORTS_LAYOUT = 0x00100000UL; /* 21 */
const uint32 B_INVALIDATE_AFTER_LAYOUT = 0x00080000UL; /* 20 */
-const uint32 B_FONT_AWARE = 0x00040000UL; /* 19 */

#define _RESIZE_MASK_ (0xffff)

diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h
index c59a549..69e6830 100644
--- a/headers/os/interface/Window.h
+++ b/headers/os/interface/Window.h
@@ -77,7 +77,8 @@ enum {
B_SAME_POSITION_IN_ALL_WORKSPACES = 0x00200000,
B_AUTO_UPDATE_SIZE_LIMITS = 0x00400000,
B_CLOSE_ON_ESCAPE = 0x00800000,
- B_NO_SERVER_SIDE_WINDOW_MODIFIERS = 0x00000200
+ B_NO_SERVER_SIDE_WINDOW_MODIFIERS = 0x00000200,
+ B_NO_FONT_UPDATES = 0x01000000
};

#define B_CURRENT_WORKSPACE 0
diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp
index 8655e5b..17e5a1f 100644
--- a/src/kits/app/Application.cpp
+++ b/src/kits/app/Application.cpp
@@ -75,9 +75,9 @@ enum {


enum {
- kNoInternalFlags = 0,
- kNoFontUpdates = 1 << 0,
- kNoColorUpdates = 1 << 1
+ kNoInternalFlags = 0,
+ kNoFontUpdates = 1 << 0,
+ kNoColorUpdates = 1 << 1
};


@@ -1088,18 +1088,7 @@ BApplication::DispatchMessage(BMessage* message,
BHandler* handler)
else
break;

- AutoLocker<BLooperList> listLock(gLooperList);
- if (!listLock.IsLocked())
- break;
-
- BWindow* window = NULL;
- uint32 count = gLooperList.CountLoopers();
- for (uint32 index = 0; index < count; ++index) {
- window =
dynamic_cast<BWindow*>(gLooperList.LooperAt(index));
- if (window == NULL || (window != NULL &&
window->fOffscreen))
- continue;
- window->PostMessage(message);
- }
+ _BroadcastMessage(message);
break;
}

@@ -1175,6 +1164,40 @@ BApplication::FontUpdatesEnabled() const


void
+BApplication::SetAppFont(font_which which, const BFont* font)
+{
+ if (font == NULL)
+ return;
+
+ BMessage message(B_FONTS_UPDATED);
+ message.AddInt32("which", (int32)which);
+
+ BFont* sysFont = NULL;
+
+ switch (which) {
+ case B_PLAIN_FONT:
+ sysFont = const_cast<BFont*>(be_plain_font);
+ break;
+ case B_BOLD_FONT:
+ sysFont = const_cast<BFont*>(be_bold_font);
+ break;
+ case B_FIXED_FONT:
+ sysFont = const_cast<BFont*>(be_fixed_font);
+ break;
+ case B_MENU_FONT:
+ // TODO: be_menu_font global
+ default:
+ break;
+ }
+
+ if (sysFont != NULL) {
+ *sysFont = font;
+ _BroadcastMessage(&message);
+ }
+}
+
+
+void
BApplication::SetColorUpdatesEnabled(bool enabled)
{
if (enabled)
@@ -1191,6 +1214,19 @@ BApplication::ColorUpdatesEnabled() const
}


+void
+BApplication::SetAppColors(const BColorMap* colors)
+{
+ if (colors == NULL)
+ return;
+
+ // TODO: (ui_color needs a little love)
+ // It is also feasible that applications will want to use color keys
that
+ // are not system constants, so we must take that into account and not
be
+ // overly restrictive.
+}
+
+
status_t
BApplication::GetSupportedSuites(BMessage* data)
{
@@ -1369,6 +1405,27 @@ BApplication::ScriptReceived(BMessage* message, int32
index,


void
+BApplication::_BroadcastMessage(BMessage* message)
+{
+ if (message == NULL)
+ return;
+
+ AutoLocker<BLooperList> listLock(gLooperList);
+ if (!listLock.IsLocked())
+ return;
+
+ BWindow* window = NULL;
+ uint32 count = gLooperList.CountLoopers();
+ for (uint32 index = 0; index < count; ++index) {
+ window = dynamic_cast<BWindow*>(gLooperList.LooperAt(index));
+ if (window == NULL || (window != NULL && window->fOffscreen))
+ continue;
+ window->PostMessage(message);
+ }
+}
+
+
+void
BApplication::BeginRectTracking(BRect rect, bool trackWhole)
{
BPrivate::AppServerLink link;
diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp
index a7b52c7..9e2006e 100644
--- a/src/kits/interface/View.cpp
+++ b/src/kits/interface/View.cpp
@@ -410,7 +410,7 @@ BView::BView(const char* name, uint32 flags, BLayout*
layout)
BHandler(name)
{
_InitData(BRect(0, 0, 0, 0), name, B_FOLLOW_NONE,
- flags | B_SUPPORTS_LAYOUT | B_FONT_AWARE);
+ flags | B_SUPPORTS_LAYOUT);
SetLayout(layout);
}

@@ -6059,7 +6059,7 @@ void
BView::_FontsUpdated(BMessage* message)
{
font_which which = B_UNKNOWN_FONT;
- if ((Flags() & B_FONT_AWARE) != 0 && fState->which_font !=
B_UNKNOWN_FONT
+ if (fState->which_font != B_UNKNOWN_FONT
&& message->FindInt32("which", (int32*)&which) == B_OK
&& fState->which_font == which) {

diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp
index 762c706..26894f7 100644
--- a/src/kits/interface/Window.cpp
+++ b/src/kits/interface/Window.cpp
@@ -1449,6 +1449,9 @@ FrameMoved(origin);

case B_FONTS_UPDATED:
{
+ if ((Flags() & B_NO_FONT_UPDATES) != 0)
+ break;
+
fTopView->_FontsUpdated(message);
target->MessageReceived(message);
break;


Other related posts:

  • » [haiku-commits] BRANCH looncraz-github.fontaware [d98da8d56289] src/kits/app headers/os/app src/kits/interface headers/os/interface - looncraz-github . fontaware