From cfc3fa87da824bdf593eb8b817a83b6376e77935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 9 Apr 2008 10:07:35 +0000 Subject: [PATCH] * Cleaned up InterfaceDefs.h, added TODO about getting rid of declaring _init_interface_kit_() in there. * Moved private get_mode_parameter() into the BPrivate namespace. * Renamed interface_misc.h to InterfacePrivate.h. * Minor other cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24869 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/InterfaceDefs.h | 323 ++++++++++--------- headers/private/interface/InterfacePrivate.h | 23 ++ headers/private/interface/interface_misc.h | 20 -- src/kits/app/Application.cpp | 53 +-- src/kits/game/WindowScreen.cpp | 26 +- src/kits/interface/InterfaceDefs.cpp | 44 +-- 6 files changed, 250 insertions(+), 239 deletions(-) create mode 100644 headers/private/interface/InterfacePrivate.h delete mode 100644 headers/private/interface/interface_misc.h diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index 04f3d76794..4c4158ea39 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2006, Haiku, Inc. + * Copyright (c) 2001-2008, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: @@ -34,7 +34,7 @@ class BRect; #endif -// key definitions +// Key definitions struct key_info { uint32 modifiers; @@ -119,88 +119,6 @@ struct key_map { uint32 tilde_tables; }; -struct mouse_map { - uint32 button[B_MAX_MOUSE_BUTTONS]; -}; - - -/*----------------------------------------------------------------*/ - -enum border_style { - B_PLAIN_BORDER, - B_FANCY_BORDER, - B_NO_BORDER -}; - -/*----------------------------------------------------------------*/ - -enum orientation { - B_HORIZONTAL, - B_VERTICAL -}; - -/*----------------------------------------------------------------*/ - -enum button_width { - B_WIDTH_AS_USUAL, - B_WIDTH_FROM_WIDEST, - B_WIDTH_FROM_LABEL -}; - -/*----------------------------------------------------------------*/ - -enum join_mode { - B_ROUND_JOIN = 0, - B_MITER_JOIN, - B_BEVEL_JOIN, - B_BUTT_JOIN, - B_SQUARE_JOIN -}; - -enum cap_mode { - B_ROUND_CAP=B_ROUND_JOIN, - B_BUTT_CAP=B_BUTT_JOIN, - B_SQUARE_CAP=B_SQUARE_JOIN -}; - -const float B_DEFAULT_MITER_LIMIT = 10.0F; - -/*----------------------------------------------------------------*/ - -struct scroll_bar_info { - bool proportional; - bool double_arrows; - int32 knob; - int32 min_knob_size; -}; - -/*----------------------------------------------------------------*/ - -enum alignment { - B_ALIGN_LEFT, - B_ALIGN_RIGHT, - B_ALIGN_CENTER, - - B_ALIGN_HORIZONTAL_CENTER = B_ALIGN_CENTER, - - B_ALIGN_HORIZONTAL_UNSET = -1L, - B_ALIGN_USE_FULL_WIDTH = -2L -}; - -enum vertical_alignment { - B_ALIGN_TOP = 0x10L, - B_ALIGN_MIDDLE = 0x20, - B_ALIGN_BOTTOM = 0x30, - - B_ALIGN_VERTICAL_CENTER = B_ALIGN_MIDDLE, - - B_ALIGN_VERTICAL_UNSET = -1L, - B_ALIGN_NO_VERTICAL = B_ALIGN_VERTICAL_UNSET, - B_ALIGN_USE_FULL_HEIGHT = -2L -}; - -/*----------------------------------------------------------------*/ - enum { B_CONTROL_TABLE = 0x00000001, B_OPTION_CAPS_SHIFT_TABLE = 0x00000002, @@ -213,8 +131,7 @@ enum { B_NORMAL_TABLE = 0x00000100 }; -/*----------------------------------------------------------------*/ - +// modifiers enum { B_SHIFT_KEY = 0x00000001, B_COMMAND_KEY = 0x00000002, @@ -234,7 +151,91 @@ enum { B_RIGHT_OPTION_KEY = 0x00008000 }; -/*----------------------------------------------------------------*/ + +// Mouse definitions + +struct mouse_map { + uint32 button[B_MAX_MOUSE_BUTTONS]; +}; + +enum mode_mouse { + B_NORMAL_MOUSE = 0, + B_FOCUS_FOLLOWS_MOUSE = 1, + B_WARP_MOUSE = 3, + B_INSTANT_WARP_MOUSE = 7 +}; + + +// View orientation/alignment/style + +enum border_style { + B_PLAIN_BORDER, + B_FANCY_BORDER, + B_NO_BORDER +}; + +enum orientation { + B_HORIZONTAL, + B_VERTICAL +}; + +enum button_width { + B_WIDTH_AS_USUAL, + B_WIDTH_FROM_WIDEST, + B_WIDTH_FROM_LABEL +}; + +struct scroll_bar_info { + bool proportional; + bool double_arrows; + int32 knob; + int32 min_knob_size; +}; + +enum alignment { + B_ALIGN_LEFT, + B_ALIGN_RIGHT, + B_ALIGN_CENTER, + + B_ALIGN_HORIZONTAL_CENTER = B_ALIGN_CENTER, + + B_ALIGN_HORIZONTAL_UNSET = -1L, + B_ALIGN_USE_FULL_WIDTH = -2L +}; + +enum vertical_alignment { + B_ALIGN_TOP = 0x10L, + B_ALIGN_MIDDLE = 0x20, + B_ALIGN_BOTTOM = 0x30, + + B_ALIGN_VERTICAL_CENTER = B_ALIGN_MIDDLE, + + B_ALIGN_VERTICAL_UNSET = -1L, + B_ALIGN_NO_VERTICAL = B_ALIGN_VERTICAL_UNSET, + B_ALIGN_USE_FULL_HEIGHT = -2L +}; + + +// Line join and cap modes + +enum join_mode { + B_ROUND_JOIN = 0, + B_MITER_JOIN, + B_BEVEL_JOIN, + B_BUTT_JOIN, + B_SQUARE_JOIN +}; + +enum cap_mode { + B_ROUND_CAP = B_ROUND_JOIN, + B_BUTT_CAP = B_BUTT_JOIN, + B_SQUARE_CAP = B_SQUARE_JOIN +}; + +const float B_DEFAULT_MITER_LIMIT = 10.0F; + + +// Bitmap and overlay constants enum bitmap_tiling { B_TILE_BITMAP_X = 0x00000001, @@ -249,66 +250,8 @@ enum overlay_options { B_OVERLAY_TRANSFER_CHANNEL = 0x00080000 }; -/*----------------------------------------------------------------*/ -status_t get_deskbar_frame(BRect *frame); - -const color_map *system_colors(); - -status_t set_screen_space(int32 index, uint32 res, - bool stick = true); - -status_t get_scroll_bar_info(scroll_bar_info *info); -status_t set_scroll_bar_info(scroll_bar_info *info); - -status_t get_mouse_type(int32 *type); -status_t set_mouse_type(int32 type); -status_t get_mouse_map(mouse_map *map); -status_t set_mouse_map(mouse_map *map); -status_t get_click_speed(bigtime_t *speed); -status_t set_click_speed(bigtime_t speed); -status_t get_mouse_speed(int32 *speed); -status_t set_mouse_speed(int32 speed); -status_t get_mouse_acceleration(int32 *speed); -status_t set_mouse_acceleration(int32 speed); - -status_t get_key_repeat_rate(int32 *rate); -status_t set_key_repeat_rate(int32 rate); -status_t get_key_repeat_delay(bigtime_t *delay); -status_t set_key_repeat_delay(bigtime_t delay); - -uint32 modifiers(); -status_t get_key_info(key_info *info); -void get_key_map(key_map **map, char **key_buffer); -status_t get_keyboard_id(uint16 *id); -void set_modifier_key(uint32 modifier, uint32 key); -void set_keyboard_locks(uint32 modifiers); - -rgb_color keyboard_navigation_color(); - -int32 count_workspaces(); -void set_workspace_count(int32 count); -int32 current_workspace(); -void activate_workspace(int32 workspace); - -bigtime_t idle_time(); - -void run_select_printer_panel(); -void run_add_printer_panel(); -void run_be_about(); - -void set_focus_follows_mouse(bool follow); -bool focus_follows_mouse(); - -enum mode_mouse { - B_NORMAL_MOUSE = 0, - B_FOCUS_FOLLOWS_MOUSE = 1, - B_WARP_MOUSE = 3, - B_INSTANT_WARP_MOUSE = 7 -}; - -void set_mouse_mode(mode_mouse mode); -mode_mouse mouse_mode(); +// Default UI Colors enum color_which { B_PANEL_BACKGROUND_COLOR = 1, @@ -350,27 +293,85 @@ enum color_which { B_WINDOW_INACTIVE_TEXT_COLOR = 24 }; -rgb_color ui_color(color_which which); -void set_ui_color(const color_which &which, - const rgb_color &color); -rgb_color tint_color(rgb_color color, float tint); -extern "C" status_t _init_interface_kit_(); - /* effects on standard gray level */ -const float B_LIGHTEN_MAX_TINT = 0.0F; /* 216 --> 255.0 (255) */ -const float B_LIGHTEN_2_TINT = 0.385F; /* 216 --> 240.0 (240) */ -const float B_LIGHTEN_1_TINT = 0.590F; /* 216 --> 232.0 (232) */ +// Color tinting -const float B_NO_TINT = 1.0F; /* 216 --> 216.0 (216) */ +const float B_LIGHTEN_MAX_TINT = 0.0f; // 216 --> 255.0 (255) +const float B_LIGHTEN_2_TINT = 0.385f; // 216 --> 240.0 (240) +const float B_LIGHTEN_1_TINT = 0.590f; // 216 --> 232.0 (232) -const float B_DARKEN_1_TINT = 1.147F; /* 216 --> 184.2 (184) */ -const float B_DARKEN_2_TINT = 1.295F; /* 216 --> 152.3 (152) */ -const float B_DARKEN_3_TINT = 1.407F; /* 216 --> 128.1 (128) */ -const float B_DARKEN_4_TINT = 1.555F; /* 216 --> 96.1 (96) */ -const float B_DARKEN_MAX_TINT = 2.0F; /* 216 --> 0.0 (0) */ +const float B_NO_TINT = 1.0f; // 216 --> 216.0 (216) + +const float B_DARKEN_1_TINT = 1.147f; // 216 --> 184.2 (184) +const float B_DARKEN_2_TINT = 1.295f; // 216 --> 152.3 (152) +const float B_DARKEN_3_TINT = 1.407f; // 216 --> 128.1 (128) +const float B_DARKEN_4_TINT = 1.555f; // 216 --> 96.1 (96) +const float B_DARKEN_MAX_TINT = 2.0f; // 216 --> 0.0 (0) + // effects on standard gray level const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT; const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT; const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT; + +status_t get_deskbar_frame(BRect* frame); + +const color_map* system_colors(); + +status_t set_screen_space(int32 index, uint32 resolution, + bool save = true); + +status_t get_scroll_bar_info(scroll_bar_info* info); +status_t set_scroll_bar_info(scroll_bar_info* info); + +status_t get_mouse_type(int32* type); +status_t set_mouse_type(int32 type); +status_t get_mouse_map(mouse_map* map); +status_t set_mouse_map(mouse_map* map); +status_t get_click_speed(bigtime_t* speed); +status_t set_click_speed(bigtime_t speed); +status_t get_mouse_speed(int32* speed); +status_t set_mouse_speed(int32 speed); +status_t get_mouse_acceleration(int32* speed); +status_t set_mouse_acceleration(int32 speed); + +status_t get_key_repeat_rate(int32* rate); +status_t set_key_repeat_rate(int32 rate); +status_t get_key_repeat_delay(bigtime_t* delay); +status_t set_key_repeat_delay(bigtime_t delay); + +uint32 modifiers(); +status_t get_key_info(key_info* info); +void get_key_map(key_map** _map, char** _keyBuffer); +status_t get_keyboard_id(uint16* _id); +void set_modifier_key(uint32 modifier, uint32 key); +void set_keyboard_locks(uint32 modifiers); + +rgb_color keyboard_navigation_color(); + +int32 count_workspaces(); +void set_workspace_count(int32 count); +int32 current_workspace(); +void activate_workspace(int32 workspace); + +bigtime_t idle_time(); + +void run_select_printer_panel(); +void run_add_printer_panel(); +void run_be_about(); + +void set_focus_follows_mouse(bool follow); +bool focus_follows_mouse(); + +void set_mouse_mode(mode_mouse mode); +mode_mouse mouse_mode(); + +rgb_color ui_color(color_which which); +void set_ui_color(const color_which& which, const rgb_color& color); +rgb_color tint_color(rgb_color color, float tint); + +extern "C" status_t _init_interface_kit_(); + // for convenience, should be removed including the friend declarations + // in Menu.h, ... + #endif // _INTERFACE_DEFS_H diff --git a/headers/private/interface/InterfacePrivate.h b/headers/private/interface/InterfacePrivate.h new file mode 100644 index 0000000000..da37bb5e58 --- /dev/null +++ b/headers/private/interface/InterfacePrivate.h @@ -0,0 +1,23 @@ +/* + * Copyright 2007-2008, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stefano Ceccherini + */ +#ifndef _INTERFACE_PRIVATE_H +#define _INTERFACE_PRIVATE_H + + +#include + + +namespace BPrivate { + +bool get_mode_parameter(uint32 mode, int32& width, int32& height, + uint32& colorSpace); + +} // namespace BPrivate + + +#endif // _INTERFACE_PRIVATE_H diff --git a/headers/private/interface/interface_misc.h b/headers/private/interface/interface_misc.h deleted file mode 100644 index 18f79eae7a..0000000000 --- a/headers/private/interface/interface_misc.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2007, Haiku, Inc. - * Distributed under the terms of the MIT License. - * - * Authors: - * Stefano Ceccherini - */ - -/** Various private functions and variables for the Interface Kit */ - - -#ifndef __INTERFACE_MISC_H -#define __INTERFACE_MISC_H - -#include - -bool get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace); - -#endif - diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index 5c8907f8c5..295871eba2 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Haiku. + * Copyright 2001-2008, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -9,6 +9,29 @@ */ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -20,30 +43,9 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - using namespace BPrivate; + BApplication *be_app = NULL; BMessenger be_app_messenger; @@ -1227,8 +1229,9 @@ BApplication::_InitGUIContext() if (error != B_OK) return error; - // Initialize the IK after we have set be_app because of a construction of a - // AppServerLink (which depends on be_app) nested inside the call to get_menu_info. + // Initialize the IK after we have set be_app because of a construction + // of a AppServerLink (which depends on be_app) nested inside the call + // to get_menu_info. error = _init_interface_kit_(); if (error != B_OK) return error; diff --git a/src/kits/game/WindowScreen.cpp b/src/kits/game/WindowScreen.cpp index f0c07763b9..07925f5f98 100644 --- a/src/kits/game/WindowScreen.cpp +++ b/src/kits/game/WindowScreen.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007, Haiku. All Rights Reserved. + * Copyright 2002-2008, Haiku. All Rights Reserved. * Copyright 2002-2005, * Marcus Overhagen, * Stefano Ceccherini (stefano.ceccherini@gmail.com), @@ -10,33 +10,33 @@ */ -#include -#include -#include #include +#include #include #include #include -#include - -#include -#include // For IS_SET_MOUSE_POSITION -#include -#include +#include +#include +#include #include +#include +#include +#include #include +#include + using BPrivate::AppServerLink; //#define TRACE_WINDOWSCREEN 1 #if TRACE_WINDOWSCREEN -#define CALLED() printf("%s\n", __PRETTY_FUNCTION__); +# define CALLED() printf("%s\n", __PRETTY_FUNCTION__); #else -#define CALLED() ; +# define CALLED() ; #endif @@ -902,7 +902,7 @@ BWindowScreen::_GetModeFromSpace(uint32 space, display_mode *dmode) int32 width, height; uint32 colorSpace; - if (!get_mode_parameter(space, width, height, colorSpace)) + if (!BPrivate::get_mode_parameter(space, width, height, colorSpace)) return B_BAD_VALUE; for (uint32 i = 0; i < fModeCount; i++) { diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 178e0f51eb..0d380423df 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006, Haiku, Inc. + * Copyright 2001-2008, Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors: @@ -8,23 +8,13 @@ * Axel Dörfler, axeld@pinc-software.de */ -/** Global functions and variables for the Interface Kit */ +/*! Global functions and variables for the Interface Kit */ -#include -#include -#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include #include #include @@ -35,9 +25,19 @@ #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // Private definitions not placed in public headers @@ -94,6 +94,8 @@ static const rgb_color _kDefaultColors[kNumColors] = { const rgb_color* BPrivate::kDefaultColors = &_kDefaultColors[0]; +namespace BPrivate { + /*! Fills the \a width, \a height, and \a colorSpace parameters according to the window screen's mode. @@ -190,6 +192,8 @@ get_mode_parameter(uint32 mode, int32& width, int32& height, uint32& colorSpace) return true; } +} // namespace BPrivate + const color_map * system_colors() @@ -204,7 +208,7 @@ set_screen_space(int32 index, uint32 space, bool stick) int32 width; int32 height; uint32 depth; - if (!get_mode_parameter(space, width, height, depth)) + if (!BPrivate::get_mode_parameter(space, width, height, depth)) return B_BAD_VALUE; BScreen screen(B_MAIN_SCREEN_ID);