Add BIconUtils::GetSystemIcon

Allow to easily access the alert icons and anything that's added to app_server
resources.

Fixes #10887.

Convert BAlert, Debugger AlertWithCheckbox and Keymap ModifierKeysWindow
to make use of it, removing the duplicate code to locate app_server
resources.

The resources are initialized only once (per application), so there is no need
to reload them for every access to the icons.

In the ticket there is discussion about putting this in BControlLook,
but I think this should in fact be moved fully into app_server with
special drawing commands for well-known icons. That would avoid loading
and rendering the icon on the application side to then send it to
app_server (especially in remote_app_server case)?

In any case, this simple API can serve as a base for applications to
use, and we can change how it is implemented later on.

Change-Id: Id370526ae5cf165cfb8bc277bc8a7f46c26f542d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6463
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
PulkoMandy
2023-05-24 10:58:48 +00:00
committed by Adrien Destugues
parent 13f2f8de06
commit 4dbd474753
11 changed files with 430 additions and 579 deletions
+30 -4
View File
@@ -1,13 +1,13 @@
/*
* Copyright 2011 Haiku, Inc. All rights reserved.
* Copyright 2011-2023 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Adrien Destugues, pulkomandy@pulkomandy.ath.cx
* Adrien Destugues, pulkomandy@pulkomandy.tk
*
* Corresponds to:
* headers/os/interface/IconUtils.h rev 42600
* src/kits/interface/IconUtils.cpp rev 42600
* headers/os/interface/IconUtils.h hrev57019
* src/kits/interface/IconUtils.cpp hrev57019
*/
@@ -114,6 +114,32 @@
*/
/*
\fn static status_t BIconUtils::GetSystemIcon(const char* iconName, BBitmap* result)
\brief Load an icon from the set of system icons.
To provide some uniformity between different applications, a base set of icons is provided
with Haiku. Whenever possible, these should be used instead of application specific icons,
to ensure consistency and ease of discovering application functions.
The available icons follow the FreeDesktop icon-naming-spec convention. At this time the
following icons are available:
- Flag icons for 245 countries
- dialog-error, dialog-information, and dialog-warning
- As an extension not available in FreeDesktop specifications, dialog-idea is also available
and corresponds to the icon used in BAlert of type B_IDEA_ALERT.
The icon is automatically scaled to fit the \a result bitmap, which must be allocated and
valid before calling this function.
\return B_OK if the icon could be loaded into the \a result BBitmap. B_ENTRY_NOT_FOUND if the
requested icon is not currently available.
\since Haiku R1
*/
/*!
\fn static status_t BIconUtils::ConvertFromCMAP8(BBitmap* source,
BBitmap* result)