From e047b40a2fd11728e4f7ac83d121299c89e9e658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 25 Aug 2015 18:06:46 +0200 Subject: [PATCH] Interface Kit: use different spacing constants. * While this breaks binary compatibility with earlier Haiku releases, use values that are less likely to clash with actual use cases. * Specifically, using a negative spacing is one way to get rid of the border of BScrollViews, to put them into a window neatly. * Also, BControlLook now uses a switch to resolve them. --- headers/os/interface/InterfaceDefs.h | 24 ++++++++++++------------ src/kits/interface/ControlLook.cpp | 27 +++++++++++++++------------ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index accef2cbff..46f3a83a6f 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Haiku, Inc. All rights reserved. + * Copyright 2001-2015, Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _INTERFACE_DEFS_H @@ -228,17 +228,17 @@ enum vertical_alignment { enum { - B_USE_DEFAULT_SPACING = -2, - B_USE_ITEM_SPACING = -3, - B_USE_ITEM_INSETS = -3, - B_USE_HALF_ITEM_SPACING = -4, - B_USE_HALF_ITEM_INSETS = -4, - B_USE_WINDOW_INSETS = -5, - B_USE_WINDOW_SPACING = -5, - B_USE_SMALL_INSETS = -6, - B_USE_SMALL_SPACING = -6, - B_USE_BIG_INSETS = -7, - B_USE_BIG_SPACING = -7 + B_USE_DEFAULT_SPACING = -1002, + B_USE_ITEM_SPACING = -1003, + B_USE_ITEM_INSETS = -1003, + B_USE_HALF_ITEM_SPACING = -1004, + B_USE_HALF_ITEM_INSETS = -1004, + B_USE_WINDOW_INSETS = -1005, + B_USE_WINDOW_SPACING = -1005, + B_USE_SMALL_INSETS = -1006, + B_USE_SMALL_SPACING = -1006, + B_USE_BIG_INSETS = -1007, + B_USE_BIG_SPACING = -1007 }; diff --git a/src/kits/interface/ControlLook.cpp b/src/kits/interface/ControlLook.cpp index 9f329a4c84..3cfad71874 100644 --- a/src/kits/interface/ControlLook.cpp +++ b/src/kits/interface/ControlLook.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Stephan Aßmus - * Copyright 2012-2014 Haiku, Inc. All rights reserved. + * Copyright 2012-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -71,17 +71,20 @@ BControlLook::DefaultItemSpacing() const float BControlLook::ComposeSpacing(float spacing) { - if (spacing == B_USE_DEFAULT_SPACING || spacing == B_USE_ITEM_SPACING) { - return be_control_look->DefaultItemSpacing(); - } else if (spacing == B_USE_HALF_ITEM_SPACING) { - return ceilf(be_control_look->DefaultItemSpacing() * 0.5f); - } else if (spacing == B_USE_WINDOW_INSETS) { - return be_control_look->DefaultItemSpacing(); - } else if (spacing == B_USE_SMALL_SPACING) { - return ceilf(be_control_look->DefaultItemSpacing() * 0.7f); - } else if (spacing == B_USE_BIG_SPACING) { - return ceilf(be_control_look->DefaultItemSpacing() * 1.3f); + switch ((int)spacing) { + case B_USE_DEFAULT_SPACING: + case B_USE_ITEM_SPACING: + return be_control_look->DefaultItemSpacing(); + case B_USE_HALF_ITEM_SPACING: + return ceilf(be_control_look->DefaultItemSpacing() * 0.5f); + case B_USE_WINDOW_SPACING: + return be_control_look->DefaultItemSpacing(); + case B_USE_SMALL_SPACING: + return ceilf(be_control_look->DefaultItemSpacing() * 0.7f); + case B_USE_BIG_SPACING: + return ceilf(be_control_look->DefaultItemSpacing() * 1.3f); } + return spacing; } @@ -2567,7 +2570,7 @@ BControlLook::_DrawNonFlatButtonBackground(BView* view, BRect& rect, rgb_color separatorBaseColor = base; if ((flags & B_ACTIVATED) != 0) separatorBaseColor = tint_color(base, B_DARKEN_1_TINT); - + rgb_color separatorLightColor = _EdgeLightColor(separatorBaseColor, (flags & B_DISABLED) != 0 ? 0.7 : 1.0, 1.0, flags); rgb_color separatorShadowColor = _EdgeShadowColor(separatorBaseColor,