haiku/headers/os/interface/ControlLook.h

460 lines
15 KiB
C
Raw Normal View History

/*
IK: Update scroll bars for alternative control look Scroll bars should look and work identically to before on HaikuControlLook. Add DrawScrollBarButton() and DrawScrollBarThumb() and DrawScrollBarBorder() methods. These methods are used to draw scroll bars in a generic way so that they can be drawn differently by alternative control look's (e.g. BeControlLook). Also it gives us back drawing of scroll bar knobs. However the knob setting is not exposed in the interface in this commit. These methods are in addition to the 2 existing DrawScrollBarBackground() methods that draw the scroll bar background. One draws the area above and below the thumb and the other is called by the first to actually draw the area. The rest of the drawing besides the backgrounds was being done in BScrollBar before. To draw the scroll bar arrows and thumb we were recyling other ControlLook methods, while this worked well enough on HaikuControlLook it wasn't flexible enough for alternative control looks. DrawScrollBarButton() is used to draw the four scroll buttons and is typically (so far) used in combination with DrawArrowShape(). DrawScrollBarThumb() draws the scroll bar thumb. DrawScrollBarBorder() draws a 1px border around the entire scroll bar, potentially B_KEYBOARD_NAVIGATION_COLOR if focused (although this is feature not currently used.) Draw unscrollable scroll bars as if they were disabled including the buttons with their arrow shapes, background, and thumb. Add FBC backwords compatibility macros in ControlLook.cpp Change-Id: I9237c5ce45d17d674785111d51de951e5686306b Reviewed-on: https://review.haiku-os.org/c/haiku/+/351 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-03-04 13:03:47 +03:00
* Copyright 2009-2020 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _CONTROL_LOOK_H
#define _CONTROL_LOOK_H
#include <Alignment.h>
#include <Font.h>
#include <Rect.h>
#include <Slider.h>
class BBitmap;
class BControl;
class BGradientLinear;
class BView;
// WARNING! This is experimental API and may change! Be prepared to
// recompile your software in a next version of haiku.
namespace BPrivate {
class BControlLook {
public:
BControlLook();
virtual ~BControlLook();
// TODO: Probably more convenient to pull these enums into global
// namespace and rename them to e.g. "B_CONTROL_LOOK_FOCUSED" instead of
// "BControlLook::B_FOCUSED".
enum frame_type {
B_BUTTON_FRAME,
B_GROUP_FRAME,
B_MENU_FIELD_FRAME,
B_SCROLL_VIEW_FRAME,
B_TEXT_CONTROL_FRAME,
};
enum background_type {
B_BUTTON_BACKGROUND,
B_BUTTON_WITH_POP_UP_BACKGROUND,
B_MENU_BACKGROUND,
B_MENU_BAR_BACKGROUND,
B_MENU_FIELD_BACKGROUND,
B_MENU_ITEM_BACKGROUND,
B_HORIZONTAL_SCROLL_BAR_BACKGROUND,
B_VERTICAL_SCROLL_BAR_BACKGROUND,
};
enum {
B_LEFT_BORDER = 1 << 0,
B_RIGHT_BORDER = 1 << 1,
B_TOP_BORDER = 1 << 2,
B_BOTTOM_BORDER = 1 << 3,
B_ALL_BORDERS = B_LEFT_BORDER | B_RIGHT_BORDER
| B_TOP_BORDER | B_BOTTOM_BORDER
};
enum {
B_LEFT_ARROW = 0,
B_RIGHT_ARROW = 1,
B_UP_ARROW = 2,
B_DOWN_ARROW = 3,
B_LEFT_UP_ARROW = 4,
B_RIGHT_UP_ARROW = 5,
B_RIGHT_DOWN_ARROW = 6,
B_LEFT_DOWN_ARROW = 7
};
enum {
B_FOCUSED = 1 << 0,
B_CLICKED = 1 << 1, // some controls activate on mouse up
B_ACTIVATED = 1 << 2,
B_HOVER = 1 << 3,
B_DISABLED = 1 << 4,
B_DEFAULT_BUTTON = 1 << 5,
B_IGNORE_OUTLINE = 1 << 6,
B_PARTIALLY_ACTIVATED = 1 << 7, // like B_ACTIVATED, but for tri-state
B_FLAT = 1 << 8, // flat look (e.g. button background)
B_INVALID = 1 << 9, // invalid value, use B_FAILURE_COLOR
Set*UIColor, etc. The inseparable changes necessary to support live color updating across the system in a sane, safe, and performant manner. BView gains: HasSystemColors() HasDefaultColors() AdoptSystemColors() AdoptParentColors() AdoptViewColor(BView*) SetViewUIColor(color_which, float tint) SetHighUIColor(... SetLowUIColor(... ViewUIColor(float* tint) HighUIColor(... LowUIColor(... DelayedInvalidate() BWindow gains a simple helper method: IsOffscreenWindow() BMessage gains: AddColor() FindColor() GetColor() HasColor() * allegedly this API is deprecated, but I implemented it anyway ReplaceColor() SetColor() Previous private ColorTools methods are made public and moved into GraphicsDefs: mix_color, blend_color, disable_color These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup of BeOS example code under the OpenTracker license. In addition, four new colors are created: B_LINK_TEXT_COLOR B_LINK_HOVER_COLOR B_LINK_ACTIVE_COLOR B_LINK_VISITED_COLOR These changes are documented in their proper user documentation files. In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit. On the app_server side, the following has changed: Add DelayedMessage - a system by which messages can be sent at a scheduled time, and can also be merged according to set rules. A single thread is used to service the message queue and multiple recipients can be set for each message. Desktop gains the ability to add message ports to a DelayedMessage so that said messages can target either all applications or all windows, as needed. Desktop maintains a BMessage which is used to queue up all pending color changes and the delayed messaging system is used to enact these changes after a short period of time has passed. This prevents abuse and allows the system to merge repeated set_ui_color events into one event for client applications, improving performance drastically. In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message to each BWindow. This is done to improve performance over having the app_server independently informing each window. Decorator changes are live now, which required some reworking. Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-10 21:52:48 +03:00
B_IS_CONTROL = 1 << 10, // use control colors
B_BLEND_FRAME = 1 << 16,
};
IK: Update scroll bars for alternative control look Scroll bars should look and work identically to before on HaikuControlLook. Add DrawScrollBarButton() and DrawScrollBarThumb() and DrawScrollBarBorder() methods. These methods are used to draw scroll bars in a generic way so that they can be drawn differently by alternative control look's (e.g. BeControlLook). Also it gives us back drawing of scroll bar knobs. However the knob setting is not exposed in the interface in this commit. These methods are in addition to the 2 existing DrawScrollBarBackground() methods that draw the scroll bar background. One draws the area above and below the thumb and the other is called by the first to actually draw the area. The rest of the drawing besides the backgrounds was being done in BScrollBar before. To draw the scroll bar arrows and thumb we were recyling other ControlLook methods, while this worked well enough on HaikuControlLook it wasn't flexible enough for alternative control looks. DrawScrollBarButton() is used to draw the four scroll buttons and is typically (so far) used in combination with DrawArrowShape(). DrawScrollBarThumb() draws the scroll bar thumb. DrawScrollBarBorder() draws a 1px border around the entire scroll bar, potentially B_KEYBOARD_NAVIGATION_COLOR if focused (although this is feature not currently used.) Draw unscrollable scroll bars as if they were disabled including the buttons with their arrow shapes, background, and thumb. Add FBC backwords compatibility macros in ControlLook.cpp Change-Id: I9237c5ce45d17d674785111d51de951e5686306b Reviewed-on: https://review.haiku-os.org/c/haiku/+/351 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-03-04 13:03:47 +03:00
enum {
B_KNOB_NONE = 0,
B_KNOB_DOTS,
B_KNOB_LINES
};
virtual BAlignment DefaultLabelAlignment() const = 0;
virtual float DefaultLabelSpacing() const = 0;
virtual float DefaultItemSpacing() const = 0;
static float ComposeSpacing(float spacing);
static BSize ComposeIconSize(int32 size);
virtual uint32 Flags(BControl* control) const = 0;
virtual void DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect,
float radius,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect,
float leftTopRadius,
float rightTopRadius,
float leftBottomRadius,
float rightBottomRadius,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawButtonBackground(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL) = 0;
virtual void DrawButtonBackground(BView* view, BRect& rect,
const BRect& updateRect,
float radius,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL) = 0;
virtual void DrawButtonBackground(BView* view, BRect& rect,
const BRect& updateRect,
float leftTopRadius,
float rightTopRadius,
float leftBottomRadius,
float rightBottomRadius,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL) = 0;
virtual void DrawMenuBarBackground(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
const BRect& updateRect,
float radius,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawMenuFieldFrame(BView* view, BRect& rect,
const BRect& updateRect,
float leftTopRadius,
float rightTopRadius,
float leftBottomRadius,
float rightBottomRadius,
const rgb_color& base,
const rgb_color& background,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawMenuFieldBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, bool popupIndicator,
uint32 flags = 0) = 0;
virtual void DrawMenuFieldBackground(BView* view,
BRect& rect, const BRect& updateRect,
float radius, const rgb_color& base,
bool popupIndicator, uint32 flags = 0) = 0;
virtual void DrawMenuFieldBackground(BView* view,
BRect& rect, const BRect& updateRect,
float leftTopRadius,
float rightTopRadius,
float leftBottomRadius,
float rightBottomRadius,
const rgb_color& base,
bool popupIndicator, uint32 flags = 0) = 0;
virtual void DrawMenuFieldBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawMenuBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawMenuItemBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawStatusBar(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& barColor,
float progressPosition) = 0;
virtual void DrawCheckBox(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0) = 0;
virtual void DrawRadioButton(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0) = 0;
virtual void DrawScrollBarBackground(BView* view,
BRect& rect1, BRect& rect2,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
orientation orientation) = 0;
virtual void DrawScrollBarBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
orientation orientation) = 0;
virtual void DrawScrollViewFrame(BView* view,
BRect& rect, const BRect& updateRect,
BRect verticalScrollBarFrame,
BRect horizontalScrollBarFrame,
const rgb_color& base,
border_style borderStyle,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawArrowShape(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 direction,
uint32 flags = 0,
float tint = B_DARKEN_MAX_TINT) = 0;
virtual rgb_color SliderBarColor(const rgb_color& base) = 0;
virtual void DrawSliderBar(BView* view, BRect rect,
const BRect& updateRect,
const rgb_color& base,
rgb_color leftFillColor,
rgb_color rightFillColor,
float sliderScale, uint32 flags,
orientation orientation) = 0;
virtual void DrawSliderBar(BView* view, BRect rect,
const BRect& updateRect,
const rgb_color& base, rgb_color fillColor,
uint32 flags, orientation orientation) = 0;
virtual void DrawSliderThumb(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
orientation orientation) = 0;
virtual void DrawSliderTriangle(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
orientation orientation) = 0;
virtual void DrawSliderTriangle(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& fill, uint32 flags,
orientation orientation) = 0;
virtual void DrawSliderHashMarks(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, int32 count,
hash_mark_location location,
uint32 flags, orientation orientation) = 0;
virtual void DrawActiveTab(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
BeControlLook: Fix app integration drawing issues Update BTab::DrawTab() to pass the current index, the index of the selected tab, and the index of the first and last tabs into BControlLook::DrawActiveTab() and BControlLook::DrawInactiveTab(). This allows you to draw tabs differently in your BTab or BControlLook subclass in many different circumstances. Modify BControlLook API to add indexes to DrawActiveTab() and DrawInactiveTab() like so: void DrawActiveTab(..., int32 index = 0, int32 selected = -1, int32 first = 0, int32 last = 0); void DrawInactiveTab(..., int32 index = 0, int32 selected = -1, int32 first = 0, int32 last = 0); These extra indexes are not used by HaikuControlLook which relies only on if the tab is active or inactive to draw. Add IndexOf(BTab* tab) method to BTabView and document it to get the index of the current tab in BTab::DrawTab(). Also add a warning in the BTabView::DrawTab() method not to use the position and full parameters anymore, use BTabView::IndexOf(), BTabView::Selection(), and BTabView::TabCount() to get the info you need. Using a dynamic_cast to a BTabView in BeControlLook to determine if the view is derived from a BTabView didn't work in the case of WebPositive. Furthermore, WebPositive does custom tab drawing which needed to be updated for alternative control look. These index parameters passed from BTab to BeControlLook allow us to draw the tab like BeOS without relying on a dynamic_cast to BTabView to get the info. Reproduce the functionality described above for BTab in WebPositive's custom tabs. Eliminate no longer needed code in favor of using indexes. Update WebPositive custom tabs to use BControlLook::DrawTabFrame() instead of BControlLook::DrawInactiveTab() matching the update made in BTabView. In BeControlLook::DrawTabFrame() fill rect with base color, WebPositive doesn't draw any tab background, so it expects this work to be done for it. Eliminate hasFrames variable from WebPositive. Rename TabSelected(index) to UpdateSelection(index) in WebPositive to better reflect its purpose. Adjusted HaikuControlLook::DrawInactiveTab() to draw the tab borders more selectively. Only draw border if left border is set for top and bottom tabs or top border is set for left and right tabs. Undo no longer needed frame manipulation border drawing workaround in HaikuControlLook::DrawTabFrame(). Draw scroll bar triangle without using DrawArrowShape(). Unlike in HaikuControlLook, DrawArrowShape() is used to draw arrows in BOutlineListView and menus distinctly from how it draws arrows in scroll bars. Draw our distinct arrows in DrawSrollBarButtons() instead. This fixes overflow of time edit up-down arrows in Clock prefs and the collapse-expand arrow in Deskbar not being vertically centered. In DrawBorders() only inset if we actually draw the border. Fix alignment issues with DrawSliderThumb dots for example in MediaPlayer volume knobs. Draw using line arrays calling AddLine instead of StrokeLine in several places. DrawMenuBar() extends to draw final pixel which eliminates an extra lines at the end of menu bars. Truncate button labels better fixing a few issues for example keymap keyboard layout button labels. Button insets has been updated a bit to fix drawing issues with buttons missing a border. Using a dynamic_cast to a BButton to determine if a view is a button in BeControlLook didn't work in the case of the keymap label. Look for B_FLAT, B_HOVER, or B_DEFAULT_BUTTON flag in BeControlLook::DrawLabel() to draw the label inverted on click. Pass the B_FLAT flag from Keymap keys when drawing using BControlLook so that the label is inverted. Change-Id: I07631f4b006bdb9aeca2adc9cbdf2da54dae8e92 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2866 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-02 00:15:29 +03:00
uint32 side = B_TOP_BORDER,
int32 index = 0, int32 selected = -1,
int32 first = 0, int32 last = 0) = 0;
virtual void DrawInactiveTab(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
BeControlLook: Fix app integration drawing issues Update BTab::DrawTab() to pass the current index, the index of the selected tab, and the index of the first and last tabs into BControlLook::DrawActiveTab() and BControlLook::DrawInactiveTab(). This allows you to draw tabs differently in your BTab or BControlLook subclass in many different circumstances. Modify BControlLook API to add indexes to DrawActiveTab() and DrawInactiveTab() like so: void DrawActiveTab(..., int32 index = 0, int32 selected = -1, int32 first = 0, int32 last = 0); void DrawInactiveTab(..., int32 index = 0, int32 selected = -1, int32 first = 0, int32 last = 0); These extra indexes are not used by HaikuControlLook which relies only on if the tab is active or inactive to draw. Add IndexOf(BTab* tab) method to BTabView and document it to get the index of the current tab in BTab::DrawTab(). Also add a warning in the BTabView::DrawTab() method not to use the position and full parameters anymore, use BTabView::IndexOf(), BTabView::Selection(), and BTabView::TabCount() to get the info you need. Using a dynamic_cast to a BTabView in BeControlLook to determine if the view is derived from a BTabView didn't work in the case of WebPositive. Furthermore, WebPositive does custom tab drawing which needed to be updated for alternative control look. These index parameters passed from BTab to BeControlLook allow us to draw the tab like BeOS without relying on a dynamic_cast to BTabView to get the info. Reproduce the functionality described above for BTab in WebPositive's custom tabs. Eliminate no longer needed code in favor of using indexes. Update WebPositive custom tabs to use BControlLook::DrawTabFrame() instead of BControlLook::DrawInactiveTab() matching the update made in BTabView. In BeControlLook::DrawTabFrame() fill rect with base color, WebPositive doesn't draw any tab background, so it expects this work to be done for it. Eliminate hasFrames variable from WebPositive. Rename TabSelected(index) to UpdateSelection(index) in WebPositive to better reflect its purpose. Adjusted HaikuControlLook::DrawInactiveTab() to draw the tab borders more selectively. Only draw border if left border is set for top and bottom tabs or top border is set for left and right tabs. Undo no longer needed frame manipulation border drawing workaround in HaikuControlLook::DrawTabFrame(). Draw scroll bar triangle without using DrawArrowShape(). Unlike in HaikuControlLook, DrawArrowShape() is used to draw arrows in BOutlineListView and menus distinctly from how it draws arrows in scroll bars. Draw our distinct arrows in DrawSrollBarButtons() instead. This fixes overflow of time edit up-down arrows in Clock prefs and the collapse-expand arrow in Deskbar not being vertically centered. In DrawBorders() only inset if we actually draw the border. Fix alignment issues with DrawSliderThumb dots for example in MediaPlayer volume knobs. Draw using line arrays calling AddLine instead of StrokeLine in several places. DrawMenuBar() extends to draw final pixel which eliminates an extra lines at the end of menu bars. Truncate button labels better fixing a few issues for example keymap keyboard layout button labels. Button insets has been updated a bit to fix drawing issues with buttons missing a border. Using a dynamic_cast to a BButton to determine if a view is a button in BeControlLook didn't work in the case of the keymap label. Look for B_FLAT, B_HOVER, or B_DEFAULT_BUTTON flag in BeControlLook::DrawLabel() to draw the label inverted on click. Pass the B_FLAT flag from Keymap keys when drawing using BControlLook so that the label is inverted. Change-Id: I07631f4b006bdb9aeca2adc9cbdf2da54dae8e92 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2866 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-02 00:15:29 +03:00
uint32 side = B_TOP_BORDER,
int32 index = 0, int32 selected = -1,
int32 first = 0, int32 last = 0) = 0;
virtual void DrawSplitter(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
orientation orientation,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
// various borders
virtual void DrawBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
border_style borderStyle, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawRaisedBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawGroupFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 borders = B_ALL_BORDERS) = 0;
virtual void DrawTextControlBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS) = 0;
// aligned labels
virtual void DrawLabel(BView* view, const char* label,
BRect rect, const BRect& updateRect,
Set*UIColor, etc. The inseparable changes necessary to support live color updating across the system in a sane, safe, and performant manner. BView gains: HasSystemColors() HasDefaultColors() AdoptSystemColors() AdoptParentColors() AdoptViewColor(BView*) SetViewUIColor(color_which, float tint) SetHighUIColor(... SetLowUIColor(... ViewUIColor(float* tint) HighUIColor(... LowUIColor(... DelayedInvalidate() BWindow gains a simple helper method: IsOffscreenWindow() BMessage gains: AddColor() FindColor() GetColor() HasColor() * allegedly this API is deprecated, but I implemented it anyway ReplaceColor() SetColor() Previous private ColorTools methods are made public and moved into GraphicsDefs: mix_color, blend_color, disable_color These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup of BeOS example code under the OpenTracker license. In addition, four new colors are created: B_LINK_TEXT_COLOR B_LINK_HOVER_COLOR B_LINK_ACTIVE_COLOR B_LINK_VISITED_COLOR These changes are documented in their proper user documentation files. In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit. On the app_server side, the following has changed: Add DelayedMessage - a system by which messages can be sent at a scheduled time, and can also be merged according to set rules. A single thread is used to service the message queue and multiple recipients can be set for each message. Desktop gains the ability to add message ports to a DelayedMessage so that said messages can target either all applications or all windows, as needed. Desktop maintains a BMessage which is used to queue up all pending color changes and the delayed messaging system is used to enact these changes after a short period of time has passed. This prevents abuse and allows the system to merge repeated set_ui_color events into one event for client applications, improving performance drastically. In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message to each BWindow. This is done to improve performance over having the app_server independently informing each window. Decorator changes are live now, which required some reworking. Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-10 21:52:48 +03:00
const rgb_color& base, uint32 flags,
const rgb_color* textColor = NULL) = 0;
virtual void DrawLabel(BView* view, const char* label,
BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
Set*UIColor, etc. The inseparable changes necessary to support live color updating across the system in a sane, safe, and performant manner. BView gains: HasSystemColors() HasDefaultColors() AdoptSystemColors() AdoptParentColors() AdoptViewColor(BView*) SetViewUIColor(color_which, float tint) SetHighUIColor(... SetLowUIColor(... ViewUIColor(float* tint) HighUIColor(... LowUIColor(... DelayedInvalidate() BWindow gains a simple helper method: IsOffscreenWindow() BMessage gains: AddColor() FindColor() GetColor() HasColor() * allegedly this API is deprecated, but I implemented it anyway ReplaceColor() SetColor() Previous private ColorTools methods are made public and moved into GraphicsDefs: mix_color, blend_color, disable_color These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup of BeOS example code under the OpenTracker license. In addition, four new colors are created: B_LINK_TEXT_COLOR B_LINK_HOVER_COLOR B_LINK_ACTIVE_COLOR B_LINK_VISITED_COLOR These changes are documented in their proper user documentation files. In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit. On the app_server side, the following has changed: Add DelayedMessage - a system by which messages can be sent at a scheduled time, and can also be merged according to set rules. A single thread is used to service the message queue and multiple recipients can be set for each message. Desktop gains the ability to add message ports to a DelayedMessage so that said messages can target either all applications or all windows, as needed. Desktop maintains a BMessage which is used to queue up all pending color changes and the delayed messaging system is used to enact these changes after a short period of time has passed. This prevents abuse and allows the system to merge repeated set_ui_color events into one event for client applications, improving performance drastically. In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message to each BWindow. This is done to improve performance over having the app_server independently informing each window. Decorator changes are live now, which required some reworking. Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-10 21:52:48 +03:00
const BAlignment& alignment,
const rgb_color* textColor = NULL) = 0;
// TODO: Would be nice to have a (non-virtual) version of this method
// which takes an array of labels and locations. That would save some
// setup with the view graphics state.
virtual void DrawLabel(BView* view, const char* label,
const rgb_color& base, uint32 flags,
Set*UIColor, etc. The inseparable changes necessary to support live color updating across the system in a sane, safe, and performant manner. BView gains: HasSystemColors() HasDefaultColors() AdoptSystemColors() AdoptParentColors() AdoptViewColor(BView*) SetViewUIColor(color_which, float tint) SetHighUIColor(... SetLowUIColor(... ViewUIColor(float* tint) HighUIColor(... LowUIColor(... DelayedInvalidate() BWindow gains a simple helper method: IsOffscreenWindow() BMessage gains: AddColor() FindColor() GetColor() HasColor() * allegedly this API is deprecated, but I implemented it anyway ReplaceColor() SetColor() Previous private ColorTools methods are made public and moved into GraphicsDefs: mix_color, blend_color, disable_color These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup of BeOS example code under the OpenTracker license. In addition, four new colors are created: B_LINK_TEXT_COLOR B_LINK_HOVER_COLOR B_LINK_ACTIVE_COLOR B_LINK_VISITED_COLOR These changes are documented in their proper user documentation files. In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit. On the app_server side, the following has changed: Add DelayedMessage - a system by which messages can be sent at a scheduled time, and can also be merged according to set rules. A single thread is used to service the message queue and multiple recipients can be set for each message. Desktop gains the ability to add message ports to a DelayedMessage so that said messages can target either all applications or all windows, as needed. Desktop maintains a BMessage which is used to queue up all pending color changes and the delayed messaging system is used to enact these changes after a short period of time has passed. This prevents abuse and allows the system to merge repeated set_ui_color events into one event for client applications, improving performance drastically. In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message to each BWindow. This is done to improve performance over having the app_server independently informing each window. Decorator changes are live now, which required some reworking. Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-10 21:52:48 +03:00
const BPoint& where,
const rgb_color* textColor = NULL) = 0;
void DrawLabel(BView* view, const char* label,
const BBitmap* icon, BRect rect,
const BRect& updateRect,
Set*UIColor, etc. The inseparable changes necessary to support live color updating across the system in a sane, safe, and performant manner. BView gains: HasSystemColors() HasDefaultColors() AdoptSystemColors() AdoptParentColors() AdoptViewColor(BView*) SetViewUIColor(color_which, float tint) SetHighUIColor(... SetLowUIColor(... ViewUIColor(float* tint) HighUIColor(... LowUIColor(... DelayedInvalidate() BWindow gains a simple helper method: IsOffscreenWindow() BMessage gains: AddColor() FindColor() GetColor() HasColor() * allegedly this API is deprecated, but I implemented it anyway ReplaceColor() SetColor() Previous private ColorTools methods are made public and moved into GraphicsDefs: mix_color, blend_color, disable_color These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup of BeOS example code under the OpenTracker license. In addition, four new colors are created: B_LINK_TEXT_COLOR B_LINK_HOVER_COLOR B_LINK_ACTIVE_COLOR B_LINK_VISITED_COLOR These changes are documented in their proper user documentation files. In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit. On the app_server side, the following has changed: Add DelayedMessage - a system by which messages can be sent at a scheduled time, and can also be merged according to set rules. A single thread is used to service the message queue and multiple recipients can be set for each message. Desktop gains the ability to add message ports to a DelayedMessage so that said messages can target either all applications or all windows, as needed. Desktop maintains a BMessage which is used to queue up all pending color changes and the delayed messaging system is used to enact these changes after a short period of time has passed. This prevents abuse and allows the system to merge repeated set_ui_color events into one event for client applications, improving performance drastically. In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message to each BWindow. This is done to improve performance over having the app_server independently informing each window. Decorator changes are live now, which required some reworking. Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-10 21:52:48 +03:00
const rgb_color& base, uint32 flags,
const rgb_color* textColor = NULL);
virtual void DrawLabel(BView* view, const char* label,
const BBitmap* icon, BRect rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
Set*UIColor, etc. The inseparable changes necessary to support live color updating across the system in a sane, safe, and performant manner. BView gains: HasSystemColors() HasDefaultColors() AdoptSystemColors() AdoptParentColors() AdoptViewColor(BView*) SetViewUIColor(color_which, float tint) SetHighUIColor(... SetLowUIColor(... ViewUIColor(float* tint) HighUIColor(... LowUIColor(... DelayedInvalidate() BWindow gains a simple helper method: IsOffscreenWindow() BMessage gains: AddColor() FindColor() GetColor() HasColor() * allegedly this API is deprecated, but I implemented it anyway ReplaceColor() SetColor() Previous private ColorTools methods are made public and moved into GraphicsDefs: mix_color, blend_color, disable_color These are fully compatible with BeOS dan0 R5.1 methods and are just code cleanup of BeOS example code under the OpenTracker license. In addition, four new colors are created: B_LINK_TEXT_COLOR B_LINK_HOVER_COLOR B_LINK_ACTIVE_COLOR B_LINK_VISITED_COLOR These changes are documented in their proper user documentation files. In addition, due to a history rewrite, B_FOLLOW_LEFT_TOP has been defined and used in lieu of B_FOLLOW_TOP | B_FOLLOW_LEFT and is included in this commit. On the app_server side, the following has changed: Add DelayedMessage - a system by which messages can be sent at a scheduled time, and can also be merged according to set rules. A single thread is used to service the message queue and multiple recipients can be set for each message. Desktop gains the ability to add message ports to a DelayedMessage so that said messages can target either all applications or all windows, as needed. Desktop maintains a BMessage which is used to queue up all pending color changes and the delayed messaging system is used to enact these changes after a short period of time has passed. This prevents abuse and allows the system to merge repeated set_ui_color events into one event for client applications, improving performance drastically. In addition, B_COLORS_UPDATED is sent to the BApplication, which forwards the message to each BWindow. This is done to improve performance over having the app_server independently informing each window. Decorator changes are live now, which required some reworking. Signed-off-by: Augustin Cavalier <waddlesplash@gmail.com>
2015-12-10 21:52:48 +03:00
const BAlignment& alignment,
const rgb_color* textColor = NULL) = 0;
virtual void GetFrameInsets(frame_type frameType,
uint32 flags, float& _left, float& _top,
float& _right, float& _bottom) = 0;
virtual void GetBackgroundInsets(
background_type backgroundType,
uint32 flags, float& _left, float& _top,
float& _right, float& _bottom) = 0;
void GetInsets(frame_type frameType,
background_type backgroundType,
uint32 flags, float& _left, float& _top,
float& _right, float& _bottom);
virtual void DrawButtonWithPopUpBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL) = 0;
virtual void DrawButtonWithPopUpBackground(BView* view,
BRect& rect, const BRect& updateRect,
float radius,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL) = 0;
virtual void DrawButtonWithPopUpBackground(BView* view,
BRect& rect, const BRect& updateRect,
float leftTopRadius,
float rightTopRadius,
float leftBottomRadius,
float rightBottomRadius,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
orientation orientation = B_HORIZONTAL) = 0;
void SetBackgroundInfo(
const BMessage& backgroundInfo);
virtual void DrawTabFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
border_style borderStyle = B_FANCY_BORDER,
uint32 side = B_TOP_BORDER) = 0;
IK: Update scroll bars for alternative control look Scroll bars should look and work identically to before on HaikuControlLook. Add DrawScrollBarButton() and DrawScrollBarThumb() and DrawScrollBarBorder() methods. These methods are used to draw scroll bars in a generic way so that they can be drawn differently by alternative control look's (e.g. BeControlLook). Also it gives us back drawing of scroll bar knobs. However the knob setting is not exposed in the interface in this commit. These methods are in addition to the 2 existing DrawScrollBarBackground() methods that draw the scroll bar background. One draws the area above and below the thumb and the other is called by the first to actually draw the area. The rest of the drawing besides the backgrounds was being done in BScrollBar before. To draw the scroll bar arrows and thumb we were recyling other ControlLook methods, while this worked well enough on HaikuControlLook it wasn't flexible enough for alternative control looks. DrawScrollBarButton() is used to draw the four scroll buttons and is typically (so far) used in combination with DrawArrowShape(). DrawScrollBarThumb() draws the scroll bar thumb. DrawScrollBarBorder() draws a 1px border around the entire scroll bar, potentially B_KEYBOARD_NAVIGATION_COLOR if focused (although this is feature not currently used.) Draw unscrollable scroll bars as if they were disabled including the buttons with their arrow shapes, background, and thumb. Add FBC backwords compatibility macros in ControlLook.cpp Change-Id: I9237c5ce45d17d674785111d51de951e5686306b Reviewed-on: https://review.haiku-os.org/c/haiku/+/351 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-03-04 13:03:47 +03:00
virtual void DrawScrollBarButton(BView* view,
BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
int32 direction, orientation orientation,
bool down = false) = 0;
virtual void DrawScrollBarThumb(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
orientation orientation,
uint32 knobStyle = B_KNOB_NONE) = 0;
virtual void DrawScrollBarBorder(BView* view,
BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
orientation orientation) = 0;
virtual float GetScrollBarWidth(
orientation orientation = B_VERTICAL);
IK: Update scroll bars for alternative control look Scroll bars should look and work identically to before on HaikuControlLook. Add DrawScrollBarButton() and DrawScrollBarThumb() and DrawScrollBarBorder() methods. These methods are used to draw scroll bars in a generic way so that they can be drawn differently by alternative control look's (e.g. BeControlLook). Also it gives us back drawing of scroll bar knobs. However the knob setting is not exposed in the interface in this commit. These methods are in addition to the 2 existing DrawScrollBarBackground() methods that draw the scroll bar background. One draws the area above and below the thumb and the other is called by the first to actually draw the area. The rest of the drawing besides the backgrounds was being done in BScrollBar before. To draw the scroll bar arrows and thumb we were recyling other ControlLook methods, while this worked well enough on HaikuControlLook it wasn't flexible enough for alternative control looks. DrawScrollBarButton() is used to draw the four scroll buttons and is typically (so far) used in combination with DrawArrowShape(). DrawScrollBarThumb() draws the scroll bar thumb. DrawScrollBarBorder() draws a 1px border around the entire scroll bar, potentially B_KEYBOARD_NAVIGATION_COLOR if focused (although this is feature not currently used.) Draw unscrollable scroll bars as if they were disabled including the buttons with their arrow shapes, background, and thumb. Add FBC backwords compatibility macros in ControlLook.cpp Change-Id: I9237c5ce45d17d674785111d51de951e5686306b Reviewed-on: https://review.haiku-os.org/c/haiku/+/351 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-03-04 13:03:47 +03:00
private:
// FBC padding
virtual void _ReservedControlLook6();
virtual void _ReservedControlLook7();
virtual void _ReservedControlLook8();
virtual void _ReservedControlLook9();
virtual void _ReservedControlLook10();
protected:
int32 fCachedWorkspace;
BMessage fBackgroundInfo;
uint32 _reserved[20];
};
extern BControlLook* be_control_look;
extern "C" _EXPORT BControlLook *instantiate_control_look(image_id id);
} // namespace BPrivate
using BPrivate::BControlLook;
using BPrivate::be_control_look;
#endif // _CONTROL_LOOK_H