12f86ba45SStephan Aßmus /* 22f86ba45SStephan Aßmus * Copyright 2009, Stephan Aßmus <superstippi@gmx.de> 3a884b43bSJohn Scipione * Copyright 2012, Haiku Inc. All rights reserved. 42f86ba45SStephan Aßmus * Distributed under the terms of the MIT License. 5a884b43bSJohn Scipione * 6a884b43bSJohn Scipione * Authors: 7a884b43bSJohn Scipione * John Scipione <jscipione@gmail.com> 82f86ba45SStephan Aßmus */ 9d452ff66SAxel Dörfler 10d452ff66SAxel Dörfler 112f86ba45SStephan Aßmus #include <ControlLook.h> 122f86ba45SStephan Aßmus 132f86ba45SStephan Aßmus #include <Control.h> 142f86ba45SStephan Aßmus #include <GradientLinear.h> 152f86ba45SStephan Aßmus #include <Region.h> 162f86ba45SStephan Aßmus #include <Shape.h> 172f86ba45SStephan Aßmus #include <String.h> 182f86ba45SStephan Aßmus #include <View.h> 19d63b75faSPhilippe Saint-Pierre #include <Window.h> 202f86ba45SStephan Aßmus 21a884b43bSJohn Scipione #include "ContainerWindow.h" 22a884b43bSJohn Scipione 23a884b43bSJohn Scipione 242f86ba45SStephan Aßmus namespace BPrivate { 252f86ba45SStephan Aßmus 26a884b43bSJohn Scipione 272f86ba45SStephan Aßmus static const float kEdgeBevelLightTint = 0.59; 282f86ba45SStephan Aßmus static const float kEdgeBevelShadowTint = 1.0735; 292f86ba45SStephan Aßmus 302f86ba45SStephan Aßmus 31d63b75faSPhilippe Saint-Pierre BControlLook::BControlLook(): 32d63b75faSPhilippe Saint-Pierre fCachedOutline(false), 33d63b75faSPhilippe Saint-Pierre fCachedWorkspace(-1) 342f86ba45SStephan Aßmus { 352f86ba45SStephan Aßmus } 362f86ba45SStephan Aßmus 372f86ba45SStephan Aßmus 382f86ba45SStephan Aßmus BControlLook::~BControlLook() 392f86ba45SStephan Aßmus { 402f86ba45SStephan Aßmus } 412f86ba45SStephan Aßmus 422f86ba45SStephan Aßmus 432f86ba45SStephan Aßmus BAlignment 442f86ba45SStephan Aßmus BControlLook::DefaultLabelAlignment() const 452f86ba45SStephan Aßmus { 462f86ba45SStephan Aßmus return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER); 472f86ba45SStephan Aßmus } 482f86ba45SStephan Aßmus 492f86ba45SStephan Aßmus 502f86ba45SStephan Aßmus float 512f86ba45SStephan Aßmus BControlLook::DefaultLabelSpacing() const 522f86ba45SStephan Aßmus { 5320a11271SAxel Dörfler return ceilf(be_plain_font->Size() / 2.0); 5420a11271SAxel Dörfler } 5520a11271SAxel Dörfler 5620a11271SAxel Dörfler 5720a11271SAxel Dörfler float 5820a11271SAxel Dörfler BControlLook::DefaultItemSpacing() const 5920a11271SAxel Dörfler { 6020a11271SAxel Dörfler return ceilf(be_plain_font->Size() * 0.85); 612f86ba45SStephan Aßmus } 622f86ba45SStephan Aßmus 632f86ba45SStephan Aßmus 6482ab3167SAlex Wilson float 656648dd3cSAlex Wilson BControlLook::ComposeSpacing(float spacing) 6682ab3167SAlex Wilson { 67d90a465eSAlex Wilson if (spacing == B_USE_DEFAULT_SPACING || spacing == B_USE_ITEM_SPACING) { 6882ab3167SAlex Wilson return be_control_look->DefaultItemSpacing(); 696648dd3cSAlex Wilson } else if (spacing == B_USE_HALF_ITEM_SPACING) { 706648dd3cSAlex Wilson return be_control_look->DefaultItemSpacing() * 0.5f; 716648dd3cSAlex Wilson } else if (spacing == B_USE_WINDOW_INSETS) { 726648dd3cSAlex Wilson return be_control_look->DefaultItemSpacing(); 736648dd3cSAlex Wilson } else if (spacing == B_USE_SMALL_SPACING) { 746648dd3cSAlex Wilson return be_control_look->DefaultItemSpacing() * 0.7f; 756648dd3cSAlex Wilson } else if (spacing == B_USE_BIG_SPACING) { 766648dd3cSAlex Wilson return be_control_look->DefaultItemSpacing() * 1.3f; 776648dd3cSAlex Wilson } 786648dd3cSAlex Wilson return spacing; 7982ab3167SAlex Wilson } 8082ab3167SAlex Wilson 8182ab3167SAlex Wilson 822f86ba45SStephan Aßmus uint32 832f86ba45SStephan Aßmus BControlLook::Flags(BControl* control) const 842f86ba45SStephan Aßmus { 852f86ba45SStephan Aßmus uint32 flags = 0; 862f86ba45SStephan Aßmus 872f86ba45SStephan Aßmus if (!control->IsEnabled()) 882f86ba45SStephan Aßmus flags |= B_DISABLED; 892f86ba45SStephan Aßmus 902f86ba45SStephan Aßmus if (control->IsFocus()) 912f86ba45SStephan Aßmus flags |= B_FOCUSED; 922f86ba45SStephan Aßmus 932f86ba45SStephan Aßmus if (control->Value() == B_CONTROL_ON) 942f86ba45SStephan Aßmus flags |= B_ACTIVATED; 952f86ba45SStephan Aßmus 9661ac1a85SStephan Aßmus if (control->Parent() != NULL 9761ac1a85SStephan Aßmus && (control->Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) { 9861ac1a85SStephan Aßmus // In this constellation, assume we want to render the control 9961ac1a85SStephan Aßmus // against the already existing view contents of the parent view. 10061ac1a85SStephan Aßmus flags |= B_BLEND_FRAME; 10161ac1a85SStephan Aßmus } 10261ac1a85SStephan Aßmus 1032f86ba45SStephan Aßmus return flags; 1042f86ba45SStephan Aßmus } 1052f86ba45SStephan Aßmus 1062f86ba45SStephan Aßmus 1072f86ba45SStephan Aßmus // #pragma mark - 1082f86ba45SStephan Aßmus 1092f86ba45SStephan Aßmus 1102f86ba45SStephan Aßmus void 1112f86ba45SStephan Aßmus BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect, 112681c2e44SStephan Aßmus const rgb_color& base, const rgb_color& background, uint32 flags, 113681c2e44SStephan Aßmus uint32 borders) 1142f86ba45SStephan Aßmus { 115a884b43bSJohn Scipione _DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base, 116a884b43bSJohn Scipione background, 1.0, 1.0, flags, borders); 117a884b43bSJohn Scipione } 118a884b43bSJohn Scipione 119a884b43bSJohn Scipione 120a884b43bSJohn Scipione void 121a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect, const BRect& updateRect, 122a884b43bSJohn Scipione float radius, const rgb_color& base, const rgb_color& background, uint32 flags, 123a884b43bSJohn Scipione uint32 borders) 124a884b43bSJohn Scipione { 125a884b43bSJohn Scipione _DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius, 126a884b43bSJohn Scipione base, background, 1.0, 1.0, flags, borders); 127a884b43bSJohn Scipione } 128a884b43bSJohn Scipione 129a884b43bSJohn Scipione 130a884b43bSJohn Scipione void 131a884b43bSJohn Scipione BControlLook::DrawButtonFrame(BView* view, BRect& rect, 132a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 133a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 134a884b43bSJohn Scipione const rgb_color& background, uint32 flags, 135a884b43bSJohn Scipione uint32 borders) 136a884b43bSJohn Scipione { 137a884b43bSJohn Scipione _DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius, 138a884b43bSJohn Scipione leftBottomRadius, rightBottomRadius, base, background, 139a884b43bSJohn Scipione 1.0, 1.0, flags, borders); 1402f86ba45SStephan Aßmus } 1412f86ba45SStephan Aßmus 1422f86ba45SStephan Aßmus 1432f86ba45SStephan Aßmus void 1442f86ba45SStephan Aßmus BControlLook::DrawButtonBackground(BView* view, BRect& rect, 1452f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 1462f86ba45SStephan Aßmus uint32 borders, enum orientation orientation) 1472f86ba45SStephan Aßmus { 148a884b43bSJohn Scipione _DrawButtonBackground(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, 149a884b43bSJohn Scipione base, flags, borders, orientation); 1502f86ba45SStephan Aßmus } 1512f86ba45SStephan Aßmus 1522f86ba45SStephan Aßmus 153a884b43bSJohn Scipione void 154a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect, 155a884b43bSJohn Scipione const BRect& updateRect, float radius, const rgb_color& base, uint32 flags, 156a884b43bSJohn Scipione uint32 borders, enum orientation orientation) 157a884b43bSJohn Scipione { 158a884b43bSJohn Scipione _DrawButtonBackground(view, rect, updateRect, radius, radius, radius, 159a884b43bSJohn Scipione radius, base, flags, borders, orientation); 1602f86ba45SStephan Aßmus } 1612f86ba45SStephan Aßmus 1622f86ba45SStephan Aßmus 163a884b43bSJohn Scipione void 164a884b43bSJohn Scipione BControlLook::DrawButtonBackground(BView* view, BRect& rect, 165a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 166a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 167a884b43bSJohn Scipione uint32 flags, uint32 borders, enum orientation orientation) 168a884b43bSJohn Scipione { 169a884b43bSJohn Scipione _DrawButtonBackground(view, rect, updateRect, leftTopRadius, 170a884b43bSJohn Scipione rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags, 171a884b43bSJohn Scipione borders, orientation); 1722f86ba45SStephan Aßmus } 1732f86ba45SStephan Aßmus 1742f86ba45SStephan Aßmus 1752f86ba45SStephan Aßmus void 1762f86ba45SStephan Aßmus BControlLook::DrawMenuBarBackground(BView* view, BRect& rect, 1771a72cb41SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 1781a72cb41SStephan Aßmus uint32 borders) 1792f86ba45SStephan Aßmus { 180a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 1812f86ba45SStephan Aßmus return; 1822f86ba45SStephan Aßmus 1832f86ba45SStephan Aßmus // the surface edges 1842f86ba45SStephan Aßmus 1852f86ba45SStephan Aßmus // colors 1861a72cb41SStephan Aßmus float topTint; 1871a72cb41SStephan Aßmus float bottomTint; 1881a72cb41SStephan Aßmus 189a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) { 1901a72cb41SStephan Aßmus rgb_color bevelColor1 = tint_color(base, 1.40); 1911a72cb41SStephan Aßmus rgb_color bevelColor2 = tint_color(base, 1.25); 1921a72cb41SStephan Aßmus 1931a72cb41SStephan Aßmus topTint = 1.25; 1941a72cb41SStephan Aßmus bottomTint = 1.20; 1952f86ba45SStephan Aßmus 1962f86ba45SStephan Aßmus _DrawFrame(view, rect, 1971a72cb41SStephan Aßmus bevelColor1, bevelColor1, 1981a72cb41SStephan Aßmus bevelColor2, bevelColor2, 1991a72cb41SStephan Aßmus borders & B_TOP_BORDER); 2001a72cb41SStephan Aßmus } else { 2011a72cb41SStephan Aßmus rgb_color cornerColor = tint_color(base, 0.9); 2021a72cb41SStephan Aßmus rgb_color bevelColorTop = tint_color(base, 0.5); 2031a72cb41SStephan Aßmus rgb_color bevelColorLeft = tint_color(base, 0.7); 2041a72cb41SStephan Aßmus rgb_color bevelColorRightBottom = tint_color(base, 1.08); 2051a72cb41SStephan Aßmus 2061a72cb41SStephan Aßmus topTint = 0.69; 2071a72cb41SStephan Aßmus bottomTint = 1.03; 2081a72cb41SStephan Aßmus 2091a72cb41SStephan Aßmus _DrawFrame(view, rect, 2101a72cb41SStephan Aßmus bevelColorLeft, bevelColorTop, 2111a72cb41SStephan Aßmus bevelColorRightBottom, bevelColorRightBottom, 2122f86ba45SStephan Aßmus cornerColor, cornerColor, 2132f86ba45SStephan Aßmus borders); 2141a72cb41SStephan Aßmus } 2152f86ba45SStephan Aßmus 216a884b43bSJohn Scipione // draw surface top 2172f86ba45SStephan Aßmus _FillGradient(view, rect, base, topTint, bottomTint); 2182f86ba45SStephan Aßmus } 2192f86ba45SStephan Aßmus 2202f86ba45SStephan Aßmus 2212f86ba45SStephan Aßmus void 222681c2e44SStephan Aßmus BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect, 223681c2e44SStephan Aßmus const BRect& updateRect, const rgb_color& base, 224681c2e44SStephan Aßmus const rgb_color& background, uint32 flags, uint32 borders) 22513cd46dfSStephan Aßmus { 226a884b43bSJohn Scipione _DrawButtonFrame(view, rect, updateRect, 0.0f, 0.0f, 0.0f, 0.0f, base, 227a884b43bSJohn Scipione background, 0.6, 1.0, flags, borders); 228a884b43bSJohn Scipione } 229a884b43bSJohn Scipione 230a884b43bSJohn Scipione 231a884b43bSJohn Scipione void 232a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect, 233a884b43bSJohn Scipione const BRect& updateRect, float radius, const rgb_color& base, 234a884b43bSJohn Scipione const rgb_color& background, uint32 flags, uint32 borders) 235a884b43bSJohn Scipione { 236a884b43bSJohn Scipione _DrawButtonFrame(view, rect, updateRect, radius, radius, radius, radius, 237a884b43bSJohn Scipione base, background, 0.6, 1.0, flags, borders); 238a884b43bSJohn Scipione } 239a884b43bSJohn Scipione 240a884b43bSJohn Scipione 241a884b43bSJohn Scipione void 242a884b43bSJohn Scipione BControlLook::DrawMenuFieldFrame(BView* view, BRect& rect, 243a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, 244a884b43bSJohn Scipione float rightTopRadius, float leftBottomRadius, 245a884b43bSJohn Scipione float rightBottomRadius, const rgb_color& base, 246a884b43bSJohn Scipione const rgb_color& background, uint32 flags, uint32 borders) 247a884b43bSJohn Scipione { 248a884b43bSJohn Scipione _DrawButtonFrame(view, rect, updateRect, leftTopRadius, rightTopRadius, 249a884b43bSJohn Scipione leftBottomRadius, rightBottomRadius, base, background, 0.6, 1.0, 250a884b43bSJohn Scipione flags, borders); 25113cd46dfSStephan Aßmus } 25213cd46dfSStephan Aßmus 25313cd46dfSStephan Aßmus 25413cd46dfSStephan Aßmus void 2552f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect, 2562f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, bool popupIndicator, 2572f86ba45SStephan Aßmus uint32 flags) 2582f86ba45SStephan Aßmus { 259a884b43bSJohn Scipione _DrawMenuFieldBackgroundOutside(view, rect, updateRect, 260a884b43bSJohn Scipione 0.0f, 0.0f, 0.0f, 0.0f, base, popupIndicator, flags); 2612f86ba45SStephan Aßmus } 2622f86ba45SStephan Aßmus 2632f86ba45SStephan Aßmus 2642f86ba45SStephan Aßmus void 2652f86ba45SStephan Aßmus BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect, 2662f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 2672f86ba45SStephan Aßmus uint32 borders) 2682f86ba45SStephan Aßmus { 269a884b43bSJohn Scipione _DrawMenuFieldBackgroundInside(view, rect, updateRect, 270a884b43bSJohn Scipione 0.0f, 0.0f, 0.0f, 0.0f, base, flags, borders); 2712f86ba45SStephan Aßmus } 2722f86ba45SStephan Aßmus 2732f86ba45SStephan Aßmus 274a884b43bSJohn Scipione void 275a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect, 276a884b43bSJohn Scipione const BRect& updateRect, float radius, const rgb_color& base, 277a884b43bSJohn Scipione bool popupIndicator, uint32 flags) 278a884b43bSJohn Scipione { 279a884b43bSJohn Scipione _DrawMenuFieldBackgroundOutside(view, rect, updateRect, radius, radius, 280a884b43bSJohn Scipione radius, radius, base, popupIndicator, flags); 2812f86ba45SStephan Aßmus } 2822f86ba45SStephan Aßmus 283a884b43bSJohn Scipione 284a884b43bSJohn Scipione void 285a884b43bSJohn Scipione BControlLook::DrawMenuFieldBackground(BView* view, BRect& rect, 286a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 287a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 288a884b43bSJohn Scipione bool popupIndicator, uint32 flags) 289a884b43bSJohn Scipione { 290a884b43bSJohn Scipione _DrawMenuFieldBackgroundOutside(view, rect, updateRect, leftTopRadius, 291a884b43bSJohn Scipione rightTopRadius, leftBottomRadius, rightBottomRadius, base, 292a884b43bSJohn Scipione popupIndicator, flags); 2932f86ba45SStephan Aßmus } 2942f86ba45SStephan Aßmus 295a884b43bSJohn Scipione 2962f86ba45SStephan Aßmus void 2972f86ba45SStephan Aßmus BControlLook::DrawMenuBackground(BView* view, BRect& rect, 2982f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 2992f86ba45SStephan Aßmus uint32 borders) 3002f86ba45SStephan Aßmus { 301a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 3022f86ba45SStephan Aßmus return; 3032f86ba45SStephan Aßmus 304a884b43bSJohn Scipione // surface top color 3052f86ba45SStephan Aßmus rgb_color background = tint_color(base, 0.75); 3062f86ba45SStephan Aßmus 307a884b43bSJohn Scipione // inner bevel colors 308a884b43bSJohn Scipione rgb_color bevelLightColor; 309a884b43bSJohn Scipione rgb_color bevelShadowColor; 310a884b43bSJohn Scipione 311a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 3122f86ba45SStephan Aßmus bevelLightColor = tint_color(background, 0.80); 3132f86ba45SStephan Aßmus bevelShadowColor = tint_color(background, 1.07); 3142f86ba45SStephan Aßmus } else { 3152f86ba45SStephan Aßmus bevelLightColor = tint_color(background, 0.6); 3162f86ba45SStephan Aßmus bevelShadowColor = tint_color(background, 1.12); 3172f86ba45SStephan Aßmus } 3182f86ba45SStephan Aßmus 319a884b43bSJohn Scipione // draw inner bevel 3202f86ba45SStephan Aßmus _DrawFrame(view, rect, 3212f86ba45SStephan Aßmus bevelLightColor, bevelLightColor, 3222f86ba45SStephan Aßmus bevelShadowColor, bevelShadowColor, 3232f86ba45SStephan Aßmus borders); 3242f86ba45SStephan Aßmus 325a884b43bSJohn Scipione // draw surface top 3262f86ba45SStephan Aßmus view->SetHighColor(background); 3272f86ba45SStephan Aßmus view->FillRect(rect); 3282f86ba45SStephan Aßmus } 3292f86ba45SStephan Aßmus 3302f86ba45SStephan Aßmus 3312f86ba45SStephan Aßmus void 3322f86ba45SStephan Aßmus BControlLook::DrawMenuItemBackground(BView* view, BRect& rect, 3332f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 3342f86ba45SStephan Aßmus uint32 borders) 3352f86ba45SStephan Aßmus { 336a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 3372f86ba45SStephan Aßmus return; 3382f86ba45SStephan Aßmus 339a884b43bSJohn Scipione // surface edges 3402f86ba45SStephan Aßmus float topTint; 3412f86ba45SStephan Aßmus float bottomTint; 3422f86ba45SStephan Aßmus rgb_color selectedColor = base; 3432f86ba45SStephan Aßmus 344a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) { 3452f86ba45SStephan Aßmus topTint = 0.9; 3462f86ba45SStephan Aßmus bottomTint = 1.05; 347a884b43bSJohn Scipione } else if ((flags & B_DISABLED) != 0) { 3482f86ba45SStephan Aßmus topTint = 0.80; 3492f86ba45SStephan Aßmus bottomTint = 1.07; 3502f86ba45SStephan Aßmus } else { 3512f86ba45SStephan Aßmus topTint = 0.6; 3522f86ba45SStephan Aßmus bottomTint = 1.12; 3532f86ba45SStephan Aßmus } 3542f86ba45SStephan Aßmus 3552f86ba45SStephan Aßmus rgb_color bevelLightColor = tint_color(selectedColor, topTint); 3562f86ba45SStephan Aßmus rgb_color bevelShadowColor = tint_color(selectedColor, bottomTint); 3572f86ba45SStephan Aßmus 358a884b43bSJohn Scipione // draw surface edges 3592f86ba45SStephan Aßmus _DrawFrame(view, rect, 3602f86ba45SStephan Aßmus bevelLightColor, bevelLightColor, 3612f86ba45SStephan Aßmus bevelShadowColor, bevelShadowColor, 3622f86ba45SStephan Aßmus borders); 3632f86ba45SStephan Aßmus 364a884b43bSJohn Scipione // draw surface top 3652f86ba45SStephan Aßmus view->SetLowColor(selectedColor); 3662f86ba45SStephan Aßmus // _FillGradient(view, rect, selectedColor, topTint, bottomTint); 3672f86ba45SStephan Aßmus _FillGradient(view, rect, selectedColor, bottomTint, topTint); 3682f86ba45SStephan Aßmus } 3692f86ba45SStephan Aßmus 3702f86ba45SStephan Aßmus 3712f86ba45SStephan Aßmus void 3722f86ba45SStephan Aßmus BControlLook::DrawStatusBar(BView* view, BRect& rect, const BRect& updateRect, 3732f86ba45SStephan Aßmus const rgb_color& base, const rgb_color& barColor, float progressPosition) 3742f86ba45SStephan Aßmus { 3752f86ba45SStephan Aßmus if (!rect.Intersects(updateRect)) 3762f86ba45SStephan Aßmus return; 3772f86ba45SStephan Aßmus 3782f86ba45SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 0.6); 3792f86ba45SStephan Aßmus 3802f86ba45SStephan Aßmus // colors 3812f86ba45SStephan Aßmus rgb_color dark1BorderColor = tint_color(base, 1.3); 3822f86ba45SStephan Aßmus rgb_color dark2BorderColor = tint_color(base, 1.2); 3832f86ba45SStephan Aßmus rgb_color dark1FilledBorderColor = tint_color(barColor, 1.20); 3842f86ba45SStephan Aßmus rgb_color dark2FilledBorderColor = tint_color(barColor, 1.45); 3852f86ba45SStephan Aßmus 3862f86ba45SStephan Aßmus BRect filledRect(rect); 3872f86ba45SStephan Aßmus filledRect.right = progressPosition - 1; 3882f86ba45SStephan Aßmus 3892f86ba45SStephan Aßmus BRect nonfilledRect(rect); 3902f86ba45SStephan Aßmus nonfilledRect.left = progressPosition; 3912f86ba45SStephan Aßmus 3922f86ba45SStephan Aßmus bool filledSurface = filledRect.Width() > 0; 3932f86ba45SStephan Aßmus bool nonfilledSurface = nonfilledRect.Width() > 0; 3942f86ba45SStephan Aßmus 3952f86ba45SStephan Aßmus if (filledSurface) { 3962f86ba45SStephan Aßmus _DrawFrame(view, filledRect, 3972f86ba45SStephan Aßmus dark1FilledBorderColor, dark1FilledBorderColor, 3982f86ba45SStephan Aßmus dark2FilledBorderColor, dark2FilledBorderColor); 3992f86ba45SStephan Aßmus 4002f86ba45SStephan Aßmus _FillGlossyGradient(view, filledRect, barColor, 0.55, 0.68, 0.76, 0.90); 4012f86ba45SStephan Aßmus } 4022f86ba45SStephan Aßmus 4032f86ba45SStephan Aßmus if (nonfilledSurface) { 4042f86ba45SStephan Aßmus _DrawFrame(view, nonfilledRect, dark1BorderColor, dark1BorderColor, 4052f86ba45SStephan Aßmus dark2BorderColor, dark2BorderColor, 4062f86ba45SStephan Aßmus B_TOP_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER); 4072f86ba45SStephan Aßmus 4082f86ba45SStephan Aßmus if (nonfilledRect.left < nonfilledRect.right) { 4092f86ba45SStephan Aßmus // shadow from fill bar, or left border 4102f86ba45SStephan Aßmus rgb_color leftBorder = dark1BorderColor; 4112f86ba45SStephan Aßmus if (filledSurface) 4122f86ba45SStephan Aßmus leftBorder = tint_color(base, 0.50); 4132f86ba45SStephan Aßmus view->SetHighColor(leftBorder); 4142f86ba45SStephan Aßmus view->StrokeLine(nonfilledRect.LeftTop(), 4152f86ba45SStephan Aßmus nonfilledRect.LeftBottom()); 4162f86ba45SStephan Aßmus nonfilledRect.left++; 4172f86ba45SStephan Aßmus } 4182f86ba45SStephan Aßmus 4192f86ba45SStephan Aßmus _FillGradient(view, nonfilledRect, base, 0.25, 0.06); 4202f86ba45SStephan Aßmus } 4212f86ba45SStephan Aßmus } 4222f86ba45SStephan Aßmus 4232f86ba45SStephan Aßmus 4242f86ba45SStephan Aßmus void 4252f86ba45SStephan Aßmus BControlLook::DrawCheckBox(BView* view, BRect& rect, const BRect& updateRect, 4262f86ba45SStephan Aßmus const rgb_color& base, uint32 flags) 4272f86ba45SStephan Aßmus { 4282f86ba45SStephan Aßmus if (!rect.Intersects(updateRect)) 4292f86ba45SStephan Aßmus return; 4302f86ba45SStephan Aßmus 4312f86ba45SStephan Aßmus rgb_color dark1BorderColor; 4322f86ba45SStephan Aßmus rgb_color dark2BorderColor; 4332f86ba45SStephan Aßmus rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 4342f86ba45SStephan Aßmus 435a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 4364f579098SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags); 4372f86ba45SStephan Aßmus 4382f86ba45SStephan Aßmus dark1BorderColor = tint_color(base, 1.15); 4392f86ba45SStephan Aßmus dark2BorderColor = tint_color(base, 1.15); 440a884b43bSJohn Scipione } else if ((flags & B_CLICKED) != 0) { 4412f86ba45SStephan Aßmus dark1BorderColor = tint_color(base, 1.50); 4422f86ba45SStephan Aßmus dark2BorderColor = tint_color(base, 1.48); 4432f86ba45SStephan Aßmus 4442f86ba45SStephan Aßmus _DrawFrame(view, rect, 4452f86ba45SStephan Aßmus dark1BorderColor, dark1BorderColor, 4462f86ba45SStephan Aßmus dark2BorderColor, dark2BorderColor); 4472f86ba45SStephan Aßmus 4482f86ba45SStephan Aßmus dark2BorderColor = dark1BorderColor; 4492f86ba45SStephan Aßmus } else { 4504f579098SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags); 4512f86ba45SStephan Aßmus 4522f86ba45SStephan Aßmus dark1BorderColor = tint_color(base, 1.40); 4532f86ba45SStephan Aßmus dark2BorderColor = tint_color(base, 1.38); 4542f86ba45SStephan Aßmus } 4552f86ba45SStephan Aßmus 456a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) { 4572f86ba45SStephan Aßmus dark1BorderColor = navigationColor; 4582f86ba45SStephan Aßmus dark2BorderColor = navigationColor; 4592f86ba45SStephan Aßmus } 4602f86ba45SStephan Aßmus 4612f86ba45SStephan Aßmus _DrawFrame(view, rect, 4622f86ba45SStephan Aßmus dark1BorderColor, dark1BorderColor, 4632f86ba45SStephan Aßmus dark2BorderColor, dark2BorderColor); 4642f86ba45SStephan Aßmus 465a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 4662f86ba45SStephan Aßmus _FillGradient(view, rect, base, 0.4, 0.2); 4672f86ba45SStephan Aßmus } else { 4682f86ba45SStephan Aßmus _FillGradient(view, rect, base, 0.15, 0.0); 4692f86ba45SStephan Aßmus } 4702f86ba45SStephan Aßmus 4712f86ba45SStephan Aßmus rgb_color markColor; 4722f86ba45SStephan Aßmus if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) { 4732f86ba45SStephan Aßmus view->SetHighColor(markColor); 4742f86ba45SStephan Aßmus 4752f86ba45SStephan Aßmus rect.InsetBy(2, 2); 4762f86ba45SStephan Aßmus view->SetPenSize(max_c(1.0, ceilf(rect.Width() / 3.5))); 4772f86ba45SStephan Aßmus view->SetDrawingMode(B_OP_OVER); 4782f86ba45SStephan Aßmus 4792f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.RightBottom()); 4802f86ba45SStephan Aßmus view->StrokeLine(rect.LeftBottom(), rect.RightTop()); 4812f86ba45SStephan Aßmus } 4822f86ba45SStephan Aßmus } 4832f86ba45SStephan Aßmus 4842f86ba45SStephan Aßmus 4852f86ba45SStephan Aßmus void 4862f86ba45SStephan Aßmus BControlLook::DrawRadioButton(BView* view, BRect& rect, const BRect& updateRect, 4872f86ba45SStephan Aßmus const rgb_color& base, uint32 flags) 4882f86ba45SStephan Aßmus { 4892f86ba45SStephan Aßmus if (!rect.Intersects(updateRect)) 4902f86ba45SStephan Aßmus return; 4912f86ba45SStephan Aßmus 4922f86ba45SStephan Aßmus rgb_color borderColor; 4932f86ba45SStephan Aßmus rgb_color bevelLight; 4942f86ba45SStephan Aßmus rgb_color bevelShadow; 4952f86ba45SStephan Aßmus rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 4962f86ba45SStephan Aßmus 497a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 4982f86ba45SStephan Aßmus borderColor = tint_color(base, 1.15); 4992f86ba45SStephan Aßmus bevelLight = base; 5002f86ba45SStephan Aßmus bevelShadow = base; 501a884b43bSJohn Scipione } else if ((flags & B_CLICKED) != 0) { 5022f86ba45SStephan Aßmus borderColor = tint_color(base, 1.50); 5032f86ba45SStephan Aßmus bevelLight = borderColor; 5042f86ba45SStephan Aßmus bevelShadow = borderColor; 5052f86ba45SStephan Aßmus } else { 5062f86ba45SStephan Aßmus borderColor = tint_color(base, 1.45); 5072f86ba45SStephan Aßmus bevelLight = tint_color(base, 0.55); 5082f86ba45SStephan Aßmus bevelShadow = tint_color(base, 1.11); 5092f86ba45SStephan Aßmus } 5102f86ba45SStephan Aßmus 511a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) { 5122f86ba45SStephan Aßmus borderColor = navigationColor; 5132f86ba45SStephan Aßmus } 5142f86ba45SStephan Aßmus 5152f86ba45SStephan Aßmus BGradientLinear bevelGradient; 5162f86ba45SStephan Aßmus bevelGradient.AddColor(bevelShadow, 0); 5172f86ba45SStephan Aßmus bevelGradient.AddColor(bevelLight, 255); 5182f86ba45SStephan Aßmus bevelGradient.SetStart(rect.LeftTop()); 5192f86ba45SStephan Aßmus bevelGradient.SetEnd(rect.RightBottom()); 5202f86ba45SStephan Aßmus 5212f86ba45SStephan Aßmus view->FillEllipse(rect, bevelGradient); 5222f86ba45SStephan Aßmus rect.InsetBy(1, 1); 5232f86ba45SStephan Aßmus 5242f86ba45SStephan Aßmus bevelGradient.MakeEmpty(); 5252f86ba45SStephan Aßmus bevelGradient.AddColor(borderColor, 0); 5262f86ba45SStephan Aßmus bevelGradient.AddColor(tint_color(borderColor, 0.8), 255); 5272f86ba45SStephan Aßmus view->FillEllipse(rect, bevelGradient); 5282f86ba45SStephan Aßmus rect.InsetBy(1, 1); 5292f86ba45SStephan Aßmus 5302f86ba45SStephan Aßmus float topTint; 5312f86ba45SStephan Aßmus float bottomTint; 532a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 5332f86ba45SStephan Aßmus topTint = 0.4; 5342f86ba45SStephan Aßmus bottomTint = 0.2; 5352f86ba45SStephan Aßmus } else { 5362f86ba45SStephan Aßmus topTint = 0.15; 5372f86ba45SStephan Aßmus bottomTint = 0.0; 5382f86ba45SStephan Aßmus } 5392f86ba45SStephan Aßmus 5402f86ba45SStephan Aßmus BGradientLinear gradient; 5412f86ba45SStephan Aßmus _MakeGradient(gradient, rect, base, topTint, bottomTint); 5422f86ba45SStephan Aßmus view->FillEllipse(rect, gradient); 5432f86ba45SStephan Aßmus 5442f86ba45SStephan Aßmus rgb_color markColor; 5452f86ba45SStephan Aßmus if (_RadioButtonAndCheckBoxMarkColor(base, markColor, flags)) { 5462f86ba45SStephan Aßmus view->SetHighColor(markColor); 5472f86ba45SStephan Aßmus rect.InsetBy(3, 3); 5482f86ba45SStephan Aßmus view->FillEllipse(rect); 5492f86ba45SStephan Aßmus } 5502f86ba45SStephan Aßmus } 5512f86ba45SStephan Aßmus 5522f86ba45SStephan Aßmus 5532f86ba45SStephan Aßmus void 5542f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect1, BRect& rect2, 5552f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 5562f86ba45SStephan Aßmus enum orientation orientation) 5572f86ba45SStephan Aßmus { 5582f86ba45SStephan Aßmus DrawScrollBarBackground(view, rect1, updateRect, base, flags, orientation); 5592f86ba45SStephan Aßmus DrawScrollBarBackground(view, rect2, updateRect, base, flags, orientation); 5602f86ba45SStephan Aßmus } 5612f86ba45SStephan Aßmus 56288969219SJohn Scipione 5632f86ba45SStephan Aßmus void 5642f86ba45SStephan Aßmus BControlLook::DrawScrollBarBackground(BView* view, BRect& rect, 5652f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 5662f86ba45SStephan Aßmus enum orientation orientation) 5672f86ba45SStephan Aßmus { 5682f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 5692f86ba45SStephan Aßmus return; 5702f86ba45SStephan Aßmus 5712f86ba45SStephan Aßmus float gradient1Tint; 5722f86ba45SStephan Aßmus float gradient2Tint; 5732f86ba45SStephan Aßmus float darkEdge1Tint; 5742f86ba45SStephan Aßmus float darkEdge2Tint; 5752f86ba45SStephan Aßmus float shadowTint; 5762f86ba45SStephan Aßmus 577a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 5782f86ba45SStephan Aßmus gradient1Tint = 0.9; 5792f86ba45SStephan Aßmus gradient2Tint = 0.8; 5802f86ba45SStephan Aßmus darkEdge1Tint = B_DARKEN_2_TINT; 5812f86ba45SStephan Aßmus darkEdge2Tint = B_DARKEN_2_TINT; 5822f86ba45SStephan Aßmus shadowTint = gradient1Tint; 5832f86ba45SStephan Aßmus } else { 5842f86ba45SStephan Aßmus gradient1Tint = 1.10; 5852f86ba45SStephan Aßmus gradient2Tint = 1.05; 5862f86ba45SStephan Aßmus darkEdge1Tint = B_DARKEN_3_TINT; 5872f86ba45SStephan Aßmus darkEdge2Tint = B_DARKEN_2_TINT; 5882f86ba45SStephan Aßmus shadowTint = gradient1Tint; 5892f86ba45SStephan Aßmus } 5902f86ba45SStephan Aßmus 5912f86ba45SStephan Aßmus rgb_color darkEdge1 = tint_color(base, darkEdge1Tint); 5922f86ba45SStephan Aßmus rgb_color darkEdge2 = tint_color(base, darkEdge2Tint); 5932f86ba45SStephan Aßmus rgb_color shadow = tint_color(base, shadowTint); 5942f86ba45SStephan Aßmus 5952f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 5962f86ba45SStephan Aßmus // dark vertical line on left edge 5972f86ba45SStephan Aßmus if (rect.Width() > 0) { 5982f86ba45SStephan Aßmus view->SetHighColor(darkEdge1); 5992f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.LeftBottom()); 6002f86ba45SStephan Aßmus rect.left++; 6012f86ba45SStephan Aßmus } 6022f86ba45SStephan Aßmus // dark vertical line on right edge 6032f86ba45SStephan Aßmus if (rect.Width() >= 0) { 6042f86ba45SStephan Aßmus view->SetHighColor(darkEdge2); 6052f86ba45SStephan Aßmus view->StrokeLine(rect.RightTop(), rect.RightBottom()); 6062f86ba45SStephan Aßmus rect.right--; 6072f86ba45SStephan Aßmus } 6082f86ba45SStephan Aßmus // vertical shadow line after left edge 6092f86ba45SStephan Aßmus if (rect.Width() >= 0) { 6102f86ba45SStephan Aßmus view->SetHighColor(shadow); 6112f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.LeftBottom()); 6122f86ba45SStephan Aßmus rect.left++; 6132f86ba45SStephan Aßmus } 6142f86ba45SStephan Aßmus // fill 6152f86ba45SStephan Aßmus if (rect.Width() >= 0) { 6162f86ba45SStephan Aßmus _FillGradient(view, rect, base, gradient1Tint, gradient2Tint, 6172f86ba45SStephan Aßmus orientation); 6182f86ba45SStephan Aßmus } 6192f86ba45SStephan Aßmus } else { 6202f86ba45SStephan Aßmus // dark vertical line on top edge 6212f86ba45SStephan Aßmus if (rect.Height() > 0) { 6222f86ba45SStephan Aßmus view->SetHighColor(darkEdge1); 6232f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.RightTop()); 6242f86ba45SStephan Aßmus rect.top++; 6252f86ba45SStephan Aßmus } 6262f86ba45SStephan Aßmus // dark vertical line on bottom edge 6272f86ba45SStephan Aßmus if (rect.Height() >= 0) { 6282f86ba45SStephan Aßmus view->SetHighColor(darkEdge2); 6292f86ba45SStephan Aßmus view->StrokeLine(rect.LeftBottom(), rect.RightBottom()); 6302f86ba45SStephan Aßmus rect.bottom--; 6312f86ba45SStephan Aßmus } 6322f86ba45SStephan Aßmus // horizontal shadow line after top edge 6332f86ba45SStephan Aßmus if (rect.Height() >= 0) { 6342f86ba45SStephan Aßmus view->SetHighColor(shadow); 6352f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.RightTop()); 6362f86ba45SStephan Aßmus rect.top++; 6372f86ba45SStephan Aßmus } 6382f86ba45SStephan Aßmus // fill 6392f86ba45SStephan Aßmus if (rect.Height() >= 0) { 6402f86ba45SStephan Aßmus _FillGradient(view, rect, base, gradient1Tint, gradient2Tint, 6412f86ba45SStephan Aßmus orientation); 6422f86ba45SStephan Aßmus } 6432f86ba45SStephan Aßmus } 6442f86ba45SStephan Aßmus } 6452f86ba45SStephan Aßmus 6462f86ba45SStephan Aßmus 64740a10e1cSStephan Aßmus void 64874bb70aeSStephan Aßmus BControlLook::DrawScrollViewFrame(BView* view, BRect& rect, 64974bb70aeSStephan Aßmus const BRect& updateRect, BRect verticalScrollBarFrame, 65074bb70aeSStephan Aßmus BRect horizontalScrollBarFrame, const rgb_color& base, 65174bb70aeSStephan Aßmus border_style border, uint32 flags, uint32 _borders) 65274bb70aeSStephan Aßmus { 653ce955579SStephan Aßmus // calculate scroll corner rect before messing with the "rect" 654ce955579SStephan Aßmus BRect scrollCornerFillRect(rect.right, rect.bottom, 655ce955579SStephan Aßmus rect.right, rect.bottom); 656ce955579SStephan Aßmus if (horizontalScrollBarFrame.IsValid()) 657ce955579SStephan Aßmus scrollCornerFillRect.left = horizontalScrollBarFrame.right + 1; 658ce955579SStephan Aßmus if (verticalScrollBarFrame.IsValid()) 659ce955579SStephan Aßmus scrollCornerFillRect.top = verticalScrollBarFrame.bottom + 1; 660ce955579SStephan Aßmus 661c44aa833SStephan Aßmus if (border == B_NO_BORDER) { 662c44aa833SStephan Aßmus if (scrollCornerFillRect.IsValid()) { 663c44aa833SStephan Aßmus view->SetHighColor(base); 664c44aa833SStephan Aßmus view->FillRect(scrollCornerFillRect); 665c44aa833SStephan Aßmus } 666c44aa833SStephan Aßmus return; 667c44aa833SStephan Aßmus } 668c44aa833SStephan Aßmus 669c44aa833SStephan Aßmus bool excludeScrollCorner = border == B_FANCY_BORDER 670c44aa833SStephan Aßmus && horizontalScrollBarFrame.IsValid() 671c44aa833SStephan Aßmus && verticalScrollBarFrame.IsValid(); 672c44aa833SStephan Aßmus 67374bb70aeSStephan Aßmus uint32 borders = _borders; 67474bb70aeSStephan Aßmus if (excludeScrollCorner) { 67574bb70aeSStephan Aßmus rect.bottom = horizontalScrollBarFrame.top; 67674bb70aeSStephan Aßmus rect.right = verticalScrollBarFrame.left; 67774bb70aeSStephan Aßmus borders &= ~(B_RIGHT_BORDER | B_BOTTOM_BORDER); 67874bb70aeSStephan Aßmus } 67974bb70aeSStephan Aßmus 68074bb70aeSStephan Aßmus rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT); 68174bb70aeSStephan Aßmus 68274bb70aeSStephan Aßmus if (border == B_FANCY_BORDER) 6834f579098SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders); 68474bb70aeSStephan Aßmus 685a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) { 68674bb70aeSStephan Aßmus rgb_color focusColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 68774bb70aeSStephan Aßmus _DrawFrame(view, rect, focusColor, focusColor, focusColor, focusColor, 68874bb70aeSStephan Aßmus borders); 68974bb70aeSStephan Aßmus } else { 69074bb70aeSStephan Aßmus _DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor, 69174bb70aeSStephan Aßmus scrollbarFrameColor, scrollbarFrameColor, borders); 69274bb70aeSStephan Aßmus } 69374bb70aeSStephan Aßmus 69474bb70aeSStephan Aßmus if (excludeScrollCorner) { 69574bb70aeSStephan Aßmus horizontalScrollBarFrame.InsetBy(-1, -1); 69674bb70aeSStephan Aßmus // do not overdraw the top edge 69774bb70aeSStephan Aßmus horizontalScrollBarFrame.top += 2; 69874bb70aeSStephan Aßmus borders = _borders; 69974bb70aeSStephan Aßmus borders &= ~B_TOP_BORDER; 70074bb70aeSStephan Aßmus _DrawOuterResessedFrame(view, horizontalScrollBarFrame, base, 7014f579098SStephan Aßmus 1.0, 1.0, flags, borders); 70274bb70aeSStephan Aßmus _DrawFrame(view, horizontalScrollBarFrame, scrollbarFrameColor, 70374bb70aeSStephan Aßmus scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor, 70474bb70aeSStephan Aßmus borders); 70574bb70aeSStephan Aßmus 70674bb70aeSStephan Aßmus 70774bb70aeSStephan Aßmus verticalScrollBarFrame.InsetBy(-1, -1); 70874bb70aeSStephan Aßmus // do not overdraw the left edge 70974bb70aeSStephan Aßmus verticalScrollBarFrame.left += 2; 71074bb70aeSStephan Aßmus borders = _borders; 71174bb70aeSStephan Aßmus borders &= ~B_LEFT_BORDER; 71274bb70aeSStephan Aßmus _DrawOuterResessedFrame(view, verticalScrollBarFrame, base, 7134f579098SStephan Aßmus 1.0, 1.0, flags, borders); 71474bb70aeSStephan Aßmus _DrawFrame(view, verticalScrollBarFrame, scrollbarFrameColor, 71574bb70aeSStephan Aßmus scrollbarFrameColor, scrollbarFrameColor, scrollbarFrameColor, 71674bb70aeSStephan Aßmus borders); 717ce955579SStephan Aßmus 718ce955579SStephan Aßmus // exclude recessed frame 719ce955579SStephan Aßmus scrollCornerFillRect.top++; 720ce955579SStephan Aßmus scrollCornerFillRect.left++; 721ce955579SStephan Aßmus } 722ce955579SStephan Aßmus 723ce955579SStephan Aßmus if (scrollCornerFillRect.IsValid()) { 724ce955579SStephan Aßmus view->SetHighColor(base); 725ce955579SStephan Aßmus view->FillRect(scrollCornerFillRect); 72674bb70aeSStephan Aßmus } 72774bb70aeSStephan Aßmus } 72874bb70aeSStephan Aßmus 72974bb70aeSStephan Aßmus 73074bb70aeSStephan Aßmus void 73140a10e1cSStephan Aßmus BControlLook::DrawArrowShape(BView* view, BRect& rect, const BRect& updateRect, 73240a10e1cSStephan Aßmus const rgb_color& base, uint32 direction, uint32 flags, float tint) 73340a10e1cSStephan Aßmus { 73440a10e1cSStephan Aßmus BPoint tri1, tri2, tri3; 73540a10e1cSStephan Aßmus float hInset = rect.Width() / 3; 73640a10e1cSStephan Aßmus float vInset = rect.Height() / 3; 73740a10e1cSStephan Aßmus rect.InsetBy(hInset, vInset); 73840a10e1cSStephan Aßmus 73940a10e1cSStephan Aßmus switch (direction) { 74040a10e1cSStephan Aßmus case B_LEFT_ARROW: 74140a10e1cSStephan Aßmus tri1.Set(rect.right, rect.top); 74240a10e1cSStephan Aßmus tri2.Set(rect.right - rect.Width() / 1.33, 74340a10e1cSStephan Aßmus (rect.top + rect.bottom + 1) / 2); 74440a10e1cSStephan Aßmus tri3.Set(rect.right, rect.bottom + 1); 74540a10e1cSStephan Aßmus break; 74640a10e1cSStephan Aßmus case B_RIGHT_ARROW: 747f9b1a47fSRyan Leavengood tri1.Set(rect.left + 1, rect.bottom + 1); 748f9b1a47fSRyan Leavengood tri2.Set(rect.left + 1 + rect.Width() / 1.33, 74940a10e1cSStephan Aßmus (rect.top + rect.bottom + 1) / 2); 750f9b1a47fSRyan Leavengood tri3.Set(rect.left + 1, rect.top); 75140a10e1cSStephan Aßmus break; 75240a10e1cSStephan Aßmus case B_UP_ARROW: 75340a10e1cSStephan Aßmus tri1.Set(rect.left, rect.bottom); 75440a10e1cSStephan Aßmus tri2.Set((rect.left + rect.right + 1) / 2, 75540a10e1cSStephan Aßmus rect.bottom - rect.Height() / 1.33); 75640a10e1cSStephan Aßmus tri3.Set(rect.right + 1, rect.bottom); 75740a10e1cSStephan Aßmus break; 75840a10e1cSStephan Aßmus case B_DOWN_ARROW: 75940a10e1cSStephan Aßmus default: 760f9b1a47fSRyan Leavengood tri1.Set(rect.left, rect.top + 1); 76140a10e1cSStephan Aßmus tri2.Set((rect.left + rect.right + 1) / 2, 762f9b1a47fSRyan Leavengood rect.top + 1 + rect.Height() / 1.33); 763f9b1a47fSRyan Leavengood tri3.Set(rect.right + 1, rect.top + 1); 76440a10e1cSStephan Aßmus break; 7651b41173cSJohn Scipione case B_LEFT_UP_ARROW: 766*17c9912bSJohn Scipione tri1.Set(rect.left, rect.bottom); 767*17c9912bSJohn Scipione tri2.Set(rect.left, rect.top); 768*17c9912bSJohn Scipione tri3.Set(rect.right - 1, rect.top); 7691b41173cSJohn Scipione break; 7701b41173cSJohn Scipione case B_RIGHT_UP_ARROW: 771348cd0c5SJohn Scipione tri1.Set(rect.left + 1, rect.top); 7721b41173cSJohn Scipione tri2.Set(rect.right, rect.top); 7731b41173cSJohn Scipione tri3.Set(rect.right, rect.bottom); 7741b41173cSJohn Scipione break; 7751b41173cSJohn Scipione case B_RIGHT_DOWN_ARROW: 7761b41173cSJohn Scipione tri1.Set(rect.right, rect.top); 7771b41173cSJohn Scipione tri2.Set(rect.right, rect.bottom); 778348cd0c5SJohn Scipione tri3.Set(rect.left + 1, rect.bottom); 7791b41173cSJohn Scipione break; 7801b41173cSJohn Scipione case B_LEFT_DOWN_ARROW: 781*17c9912bSJohn Scipione tri1.Set(rect.right - 1, rect.bottom); 782*17c9912bSJohn Scipione tri2.Set(rect.left, rect.bottom); 783*17c9912bSJohn Scipione tri3.Set(rect.left, rect.top); 7841b41173cSJohn Scipione break; 78540a10e1cSStephan Aßmus } 78640a10e1cSStephan Aßmus 78740a10e1cSStephan Aßmus BShape arrowShape; 78840a10e1cSStephan Aßmus arrowShape.MoveTo(tri1); 78940a10e1cSStephan Aßmus arrowShape.LineTo(tri2); 79040a10e1cSStephan Aßmus arrowShape.LineTo(tri3); 79140a10e1cSStephan Aßmus 792a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 79340a10e1cSStephan Aßmus tint = (tint + B_NO_TINT + B_NO_TINT) / 3; 79440a10e1cSStephan Aßmus 79540a10e1cSStephan Aßmus view->SetHighColor(tint_color(base, tint)); 79640a10e1cSStephan Aßmus 79740a10e1cSStephan Aßmus float penSize = view->PenSize(); 79840a10e1cSStephan Aßmus drawing_mode mode = view->DrawingMode(); 79940a10e1cSStephan Aßmus 800f44a56caSRyan Leavengood view->MovePenTo(BPoint(0, 0)); 801f44a56caSRyan Leavengood 80240a10e1cSStephan Aßmus view->SetPenSize(ceilf(hInset / 2.0)); 80340a10e1cSStephan Aßmus view->SetDrawingMode(B_OP_OVER); 80440a10e1cSStephan Aßmus view->StrokeShape(&arrowShape); 80540a10e1cSStephan Aßmus 80640a10e1cSStephan Aßmus view->SetPenSize(penSize); 80740a10e1cSStephan Aßmus view->SetDrawingMode(mode); 80840a10e1cSStephan Aßmus } 80940a10e1cSStephan Aßmus 81040a10e1cSStephan Aßmus 8112f86ba45SStephan Aßmus rgb_color 8122f86ba45SStephan Aßmus BControlLook::SliderBarColor(const rgb_color& base) 8132f86ba45SStephan Aßmus { 8142f86ba45SStephan Aßmus return tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT); 8152f86ba45SStephan Aßmus } 8162f86ba45SStephan Aßmus 8172f86ba45SStephan Aßmus 8182f86ba45SStephan Aßmus void 8192f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect, 8202f86ba45SStephan Aßmus const rgb_color& base, rgb_color leftFillColor, rgb_color rightFillColor, 8212f86ba45SStephan Aßmus float sliderScale, uint32 flags, enum orientation orientation) 8222f86ba45SStephan Aßmus { 8232f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 8242f86ba45SStephan Aßmus return; 8252f86ba45SStephan Aßmus 8265666b4f7SJohn Scipione // save the clipping constraints of the view 8275666b4f7SJohn Scipione view->PushState(); 8285666b4f7SJohn Scipione 8292f86ba45SStephan Aßmus // separate the bar in two sides 8302f86ba45SStephan Aßmus float sliderPosition; 8312f86ba45SStephan Aßmus BRect leftBarSide = rect; 8322f86ba45SStephan Aßmus BRect rightBarSide = rect; 8332f86ba45SStephan Aßmus 8342f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 8352f86ba45SStephan Aßmus sliderPosition = floorf(rect.left + 2 + (rect.Width() - 2) 8362f86ba45SStephan Aßmus * sliderScale); 8372f86ba45SStephan Aßmus leftBarSide.right = sliderPosition - 1; 8382f86ba45SStephan Aßmus rightBarSide.left = sliderPosition; 8392f86ba45SStephan Aßmus } else { 840f3997b74SStephan Aßmus // NOTE: position is reverse of coords 8412f86ba45SStephan Aßmus sliderPosition = floorf(rect.top + 2 + (rect.Height() - 2) 842f3997b74SStephan Aßmus * (1.0 - sliderScale)); 843f3997b74SStephan Aßmus leftBarSide.top = sliderPosition; 844f3997b74SStephan Aßmus rightBarSide.bottom = sliderPosition - 1; 8452f86ba45SStephan Aßmus } 8462f86ba45SStephan Aßmus 8472f86ba45SStephan Aßmus // fill the background for the corners, exclude the middle bar for now 8482f86ba45SStephan Aßmus BRegion region(rect); 8492f86ba45SStephan Aßmus region.Exclude(rightBarSide); 8502f86ba45SStephan Aßmus view->ConstrainClippingRegion(®ion); 8512f86ba45SStephan Aßmus 8522f86ba45SStephan Aßmus view->PushState(); 8532f86ba45SStephan Aßmus 8542f86ba45SStephan Aßmus DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags, 8552f86ba45SStephan Aßmus orientation); 8562f86ba45SStephan Aßmus 8572f86ba45SStephan Aßmus view->PopState(); 8582f86ba45SStephan Aßmus 8592f86ba45SStephan Aßmus region.Set(rect); 8602f86ba45SStephan Aßmus region.Exclude(leftBarSide); 8612f86ba45SStephan Aßmus view->ConstrainClippingRegion(®ion); 8622f86ba45SStephan Aßmus 8632f86ba45SStephan Aßmus view->PushState(); 8642f86ba45SStephan Aßmus 8652f86ba45SStephan Aßmus DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags, 8662f86ba45SStephan Aßmus orientation); 8672f86ba45SStephan Aßmus 8682f86ba45SStephan Aßmus view->PopState(); 8693244c2bcSJohn Scipione 8705666b4f7SJohn Scipione // restore the clipping constraints of the view 8715666b4f7SJohn Scipione view->PopState(); 8722f86ba45SStephan Aßmus } 8732f86ba45SStephan Aßmus 8742f86ba45SStephan Aßmus 8752f86ba45SStephan Aßmus void 8762f86ba45SStephan Aßmus BControlLook::DrawSliderBar(BView* view, BRect rect, const BRect& updateRect, 8772f86ba45SStephan Aßmus const rgb_color& base, rgb_color fillColor, uint32 flags, 8782f86ba45SStephan Aßmus enum orientation orientation) 8792f86ba45SStephan Aßmus { 8802f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 8812f86ba45SStephan Aßmus return; 8822f86ba45SStephan Aßmus 8832f86ba45SStephan Aßmus // separate the rect into corners 8842f86ba45SStephan Aßmus BRect leftCorner(rect); 8852f86ba45SStephan Aßmus BRect rightCorner(rect); 8862f86ba45SStephan Aßmus BRect barRect(rect); 8872f86ba45SStephan Aßmus 8882f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 8892f86ba45SStephan Aßmus leftCorner.right = leftCorner.left + leftCorner.Height(); 8902f86ba45SStephan Aßmus rightCorner.left = rightCorner.right - rightCorner.Height(); 8912f86ba45SStephan Aßmus barRect.left += ceilf(barRect.Height() / 2); 8922f86ba45SStephan Aßmus barRect.right -= ceilf(barRect.Height() / 2); 8932f86ba45SStephan Aßmus } else { 8942f86ba45SStephan Aßmus leftCorner.bottom = leftCorner.top + leftCorner.Width(); 8952f86ba45SStephan Aßmus rightCorner.top = rightCorner.bottom - rightCorner.Width(); 8962f86ba45SStephan Aßmus barRect.top += ceilf(barRect.Width() / 2); 8972f86ba45SStephan Aßmus barRect.bottom -= ceilf(barRect.Width() / 2); 8982f86ba45SStephan Aßmus } 8992f86ba45SStephan Aßmus 9002f86ba45SStephan Aßmus // fill the background for the corners, exclude the middle bar for now 9012f86ba45SStephan Aßmus BRegion region(rect); 9022f86ba45SStephan Aßmus region.Exclude(barRect); 9032f86ba45SStephan Aßmus view->ConstrainClippingRegion(®ion); 9042f86ba45SStephan Aßmus 90561ac1a85SStephan Aßmus if ((flags & B_BLEND_FRAME) == 0) { 9062f86ba45SStephan Aßmus view->SetHighColor(base); 9072f86ba45SStephan Aßmus view->FillRect(rect); 90861ac1a85SStephan Aßmus } 9092f86ba45SStephan Aßmus 9102f86ba45SStephan Aßmus // figure out the tints to be used 9112f86ba45SStephan Aßmus float edgeLightTint; 9122f86ba45SStephan Aßmus float edgeShadowTint; 9132f86ba45SStephan Aßmus float frameLightTint; 9142f86ba45SStephan Aßmus float frameShadowTint; 9152f86ba45SStephan Aßmus float fillLightTint; 9162f86ba45SStephan Aßmus float fillShadowTint; 91761ac1a85SStephan Aßmus uint8 edgeLightAlpha; 91861ac1a85SStephan Aßmus uint8 edgeShadowAlpha; 91961ac1a85SStephan Aßmus uint8 frameLightAlpha; 92061ac1a85SStephan Aßmus uint8 frameShadowAlpha; 9212f86ba45SStephan Aßmus 922a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 9232f86ba45SStephan Aßmus edgeLightTint = 1.0; 9242f86ba45SStephan Aßmus edgeShadowTint = 1.0; 9252f86ba45SStephan Aßmus frameLightTint = 1.20; 9262f86ba45SStephan Aßmus frameShadowTint = 1.25; 9272f86ba45SStephan Aßmus fillLightTint = 0.9; 9282f86ba45SStephan Aßmus fillShadowTint = 1.05; 92910ddee8dSStephan Aßmus edgeLightAlpha = 12; 93010ddee8dSStephan Aßmus edgeShadowAlpha = 12; 93161ac1a85SStephan Aßmus frameLightAlpha = 40; 93261ac1a85SStephan Aßmus frameShadowAlpha = 45; 9332f86ba45SStephan Aßmus 9342f86ba45SStephan Aßmus fillColor.red = uint8(fillColor.red * 0.4 + base.red * 0.6); 9352f86ba45SStephan Aßmus fillColor.green = uint8(fillColor.green * 0.4 + base.green * 0.6); 9362f86ba45SStephan Aßmus fillColor.blue = uint8(fillColor.blue * 0.4 + base.blue * 0.6); 9372f86ba45SStephan Aßmus } else { 9382f86ba45SStephan Aßmus edgeLightTint = 0.65; 9392f86ba45SStephan Aßmus edgeShadowTint = 1.07; 9402f86ba45SStephan Aßmus frameLightTint = 1.40; 9412f86ba45SStephan Aßmus frameShadowTint = 1.50; 9422f86ba45SStephan Aßmus fillLightTint = 0.8; 9432f86ba45SStephan Aßmus fillShadowTint = 1.1; 94410ddee8dSStephan Aßmus edgeLightAlpha = 15; 94510ddee8dSStephan Aßmus edgeShadowAlpha = 15; 94661ac1a85SStephan Aßmus frameLightAlpha = 92; 94761ac1a85SStephan Aßmus frameShadowAlpha = 107; 9482f86ba45SStephan Aßmus } 9492f86ba45SStephan Aßmus 95061ac1a85SStephan Aßmus rgb_color edgeLightColor; 95161ac1a85SStephan Aßmus rgb_color edgeShadowColor; 95261ac1a85SStephan Aßmus rgb_color frameLightColor; 95361ac1a85SStephan Aßmus rgb_color frameShadowColor; 9542f86ba45SStephan Aßmus rgb_color fillLightColor = tint_color(fillColor, fillLightTint); 9552f86ba45SStephan Aßmus rgb_color fillShadowColor = tint_color(fillColor, fillShadowTint); 9562f86ba45SStephan Aßmus 95761ac1a85SStephan Aßmus drawing_mode oldMode = view->DrawingMode(); 95861ac1a85SStephan Aßmus 959a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 96061ac1a85SStephan Aßmus edgeLightColor = (rgb_color){ 255, 255, 255, edgeLightAlpha }; 96161ac1a85SStephan Aßmus edgeShadowColor = (rgb_color){ 0, 0, 0, edgeShadowAlpha }; 96261ac1a85SStephan Aßmus frameLightColor = (rgb_color){ 0, 0, 0, frameLightAlpha }; 96361ac1a85SStephan Aßmus frameShadowColor = (rgb_color){ 0, 0, 0, frameShadowAlpha }; 96461ac1a85SStephan Aßmus 96561ac1a85SStephan Aßmus view->SetDrawingMode(B_OP_ALPHA); 96661ac1a85SStephan Aßmus } else { 96761ac1a85SStephan Aßmus edgeLightColor = tint_color(base, edgeLightTint); 96861ac1a85SStephan Aßmus edgeShadowColor = tint_color(base, edgeShadowTint); 96961ac1a85SStephan Aßmus frameLightColor = tint_color(fillColor, frameLightTint); 97061ac1a85SStephan Aßmus frameShadowColor = tint_color(fillColor, frameShadowTint); 97161ac1a85SStephan Aßmus } 97261ac1a85SStephan Aßmus 9732f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 9742f86ba45SStephan Aßmus _DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor, 9752f86ba45SStephan Aßmus edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, 9762f86ba45SStephan Aßmus fillShadowColor, 1.0, 1.0, 0.0, -1.0, orientation); 9772f86ba45SStephan Aßmus 9782f86ba45SStephan Aßmus _DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor, 9792f86ba45SStephan Aßmus edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, 9802f86ba45SStephan Aßmus fillShadowColor, 0.0, 1.0, -1.0, -1.0, orientation); 9812f86ba45SStephan Aßmus } else { 9822f86ba45SStephan Aßmus _DrawRoundBarCorner(view, leftCorner, updateRect, edgeLightColor, 9832f86ba45SStephan Aßmus edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, 9842f86ba45SStephan Aßmus fillShadowColor, 1.0, 1.0, -1.0, 0.0, orientation); 9852f86ba45SStephan Aßmus 9862f86ba45SStephan Aßmus _DrawRoundBarCorner(view, rightCorner, updateRect, edgeLightColor, 9872f86ba45SStephan Aßmus edgeShadowColor, frameLightColor, frameShadowColor, fillLightColor, 9882f86ba45SStephan Aßmus fillShadowColor, 1.0, 0.0, -1.0, -1.0, orientation); 9892f86ba45SStephan Aßmus } 9902f86ba45SStephan Aßmus 9912f86ba45SStephan Aßmus view->ConstrainClippingRegion(NULL); 9922f86ba45SStephan Aßmus 9932f86ba45SStephan Aßmus view->BeginLineArray(4); 9942f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 9952f86ba45SStephan Aßmus view->AddLine(barRect.LeftTop(), barRect.RightTop(), edgeShadowColor); 9962f86ba45SStephan Aßmus view->AddLine(barRect.LeftBottom(), barRect.RightBottom(), 9972f86ba45SStephan Aßmus edgeLightColor); 9982f86ba45SStephan Aßmus barRect.InsetBy(0, 1); 9992f86ba45SStephan Aßmus view->AddLine(barRect.LeftTop(), barRect.RightTop(), frameShadowColor); 10002f86ba45SStephan Aßmus view->AddLine(barRect.LeftBottom(), barRect.RightBottom(), 10012f86ba45SStephan Aßmus frameLightColor); 10022f86ba45SStephan Aßmus barRect.InsetBy(0, 1); 10032f86ba45SStephan Aßmus } else { 10042f86ba45SStephan Aßmus view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), edgeShadowColor); 10052f86ba45SStephan Aßmus view->AddLine(barRect.RightTop(), barRect.RightBottom(), 10062f86ba45SStephan Aßmus edgeLightColor); 10072f86ba45SStephan Aßmus barRect.InsetBy(1, 0); 10082f86ba45SStephan Aßmus view->AddLine(barRect.LeftTop(), barRect.LeftBottom(), frameShadowColor); 10092f86ba45SStephan Aßmus view->AddLine(barRect.RightTop(), barRect.RightBottom(), 10102f86ba45SStephan Aßmus frameLightColor); 10112f86ba45SStephan Aßmus barRect.InsetBy(1, 0); 10122f86ba45SStephan Aßmus } 10132f86ba45SStephan Aßmus view->EndLineArray(); 10142f86ba45SStephan Aßmus 101561ac1a85SStephan Aßmus view->SetDrawingMode(oldMode); 101661ac1a85SStephan Aßmus 10172f86ba45SStephan Aßmus _FillGradient(view, barRect, fillColor, fillShadowTint, fillLightTint, 10182f86ba45SStephan Aßmus orientation); 10192f86ba45SStephan Aßmus } 10202f86ba45SStephan Aßmus 10212f86ba45SStephan Aßmus 10222f86ba45SStephan Aßmus void 10232f86ba45SStephan Aßmus BControlLook::DrawSliderThumb(BView* view, BRect& rect, const BRect& updateRect, 10242f86ba45SStephan Aßmus const rgb_color& base, uint32 flags, enum orientation orientation) 10252f86ba45SStephan Aßmus { 10262f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 10272f86ba45SStephan Aßmus return; 10282f86ba45SStephan Aßmus 10292f86ba45SStephan Aßmus // figure out frame color 10302f86ba45SStephan Aßmus rgb_color frameLightColor; 10312f86ba45SStephan Aßmus rgb_color frameShadowColor; 10322f86ba45SStephan Aßmus rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 }; 10332f86ba45SStephan Aßmus 1034a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) { 10352f86ba45SStephan Aßmus // focused 10362f86ba45SStephan Aßmus frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 10372f86ba45SStephan Aßmus frameShadowColor = frameLightColor; 10382f86ba45SStephan Aßmus } else { 10392f86ba45SStephan Aßmus // figure out the tints to be used 10402f86ba45SStephan Aßmus float frameLightTint; 10412f86ba45SStephan Aßmus float frameShadowTint; 10422f86ba45SStephan Aßmus 1043a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 10442f86ba45SStephan Aßmus frameLightTint = 1.30; 10452f86ba45SStephan Aßmus frameShadowTint = 1.35; 10462f86ba45SStephan Aßmus shadowColor.alpha = 30; 10472f86ba45SStephan Aßmus } else { 10482f86ba45SStephan Aßmus frameLightTint = 1.6; 10492f86ba45SStephan Aßmus frameShadowTint = 1.65; 10502f86ba45SStephan Aßmus } 10512f86ba45SStephan Aßmus 10522f86ba45SStephan Aßmus frameLightColor = tint_color(base, frameLightTint); 10532f86ba45SStephan Aßmus frameShadowColor = tint_color(base, frameShadowTint); 10542f86ba45SStephan Aßmus } 10552f86ba45SStephan Aßmus 10562f86ba45SStephan Aßmus BRect originalRect(rect); 10572f86ba45SStephan Aßmus rect.right--; 10582f86ba45SStephan Aßmus rect.bottom--; 10592f86ba45SStephan Aßmus 10602f86ba45SStephan Aßmus _DrawFrame(view, rect, frameLightColor, frameLightColor, 10612f86ba45SStephan Aßmus frameShadowColor, frameShadowColor); 10622f86ba45SStephan Aßmus 10632f86ba45SStephan Aßmus flags &= ~B_ACTIVATED; 10642f86ba45SStephan Aßmus DrawButtonBackground(view, rect, updateRect, base, flags); 10652f86ba45SStephan Aßmus 10662f86ba45SStephan Aßmus // thumb shadow 10672f86ba45SStephan Aßmus view->SetDrawingMode(B_OP_ALPHA); 10682f86ba45SStephan Aßmus view->SetHighColor(shadowColor); 10692f86ba45SStephan Aßmus originalRect.left++; 10702f86ba45SStephan Aßmus originalRect.top++; 10712f86ba45SStephan Aßmus view->StrokeLine(originalRect.LeftBottom(), originalRect.RightBottom()); 10722f86ba45SStephan Aßmus originalRect.bottom--; 10732f86ba45SStephan Aßmus view->StrokeLine(originalRect.RightTop(), originalRect.RightBottom()); 10742f86ba45SStephan Aßmus 10752f86ba45SStephan Aßmus // thumb edge 10762f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 10772f86ba45SStephan Aßmus rect.InsetBy(0, floorf(rect.Height() / 4)); 10782f86ba45SStephan Aßmus rect.left = floorf((rect.left + rect.right) / 2); 10792f86ba45SStephan Aßmus rect.right = rect.left + 1; 10802f86ba45SStephan Aßmus shadowColor = tint_color(base, B_DARKEN_2_TINT); 10812f86ba45SStephan Aßmus shadowColor.alpha = 128; 10822f86ba45SStephan Aßmus view->SetHighColor(shadowColor); 10832f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.LeftBottom()); 10842f86ba45SStephan Aßmus rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT); 10852f86ba45SStephan Aßmus lightColor.alpha = 128; 10862f86ba45SStephan Aßmus view->SetHighColor(lightColor); 10872f86ba45SStephan Aßmus view->StrokeLine(rect.RightTop(), rect.RightBottom()); 10882f86ba45SStephan Aßmus } else { 10892f86ba45SStephan Aßmus rect.InsetBy(floorf(rect.Width() / 4), 0); 10902f86ba45SStephan Aßmus rect.top = floorf((rect.top + rect.bottom) / 2); 10912f86ba45SStephan Aßmus rect.bottom = rect.top + 1; 10922f86ba45SStephan Aßmus shadowColor = tint_color(base, B_DARKEN_2_TINT); 10932f86ba45SStephan Aßmus shadowColor.alpha = 128; 10942f86ba45SStephan Aßmus view->SetHighColor(shadowColor); 10952f86ba45SStephan Aßmus view->StrokeLine(rect.LeftTop(), rect.RightTop()); 10962f86ba45SStephan Aßmus rgb_color lightColor = tint_color(base, B_LIGHTEN_2_TINT); 10972f86ba45SStephan Aßmus lightColor.alpha = 128; 10982f86ba45SStephan Aßmus view->SetHighColor(lightColor); 10992f86ba45SStephan Aßmus view->StrokeLine(rect.LeftBottom(), rect.RightBottom()); 11002f86ba45SStephan Aßmus } 11012f86ba45SStephan Aßmus 11022f86ba45SStephan Aßmus view->SetDrawingMode(B_OP_COPY); 11032f86ba45SStephan Aßmus } 11042f86ba45SStephan Aßmus 11052f86ba45SStephan Aßmus 11062f86ba45SStephan Aßmus void 11072f86ba45SStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect, 11082f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 11092f86ba45SStephan Aßmus enum orientation orientation) 11102f86ba45SStephan Aßmus { 11118ee9217eSStephan Aßmus DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation); 11128ee9217eSStephan Aßmus } 11138ee9217eSStephan Aßmus 11148ee9217eSStephan Aßmus 11158ee9217eSStephan Aßmus void 11168ee9217eSStephan Aßmus BControlLook::DrawSliderTriangle(BView* view, BRect& rect, 11178ee9217eSStephan Aßmus const BRect& updateRect, const rgb_color& base, const rgb_color& fill, 11188ee9217eSStephan Aßmus uint32 flags, enum orientation orientation) 11198ee9217eSStephan Aßmus { 11202f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 11212f86ba45SStephan Aßmus return; 11222f86ba45SStephan Aßmus 11232f86ba45SStephan Aßmus // figure out frame color 11242f86ba45SStephan Aßmus rgb_color frameLightColor; 11252f86ba45SStephan Aßmus rgb_color frameShadowColor; 11262f86ba45SStephan Aßmus rgb_color shadowColor = (rgb_color){ 0, 0, 0, 60 }; 11272f86ba45SStephan Aßmus 11282f86ba45SStephan Aßmus float topTint = 0.49; 11292f86ba45SStephan Aßmus float middleTint1 = 0.62; 11302f86ba45SStephan Aßmus float middleTint2 = 0.76; 11312f86ba45SStephan Aßmus float bottomTint = 0.90; 11322f86ba45SStephan Aßmus 1133a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 11342f86ba45SStephan Aßmus topTint = (topTint + B_NO_TINT) / 2; 11352f86ba45SStephan Aßmus middleTint1 = (middleTint1 + B_NO_TINT) / 2; 11362f86ba45SStephan Aßmus middleTint2 = (middleTint2 + B_NO_TINT) / 2; 11372f86ba45SStephan Aßmus bottomTint = (bottomTint + B_NO_TINT) / 2; 1138a884b43bSJohn Scipione } else if ((flags & B_HOVER) != 0) { 11392f86ba45SStephan Aßmus static const float kHoverTintFactor = 0.85; 11402f86ba45SStephan Aßmus topTint *= kHoverTintFactor; 11412f86ba45SStephan Aßmus middleTint1 *= kHoverTintFactor; 11422f86ba45SStephan Aßmus middleTint2 *= kHoverTintFactor; 11432f86ba45SStephan Aßmus bottomTint *= kHoverTintFactor; 11442f86ba45SStephan Aßmus } 11452f86ba45SStephan Aßmus 1146a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) { 11472f86ba45SStephan Aßmus // focused 11482f86ba45SStephan Aßmus frameLightColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 11492f86ba45SStephan Aßmus frameShadowColor = frameLightColor; 11502f86ba45SStephan Aßmus } else { 11512f86ba45SStephan Aßmus // figure out the tints to be used 11522f86ba45SStephan Aßmus float frameLightTint; 11532f86ba45SStephan Aßmus float frameShadowTint; 11542f86ba45SStephan Aßmus 1155a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 11562f86ba45SStephan Aßmus frameLightTint = 1.30; 11572f86ba45SStephan Aßmus frameShadowTint = 1.35; 11582f86ba45SStephan Aßmus shadowColor.alpha = 30; 11592f86ba45SStephan Aßmus } else { 11602f86ba45SStephan Aßmus frameLightTint = 1.6; 11612f86ba45SStephan Aßmus frameShadowTint = 1.65; 11622f86ba45SStephan Aßmus } 11632f86ba45SStephan Aßmus 11642f86ba45SStephan Aßmus frameLightColor = tint_color(base, frameLightTint); 11652f86ba45SStephan Aßmus frameShadowColor = tint_color(base, frameShadowTint); 11662f86ba45SStephan Aßmus } 11672f86ba45SStephan Aßmus 11688ee9217eSStephan Aßmus // make room for the shadow 11698ee9217eSStephan Aßmus rect.right--; 11708ee9217eSStephan Aßmus rect.bottom--; 11712f86ba45SStephan Aßmus 11722f86ba45SStephan Aßmus uint32 viewFlags = view->Flags(); 11732f86ba45SStephan Aßmus view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE); 11742f86ba45SStephan Aßmus view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); 11752f86ba45SStephan Aßmus 1176f3997b74SStephan Aßmus float centerh = (rect.left + rect.right) / 2; 1177f3997b74SStephan Aßmus float centerv = (rect.top + rect.bottom) / 2; 11782f86ba45SStephan Aßmus 11798ee9217eSStephan Aßmus BShape shape; 1180f3997b74SStephan Aßmus if (orientation == B_HORIZONTAL) { 11818ee9217eSStephan Aßmus shape.MoveTo(BPoint(rect.left + 0.5, rect.bottom + 0.5)); 11828ee9217eSStephan Aßmus shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5)); 11838ee9217eSStephan Aßmus shape.LineTo(BPoint(rect.right + 0.5, rect.bottom - 1 + 0.5)); 1184f3997b74SStephan Aßmus shape.LineTo(BPoint(centerh + 0.5, rect.top + 0.5)); 11858ee9217eSStephan Aßmus shape.LineTo(BPoint(rect.left + 0.5, rect.bottom - 1 + 0.5)); 1186f3997b74SStephan Aßmus } else { 1187f3997b74SStephan Aßmus shape.MoveTo(BPoint(rect.right + 0.5, rect.top + 0.5)); 1188f3997b74SStephan Aßmus shape.LineTo(BPoint(rect.right + 0.5, rect.bottom + 0.5)); 1189f3997b74SStephan Aßmus shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.bottom + 0.5)); 1190f3997b74SStephan Aßmus shape.LineTo(BPoint(rect.left + 0.5, centerv + 0.5)); 1191f3997b74SStephan Aßmus shape.LineTo(BPoint(rect.right - 1 + 0.5, rect.top + 0.5)); 1192f3997b74SStephan Aßmus } 11938ee9217eSStephan Aßmus shape.Close(); 11948ee9217eSStephan Aßmus 11958ee9217eSStephan Aßmus view->MovePenTo(BPoint(1, 1)); 11968ee9217eSStephan Aßmus 11978ee9217eSStephan Aßmus view->SetDrawingMode(B_OP_ALPHA); 11988ee9217eSStephan Aßmus view->SetHighColor(shadowColor); 11998ee9217eSStephan Aßmus view->StrokeShape(&shape); 12008ee9217eSStephan Aßmus 12018ee9217eSStephan Aßmus view->MovePenTo(B_ORIGIN); 12028ee9217eSStephan Aßmus 12038ee9217eSStephan Aßmus view->SetDrawingMode(B_OP_COPY); 12042f86ba45SStephan Aßmus view->SetHighColor(frameLightColor); 12058ee9217eSStephan Aßmus view->StrokeShape(&shape); 12062f86ba45SStephan Aßmus 12072f86ba45SStephan Aßmus rect.InsetBy(1, 1); 12088ee9217eSStephan Aßmus shape.Clear(); 1209f3997b74SStephan Aßmus if (orientation == B_HORIZONTAL) { 12108ee9217eSStephan Aßmus shape.MoveTo(BPoint(rect.left, rect.bottom + 1)); 12118ee9217eSStephan Aßmus shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1)); 1212f3997b74SStephan Aßmus shape.LineTo(BPoint(centerh + 0.5, rect.top)); 1213f3997b74SStephan Aßmus } else { 1214f3997b74SStephan Aßmus shape.MoveTo(BPoint(rect.right + 1, rect.top)); 1215f3997b74SStephan Aßmus shape.LineTo(BPoint(rect.right + 1, rect.bottom + 1)); 1216f3997b74SStephan Aßmus shape.LineTo(BPoint(rect.left, centerv + 0.5)); 1217f3997b74SStephan Aßmus } 12188ee9217eSStephan Aßmus shape.Close(); 12192f86ba45SStephan Aßmus 12202f86ba45SStephan Aßmus BGradientLinear gradient; 1221a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 12228ee9217eSStephan Aßmus _MakeGradient(gradient, rect, fill, topTint, bottomTint); 12232f86ba45SStephan Aßmus } else { 12248ee9217eSStephan Aßmus _MakeGlossyGradient(gradient, rect, fill, topTint, middleTint1, 12252f86ba45SStephan Aßmus middleTint2, bottomTint); 12262f86ba45SStephan Aßmus } 12272f86ba45SStephan Aßmus 12288ee9217eSStephan Aßmus view->FillShape(&shape, gradient); 12292f86ba45SStephan Aßmus 12302f86ba45SStephan Aßmus view->SetFlags(viewFlags); 12312f86ba45SStephan Aßmus } 12322f86ba45SStephan Aßmus 12332f86ba45SStephan Aßmus 12342f86ba45SStephan Aßmus void 12352f86ba45SStephan Aßmus BControlLook::DrawSliderHashMarks(BView* view, BRect& rect, 12362f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, int32 count, 12372f86ba45SStephan Aßmus hash_mark_location location, uint32 flags, enum orientation orientation) 12382f86ba45SStephan Aßmus { 12392f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 12402f86ba45SStephan Aßmus return; 12412f86ba45SStephan Aßmus 12422f86ba45SStephan Aßmus rgb_color lightColor; 12432f86ba45SStephan Aßmus rgb_color darkColor; 12442f86ba45SStephan Aßmus 1245a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 12462f86ba45SStephan Aßmus lightColor = tint_color(base, 0.9); 12472f86ba45SStephan Aßmus darkColor = tint_color(base, 1.07); 12482f86ba45SStephan Aßmus } else { 12492f86ba45SStephan Aßmus lightColor = tint_color(base, 0.8); 12502f86ba45SStephan Aßmus darkColor = tint_color(base, 1.14); 12512f86ba45SStephan Aßmus } 12522f86ba45SStephan Aßmus 12532f86ba45SStephan Aßmus int32 hashMarkCount = max_c(count, 2); 12542f86ba45SStephan Aßmus // draw at least two hashmarks at min/max if 12552f86ba45SStephan Aßmus // fHashMarks != B_HASH_MARKS_NONE 12562f86ba45SStephan Aßmus float factor; 12572f86ba45SStephan Aßmus float startPos; 12582f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 12592f86ba45SStephan Aßmus factor = (rect.Width() - 2) / (hashMarkCount - 1); 12602f86ba45SStephan Aßmus startPos = rect.left + 1; 12612f86ba45SStephan Aßmus } else { 12622f86ba45SStephan Aßmus factor = (rect.Height() - 2) / (hashMarkCount - 1); 12632f86ba45SStephan Aßmus startPos = rect.top + 1; 12642f86ba45SStephan Aßmus } 12652f86ba45SStephan Aßmus 12662f86ba45SStephan Aßmus if (location & B_HASH_MARKS_TOP) { 12672f86ba45SStephan Aßmus view->BeginLineArray(hashMarkCount * 2); 12682f86ba45SStephan Aßmus 12692f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 12702f86ba45SStephan Aßmus float pos = startPos; 12712f86ba45SStephan Aßmus for (int32 i = 0; i < hashMarkCount; i++) { 12722f86ba45SStephan Aßmus view->AddLine(BPoint(pos, rect.top), 12732f86ba45SStephan Aßmus BPoint(pos, rect.top + 4), darkColor); 12742f86ba45SStephan Aßmus view->AddLine(BPoint(pos + 1, rect.top), 12752f86ba45SStephan Aßmus BPoint(pos + 1, rect.top + 4), lightColor); 12762f86ba45SStephan Aßmus 12772f86ba45SStephan Aßmus pos += factor; 12782f86ba45SStephan Aßmus } 12792f86ba45SStephan Aßmus } else { 12802f86ba45SStephan Aßmus float pos = startPos; 12812f86ba45SStephan Aßmus for (int32 i = 0; i < hashMarkCount; i++) { 12822f86ba45SStephan Aßmus view->AddLine(BPoint(rect.left, pos), 12832f86ba45SStephan Aßmus BPoint(rect.left + 4, pos), darkColor); 12842f86ba45SStephan Aßmus view->AddLine(BPoint(rect.left, pos + 1), 12852f86ba45SStephan Aßmus BPoint(rect.left + 4, pos + 1), lightColor); 12862f86ba45SStephan Aßmus 12872f86ba45SStephan Aßmus pos += factor; 12882f86ba45SStephan Aßmus } 12892f86ba45SStephan Aßmus } 12902f86ba45SStephan Aßmus 12912f86ba45SStephan Aßmus view->EndLineArray(); 12922f86ba45SStephan Aßmus } 12932f86ba45SStephan Aßmus 12942f86ba45SStephan Aßmus if (location & B_HASH_MARKS_BOTTOM) { 12952f86ba45SStephan Aßmus 12962f86ba45SStephan Aßmus view->BeginLineArray(hashMarkCount * 2); 12972f86ba45SStephan Aßmus 12982f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) { 12992f86ba45SStephan Aßmus float pos = startPos; 13002f86ba45SStephan Aßmus for (int32 i = 0; i < hashMarkCount; i++) { 13012f86ba45SStephan Aßmus view->AddLine(BPoint(pos, rect.bottom - 4), 13022f86ba45SStephan Aßmus BPoint(pos, rect.bottom), darkColor); 13032f86ba45SStephan Aßmus view->AddLine(BPoint(pos + 1, rect.bottom - 4), 13042f86ba45SStephan Aßmus BPoint(pos + 1, rect.bottom), lightColor); 13052f86ba45SStephan Aßmus 13062f86ba45SStephan Aßmus pos += factor; 13072f86ba45SStephan Aßmus } 13082f86ba45SStephan Aßmus } else { 13092f86ba45SStephan Aßmus float pos = startPos; 13102f86ba45SStephan Aßmus for (int32 i = 0; i < hashMarkCount; i++) { 13112f86ba45SStephan Aßmus view->AddLine(BPoint(rect.right - 4, pos), 13122f86ba45SStephan Aßmus BPoint(rect.right, pos), darkColor); 13132f86ba45SStephan Aßmus view->AddLine(BPoint(rect.right - 4, pos + 1), 13142f86ba45SStephan Aßmus BPoint(rect.right, pos + 1), lightColor); 13152f86ba45SStephan Aßmus 13162f86ba45SStephan Aßmus pos += factor; 13172f86ba45SStephan Aßmus } 13182f86ba45SStephan Aßmus } 13192f86ba45SStephan Aßmus 13202f86ba45SStephan Aßmus view->EndLineArray(); 13212f86ba45SStephan Aßmus } 13222f86ba45SStephan Aßmus } 13232f86ba45SStephan Aßmus 13242f86ba45SStephan Aßmus 13252f86ba45SStephan Aßmus void 13262f86ba45SStephan Aßmus BControlLook::DrawActiveTab(BView* view, BRect& rect, const BRect& updateRect, 13272f86ba45SStephan Aßmus const rgb_color& base, uint32 flags, uint32 borders) 13282f86ba45SStephan Aßmus { 13292f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 13302f86ba45SStephan Aßmus return; 13312f86ba45SStephan Aßmus 13325666b4f7SJohn Scipione // save the clipping constraints of the view 13335666b4f7SJohn Scipione view->PushState(); 1334a884b43bSJohn Scipione 13355666b4f7SJohn Scipione // set clipping constraints to updateRect 13365666b4f7SJohn Scipione BRegion clipping(updateRect); 1337a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 1338a884b43bSJohn Scipione 13392f86ba45SStephan Aßmus rgb_color edgeShadowColor; 13402f86ba45SStephan Aßmus rgb_color edgeLightColor; 13412f86ba45SStephan Aßmus rgb_color frameShadowColor; 13422f86ba45SStephan Aßmus rgb_color frameLightColor; 13432f86ba45SStephan Aßmus rgb_color bevelShadowColor; 13442f86ba45SStephan Aßmus rgb_color bevelLightColor; 13452f86ba45SStephan Aßmus BGradientLinear fillGradient; 13462f86ba45SStephan Aßmus fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3)); 13472f86ba45SStephan Aßmus fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3)); 13482f86ba45SStephan Aßmus 1349a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 13502f86ba45SStephan Aßmus edgeLightColor = base; 1351a884b43bSJohn Scipione edgeShadowColor = base; 13522f86ba45SStephan Aßmus frameLightColor = tint_color(base, 1.25); 1353a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.30); 13542f86ba45SStephan Aßmus bevelLightColor = tint_color(base, 0.8); 1355a884b43bSJohn Scipione bevelShadowColor = tint_color(base, 1.07); 13562f86ba45SStephan Aßmus fillGradient.AddColor(tint_color(base, 0.85), 0); 13572f86ba45SStephan Aßmus fillGradient.AddColor(base, 255); 13582f86ba45SStephan Aßmus } else { 13592f86ba45SStephan Aßmus edgeLightColor = tint_color(base, 0.80); 1360a884b43bSJohn Scipione edgeShadowColor = tint_color(base, 1.03); 13612f86ba45SStephan Aßmus frameLightColor = tint_color(base, 1.30); 1362a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.30); 13632f86ba45SStephan Aßmus bevelLightColor = tint_color(base, 0.6); 1364a884b43bSJohn Scipione bevelShadowColor = tint_color(base, 1.07); 13652f86ba45SStephan Aßmus fillGradient.AddColor(tint_color(base, 0.75), 0); 13662f86ba45SStephan Aßmus fillGradient.AddColor(tint_color(base, 1.03), 255); 13672f86ba45SStephan Aßmus } 136812ea5a2cSStephan Aßmus 1369a884b43bSJohn Scipione static const float kRoundCornerRadius = 4.0f; 13702f86ba45SStephan Aßmus 1371a884b43bSJohn Scipione // left top corner dimensions 1372a884b43bSJohn Scipione BRect leftTopCorner(rect); 1373a884b43bSJohn Scipione leftTopCorner.right = floorf(leftTopCorner.left + kRoundCornerRadius); 1374a884b43bSJohn Scipione leftTopCorner.bottom = floorf(rect.top + kRoundCornerRadius); 1375a884b43bSJohn Scipione clipping.Exclude(leftTopCorner); 13762f86ba45SStephan Aßmus 1377a884b43bSJohn Scipione // draw the left top corner 1378a884b43bSJohn Scipione _DrawRoundCornerLeftTop(view, leftTopCorner, updateRect, base, 1379a884b43bSJohn Scipione edgeShadowColor, frameLightColor, bevelLightColor, 1380a884b43bSJohn Scipione fillGradient); 13812f86ba45SStephan Aßmus 1382a884b43bSJohn Scipione // right top corner dimensions 1383a884b43bSJohn Scipione BRect rightTopCorner(rect); 1384a884b43bSJohn Scipione rightTopCorner.right = floorf(rect.right); 1385a884b43bSJohn Scipione rightTopCorner.left = floorf(rightTopCorner.right - kRoundCornerRadius); 1386a884b43bSJohn Scipione rightTopCorner.bottom = floorf(rect.top + kRoundCornerRadius); 1387a884b43bSJohn Scipione clipping.Exclude(rightTopCorner); 13882f86ba45SStephan Aßmus 1389a884b43bSJohn Scipione // draw the right top corner 1390a884b43bSJohn Scipione _DrawRoundCornerRightTop(view, rightTopCorner, updateRect, base, 1391a884b43bSJohn Scipione edgeShadowColor, edgeLightColor, frameLightColor, 1392a884b43bSJohn Scipione frameShadowColor, bevelLightColor, bevelShadowColor, 1393a884b43bSJohn Scipione fillGradient); 13942f86ba45SStephan Aßmus 1395a884b43bSJohn Scipione // clip out the corners 13962f86ba45SStephan Aßmus view->ConstrainClippingRegion(&clipping); 13972f86ba45SStephan Aßmus 1398a884b43bSJohn Scipione // draw the rest of frame and fill 13992f86ba45SStephan Aßmus _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor, 14002f86ba45SStephan Aßmus edgeLightColor, 14012f86ba45SStephan Aßmus borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER)); 14022f86ba45SStephan Aßmus if ((borders & B_LEFT_BORDER) == 0) 14032f86ba45SStephan Aßmus rect.left++; 14042f86ba45SStephan Aßmus if ((borders & B_RIGHT_BORDER) == 0) 14052f86ba45SStephan Aßmus rect.right--; 14062f86ba45SStephan Aßmus 14072f86ba45SStephan Aßmus _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor, 14082f86ba45SStephan Aßmus frameShadowColor, B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER); 14092f86ba45SStephan Aßmus 14102f86ba45SStephan Aßmus _DrawFrame(view, rect, bevelLightColor, bevelLightColor, bevelShadowColor, 14112f86ba45SStephan Aßmus bevelShadowColor); 14122f86ba45SStephan Aßmus 14132f86ba45SStephan Aßmus view->FillRect(rect, fillGradient); 14142f86ba45SStephan Aßmus 14155666b4f7SJohn Scipione // restore the clipping constraints of the view 14165666b4f7SJohn Scipione view->PopState(); 14172f86ba45SStephan Aßmus } 14182f86ba45SStephan Aßmus 14192f86ba45SStephan Aßmus 14202f86ba45SStephan Aßmus void 142183aff015SPhilippe Houdoin BControlLook::DrawInactiveTab(BView* view, BRect& rect, const BRect& updateRect, 14222f86ba45SStephan Aßmus const rgb_color& base, uint32 flags, uint32 borders) 14232f86ba45SStephan Aßmus { 14242f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 14252f86ba45SStephan Aßmus return; 14262f86ba45SStephan Aßmus 14272f86ba45SStephan Aßmus rgb_color edgeShadowColor; 14282f86ba45SStephan Aßmus rgb_color edgeLightColor; 14292f86ba45SStephan Aßmus rgb_color frameShadowColor; 14302f86ba45SStephan Aßmus rgb_color frameLightColor; 14312f86ba45SStephan Aßmus rgb_color bevelShadowColor; 14322f86ba45SStephan Aßmus rgb_color bevelLightColor; 14332f86ba45SStephan Aßmus BGradientLinear fillGradient; 14342f86ba45SStephan Aßmus fillGradient.SetStart(rect.LeftTop() + BPoint(3, 3)); 14352f86ba45SStephan Aßmus fillGradient.SetEnd(rect.LeftBottom() + BPoint(3, -3)); 14362f86ba45SStephan Aßmus 1437a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 14382f86ba45SStephan Aßmus edgeLightColor = base; 1439a884b43bSJohn Scipione edgeShadowColor = base; 14402f86ba45SStephan Aßmus frameLightColor = tint_color(base, 1.25); 1441a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.30); 14422f86ba45SStephan Aßmus bevelLightColor = tint_color(base, 0.8); 1443a884b43bSJohn Scipione bevelShadowColor = tint_color(base, 1.07); 14442f86ba45SStephan Aßmus fillGradient.AddColor(tint_color(base, 0.85), 0); 14452f86ba45SStephan Aßmus fillGradient.AddColor(base, 255); 14462f86ba45SStephan Aßmus } else { 14472f86ba45SStephan Aßmus edgeLightColor = tint_color(base, 0.80); 1448a884b43bSJohn Scipione edgeShadowColor = tint_color(base, 1.03); 14492f86ba45SStephan Aßmus frameLightColor = tint_color(base, 1.30); 1450a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.30); 14512f86ba45SStephan Aßmus bevelLightColor = tint_color(base, 1.10); 1452a884b43bSJohn Scipione bevelShadowColor = tint_color(base, 1.17); 14532f86ba45SStephan Aßmus fillGradient.AddColor(tint_color(base, 1.12), 0); 14542f86ba45SStephan Aßmus fillGradient.AddColor(tint_color(base, 1.08), 255); 14552f86ba45SStephan Aßmus } 14562f86ba45SStephan Aßmus 14572f86ba45SStephan Aßmus // active tabs stand out at the top, but this is an inactive tab 14582f86ba45SStephan Aßmus view->SetHighColor(base); 14592f86ba45SStephan Aßmus view->FillRect(BRect(rect.left, rect.top, rect.right, rect.top + 4)); 14602f86ba45SStephan Aßmus rect.top += 4; 14612f86ba45SStephan Aßmus 14622f86ba45SStephan Aßmus // frame and fill 14632f86ba45SStephan Aßmus _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor, 14642f86ba45SStephan Aßmus edgeLightColor, 14652f86ba45SStephan Aßmus borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER)); 14662f86ba45SStephan Aßmus 14672f86ba45SStephan Aßmus _DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor, 14682f86ba45SStephan Aßmus frameShadowColor, 14692f86ba45SStephan Aßmus borders & (B_LEFT_BORDER | B_TOP_BORDER | B_RIGHT_BORDER)); 14702f86ba45SStephan Aßmus 1471b3601d82SStephan Aßmus if (rect.IsValid()) { 1472b3601d82SStephan Aßmus _DrawFrame(view, rect, bevelShadowColor, bevelShadowColor, 1473b3601d82SStephan Aßmus bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders); 1474b3601d82SStephan Aßmus } else { 1475b3601d82SStephan Aßmus if ((B_LEFT_BORDER & ~borders) != 0) 1476b3601d82SStephan Aßmus rect.left++; 1477b3601d82SStephan Aßmus } 14782f86ba45SStephan Aßmus 14792f86ba45SStephan Aßmus view->FillRect(rect, fillGradient); 14802f86ba45SStephan Aßmus } 14812f86ba45SStephan Aßmus 14822f86ba45SStephan Aßmus 14831f9fd6d8SStephan Aßmus void 14841f9fd6d8SStephan Aßmus BControlLook::DrawSplitter(BView* view, BRect& rect, const BRect& updateRect, 14851f9fd6d8SStephan Aßmus const rgb_color& base, enum orientation orientation, uint32 flags, 14861f9fd6d8SStephan Aßmus uint32 borders) 14871f9fd6d8SStephan Aßmus { 1488a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 1489a884b43bSJohn Scipione return; 1490a884b43bSJohn Scipione 14911f9fd6d8SStephan Aßmus rgb_color background; 14921f9fd6d8SStephan Aßmus if ((flags & (B_CLICKED | B_ACTIVATED)) != 0) 14931f9fd6d8SStephan Aßmus background = tint_color(base, B_DARKEN_1_TINT); 14941f9fd6d8SStephan Aßmus else 14951f9fd6d8SStephan Aßmus background = base; 14961f9fd6d8SStephan Aßmus 14971f9fd6d8SStephan Aßmus rgb_color light = tint_color(background, 0.6); 14981f9fd6d8SStephan Aßmus rgb_color shadow = tint_color(background, 1.21); 14991f9fd6d8SStephan Aßmus 15001f9fd6d8SStephan Aßmus // frame 15011f9fd6d8SStephan Aßmus if (borders != 0 && rect.Width() > 3 && rect.Height() > 3) 15021f9fd6d8SStephan Aßmus DrawRaisedBorder(view, rect, updateRect, background, flags, borders); 15031f9fd6d8SStephan Aßmus 15041f9fd6d8SStephan Aßmus // dots and rest of background 15051f9fd6d8SStephan Aßmus if (orientation == B_HORIZONTAL) { 15061f9fd6d8SStephan Aßmus if (rect.Width() > 2) { 15071f9fd6d8SStephan Aßmus // background on left/right 15081f9fd6d8SStephan Aßmus BRegion region(rect); 15091f9fd6d8SStephan Aßmus rect.left = floorf((rect.left + rect.right) / 2.0 - 0.5); 15101f9fd6d8SStephan Aßmus rect.right = rect.left + 1; 15111f9fd6d8SStephan Aßmus region.Exclude(rect); 15121f9fd6d8SStephan Aßmus view->SetHighColor(background); 15131f9fd6d8SStephan Aßmus view->FillRegion(®ion); 15141f9fd6d8SStephan Aßmus } 15151f9fd6d8SStephan Aßmus 15161f9fd6d8SStephan Aßmus BPoint dot = rect.LeftTop(); 15171f9fd6d8SStephan Aßmus BPoint stop = rect.LeftBottom(); 15181f9fd6d8SStephan Aßmus int32 num = 1; 15191f9fd6d8SStephan Aßmus while (dot.y <= stop.y) { 15201f9fd6d8SStephan Aßmus rgb_color col1; 15211f9fd6d8SStephan Aßmus rgb_color col2; 15221f9fd6d8SStephan Aßmus switch (num) { 15231f9fd6d8SStephan Aßmus case 1: 15241f9fd6d8SStephan Aßmus col1 = background; 15251f9fd6d8SStephan Aßmus col2 = background; 15261f9fd6d8SStephan Aßmus break; 15271f9fd6d8SStephan Aßmus case 2: 15281f9fd6d8SStephan Aßmus col1 = shadow; 15291f9fd6d8SStephan Aßmus col2 = background; 15301f9fd6d8SStephan Aßmus break; 15311f9fd6d8SStephan Aßmus case 3: 1532a5339f65SStephan Aßmus default: 15331f9fd6d8SStephan Aßmus col1 = background; 15341f9fd6d8SStephan Aßmus col2 = light; 15351f9fd6d8SStephan Aßmus num = 0; 15361f9fd6d8SStephan Aßmus break; 15371f9fd6d8SStephan Aßmus } 15381f9fd6d8SStephan Aßmus view->SetHighColor(col1); 15391f9fd6d8SStephan Aßmus view->StrokeLine(dot, dot, B_SOLID_HIGH); 15401f9fd6d8SStephan Aßmus view->SetHighColor(col2); 15411f9fd6d8SStephan Aßmus dot.x++; 15421f9fd6d8SStephan Aßmus view->StrokeLine(dot, dot, B_SOLID_HIGH); 15431f9fd6d8SStephan Aßmus dot.x -= 1.0; 15441f9fd6d8SStephan Aßmus // next pixel 15451f9fd6d8SStephan Aßmus num++; 15461f9fd6d8SStephan Aßmus dot.y++; 15471f9fd6d8SStephan Aßmus } 15481f9fd6d8SStephan Aßmus } else { 15491f9fd6d8SStephan Aßmus if (rect.Height() > 2) { 15501f9fd6d8SStephan Aßmus // background on left/right 15511f9fd6d8SStephan Aßmus BRegion region(rect); 15521f9fd6d8SStephan Aßmus rect.top = floorf((rect.top + rect.bottom) / 2.0 - 0.5); 15531f9fd6d8SStephan Aßmus rect.bottom = rect.top + 1; 15541f9fd6d8SStephan Aßmus region.Exclude(rect); 15551f9fd6d8SStephan Aßmus view->SetHighColor(background); 15561f9fd6d8SStephan Aßmus view->FillRegion(®ion); 15571f9fd6d8SStephan Aßmus } 15581f9fd6d8SStephan Aßmus 15591f9fd6d8SStephan Aßmus BPoint dot = rect.LeftTop(); 15601f9fd6d8SStephan Aßmus BPoint stop = rect.RightTop(); 15611f9fd6d8SStephan Aßmus int32 num = 1; 15621f9fd6d8SStephan Aßmus while (dot.x <= stop.x) { 15631f9fd6d8SStephan Aßmus rgb_color col1; 15641f9fd6d8SStephan Aßmus rgb_color col2; 15651f9fd6d8SStephan Aßmus switch (num) { 15661f9fd6d8SStephan Aßmus case 1: 15671f9fd6d8SStephan Aßmus col1 = background; 15681f9fd6d8SStephan Aßmus col2 = background; 15691f9fd6d8SStephan Aßmus break; 15701f9fd6d8SStephan Aßmus case 2: 15711f9fd6d8SStephan Aßmus col1 = shadow; 15721f9fd6d8SStephan Aßmus col2 = background; 15731f9fd6d8SStephan Aßmus break; 15741f9fd6d8SStephan Aßmus case 3: 15759f981a88SFrançois Revol default: 15761f9fd6d8SStephan Aßmus col1 = background; 15771f9fd6d8SStephan Aßmus col2 = light; 15781f9fd6d8SStephan Aßmus num = 0; 15791f9fd6d8SStephan Aßmus break; 15801f9fd6d8SStephan Aßmus } 15811f9fd6d8SStephan Aßmus view->SetHighColor(col1); 15821f9fd6d8SStephan Aßmus view->StrokeLine(dot, dot, B_SOLID_HIGH); 15831f9fd6d8SStephan Aßmus view->SetHighColor(col2); 15841f9fd6d8SStephan Aßmus dot.y++; 15851f9fd6d8SStephan Aßmus view->StrokeLine(dot, dot, B_SOLID_HIGH); 15861f9fd6d8SStephan Aßmus dot.y -= 1.0; 15871f9fd6d8SStephan Aßmus // next pixel 15881f9fd6d8SStephan Aßmus num++; 15891f9fd6d8SStephan Aßmus dot.x++; 15901f9fd6d8SStephan Aßmus } 15911f9fd6d8SStephan Aßmus } 15921f9fd6d8SStephan Aßmus } 15931f9fd6d8SStephan Aßmus 15941f9fd6d8SStephan Aßmus 15952f86ba45SStephan Aßmus // #pragma mark - 15962f86ba45SStephan Aßmus 15972f86ba45SStephan Aßmus 15982f86ba45SStephan Aßmus void 15992f86ba45SStephan Aßmus BControlLook::DrawBorder(BView* view, BRect& rect, const BRect& updateRect, 16002f86ba45SStephan Aßmus const rgb_color& base, border_style border, uint32 flags, uint32 borders) 16012f86ba45SStephan Aßmus { 16022f86ba45SStephan Aßmus if (border == B_NO_BORDER) 16032f86ba45SStephan Aßmus return; 16042f86ba45SStephan Aßmus 16052f86ba45SStephan Aßmus rgb_color scrollbarFrameColor = tint_color(base, B_DARKEN_2_TINT); 1606a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) 16072f86ba45SStephan Aßmus scrollbarFrameColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 16082f86ba45SStephan Aßmus 16092f86ba45SStephan Aßmus if (border == B_FANCY_BORDER) 16104f579098SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 1.0, 1.0, flags, borders); 16112f86ba45SStephan Aßmus 16122f86ba45SStephan Aßmus _DrawFrame(view, rect, scrollbarFrameColor, scrollbarFrameColor, 16132f86ba45SStephan Aßmus scrollbarFrameColor, scrollbarFrameColor, borders); 16142f86ba45SStephan Aßmus } 16152f86ba45SStephan Aßmus 16162f86ba45SStephan Aßmus 16172f86ba45SStephan Aßmus void 16182f86ba45SStephan Aßmus BControlLook::DrawRaisedBorder(BView* view, BRect& rect, 16192f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 16202f86ba45SStephan Aßmus uint32 borders) 16212f86ba45SStephan Aßmus { 16222f86ba45SStephan Aßmus rgb_color lightColor; 16232f86ba45SStephan Aßmus rgb_color shadowColor; 16242f86ba45SStephan Aßmus 1625a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 16262f86ba45SStephan Aßmus lightColor = base; 16272f86ba45SStephan Aßmus shadowColor = base; 16282f86ba45SStephan Aßmus } else { 16292f86ba45SStephan Aßmus lightColor = tint_color(base, 0.85); 16302f86ba45SStephan Aßmus shadowColor = tint_color(base, 1.07); 16312f86ba45SStephan Aßmus } 16322f86ba45SStephan Aßmus 16332f86ba45SStephan Aßmus _DrawFrame(view, rect, lightColor, lightColor, shadowColor, shadowColor, 16342f86ba45SStephan Aßmus borders); 16352f86ba45SStephan Aßmus } 16362f86ba45SStephan Aßmus 16372f86ba45SStephan Aßmus 16382f86ba45SStephan Aßmus void 16392f86ba45SStephan Aßmus BControlLook::DrawTextControlBorder(BView* view, BRect& rect, 16402f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 16412f86ba45SStephan Aßmus uint32 borders) 16422f86ba45SStephan Aßmus { 16432f86ba45SStephan Aßmus if (!rect.Intersects(updateRect)) 16442f86ba45SStephan Aßmus return; 16452f86ba45SStephan Aßmus 16462f86ba45SStephan Aßmus rgb_color dark1BorderColor; 16472f86ba45SStephan Aßmus rgb_color dark2BorderColor; 16482f86ba45SStephan Aßmus rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); 16492f86ba45SStephan Aßmus 1650a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 16514f579098SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 0.0, 1.0, flags, borders); 16522f86ba45SStephan Aßmus 1653a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) 16544f579098SStephan Aßmus dark1BorderColor = (rgb_color){ 0, 0, 0, 40 }; 16554f579098SStephan Aßmus else 16562f86ba45SStephan Aßmus dark1BorderColor = tint_color(base, 1.15); 16574f579098SStephan Aßmus dark2BorderColor = dark1BorderColor; 1658a884b43bSJohn Scipione } else if ((flags & B_CLICKED) != 0) { 16592f86ba45SStephan Aßmus dark1BorderColor = tint_color(base, 1.50); 16602f86ba45SStephan Aßmus dark2BorderColor = tint_color(base, 1.49); 16612f86ba45SStephan Aßmus 16624f579098SStephan Aßmus // BCheckBox uses this to indicate the clicked state... 16632f86ba45SStephan Aßmus _DrawFrame(view, rect, 16642f86ba45SStephan Aßmus dark1BorderColor, dark1BorderColor, 16652f86ba45SStephan Aßmus dark2BorderColor, dark2BorderColor); 16662f86ba45SStephan Aßmus 16672f86ba45SStephan Aßmus dark2BorderColor = dark1BorderColor; 16682f86ba45SStephan Aßmus } else { 16694f579098SStephan Aßmus _DrawOuterResessedFrame(view, rect, base, 0.6, 1.0, flags, borders); 16702f86ba45SStephan Aßmus 1671a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 16724f579098SStephan Aßmus dark1BorderColor = (rgb_color){ 0, 0, 0, 102 }; 16734f579098SStephan Aßmus dark2BorderColor = (rgb_color){ 0, 0, 0, 97 }; 16744f579098SStephan Aßmus } else { 16752f86ba45SStephan Aßmus dark1BorderColor = tint_color(base, 1.40); 16762f86ba45SStephan Aßmus dark2BorderColor = tint_color(base, 1.38); 16772f86ba45SStephan Aßmus } 16784f579098SStephan Aßmus } 16792f86ba45SStephan Aßmus 1680a884b43bSJohn Scipione if ((flags & B_DISABLED) == 0 && (flags & B_FOCUSED) != 0) { 16812f86ba45SStephan Aßmus dark1BorderColor = navigationColor; 16822f86ba45SStephan Aßmus dark2BorderColor = navigationColor; 16832f86ba45SStephan Aßmus } 16842f86ba45SStephan Aßmus 1685a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 16864f579098SStephan Aßmus drawing_mode oldMode = view->DrawingMode(); 16874f579098SStephan Aßmus view->SetDrawingMode(B_OP_ALPHA); 16884f579098SStephan Aßmus 16892f86ba45SStephan Aßmus _DrawFrame(view, rect, 16902f86ba45SStephan Aßmus dark1BorderColor, dark1BorderColor, 16912f86ba45SStephan Aßmus dark2BorderColor, dark2BorderColor, borders); 16924f579098SStephan Aßmus 16934f579098SStephan Aßmus view->SetDrawingMode(oldMode); 16944f579098SStephan Aßmus } else { 16954f579098SStephan Aßmus _DrawFrame(view, rect, 16964f579098SStephan Aßmus dark1BorderColor, dark1BorderColor, 16974f579098SStephan Aßmus dark2BorderColor, dark2BorderColor, borders); 16984f579098SStephan Aßmus } 16992f86ba45SStephan Aßmus } 17002f86ba45SStephan Aßmus 17012f86ba45SStephan Aßmus 17022f86ba45SStephan Aßmus void 17032f86ba45SStephan Aßmus BControlLook::DrawGroupFrame(BView* view, BRect& rect, const BRect& updateRect, 17042f86ba45SStephan Aßmus const rgb_color& base, uint32 borders) 17052f86ba45SStephan Aßmus { 17062f86ba45SStephan Aßmus rgb_color frameColor = tint_color(base, 1.30); 17072f86ba45SStephan Aßmus rgb_color bevelLight = tint_color(base, 0.8); 17082f86ba45SStephan Aßmus rgb_color bevelShadow = tint_color(base, 1.03); 17092f86ba45SStephan Aßmus 17102f86ba45SStephan Aßmus _DrawFrame(view, rect, bevelShadow, bevelShadow, bevelLight, bevelLight, 17112f86ba45SStephan Aßmus borders); 17122f86ba45SStephan Aßmus 17132f86ba45SStephan Aßmus _DrawFrame(view, rect, frameColor, frameColor, frameColor, frameColor, 17142f86ba45SStephan Aßmus borders); 17152f86ba45SStephan Aßmus 17162f86ba45SStephan Aßmus _DrawFrame(view, rect, bevelLight, bevelLight, bevelShadow, bevelShadow, 17172f86ba45SStephan Aßmus borders); 17182f86ba45SStephan Aßmus } 17192f86ba45SStephan Aßmus 17202f86ba45SStephan Aßmus 17212f86ba45SStephan Aßmus void 17222f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect, 17232f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags) 17242f86ba45SStephan Aßmus { 17252f86ba45SStephan Aßmus DrawLabel(view, label, rect, updateRect, base, flags, 17262f86ba45SStephan Aßmus DefaultLabelAlignment()); 17272f86ba45SStephan Aßmus } 17282f86ba45SStephan Aßmus 17292f86ba45SStephan Aßmus 17302f86ba45SStephan Aßmus void 17312f86ba45SStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, BRect rect, 17322f86ba45SStephan Aßmus const BRect& updateRect, const rgb_color& base, uint32 flags, 17332f86ba45SStephan Aßmus const BAlignment& alignment) 17342f86ba45SStephan Aßmus { 17352f86ba45SStephan Aßmus if (!rect.Intersects(updateRect)) 17362f86ba45SStephan Aßmus return; 17372f86ba45SStephan Aßmus 17382f86ba45SStephan Aßmus // truncate the label if necessary and get the width and height 17392f86ba45SStephan Aßmus BString truncatedLabel(label); 17402f86ba45SStephan Aßmus 17412f86ba45SStephan Aßmus BFont font; 17422f86ba45SStephan Aßmus view->GetFont(&font); 17432f86ba45SStephan Aßmus 17442f86ba45SStephan Aßmus float width = rect.Width(); 17452f86ba45SStephan Aßmus font.TruncateString(&truncatedLabel, B_TRUNCATE_END, width); 17462f86ba45SStephan Aßmus width = font.StringWidth(truncatedLabel.String()); 17472f86ba45SStephan Aßmus 17482f86ba45SStephan Aßmus font_height fontHeight; 17492f86ba45SStephan Aßmus font.GetHeight(&fontHeight); 17502f86ba45SStephan Aßmus float height = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent); 17512f86ba45SStephan Aßmus 17522f86ba45SStephan Aßmus // handle alignment 17532f86ba45SStephan Aßmus BPoint location; 17542f86ba45SStephan Aßmus 17552f86ba45SStephan Aßmus switch (alignment.horizontal) { 17562f86ba45SStephan Aßmus default: 17572f86ba45SStephan Aßmus case B_ALIGN_LEFT: 17582f86ba45SStephan Aßmus location.x = rect.left; 17592f86ba45SStephan Aßmus break; 17602f86ba45SStephan Aßmus case B_ALIGN_RIGHT: 17612f86ba45SStephan Aßmus location.x = rect.right - width; 17622f86ba45SStephan Aßmus break; 17632f86ba45SStephan Aßmus case B_ALIGN_CENTER: 17642f86ba45SStephan Aßmus location.x = (rect.left + rect.right - width) / 2.0f; 17652f86ba45SStephan Aßmus break; 17662f86ba45SStephan Aßmus } 17672f86ba45SStephan Aßmus 17682f86ba45SStephan Aßmus switch (alignment.vertical) { 17692f86ba45SStephan Aßmus case B_ALIGN_TOP: 17702f86ba45SStephan Aßmus location.y = rect.top + ceilf(fontHeight.ascent); 17712f86ba45SStephan Aßmus break; 17722f86ba45SStephan Aßmus default: 17732f86ba45SStephan Aßmus case B_ALIGN_MIDDLE: 17742f86ba45SStephan Aßmus location.y = floorf((rect.top + rect.bottom - height) / 2.0f + 0.5f) 17752f86ba45SStephan Aßmus + ceilf(fontHeight.ascent); 17762f86ba45SStephan Aßmus break; 17772f86ba45SStephan Aßmus case B_ALIGN_BOTTOM: 17782f86ba45SStephan Aßmus location.y = rect.bottom - ceilf(fontHeight.descent); 17792f86ba45SStephan Aßmus break; 17802f86ba45SStephan Aßmus } 17812f86ba45SStephan Aßmus 1782c4e211feSStephan Aßmus DrawLabel(view, truncatedLabel.String(), base, flags, location); 1783c4e211feSStephan Aßmus } 1784c4e211feSStephan Aßmus 1785c4e211feSStephan Aßmus 1786c4e211feSStephan Aßmus void 1787c4e211feSStephan Aßmus BControlLook::DrawLabel(BView* view, const char* label, const rgb_color& base, 1788c4e211feSStephan Aßmus uint32 flags, const BPoint& where) 1789c4e211feSStephan Aßmus { 1790c4e211feSStephan Aßmus // setup the text color 1791c4e211feSStephan Aßmus // TODO: Should either use the ui_color(B_CONTROL_TEXT_COLOR) here, 1792c4e211feSStephan Aßmus // or elliminate that constant alltogether (stippi: +1). 1793d63b75faSPhilippe Saint-Pierre 1794d63b75faSPhilippe Saint-Pierre BWindow* window = view->Window(); 1795d63b75faSPhilippe Saint-Pierre bool isDesktop = window 1796d63b75faSPhilippe Saint-Pierre && window->Feel() == kPrivateDesktopWindowFeel 1797d63b75faSPhilippe Saint-Pierre && window->Look() == kPrivateDesktopWindowLook 1798d63b75faSPhilippe Saint-Pierre && view->Parent() 1799d63b75faSPhilippe Saint-Pierre && view->Parent()->Parent() == NULL 1800d63b75faSPhilippe Saint-Pierre && (flags & B_IGNORE_OUTLINE) == 0; 1801d63b75faSPhilippe Saint-Pierre 1802d63b75faSPhilippe Saint-Pierre rgb_color low; 1803c4e211feSStephan Aßmus rgb_color color; 1804d63b75faSPhilippe Saint-Pierre rgb_color glowColor; 1805d63b75faSPhilippe Saint-Pierre 1806d63b75faSPhilippe Saint-Pierre if (isDesktop) 1807d63b75faSPhilippe Saint-Pierre low = view->Parent()->ViewColor(); 1808c4e211feSStephan Aßmus else 1809d63b75faSPhilippe Saint-Pierre low = base; 1810d63b75faSPhilippe Saint-Pierre 1811d63b75faSPhilippe Saint-Pierre if (low.red + low.green + low.blue > 128 * 3) { 1812d63b75faSPhilippe Saint-Pierre color = tint_color(low, B_DARKEN_MAX_TINT); 1813d63b75faSPhilippe Saint-Pierre glowColor = kWhite; 1814d63b75faSPhilippe Saint-Pierre } else { 1815d63b75faSPhilippe Saint-Pierre color = tint_color(low, B_LIGHTEN_MAX_TINT); 1816d63b75faSPhilippe Saint-Pierre glowColor = kBlack; 1817d63b75faSPhilippe Saint-Pierre } 1818c4e211feSStephan Aßmus 1819a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 1820d63b75faSPhilippe Saint-Pierre color.red = (uint8)(((int32)low.red + color.red + 1) / 2); 1821d63b75faSPhilippe Saint-Pierre color.green = (uint8)(((int32)low.green + color.green + 1) / 2); 1822d63b75faSPhilippe Saint-Pierre color.blue = (uint8)(((int32)low.blue + color.blue + 1) / 2); 1823d63b75faSPhilippe Saint-Pierre } 1824d63b75faSPhilippe Saint-Pierre 1825d63b75faSPhilippe Saint-Pierre drawing_mode oldMode = view->DrawingMode(); 1826d63b75faSPhilippe Saint-Pierre 1827d63b75faSPhilippe Saint-Pierre if (isDesktop) { 1828a884b43bSJohn Scipione // drawing occurs on the desktop 1829d63b75faSPhilippe Saint-Pierre if (fCachedWorkspace != current_workspace()) { 1830d63b75faSPhilippe Saint-Pierre int8 indice = 0; 1831d63b75faSPhilippe Saint-Pierre int32 mask; 1832d63b75faSPhilippe Saint-Pierre bool tmpOutline; 1833d63b75faSPhilippe Saint-Pierre while (fBackgroundInfo.FindInt32("be:bgndimginfoworkspaces", 1834d63b75faSPhilippe Saint-Pierre indice, &mask) == B_OK 1835d63b75faSPhilippe Saint-Pierre && fBackgroundInfo.FindBool("be:bgndimginfoerasetext", 1836d63b75faSPhilippe Saint-Pierre indice, &tmpOutline) == B_OK) { 1837d63b75faSPhilippe Saint-Pierre 1838d63b75faSPhilippe Saint-Pierre if (((1 << current_workspace()) & mask) != 0) { 1839d63b75faSPhilippe Saint-Pierre fCachedOutline = tmpOutline; 1840d63b75faSPhilippe Saint-Pierre fCachedWorkspace = current_workspace(); 1841d63b75faSPhilippe Saint-Pierre break; 1842d63b75faSPhilippe Saint-Pierre } 1843d63b75faSPhilippe Saint-Pierre indice++; 1844d63b75faSPhilippe Saint-Pierre } 1845d63b75faSPhilippe Saint-Pierre } 1846d63b75faSPhilippe Saint-Pierre 1847d63b75faSPhilippe Saint-Pierre if (fCachedOutline) { 1848d63b75faSPhilippe Saint-Pierre BFont font; 1849d63b75faSPhilippe Saint-Pierre view->GetFont(&font); 1850d63b75faSPhilippe Saint-Pierre 1851d63b75faSPhilippe Saint-Pierre view->SetDrawingMode(B_OP_ALPHA); 1852d63b75faSPhilippe Saint-Pierre view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); 1853d63b75faSPhilippe Saint-Pierre // Draw glow or outline 1854d63b75faSPhilippe Saint-Pierre if (glowColor == kWhite) { 1855d63b75faSPhilippe Saint-Pierre font.SetFalseBoldWidth(2.0); 1856d63b75faSPhilippe Saint-Pierre view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); 1857d63b75faSPhilippe Saint-Pierre 1858d63b75faSPhilippe Saint-Pierre glowColor.alpha = 30; 1859d63b75faSPhilippe Saint-Pierre view->SetHighColor(glowColor); 1860d63b75faSPhilippe Saint-Pierre view->DrawString(label, where); 1861d63b75faSPhilippe Saint-Pierre 1862d63b75faSPhilippe Saint-Pierre font.SetFalseBoldWidth(1.0); 1863d63b75faSPhilippe Saint-Pierre view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); 1864d63b75faSPhilippe Saint-Pierre 1865d63b75faSPhilippe Saint-Pierre glowColor.alpha = 65; 1866d63b75faSPhilippe Saint-Pierre view->SetHighColor(glowColor); 1867d63b75faSPhilippe Saint-Pierre view->DrawString(label, where); 1868d63b75faSPhilippe Saint-Pierre 1869d63b75faSPhilippe Saint-Pierre font.SetFalseBoldWidth(0.0); 1870d63b75faSPhilippe Saint-Pierre view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); 1871d63b75faSPhilippe Saint-Pierre } else if (glowColor == kBlack) { 1872d63b75faSPhilippe Saint-Pierre font.SetFalseBoldWidth(1.0); 1873d63b75faSPhilippe Saint-Pierre view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); 1874d63b75faSPhilippe Saint-Pierre 1875d63b75faSPhilippe Saint-Pierre glowColor.alpha = 30; 1876d63b75faSPhilippe Saint-Pierre view->SetHighColor(glowColor); 1877d63b75faSPhilippe Saint-Pierre view->DrawString(label, where); 1878d63b75faSPhilippe Saint-Pierre 1879d63b75faSPhilippe Saint-Pierre font.SetFalseBoldWidth(0.0); 1880d63b75faSPhilippe Saint-Pierre view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH); 1881d63b75faSPhilippe Saint-Pierre 1882d63b75faSPhilippe Saint-Pierre glowColor.alpha = 200; 1883d63b75faSPhilippe Saint-Pierre view->SetHighColor(glowColor); 1884d63b75faSPhilippe Saint-Pierre view->DrawString(label, BPoint(where.x + 1, where.y + 1)); 1885d63b75faSPhilippe Saint-Pierre } 1886d63b75faSPhilippe Saint-Pierre } 1887c4e211feSStephan Aßmus } 1888c4e211feSStephan Aßmus 1889c4e211feSStephan Aßmus view->SetHighColor(color); 1890c4e211feSStephan Aßmus view->SetDrawingMode(B_OP_OVER); 1891c4e211feSStephan Aßmus view->DrawString(label, where); 1892c4e211feSStephan Aßmus view->SetDrawingMode(oldMode); 18932f86ba45SStephan Aßmus } 18942f86ba45SStephan Aßmus 18952f86ba45SStephan Aßmus 1896d63b75faSPhilippe Saint-Pierre void 1897d452ff66SAxel Dörfler BControlLook::SetBackgroundInfo(const BMessage& backgroundInfo) 1898d63b75faSPhilippe Saint-Pierre { 1899d452ff66SAxel Dörfler fBackgroundInfo = backgroundInfo; 1900d63b75faSPhilippe Saint-Pierre fCachedWorkspace = -1; 1901d63b75faSPhilippe Saint-Pierre } 1902d63b75faSPhilippe Saint-Pierre 1903d63b75faSPhilippe Saint-Pierre 19042f86ba45SStephan Aßmus // #pragma mark - 19052f86ba45SStephan Aßmus 19062f86ba45SStephan Aßmus 19072f86ba45SStephan Aßmus void 190813cd46dfSStephan Aßmus BControlLook::_DrawButtonFrame(BView* view, BRect& rect, 1909a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 1910a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 1911a884b43bSJohn Scipione const rgb_color& background, float contrast, float brightness, 1912a884b43bSJohn Scipione uint32 flags, uint32 borders) 191313cd46dfSStephan Aßmus { 1914a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 1915a884b43bSJohn Scipione return; 191613cd46dfSStephan Aßmus 19174fa76719SJohn Scipione // save the clipping constraints of the view 19184fa76719SJohn Scipione view->PushState(); 191913cd46dfSStephan Aßmus 19205666b4f7SJohn Scipione // set clipping constraints to updateRect 19214fa76719SJohn Scipione BRegion clipping(updateRect); 1922a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 1923a884b43bSJohn Scipione 1924a884b43bSJohn Scipione // outer edge colors 1925a884b43bSJohn Scipione rgb_color edgeLightColor; 1926a884b43bSJohn Scipione rgb_color edgeShadowColor; 1927a884b43bSJohn Scipione 1928a884b43bSJohn Scipione // default button frame color 19294f579098SStephan Aßmus // TODO: B_BLEND_FRAME 1930a884b43bSJohn Scipione float defaultIndicatorTint = 1.2; 1931a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 1932a884b43bSJohn Scipione defaultIndicatorTint = (B_NO_TINT + defaultIndicatorTint) / 2; 193313cd46dfSStephan Aßmus 1934a884b43bSJohn Scipione rgb_color defaultIndicatorColor = tint_color(base, defaultIndicatorTint); 193588969219SJohn Scipione rgb_color cornerBgColor; 193688969219SJohn Scipione 193788969219SJohn Scipione drawing_mode oldMode = view->DrawingMode(); 193813cd46dfSStephan Aßmus 1939a884b43bSJohn Scipione if ((flags & B_DEFAULT_BUTTON) != 0) { 194088969219SJohn Scipione cornerBgColor = defaultIndicatorColor; 1941a884b43bSJohn Scipione edgeLightColor = _EdgeLightColor(defaultIndicatorColor, 1942a884b43bSJohn Scipione contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), 1943a884b43bSJohn Scipione brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags); 1944a884b43bSJohn Scipione edgeShadowColor = _EdgeShadowColor(defaultIndicatorColor, 1945a884b43bSJohn Scipione contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), 1946a884b43bSJohn Scipione brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), flags); 194713cd46dfSStephan Aßmus 194888969219SJohn Scipione // draw default button indicator 1949a884b43bSJohn Scipione view->SetHighColor(background); 1950a884b43bSJohn Scipione view->FillRect(rect); 195113cd46dfSStephan Aßmus view->SetHighColor(base); 1952a884b43bSJohn Scipione view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius); 1953a884b43bSJohn Scipione rect.InsetBy(1, 1); 195413cd46dfSStephan Aßmus 1955a884b43bSJohn Scipione view->SetHighColor(defaultIndicatorColor); 1956a884b43bSJohn Scipione view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius); 1957a884b43bSJohn Scipione rect.InsetBy(1, 1); 195813cd46dfSStephan Aßmus 1959a884b43bSJohn Scipione view->StrokeRoundRect(rect, leftTopRadius, leftTopRadius); 1960a884b43bSJohn Scipione rect.InsetBy(1, 1); 196113cd46dfSStephan Aßmus } else { 196288969219SJohn Scipione cornerBgColor = background; 196341651bb3SJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 196441651bb3SJohn Scipione // set the background color to transparent for the case 196541651bb3SJohn Scipione // that we are on the desktop 196641651bb3SJohn Scipione cornerBgColor.alpha = 0; 196741651bb3SJohn Scipione view->SetDrawingMode(B_OP_ALPHA); 196841651bb3SJohn Scipione } 196988969219SJohn Scipione 1970a884b43bSJohn Scipione edgeLightColor = _EdgeLightColor(background, 1971a884b43bSJohn Scipione contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0), 1972a884b43bSJohn Scipione brightness * 1.0, flags); 1973a884b43bSJohn Scipione edgeShadowColor = _EdgeShadowColor(background, 1974a884b43bSJohn Scipione contrast * (flags & B_DISABLED) != 0 ? 0.0 : 1.0, 1975a884b43bSJohn Scipione brightness * 1.0, flags); 197613cd46dfSStephan Aßmus } 197713cd46dfSStephan Aßmus 1978a884b43bSJohn Scipione // frame colors 1979a884b43bSJohn Scipione rgb_color frameLightColor = _FrameLightColor(base, flags); 1980a884b43bSJohn Scipione rgb_color frameShadowColor = _FrameShadowColor(base, flags); 1981a884b43bSJohn Scipione 1982a884b43bSJohn Scipione // rounded corners 1983a884b43bSJohn Scipione 1984a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0 1985a884b43bSJohn Scipione && leftTopRadius > 0) { 1986a884b43bSJohn Scipione // draw left top rounded corner 1987a884b43bSJohn Scipione BRect leftTopCorner(floorf(rect.left), floorf(rect.top), 1988a884b43bSJohn Scipione floorf(rect.left + leftTopRadius), 1989a884b43bSJohn Scipione floorf(rect.top + leftTopRadius)); 1990a884b43bSJohn Scipione clipping.Exclude(leftTopCorner); 1991a884b43bSJohn Scipione _DrawRoundCornerFrameLeftTop(view, leftTopCorner, updateRect, 1992a884b43bSJohn Scipione cornerBgColor, edgeShadowColor, frameLightColor); 1993a884b43bSJohn Scipione } 1994a884b43bSJohn Scipione 1995a884b43bSJohn Scipione if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0 1996a884b43bSJohn Scipione && rightTopRadius > 0) { 1997a884b43bSJohn Scipione // draw right top rounded corner 1998a884b43bSJohn Scipione BRect rightTopCorner(floorf(rect.right - rightTopRadius), 1999a884b43bSJohn Scipione floorf(rect.top), floorf(rect.right), 2000a884b43bSJohn Scipione floorf(rect.top + rightTopRadius)); 2001a884b43bSJohn Scipione clipping.Exclude(rightTopCorner); 2002a884b43bSJohn Scipione _DrawRoundCornerFrameRightTop(view, rightTopCorner, updateRect, 2003a884b43bSJohn Scipione cornerBgColor, edgeShadowColor, edgeLightColor, 2004a884b43bSJohn Scipione frameLightColor, frameShadowColor); 2005a884b43bSJohn Scipione } 2006a884b43bSJohn Scipione 2007a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0 2008a884b43bSJohn Scipione && leftBottomRadius > 0) { 2009a884b43bSJohn Scipione // draw left bottom rounded corner 2010a884b43bSJohn Scipione BRect leftBottomCorner(floorf(rect.left), 2011a884b43bSJohn Scipione floorf(rect.bottom - leftBottomRadius), 2012a884b43bSJohn Scipione floorf(rect.left + leftBottomRadius), floorf(rect.bottom)); 2013a884b43bSJohn Scipione clipping.Exclude(leftBottomCorner); 2014a884b43bSJohn Scipione _DrawRoundCornerFrameLeftBottom(view, leftBottomCorner, updateRect, 2015a884b43bSJohn Scipione cornerBgColor, edgeShadowColor, edgeLightColor, 2016a884b43bSJohn Scipione frameLightColor, frameShadowColor); 2017a884b43bSJohn Scipione } 2018a884b43bSJohn Scipione 2019a884b43bSJohn Scipione if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0 2020a884b43bSJohn Scipione && rightBottomRadius > 0) { 2021a884b43bSJohn Scipione // draw right bottom rounded corner 2022a884b43bSJohn Scipione BRect rightBottomCorner(floorf(rect.right - rightBottomRadius), 2023a884b43bSJohn Scipione floorf(rect.bottom - rightBottomRadius), floorf(rect.right), 2024a884b43bSJohn Scipione floorf(rect.bottom)); 2025a884b43bSJohn Scipione clipping.Exclude(rightBottomCorner); 2026a884b43bSJohn Scipione _DrawRoundCornerFrameRightBottom(view, rightBottomCorner, 2027a884b43bSJohn Scipione updateRect, cornerBgColor, edgeLightColor, frameShadowColor); 2028a884b43bSJohn Scipione } 2029a884b43bSJohn Scipione 2030a884b43bSJohn Scipione // clip out the corners 2031a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2032a884b43bSJohn Scipione 2033a884b43bSJohn Scipione // draw outer edge 2034a884b43bSJohn Scipione if ((flags & B_DEFAULT_BUTTON) != 0) { 2035a884b43bSJohn Scipione _DrawOuterResessedFrame(view, rect, defaultIndicatorColor, 2036a884b43bSJohn Scipione contrast * ((flags & B_DISABLED) != 0 ? 0.3 : 0.8), 2037a884b43bSJohn Scipione brightness * ((flags & B_DISABLED) != 0 ? 1.0 : 0.9), 2038a884b43bSJohn Scipione flags, borders); 2039a884b43bSJohn Scipione } else { 2040a884b43bSJohn Scipione _DrawOuterResessedFrame(view, rect, background, 2041a884b43bSJohn Scipione contrast * ((flags & B_DISABLED) != 0 ? 0.0 : 1.0), 2042a884b43bSJohn Scipione brightness * 1.0, flags, borders); 2043a884b43bSJohn Scipione } 2044a884b43bSJohn Scipione 204588969219SJohn Scipione view->SetDrawingMode(oldMode); 204688969219SJohn Scipione 2047a884b43bSJohn Scipione // draw frame 2048a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 20494f579098SStephan Aßmus drawing_mode oldDrawingMode = view->DrawingMode(); 20504f579098SStephan Aßmus view->SetDrawingMode(B_OP_ALPHA); 20514f579098SStephan Aßmus 2052a884b43bSJohn Scipione _DrawFrame(view, rect, frameLightColor, frameLightColor, 2053a884b43bSJohn Scipione frameShadowColor, frameShadowColor, borders); 20544f579098SStephan Aßmus 20554f579098SStephan Aßmus view->SetDrawingMode(oldDrawingMode); 20564f579098SStephan Aßmus } else { 2057a884b43bSJohn Scipione _DrawFrame(view, rect, frameLightColor, frameLightColor, 2058a884b43bSJohn Scipione frameShadowColor, frameShadowColor, borders); 20594f579098SStephan Aßmus } 2060a884b43bSJohn Scipione 20614fa76719SJohn Scipione // restore the clipping constraints of the view 20624fa76719SJohn Scipione view->PopState(); 206313cd46dfSStephan Aßmus } 206413cd46dfSStephan Aßmus 206513cd46dfSStephan Aßmus 206613cd46dfSStephan Aßmus void 20672f86ba45SStephan Aßmus BControlLook::_DrawOuterResessedFrame(BView* view, BRect& rect, 20684f579098SStephan Aßmus const rgb_color& base, float contrast, float brightness, uint32 flags, 20694f579098SStephan Aßmus uint32 borders) 20702f86ba45SStephan Aßmus { 2071a884b43bSJohn Scipione rgb_color edgeLightColor = _EdgeLightColor(base, contrast, 2072a884b43bSJohn Scipione brightness, flags); 2073a884b43bSJohn Scipione rgb_color edgeShadowColor = _EdgeShadowColor(base, contrast, 2074a884b43bSJohn Scipione brightness, flags); 2075a884b43bSJohn Scipione 2076a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 20774f579098SStephan Aßmus // assumes the background has already been painted 20784f579098SStephan Aßmus drawing_mode oldDrawingMode = view->DrawingMode(); 20794f579098SStephan Aßmus view->SetDrawingMode(B_OP_ALPHA); 20804f579098SStephan Aßmus 2081a884b43bSJohn Scipione _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, 2082a884b43bSJohn Scipione edgeLightColor, edgeLightColor, borders); 20834f579098SStephan Aßmus 20844f579098SStephan Aßmus view->SetDrawingMode(oldDrawingMode); 20854f579098SStephan Aßmus } else { 2086a884b43bSJohn Scipione _DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, 2087a884b43bSJohn Scipione edgeLightColor, edgeLightColor, borders); 20882f86ba45SStephan Aßmus } 20894f579098SStephan Aßmus } 20902f86ba45SStephan Aßmus 20912f86ba45SStephan Aßmus 20922f86ba45SStephan Aßmus void 20932f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left, 20942f86ba45SStephan Aßmus const rgb_color& top, const rgb_color& right, const rgb_color& bottom, 20952f86ba45SStephan Aßmus uint32 borders) 20962f86ba45SStephan Aßmus { 20972f86ba45SStephan Aßmus view->BeginLineArray(4); 20982f86ba45SStephan Aßmus 20992f86ba45SStephan Aßmus if (borders & B_LEFT_BORDER) { 21002f86ba45SStephan Aßmus view->AddLine( 21012f86ba45SStephan Aßmus BPoint(rect.left, rect.bottom), 21022f86ba45SStephan Aßmus BPoint(rect.left, rect.top), left); 21032f86ba45SStephan Aßmus rect.left++; 21042f86ba45SStephan Aßmus } 21052f86ba45SStephan Aßmus if (borders & B_TOP_BORDER) { 21062f86ba45SStephan Aßmus view->AddLine( 21072f86ba45SStephan Aßmus BPoint(rect.left, rect.top), 21082f86ba45SStephan Aßmus BPoint(rect.right, rect.top), top); 21092f86ba45SStephan Aßmus rect.top++; 21102f86ba45SStephan Aßmus } 21112f86ba45SStephan Aßmus if (borders & B_RIGHT_BORDER) { 21122f86ba45SStephan Aßmus view->AddLine( 21132f86ba45SStephan Aßmus BPoint(rect.right, rect.top), 21142f86ba45SStephan Aßmus BPoint(rect.right, rect.bottom), right); 21152f86ba45SStephan Aßmus rect.right--; 21162f86ba45SStephan Aßmus } 21172f86ba45SStephan Aßmus if (borders & B_BOTTOM_BORDER) { 21182f86ba45SStephan Aßmus view->AddLine( 21192f86ba45SStephan Aßmus BPoint(rect.left, rect.bottom), 21202f86ba45SStephan Aßmus BPoint(rect.right, rect.bottom), bottom); 21212f86ba45SStephan Aßmus rect.bottom--; 21222f86ba45SStephan Aßmus } 21232f86ba45SStephan Aßmus 21242f86ba45SStephan Aßmus view->EndLineArray(); 21252f86ba45SStephan Aßmus } 21262f86ba45SStephan Aßmus 21272f86ba45SStephan Aßmus 21282f86ba45SStephan Aßmus void 21292f86ba45SStephan Aßmus BControlLook::_DrawFrame(BView* view, BRect& rect, const rgb_color& left, 21302f86ba45SStephan Aßmus const rgb_color& top, const rgb_color& right, const rgb_color& bottom, 21312f86ba45SStephan Aßmus const rgb_color& rightTop, const rgb_color& leftBottom, uint32 borders) 21322f86ba45SStephan Aßmus { 21332f86ba45SStephan Aßmus view->BeginLineArray(6); 21342f86ba45SStephan Aßmus 21352f86ba45SStephan Aßmus if (borders & B_TOP_BORDER) { 21362f86ba45SStephan Aßmus if (borders & B_RIGHT_BORDER) { 21372f86ba45SStephan Aßmus view->AddLine( 21382f86ba45SStephan Aßmus BPoint(rect.left, rect.top), 21392f86ba45SStephan Aßmus BPoint(rect.right - 1, rect.top), top); 21402f86ba45SStephan Aßmus view->AddLine( 21412f86ba45SStephan Aßmus BPoint(rect.right, rect.top), 21422f86ba45SStephan Aßmus BPoint(rect.right, rect.top), rightTop); 21432f86ba45SStephan Aßmus } else { 21442f86ba45SStephan Aßmus view->AddLine( 21452f86ba45SStephan Aßmus BPoint(rect.left, rect.top), 21462f86ba45SStephan Aßmus BPoint(rect.right, rect.top), top); 21472f86ba45SStephan Aßmus } 21482f86ba45SStephan Aßmus rect.top++; 21492f86ba45SStephan Aßmus } 21502f86ba45SStephan Aßmus 21512f86ba45SStephan Aßmus if (borders & B_LEFT_BORDER) { 21522f86ba45SStephan Aßmus view->AddLine( 21532f86ba45SStephan Aßmus BPoint(rect.left, rect.top), 21542f86ba45SStephan Aßmus BPoint(rect.left, rect.bottom - 1), left); 21552f86ba45SStephan Aßmus view->AddLine( 21562f86ba45SStephan Aßmus BPoint(rect.left, rect.bottom), 21572f86ba45SStephan Aßmus BPoint(rect.left, rect.bottom), leftBottom); 21582f86ba45SStephan Aßmus rect.left++; 21592f86ba45SStephan Aßmus } 21602f86ba45SStephan Aßmus 21612f86ba45SStephan Aßmus if (borders & B_BOTTOM_BORDER) { 21622f86ba45SStephan Aßmus view->AddLine( 21632f86ba45SStephan Aßmus BPoint(rect.left, rect.bottom), 21642f86ba45SStephan Aßmus BPoint(rect.right, rect.bottom), bottom); 21652f86ba45SStephan Aßmus rect.bottom--; 21662f86ba45SStephan Aßmus } 21672f86ba45SStephan Aßmus 21682f86ba45SStephan Aßmus if (borders & B_RIGHT_BORDER) { 21692f86ba45SStephan Aßmus view->AddLine( 21702f86ba45SStephan Aßmus BPoint(rect.right, rect.bottom), 21712f86ba45SStephan Aßmus BPoint(rect.right, rect.top), right); 21722f86ba45SStephan Aßmus rect.right--; 21732f86ba45SStephan Aßmus } 21742f86ba45SStephan Aßmus 21752f86ba45SStephan Aßmus view->EndLineArray(); 21762f86ba45SStephan Aßmus } 21772f86ba45SStephan Aßmus 21782f86ba45SStephan Aßmus 21792f86ba45SStephan Aßmus void 2180a884b43bSJohn Scipione BControlLook::_DrawButtonBackground(BView* view, BRect& rect, 2181a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 2182a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 2183a884b43bSJohn Scipione uint32 flags, uint32 borders, enum orientation orientation) 21842f86ba45SStephan Aßmus { 2185a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 2186a884b43bSJohn Scipione return; 21872f86ba45SStephan Aßmus 21884fa76719SJohn Scipione // save the clipping constraints of the view 21894fa76719SJohn Scipione view->PushState(); 21902f86ba45SStephan Aßmus 21915666b4f7SJohn Scipione // set clipping constraints to updateRect 21924fa76719SJohn Scipione BRegion clipping(updateRect); 2193a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 21942f86ba45SStephan Aßmus 2195a884b43bSJohn Scipione // inner bevel colors 2196a884b43bSJohn Scipione rgb_color bevelLightColor = _BevelLightColor(base, flags); 2197a884b43bSJohn Scipione rgb_color bevelShadowColor = _BevelShadowColor(base, flags); 2198a884b43bSJohn Scipione 2199a884b43bSJohn Scipione // button background color 2200a884b43bSJohn Scipione rgb_color buttonBgColor; 2201a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 2202a884b43bSJohn Scipione buttonBgColor = tint_color(base, 0.7); 22032f86ba45SStephan Aßmus else 2204a884b43bSJohn Scipione buttonBgColor = tint_color(base, B_LIGHTEN_1_TINT); 2205a884b43bSJohn Scipione 2206a884b43bSJohn Scipione // surface top gradient 2207a884b43bSJohn Scipione BGradientLinear fillGradient; 2208a884b43bSJohn Scipione _MakeButtonGradient(fillGradient, rect, base, flags, orientation); 2209a884b43bSJohn Scipione 2210a884b43bSJohn Scipione // rounded corners 2211a884b43bSJohn Scipione 2212a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0 2213a884b43bSJohn Scipione && leftTopRadius > 0) { 2214a884b43bSJohn Scipione // draw left top rounded corner 2215a884b43bSJohn Scipione BRect leftTopCorner(floorf(rect.left), floorf(rect.top), 2216a884b43bSJohn Scipione floorf(rect.left + leftTopRadius - 2.0), 2217a884b43bSJohn Scipione floorf(rect.top + leftTopRadius - 2.0)); 2218a884b43bSJohn Scipione clipping.Exclude(leftTopCorner); 2219a884b43bSJohn Scipione _DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect, 2220a884b43bSJohn Scipione bevelLightColor, fillGradient); 2221a884b43bSJohn Scipione } 2222a884b43bSJohn Scipione 2223a884b43bSJohn Scipione if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0 2224a884b43bSJohn Scipione && rightTopRadius > 0) { 2225a884b43bSJohn Scipione // draw right top rounded corner 2226a884b43bSJohn Scipione BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0), 2227a884b43bSJohn Scipione floorf(rect.top), floorf(rect.right), 2228a884b43bSJohn Scipione floorf(rect.top + rightTopRadius - 2.0)); 2229a884b43bSJohn Scipione clipping.Exclude(rightTopCorner); 2230a884b43bSJohn Scipione _DrawRoundCornerBackgroundRightTop(view, rightTopCorner, 2231a884b43bSJohn Scipione updateRect, bevelLightColor, bevelShadowColor, fillGradient); 2232a884b43bSJohn Scipione } 2233a884b43bSJohn Scipione 2234a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0 2235a884b43bSJohn Scipione && leftBottomRadius > 0) { 2236a884b43bSJohn Scipione // draw left bottom rounded corner 2237a884b43bSJohn Scipione BRect leftBottomCorner(floorf(rect.left), 2238a884b43bSJohn Scipione floorf(rect.bottom - leftBottomRadius + 2.0), 2239a884b43bSJohn Scipione floorf(rect.left + leftBottomRadius - 2.0), 2240a884b43bSJohn Scipione floorf(rect.bottom)); 2241a884b43bSJohn Scipione clipping.Exclude(leftBottomCorner); 2242a884b43bSJohn Scipione _DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner, 2243a884b43bSJohn Scipione updateRect, bevelLightColor, bevelShadowColor, fillGradient); 2244a884b43bSJohn Scipione } 2245a884b43bSJohn Scipione 2246a884b43bSJohn Scipione if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0 2247a884b43bSJohn Scipione && rightBottomRadius > 0) { 2248a884b43bSJohn Scipione // draw right bottom rounded corner 2249a884b43bSJohn Scipione BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0), 2250a884b43bSJohn Scipione floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right), 2251a884b43bSJohn Scipione floorf(rect.bottom)); 2252a884b43bSJohn Scipione clipping.Exclude(rightBottomCorner); 2253a884b43bSJohn Scipione _DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner, 2254a884b43bSJohn Scipione updateRect, bevelShadowColor, fillGradient); 2255a884b43bSJohn Scipione } 2256a884b43bSJohn Scipione 2257a884b43bSJohn Scipione // clip out the corners 2258a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2259a884b43bSJohn Scipione 2260a884b43bSJohn Scipione // draw inner bevel 2261a884b43bSJohn Scipione 2262a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) { 2263a884b43bSJohn Scipione view->BeginLineArray(4); 2264a884b43bSJohn Scipione 2265a884b43bSJohn Scipione // shadow along left/top borders 2266a884b43bSJohn Scipione if (borders & B_LEFT_BORDER) { 2267a884b43bSJohn Scipione view->AddLine(BPoint(rect.left, rect.top), 2268a884b43bSJohn Scipione BPoint(rect.left, rect.bottom), bevelLightColor); 2269a884b43bSJohn Scipione rect.left++; 2270a884b43bSJohn Scipione } 2271a884b43bSJohn Scipione if (borders & B_TOP_BORDER) { 2272a884b43bSJohn Scipione view->AddLine(BPoint(rect.left, rect.top), 2273a884b43bSJohn Scipione BPoint(rect.right, rect.top), bevelLightColor); 2274a884b43bSJohn Scipione rect.top++; 2275a884b43bSJohn Scipione } 2276a884b43bSJohn Scipione 2277a884b43bSJohn Scipione // softer shadow along left/top borders 2278a884b43bSJohn Scipione if (borders & B_LEFT_BORDER) { 2279a884b43bSJohn Scipione view->AddLine(BPoint(rect.left, rect.top), 2280a884b43bSJohn Scipione BPoint(rect.left, rect.bottom), bevelShadowColor); 2281a884b43bSJohn Scipione rect.left++; 2282a884b43bSJohn Scipione } 2283a884b43bSJohn Scipione if (borders & B_TOP_BORDER) { 2284a884b43bSJohn Scipione view->AddLine(BPoint(rect.left, rect.top), 2285a884b43bSJohn Scipione BPoint(rect.right, rect.top), bevelShadowColor); 2286a884b43bSJohn Scipione rect.top++; 2287a884b43bSJohn Scipione } 2288a884b43bSJohn Scipione 2289a884b43bSJohn Scipione view->EndLineArray(); 2290a884b43bSJohn Scipione } else { 2291a884b43bSJohn Scipione _DrawFrame(view, rect, 2292a884b43bSJohn Scipione bevelLightColor, bevelLightColor, 2293a884b43bSJohn Scipione bevelShadowColor, bevelShadowColor, 2294a884b43bSJohn Scipione buttonBgColor, buttonBgColor, borders); 2295a884b43bSJohn Scipione } 2296a884b43bSJohn Scipione 2297a884b43bSJohn Scipione // fill in the background 2298a884b43bSJohn Scipione view->FillRect(rect, fillGradient); 2299a884b43bSJohn Scipione 23004fa76719SJohn Scipione // restore the clipping constraints of the view 23014fa76719SJohn Scipione view->PopState(); 23022f86ba45SStephan Aßmus } 23032f86ba45SStephan Aßmus 23042f86ba45SStephan Aßmus 23052f86ba45SStephan Aßmus void 2306a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundOutside(BView* view, BRect& rect, 2307a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 2308a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 2309a884b43bSJohn Scipione bool popupIndicator, uint32 flags) 23102f86ba45SStephan Aßmus { 2311a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 2312a884b43bSJohn Scipione return; 2313a884b43bSJohn Scipione 2314a884b43bSJohn Scipione if (popupIndicator) { 2315a884b43bSJohn Scipione BRect leftRect(rect); 2316a884b43bSJohn Scipione leftRect.right -= 10; 2317a884b43bSJohn Scipione 2318a884b43bSJohn Scipione BRect rightRect(rect); 2319a884b43bSJohn Scipione rightRect.left = rightRect.right - 9; 2320a884b43bSJohn Scipione 2321a884b43bSJohn Scipione _DrawMenuFieldBackgroundInside(view, leftRect, updateRect, 2322a884b43bSJohn Scipione leftTopRadius, 0.0f, leftBottomRadius, 0.0f, base, flags, 2323a884b43bSJohn Scipione B_LEFT_BORDER | B_TOP_BORDER | B_BOTTOM_BORDER); 2324a884b43bSJohn Scipione 2325a884b43bSJohn Scipione _DrawMenuFieldBackgroundInside(view, rightRect, updateRect, 2326a884b43bSJohn Scipione 0.0f, rightTopRadius, 0.0f, rightBottomRadius, base, flags, 2327a884b43bSJohn Scipione B_TOP_BORDER | B_RIGHT_BORDER | B_BOTTOM_BORDER); 2328a884b43bSJohn Scipione 2329a884b43bSJohn Scipione // popup marker 2330a884b43bSJohn Scipione BPoint center(roundf((rightRect.left + rightRect.right) / 2.0), 2331a884b43bSJohn Scipione roundf((rightRect.top + rightRect.bottom) / 2.0)); 2332a884b43bSJohn Scipione BPoint triangle[3]; 2333a884b43bSJohn Scipione triangle[0] = center + BPoint(-2.5, -0.5); 2334a884b43bSJohn Scipione triangle[1] = center + BPoint(2.5, -0.5); 2335a884b43bSJohn Scipione triangle[2] = center + BPoint(0.0, 2.0); 2336a884b43bSJohn Scipione 2337a884b43bSJohn Scipione uint32 viewFlags = view->Flags(); 2338a884b43bSJohn Scipione view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE); 2339a884b43bSJohn Scipione 2340a884b43bSJohn Scipione rgb_color markColor; 2341a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 2342a884b43bSJohn Scipione markColor = tint_color(base, 1.35); 23432f86ba45SStephan Aßmus else 2344a884b43bSJohn Scipione markColor = tint_color(base, 1.65); 2345a884b43bSJohn Scipione 2346a884b43bSJohn Scipione view->SetHighColor(markColor); 2347a884b43bSJohn Scipione view->FillTriangle(triangle[0], triangle[1], triangle[2]); 2348a884b43bSJohn Scipione 2349a884b43bSJohn Scipione // draw a line on the left of the popup frame 2350a884b43bSJohn Scipione rgb_color bevelShadowColor = _BevelShadowColor(base, flags); 2351a884b43bSJohn Scipione view->SetHighColor(bevelShadowColor); 2352a884b43bSJohn Scipione BPoint leftTopCorner(floorf(rightRect.left - 1.0), 2353a884b43bSJohn Scipione floorf(rightRect.top - 1.0)); 2354a884b43bSJohn Scipione BPoint leftBottomCorner(floorf(rightRect.left - 1.0), 2355a884b43bSJohn Scipione floorf(rightRect.bottom + 1.0)); 2356a884b43bSJohn Scipione view->StrokeLine(leftTopCorner, leftBottomCorner); 2357a884b43bSJohn Scipione 2358a884b43bSJohn Scipione view->SetFlags(viewFlags); 2359a884b43bSJohn Scipione 2360a884b43bSJohn Scipione rect = leftRect; 2361a884b43bSJohn Scipione } else { 2362a884b43bSJohn Scipione _DrawMenuFieldBackgroundInside(view, rect, updateRect, leftTopRadius, 2363a884b43bSJohn Scipione rightTopRadius, leftBottomRadius, rightBottomRadius, base, flags); 2364a884b43bSJohn Scipione } 23652f86ba45SStephan Aßmus } 23662f86ba45SStephan Aßmus 23672f86ba45SStephan Aßmus 2368a884b43bSJohn Scipione void 2369a884b43bSJohn Scipione BControlLook::_DrawMenuFieldBackgroundInside(BView* view, BRect& rect, 2370a884b43bSJohn Scipione const BRect& updateRect, float leftTopRadius, float rightTopRadius, 2371a884b43bSJohn Scipione float leftBottomRadius, float rightBottomRadius, const rgb_color& base, 2372a884b43bSJohn Scipione uint32 flags, uint32 borders) 23732f86ba45SStephan Aßmus { 2374a884b43bSJohn Scipione if (!rect.IsValid() || !rect.Intersects(updateRect)) 2375a884b43bSJohn Scipione return; 2376a884b43bSJohn Scipione 23775666b4f7SJohn Scipione // save the clipping constraints of the view 23785666b4f7SJohn Scipione view->PushState(); 2379a884b43bSJohn Scipione 23805666b4f7SJohn Scipione // set clipping constraints to updateRect 23815666b4f7SJohn Scipione BRegion clipping(updateRect); 2382a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2383a884b43bSJohn Scipione 2384a884b43bSJohn Scipione // frame colors 2385a884b43bSJohn Scipione rgb_color frameLightColor = _FrameLightColor(base, flags); 2386a884b43bSJohn Scipione rgb_color frameShadowColor = _FrameShadowColor(base, flags); 2387a884b43bSJohn Scipione 2388a884b43bSJohn Scipione // indicator background color 2389a884b43bSJohn Scipione rgb_color indicatorBase; 2390a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0) 2391a884b43bSJohn Scipione indicatorBase = base; 2392a884b43bSJohn Scipione else { 2393a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 2394a884b43bSJohn Scipione indicatorBase = tint_color(base, 1.05); 2395a884b43bSJohn Scipione else 2396a884b43bSJohn Scipione indicatorBase = tint_color(base, 1.12); 23972f86ba45SStephan Aßmus } 23982f86ba45SStephan Aßmus 2399a884b43bSJohn Scipione // bevel colors 2400a884b43bSJohn Scipione rgb_color cornerColor = tint_color(indicatorBase, 0.85); 2401a884b43bSJohn Scipione rgb_color bevelColor1 = tint_color(indicatorBase, 0.3); 2402a884b43bSJohn Scipione rgb_color bevelColor2 = tint_color(indicatorBase, 0.5); 2403a884b43bSJohn Scipione rgb_color bevelColor3 = tint_color(indicatorBase, 1.03); 24042f86ba45SStephan Aßmus 2405a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 2406a884b43bSJohn Scipione cornerColor = tint_color(indicatorBase, 0.8); 2407a884b43bSJohn Scipione bevelColor1 = tint_color(indicatorBase, 0.7); 2408a884b43bSJohn Scipione bevelColor2 = tint_color(indicatorBase, 0.8); 2409a884b43bSJohn Scipione bevelColor3 = tint_color(indicatorBase, 1.01); 24102f86ba45SStephan Aßmus } else { 2411a884b43bSJohn Scipione cornerColor = tint_color(indicatorBase, 0.85); 2412a884b43bSJohn Scipione bevelColor1 = tint_color(indicatorBase, 0.3); 2413a884b43bSJohn Scipione bevelColor2 = tint_color(indicatorBase, 0.5); 2414a884b43bSJohn Scipione bevelColor3 = tint_color(indicatorBase, 1.03); 24152f86ba45SStephan Aßmus } 2416a884b43bSJohn Scipione 2417a884b43bSJohn Scipione // surface top gradient 2418a884b43bSJohn Scipione BGradientLinear fillGradient; 2419a884b43bSJohn Scipione _MakeButtonGradient(fillGradient, rect, indicatorBase, flags); 2420a884b43bSJohn Scipione 2421a884b43bSJohn Scipione // rounded corners 2422a884b43bSJohn Scipione 2423a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0 && (borders & B_TOP_BORDER) != 0 2424a884b43bSJohn Scipione && leftTopRadius > 0) { 2425a884b43bSJohn Scipione // draw left top rounded corner 2426a884b43bSJohn Scipione BRect leftTopCorner(floorf(rect.left), floorf(rect.top), 2427a884b43bSJohn Scipione floorf(rect.left + leftTopRadius - 2.0), 2428a884b43bSJohn Scipione floorf(rect.top + leftTopRadius - 2.0)); 2429a884b43bSJohn Scipione clipping.Exclude(leftTopCorner); 2430a884b43bSJohn Scipione 2431a884b43bSJohn Scipione BRegion cornerClipping(leftTopCorner); 2432a884b43bSJohn Scipione view->ConstrainClippingRegion(&cornerClipping); 2433a884b43bSJohn Scipione 2434a884b43bSJohn Scipione BRect ellipseRect(leftTopCorner); 2435a884b43bSJohn Scipione ellipseRect.InsetBy(-1.0, -1.0); 2436a884b43bSJohn Scipione ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2; 2437a884b43bSJohn Scipione ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2; 2438a884b43bSJohn Scipione 2439a884b43bSJohn Scipione // draw the frame (again) 2440a884b43bSJohn Scipione view->SetHighColor(frameLightColor); 2441a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2442a884b43bSJohn Scipione 2443a884b43bSJohn Scipione // draw the bevel and background 2444a884b43bSJohn Scipione _DrawRoundCornerBackgroundLeftTop(view, leftTopCorner, updateRect, 2445a884b43bSJohn Scipione bevelColor1, fillGradient); 2446a884b43bSJohn Scipione } 2447a884b43bSJohn Scipione 2448a884b43bSJohn Scipione if ((borders & B_TOP_BORDER) != 0 && (borders & B_RIGHT_BORDER) != 0 2449a884b43bSJohn Scipione && rightTopRadius > 0) { 2450a884b43bSJohn Scipione // draw right top rounded corner 2451a884b43bSJohn Scipione BRect rightTopCorner(floorf(rect.right - rightTopRadius + 2.0), 2452a884b43bSJohn Scipione floorf(rect.top), floorf(rect.right), 2453a884b43bSJohn Scipione floorf(rect.top + rightTopRadius - 2.0)); 2454a884b43bSJohn Scipione clipping.Exclude(rightTopCorner); 2455a884b43bSJohn Scipione 2456a884b43bSJohn Scipione BRegion cornerClipping(rightTopCorner); 2457a884b43bSJohn Scipione view->ConstrainClippingRegion(&cornerClipping); 2458a884b43bSJohn Scipione 2459a884b43bSJohn Scipione BRect ellipseRect(rightTopCorner); 2460a884b43bSJohn Scipione ellipseRect.InsetBy(-1.0, -1.0); 2461a884b43bSJohn Scipione ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2; 2462a884b43bSJohn Scipione ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2; 2463a884b43bSJohn Scipione 2464a884b43bSJohn Scipione // draw the frame (again) 2465a884b43bSJohn Scipione if (frameLightColor == frameShadowColor) { 2466a884b43bSJohn Scipione view->SetHighColor(frameLightColor); 2467a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 24682f86ba45SStephan Aßmus } else { 2469a884b43bSJohn Scipione BGradientLinear gradient; 2470a884b43bSJohn Scipione gradient.AddColor(frameLightColor, 0); 2471a884b43bSJohn Scipione gradient.AddColor(frameShadowColor, 255); 2472a884b43bSJohn Scipione gradient.SetStart(rightTopCorner.LeftTop()); 2473a884b43bSJohn Scipione gradient.SetEnd(rightTopCorner.RightBottom()); 2474a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 24752f86ba45SStephan Aßmus } 24762f86ba45SStephan Aßmus 2477a884b43bSJohn Scipione // draw the bevel and background 2478a884b43bSJohn Scipione _DrawRoundCornerBackgroundRightTop(view, rightTopCorner, updateRect, 2479a884b43bSJohn Scipione bevelColor1, bevelColor3, fillGradient); 2480a884b43bSJohn Scipione } 24812f86ba45SStephan Aßmus 2482a884b43bSJohn Scipione if ((borders & B_LEFT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0 2483a884b43bSJohn Scipione && leftBottomRadius > 0) { 2484a884b43bSJohn Scipione // draw left bottom rounded corner 2485a884b43bSJohn Scipione BRect leftBottomCorner(floorf(rect.left), 2486a884b43bSJohn Scipione floorf(rect.bottom - leftBottomRadius + 2.0), 2487a884b43bSJohn Scipione floorf(rect.left + leftBottomRadius - 2.0), 2488a884b43bSJohn Scipione floorf(rect.bottom)); 2489a884b43bSJohn Scipione clipping.Exclude(leftBottomCorner); 2490a884b43bSJohn Scipione 2491a884b43bSJohn Scipione BRegion cornerClipping(leftBottomCorner); 2492a884b43bSJohn Scipione view->ConstrainClippingRegion(&cornerClipping); 2493a884b43bSJohn Scipione 2494a884b43bSJohn Scipione BRect ellipseRect(leftBottomCorner); 2495a884b43bSJohn Scipione ellipseRect.InsetBy(-1.0, -1.0); 2496a884b43bSJohn Scipione ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2; 2497a884b43bSJohn Scipione ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2; 2498a884b43bSJohn Scipione 2499a884b43bSJohn Scipione // draw the frame (again) 2500a884b43bSJohn Scipione if (frameLightColor == frameShadowColor) { 2501a884b43bSJohn Scipione view->SetHighColor(frameLightColor); 2502a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2503a884b43bSJohn Scipione } else { 2504a884b43bSJohn Scipione BGradientLinear gradient; 2505a884b43bSJohn Scipione gradient.AddColor(frameLightColor, 0); 2506a884b43bSJohn Scipione gradient.AddColor(frameShadowColor, 255); 2507a884b43bSJohn Scipione gradient.SetStart(leftBottomCorner.LeftTop()); 2508a884b43bSJohn Scipione gradient.SetEnd(leftBottomCorner.RightBottom()); 2509a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2510a884b43bSJohn Scipione } 2511a884b43bSJohn Scipione 2512a884b43bSJohn Scipione // draw the bevel and background 2513a884b43bSJohn Scipione _DrawRoundCornerBackgroundLeftBottom(view, leftBottomCorner, 2514a884b43bSJohn Scipione updateRect, bevelColor2, bevelColor3, fillGradient); 2515a884b43bSJohn Scipione } 2516a884b43bSJohn Scipione 2517a884b43bSJohn Scipione if ((borders & B_RIGHT_BORDER) != 0 && (borders & B_BOTTOM_BORDER) != 0 2518a884b43bSJohn Scipione && rightBottomRadius > 0) { 2519a884b43bSJohn Scipione // draw right bottom rounded corner 2520a884b43bSJohn Scipione BRect rightBottomCorner(floorf(rect.right - rightBottomRadius + 2.0), 2521a884b43bSJohn Scipione floorf(rect.bottom - rightBottomRadius + 2.0), floorf(rect.right), 2522a884b43bSJohn Scipione floorf(rect.bottom)); 2523a884b43bSJohn Scipione clipping.Exclude(rightBottomCorner); 2524a884b43bSJohn Scipione 2525a884b43bSJohn Scipione BRegion cornerClipping(rightBottomCorner); 2526a884b43bSJohn Scipione view->ConstrainClippingRegion(&cornerClipping); 2527a884b43bSJohn Scipione 2528a884b43bSJohn Scipione BRect ellipseRect(rightBottomCorner); 2529a884b43bSJohn Scipione ellipseRect.InsetBy(-1.0, -1.0); 2530a884b43bSJohn Scipione ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2; 2531a884b43bSJohn Scipione ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2; 2532a884b43bSJohn Scipione 2533a884b43bSJohn Scipione // draw the frame (again) 2534a884b43bSJohn Scipione view->SetHighColor(frameShadowColor); 2535a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2536a884b43bSJohn Scipione 2537a884b43bSJohn Scipione // draw the bevel and background 2538a884b43bSJohn Scipione _DrawRoundCornerBackgroundRightBottom(view, rightBottomCorner, 2539a884b43bSJohn Scipione updateRect, bevelColor3, fillGradient); 2540a884b43bSJohn Scipione } 2541a884b43bSJohn Scipione 2542a884b43bSJohn Scipione // clip out the corners 2543a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2544a884b43bSJohn Scipione 2545a884b43bSJohn Scipione // draw the bevel 2546a884b43bSJohn Scipione _DrawFrame(view, rect, 2547a884b43bSJohn Scipione bevelColor2, bevelColor1, 2548a884b43bSJohn Scipione bevelColor3, bevelColor3, 2549a884b43bSJohn Scipione cornerColor, cornerColor, 2550a884b43bSJohn Scipione borders); 2551a884b43bSJohn Scipione 2552a884b43bSJohn Scipione // fill in the background 2553a884b43bSJohn Scipione view->FillRect(rect, fillGradient); 2554a884b43bSJohn Scipione 25555666b4f7SJohn Scipione // restore the clipping constraints of the view 25565666b4f7SJohn Scipione view->PopState(); 2557a884b43bSJohn Scipione } 2558a884b43bSJohn Scipione 2559a884b43bSJohn Scipione 2560a884b43bSJohn Scipione void 2561a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftTop(BView* view, BRect& cornerRect, 2562a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2563a884b43bSJohn Scipione const rgb_color& edgeColor, const rgb_color& frameColor, 2564a884b43bSJohn Scipione const rgb_color& bevelColor, const BGradientLinear& fillGradient) 2565a884b43bSJohn Scipione { 2566a884b43bSJohn Scipione _DrawRoundCornerFrameLeftTop(view, cornerRect, updateRect, 2567a884b43bSJohn Scipione background, edgeColor, frameColor); 2568a884b43bSJohn Scipione _DrawRoundCornerBackgroundLeftTop(view, cornerRect, updateRect, 2569a884b43bSJohn Scipione bevelColor, fillGradient); 2570a884b43bSJohn Scipione } 2571a884b43bSJohn Scipione 2572a884b43bSJohn Scipione 2573a884b43bSJohn Scipione void 2574a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftTop(BView* view, BRect& cornerRect, 2575a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2576a884b43bSJohn Scipione const rgb_color& edgeColor, const rgb_color& frameColor) 2577a884b43bSJohn Scipione { 2578a884b43bSJohn Scipione // constrain clipping region to corner 2579a884b43bSJohn Scipione BRegion clipping(cornerRect); 2580a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2581a884b43bSJohn Scipione 2582a884b43bSJohn Scipione // background 2583a884b43bSJohn Scipione view->SetHighColor(background); 2584a884b43bSJohn Scipione view->FillRect(cornerRect); 2585a884b43bSJohn Scipione 2586a884b43bSJohn Scipione // outer edge 2587a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2588a884b43bSJohn Scipione ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2; 2589a884b43bSJohn Scipione ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2; 2590a884b43bSJohn Scipione 2591a884b43bSJohn Scipione view->SetHighColor(edgeColor); 2592a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2593a884b43bSJohn Scipione 2594a884b43bSJohn Scipione // frame 2595a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2596a884b43bSJohn Scipione cornerRect.left++; 2597a884b43bSJohn Scipione cornerRect.top++; 2598a884b43bSJohn Scipione view->SetHighColor(frameColor); 2599a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2600a884b43bSJohn Scipione 2601a884b43bSJohn Scipione // prepare for bevel 2602a884b43bSJohn Scipione cornerRect.left++; 2603a884b43bSJohn Scipione cornerRect.top++; 2604a884b43bSJohn Scipione } 2605a884b43bSJohn Scipione 2606a884b43bSJohn Scipione 2607a884b43bSJohn Scipione void 2608a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftTop(BView* view, BRect& cornerRect, 2609a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& bevelColor, 2610a884b43bSJohn Scipione const BGradientLinear& fillGradient) 2611a884b43bSJohn Scipione { 2612a884b43bSJohn Scipione // constrain clipping region to corner 2613a884b43bSJohn Scipione BRegion clipping(cornerRect); 2614a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2615a884b43bSJohn Scipione 2616a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2617a884b43bSJohn Scipione ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2; 2618a884b43bSJohn Scipione ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2; 2619a884b43bSJohn Scipione 2620a884b43bSJohn Scipione // bevel 2621a884b43bSJohn Scipione view->SetHighColor(bevelColor); 2622a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2623a884b43bSJohn Scipione 2624a884b43bSJohn Scipione // gradient 2625a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2626a884b43bSJohn Scipione view->FillEllipse(ellipseRect, fillGradient); 2627a884b43bSJohn Scipione } 2628a884b43bSJohn Scipione 2629a884b43bSJohn Scipione 2630a884b43bSJohn Scipione void 2631a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightTop(BView* view, BRect& cornerRect, 2632a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2633a884b43bSJohn Scipione const rgb_color& edgeTopColor, const rgb_color& edgeRightColor, 2634a884b43bSJohn Scipione const rgb_color& frameTopColor, const rgb_color& frameRightColor, 2635a884b43bSJohn Scipione const rgb_color& bevelTopColor, const rgb_color& bevelRightColor, 2636a884b43bSJohn Scipione const BGradientLinear& fillGradient) 2637a884b43bSJohn Scipione { 2638a884b43bSJohn Scipione _DrawRoundCornerFrameRightTop(view, cornerRect, updateRect, 2639a884b43bSJohn Scipione background, edgeTopColor, edgeRightColor, frameTopColor, 2640a884b43bSJohn Scipione frameRightColor); 2641a884b43bSJohn Scipione _DrawRoundCornerBackgroundRightTop(view, cornerRect, updateRect, 2642a884b43bSJohn Scipione bevelTopColor, bevelRightColor, fillGradient); 2643a884b43bSJohn Scipione } 2644a884b43bSJohn Scipione 2645a884b43bSJohn Scipione 2646a884b43bSJohn Scipione void 2647a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightTop(BView* view, BRect& cornerRect, 2648a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2649a884b43bSJohn Scipione const rgb_color& edgeTopColor, const rgb_color& edgeRightColor, 2650a884b43bSJohn Scipione const rgb_color& frameTopColor, const rgb_color& frameRightColor) 2651a884b43bSJohn Scipione { 2652a884b43bSJohn Scipione // constrain clipping region to corner 2653a884b43bSJohn Scipione BRegion clipping(cornerRect); 2654a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2655a884b43bSJohn Scipione 2656a884b43bSJohn Scipione // background 2657a884b43bSJohn Scipione view->SetHighColor(background); 2658a884b43bSJohn Scipione view->FillRect(cornerRect); 2659a884b43bSJohn Scipione 2660a884b43bSJohn Scipione // outer edge 2661a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2662a884b43bSJohn Scipione ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2; 2663a884b43bSJohn Scipione ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2; 2664a884b43bSJohn Scipione 2665a884b43bSJohn Scipione BGradientLinear gradient; 2666a884b43bSJohn Scipione gradient.AddColor(edgeTopColor, 0); 2667a884b43bSJohn Scipione gradient.AddColor(edgeRightColor, 255); 2668a884b43bSJohn Scipione gradient.SetStart(cornerRect.LeftTop()); 2669a884b43bSJohn Scipione gradient.SetEnd(cornerRect.RightBottom()); 2670a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2671a884b43bSJohn Scipione 2672a884b43bSJohn Scipione // frame 2673a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2674a884b43bSJohn Scipione cornerRect.right--; 2675a884b43bSJohn Scipione cornerRect.top++; 2676a884b43bSJohn Scipione if (frameTopColor == frameRightColor) { 2677a884b43bSJohn Scipione view->SetHighColor(frameTopColor); 2678a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2679a884b43bSJohn Scipione } else { 2680a884b43bSJohn Scipione gradient.SetColor(0, frameTopColor); 2681a884b43bSJohn Scipione gradient.SetColor(1, frameRightColor); 2682a884b43bSJohn Scipione gradient.SetStart(cornerRect.LeftTop()); 2683a884b43bSJohn Scipione gradient.SetEnd(cornerRect.RightBottom()); 2684a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2685a884b43bSJohn Scipione } 2686a884b43bSJohn Scipione 2687a884b43bSJohn Scipione // prepare for bevel 2688a884b43bSJohn Scipione cornerRect.right--; 2689a884b43bSJohn Scipione cornerRect.top++; 2690a884b43bSJohn Scipione } 2691a884b43bSJohn Scipione 2692a884b43bSJohn Scipione 2693a884b43bSJohn Scipione void 2694a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightTop(BView* view, BRect& cornerRect, 2695a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& bevelTopColor, 2696a884b43bSJohn Scipione const rgb_color& bevelRightColor, const BGradientLinear& fillGradient) 2697a884b43bSJohn Scipione { 2698a884b43bSJohn Scipione // constrain clipping region to corner 2699a884b43bSJohn Scipione BRegion clipping(cornerRect); 2700a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2701a884b43bSJohn Scipione 2702a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2703a884b43bSJohn Scipione ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2; 2704a884b43bSJohn Scipione ellipseRect.bottom = ellipseRect.top + ellipseRect.Height() * 2; 2705a884b43bSJohn Scipione 2706a884b43bSJohn Scipione // bevel 2707a884b43bSJohn Scipione BGradientLinear gradient; 2708a884b43bSJohn Scipione gradient.AddColor(bevelTopColor, 0); 2709a884b43bSJohn Scipione gradient.AddColor(bevelRightColor, 255); 2710a884b43bSJohn Scipione gradient.SetStart(cornerRect.LeftTop()); 2711a884b43bSJohn Scipione gradient.SetEnd(cornerRect.RightBottom()); 2712a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2713a884b43bSJohn Scipione 2714a884b43bSJohn Scipione // gradient 2715a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2716a884b43bSJohn Scipione view->FillEllipse(ellipseRect, fillGradient); 2717a884b43bSJohn Scipione } 2718a884b43bSJohn Scipione 2719a884b43bSJohn Scipione 2720a884b43bSJohn Scipione void 2721a884b43bSJohn Scipione BControlLook::_DrawRoundCornerLeftBottom(BView* view, BRect& cornerRect, 2722a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2723a884b43bSJohn Scipione const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor, 2724a884b43bSJohn Scipione const rgb_color& frameLeftColor, const rgb_color& frameBottomColor, 2725a884b43bSJohn Scipione const rgb_color& bevelLeftColor, const rgb_color& bevelBottomColor, 2726a884b43bSJohn Scipione const BGradientLinear& fillGradient) 2727a884b43bSJohn Scipione { 2728a884b43bSJohn Scipione _DrawRoundCornerFrameLeftBottom(view, cornerRect, updateRect, 2729a884b43bSJohn Scipione background, edgeLeftColor, edgeBottomColor, frameLeftColor, 2730a884b43bSJohn Scipione frameBottomColor); 2731a884b43bSJohn Scipione _DrawRoundCornerBackgroundLeftBottom(view, cornerRect, updateRect, 2732a884b43bSJohn Scipione bevelLeftColor, bevelBottomColor, fillGradient); 2733a884b43bSJohn Scipione } 2734a884b43bSJohn Scipione 2735a884b43bSJohn Scipione 2736a884b43bSJohn Scipione void 2737a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameLeftBottom(BView* view, BRect& cornerRect, 2738a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2739a884b43bSJohn Scipione const rgb_color& edgeLeftColor, const rgb_color& edgeBottomColor, 2740a884b43bSJohn Scipione const rgb_color& frameLeftColor, const rgb_color& frameBottomColor) 2741a884b43bSJohn Scipione { 2742a884b43bSJohn Scipione // constrain clipping region to corner 2743a884b43bSJohn Scipione BRegion clipping(cornerRect); 2744a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2745a884b43bSJohn Scipione 2746a884b43bSJohn Scipione // background 2747a884b43bSJohn Scipione view->SetHighColor(background); 2748a884b43bSJohn Scipione view->FillRect(cornerRect); 2749a884b43bSJohn Scipione 2750a884b43bSJohn Scipione // outer edge 2751a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2752a884b43bSJohn Scipione ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2; 2753a884b43bSJohn Scipione ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2; 2754a884b43bSJohn Scipione 2755a884b43bSJohn Scipione BGradientLinear gradient; 2756a884b43bSJohn Scipione gradient.AddColor(edgeLeftColor, 0); 2757a884b43bSJohn Scipione gradient.AddColor(edgeBottomColor, 255); 2758a884b43bSJohn Scipione gradient.SetStart(cornerRect.LeftTop()); 2759a884b43bSJohn Scipione gradient.SetEnd(cornerRect.RightBottom()); 2760a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2761a884b43bSJohn Scipione 2762a884b43bSJohn Scipione // frame 2763a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2764a884b43bSJohn Scipione cornerRect.left++; 2765a884b43bSJohn Scipione cornerRect.bottom--; 2766a884b43bSJohn Scipione if (frameLeftColor == frameBottomColor) { 2767a884b43bSJohn Scipione view->SetHighColor(frameLeftColor); 2768a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2769a884b43bSJohn Scipione } else { 2770a884b43bSJohn Scipione gradient.SetColor(0, frameLeftColor); 2771a884b43bSJohn Scipione gradient.SetColor(1, frameBottomColor); 2772a884b43bSJohn Scipione gradient.SetStart(cornerRect.LeftTop()); 2773a884b43bSJohn Scipione gradient.SetEnd(cornerRect.RightBottom()); 2774a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2775a884b43bSJohn Scipione } 2776a884b43bSJohn Scipione 2777a884b43bSJohn Scipione // prepare for bevel 2778a884b43bSJohn Scipione cornerRect.left++; 2779a884b43bSJohn Scipione cornerRect.bottom--; 2780a884b43bSJohn Scipione } 2781a884b43bSJohn Scipione 2782a884b43bSJohn Scipione 2783a884b43bSJohn Scipione void 2784a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundLeftBottom(BView* view, BRect& cornerRect, 2785a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& bevelLeftColor, 2786a884b43bSJohn Scipione const rgb_color& bevelBottomColor, const BGradientLinear& fillGradient) 2787a884b43bSJohn Scipione { 2788a884b43bSJohn Scipione // constrain clipping region to corner 2789a884b43bSJohn Scipione BRegion clipping(cornerRect); 2790a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2791a884b43bSJohn Scipione 2792a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2793a884b43bSJohn Scipione ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2; 2794a884b43bSJohn Scipione ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2; 2795a884b43bSJohn Scipione 2796a884b43bSJohn Scipione // bevel 2797a884b43bSJohn Scipione BGradientLinear gradient; 2798a884b43bSJohn Scipione gradient.AddColor(bevelLeftColor, 0); 2799a884b43bSJohn Scipione gradient.AddColor(bevelBottomColor, 255); 2800a884b43bSJohn Scipione gradient.SetStart(cornerRect.LeftTop()); 2801a884b43bSJohn Scipione gradient.SetEnd(cornerRect.RightBottom()); 2802a884b43bSJohn Scipione view->FillEllipse(ellipseRect, gradient); 2803a884b43bSJohn Scipione 2804a884b43bSJohn Scipione // gradient 2805a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2806a884b43bSJohn Scipione view->FillEllipse(ellipseRect, fillGradient); 2807a884b43bSJohn Scipione 2808a884b43bSJohn Scipione view->PopState(); 2809a884b43bSJohn Scipione } 2810a884b43bSJohn Scipione 2811a884b43bSJohn Scipione 2812a884b43bSJohn Scipione void 2813a884b43bSJohn Scipione BControlLook::_DrawRoundCornerRightBottom(BView* view, BRect& cornerRect, 2814a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2815a884b43bSJohn Scipione const rgb_color& edgeColor, const rgb_color& frameColor, 2816a884b43bSJohn Scipione const rgb_color& bevelColor, const BGradientLinear& fillGradient) 2817a884b43bSJohn Scipione { 2818a884b43bSJohn Scipione _DrawRoundCornerFrameRightBottom(view, cornerRect, updateRect, 2819a884b43bSJohn Scipione background, edgeColor, frameColor); 2820a884b43bSJohn Scipione _DrawRoundCornerBackgroundRightBottom(view, cornerRect, updateRect, 2821a884b43bSJohn Scipione bevelColor, fillGradient); 2822a884b43bSJohn Scipione } 2823a884b43bSJohn Scipione 2824a884b43bSJohn Scipione 2825a884b43bSJohn Scipione void 2826a884b43bSJohn Scipione BControlLook::_DrawRoundCornerFrameRightBottom(BView* view, BRect& cornerRect, 2827a884b43bSJohn Scipione const BRect& updateRect, const rgb_color& background, 2828a884b43bSJohn Scipione const rgb_color& edgeColor, const rgb_color& frameColor) 2829a884b43bSJohn Scipione { 2830a884b43bSJohn Scipione // constrain clipping region to corner 2831a884b43bSJohn Scipione BRegion clipping(cornerRect); 2832a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2833a884b43bSJohn Scipione 2834a884b43bSJohn Scipione // background 2835a884b43bSJohn Scipione view->SetHighColor(background); 2836a884b43bSJohn Scipione view->FillRect(cornerRect); 2837a884b43bSJohn Scipione 2838a884b43bSJohn Scipione // outer edge 2839a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2840a884b43bSJohn Scipione ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2; 2841a884b43bSJohn Scipione ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2; 2842a884b43bSJohn Scipione 2843a884b43bSJohn Scipione view->SetHighColor(edgeColor); 2844a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2845a884b43bSJohn Scipione 2846a884b43bSJohn Scipione // frame 2847a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2848a884b43bSJohn Scipione cornerRect.right--; 2849a884b43bSJohn Scipione cornerRect.bottom++; 2850a884b43bSJohn Scipione view->SetHighColor(frameColor); 2851a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2852a884b43bSJohn Scipione 2853a884b43bSJohn Scipione // prepare for bevel 2854a884b43bSJohn Scipione cornerRect.left++; 2855a884b43bSJohn Scipione cornerRect.bottom--; 2856a884b43bSJohn Scipione } 2857a884b43bSJohn Scipione 2858a884b43bSJohn Scipione 2859a884b43bSJohn Scipione void 2860a884b43bSJohn Scipione BControlLook::_DrawRoundCornerBackgroundRightBottom(BView* view, 2861a884b43bSJohn Scipione BRect& cornerRect, const BRect& updateRect, const rgb_color& bevelColor, 2862a884b43bSJohn Scipione const BGradientLinear& fillGradient) 2863a884b43bSJohn Scipione { 2864a884b43bSJohn Scipione // constrain clipping region to corner 2865a884b43bSJohn Scipione BRegion clipping(cornerRect); 2866a884b43bSJohn Scipione view->ConstrainClippingRegion(&clipping); 2867a884b43bSJohn Scipione 2868a884b43bSJohn Scipione BRect ellipseRect(cornerRect); 2869a884b43bSJohn Scipione ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2; 2870a884b43bSJohn Scipione ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2; 2871a884b43bSJohn Scipione 2872a884b43bSJohn Scipione // bevel 2873a884b43bSJohn Scipione view->SetHighColor(bevelColor); 2874a884b43bSJohn Scipione view->FillEllipse(ellipseRect); 2875a884b43bSJohn Scipione 2876a884b43bSJohn Scipione // gradient 2877a884b43bSJohn Scipione ellipseRect.InsetBy(1, 1); 2878a884b43bSJohn Scipione view->FillEllipse(ellipseRect, fillGradient); 28792f86ba45SStephan Aßmus } 28802f86ba45SStephan Aßmus 28812f86ba45SStephan Aßmus 28822f86ba45SStephan Aßmus void 28832f86ba45SStephan Aßmus BControlLook::_DrawRoundBarCorner(BView* view, BRect& rect, 28842f86ba45SStephan Aßmus const BRect& updateRect, 28852f86ba45SStephan Aßmus const rgb_color& edgeLightColor, const rgb_color& edgeShadowColor, 28862f86ba45SStephan Aßmus const rgb_color& frameLightColor, const rgb_color& frameShadowColor, 28872f86ba45SStephan Aßmus const rgb_color& fillLightColor, const rgb_color& fillShadowColor, 28882f86ba45SStephan Aßmus float leftInset, float topInset, float rightInset, float bottomInset, 28892f86ba45SStephan Aßmus enum orientation orientation) 28902f86ba45SStephan Aßmus { 28912f86ba45SStephan Aßmus if (!rect.IsValid() || !rect.Intersects(updateRect)) 28922f86ba45SStephan Aßmus return; 28932f86ba45SStephan Aßmus 28942f86ba45SStephan Aßmus BGradientLinear gradient; 28952f86ba45SStephan Aßmus gradient.AddColor(edgeShadowColor, 0); 28962f86ba45SStephan Aßmus gradient.AddColor(edgeLightColor, 255); 28972f86ba45SStephan Aßmus gradient.SetStart(rect.LeftTop()); 28982f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) 28992f86ba45SStephan Aßmus gradient.SetEnd(rect.LeftBottom()); 29002f86ba45SStephan Aßmus else 29012f86ba45SStephan Aßmus gradient.SetEnd(rect.RightTop()); 29022f86ba45SStephan Aßmus 29032f86ba45SStephan Aßmus view->FillEllipse(rect, gradient); 29042f86ba45SStephan Aßmus 29052f86ba45SStephan Aßmus rect.left += leftInset; 29062f86ba45SStephan Aßmus rect.top += topInset; 29072f86ba45SStephan Aßmus rect.right += rightInset; 29082f86ba45SStephan Aßmus rect.bottom += bottomInset; 29092f86ba45SStephan Aßmus 29102f86ba45SStephan Aßmus gradient.MakeEmpty(); 29112f86ba45SStephan Aßmus gradient.AddColor(frameShadowColor, 0); 29122f86ba45SStephan Aßmus gradient.AddColor(frameLightColor, 255); 29132f86ba45SStephan Aßmus gradient.SetStart(rect.LeftTop()); 29142f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) 29152f86ba45SStephan Aßmus gradient.SetEnd(rect.LeftBottom()); 29162f86ba45SStephan Aßmus else 29172f86ba45SStephan Aßmus gradient.SetEnd(rect.RightTop()); 29182f86ba45SStephan Aßmus 29192f86ba45SStephan Aßmus view->FillEllipse(rect, gradient); 29202f86ba45SStephan Aßmus 29212f86ba45SStephan Aßmus rect.left += leftInset; 29222f86ba45SStephan Aßmus rect.top += topInset; 29232f86ba45SStephan Aßmus rect.right += rightInset; 29242f86ba45SStephan Aßmus rect.bottom += bottomInset; 29252f86ba45SStephan Aßmus 29262f86ba45SStephan Aßmus gradient.MakeEmpty(); 29272f86ba45SStephan Aßmus gradient.AddColor(fillShadowColor, 0); 29282f86ba45SStephan Aßmus gradient.AddColor(fillLightColor, 255); 29292f86ba45SStephan Aßmus gradient.SetStart(rect.LeftTop()); 29302f86ba45SStephan Aßmus if (orientation == B_HORIZONTAL) 29312f86ba45SStephan Aßmus gradient.SetEnd(rect.LeftBottom()); 29322f86ba45SStephan Aßmus else 29332f86ba45SStephan Aßmus gradient.SetEnd(rect.RightTop()); 29342f86ba45SStephan Aßmus 29352f86ba45SStephan Aßmus view->FillEllipse(rect, gradient); 29362f86ba45SStephan Aßmus } 29372f86ba45SStephan Aßmus 29382f86ba45SStephan Aßmus 2939a884b43bSJohn Scipione rgb_color 2940a884b43bSJohn Scipione BControlLook::_EdgeLightColor(const rgb_color& base, float contrast, 2941a884b43bSJohn Scipione float brightness, uint32 flags) 29422f86ba45SStephan Aßmus { 2943a884b43bSJohn Scipione rgb_color edgeLightColor; 29442f86ba45SStephan Aßmus 2945a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 2946a884b43bSJohn Scipione uint8 alpha = uint8(20 * contrast); 2947a884b43bSJohn Scipione uint32 white = uint8(255 * brightness); 29482f86ba45SStephan Aßmus 2949a884b43bSJohn Scipione edgeLightColor = (rgb_color){ white, white, white, alpha }; 29502f86ba45SStephan Aßmus } else { 2951a884b43bSJohn Scipione // colors 2952a884b43bSJohn Scipione float tintLight = kEdgeBevelLightTint; 2953a884b43bSJohn Scipione 2954a884b43bSJohn Scipione if (contrast == 0.0) 2955a884b43bSJohn Scipione tintLight = B_NO_TINT; 2956a884b43bSJohn Scipione else if (contrast != 1.0) 2957a884b43bSJohn Scipione tintLight = B_NO_TINT + (tintLight - B_NO_TINT) * contrast; 2958a884b43bSJohn Scipione 2959a884b43bSJohn Scipione edgeLightColor = tint_color(base, tintLight); 2960a884b43bSJohn Scipione 2961a884b43bSJohn Scipione if (brightness < 1.0) { 2962a884b43bSJohn Scipione edgeLightColor.red = uint8(edgeLightColor.red * brightness); 2963a884b43bSJohn Scipione edgeLightColor.green = uint8(edgeLightColor.green * brightness); 2964a884b43bSJohn Scipione edgeLightColor.blue = uint8(edgeLightColor.blue * brightness); 2965a884b43bSJohn Scipione } 29662f86ba45SStephan Aßmus } 29672f86ba45SStephan Aßmus 2968a884b43bSJohn Scipione return edgeLightColor; 2969a884b43bSJohn Scipione } 2970a884b43bSJohn Scipione 2971a884b43bSJohn Scipione 2972a884b43bSJohn Scipione rgb_color 2973a884b43bSJohn Scipione BControlLook::_EdgeShadowColor(const rgb_color& base, float contrast, 2974a884b43bSJohn Scipione float brightness, uint32 flags) 2975a884b43bSJohn Scipione { 2976a884b43bSJohn Scipione rgb_color edgeShadowColor; 2977a884b43bSJohn Scipione 2978a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) { 2979a884b43bSJohn Scipione uint8 alpha = uint8(20 * contrast); 2980a884b43bSJohn Scipione edgeShadowColor = (rgb_color){ 0, 0, 0, alpha }; 2981a884b43bSJohn Scipione } else { 2982a884b43bSJohn Scipione float tintShadow = kEdgeBevelShadowTint; 2983a884b43bSJohn Scipione 2984a884b43bSJohn Scipione if (contrast == 0.0) 2985a884b43bSJohn Scipione tintShadow = B_NO_TINT; 2986a884b43bSJohn Scipione else if (contrast != 1.0) 2987a884b43bSJohn Scipione tintShadow = B_NO_TINT + (tintShadow - B_NO_TINT) * contrast; 2988a884b43bSJohn Scipione 2989a884b43bSJohn Scipione edgeShadowColor = tint_color(base, tintShadow); 2990a884b43bSJohn Scipione 2991a884b43bSJohn Scipione if (brightness < 1.0) { 2992a884b43bSJohn Scipione edgeShadowColor.red = uint8(edgeShadowColor.red * brightness); 2993a884b43bSJohn Scipione edgeShadowColor.green = uint8(edgeShadowColor.green * brightness); 2994a884b43bSJohn Scipione edgeShadowColor.blue = uint8(edgeShadowColor.blue * brightness); 2995a884b43bSJohn Scipione } 2996a884b43bSJohn Scipione } 2997a884b43bSJohn Scipione 2998a884b43bSJohn Scipione return edgeShadowColor; 2999a884b43bSJohn Scipione } 3000a884b43bSJohn Scipione 3001a884b43bSJohn Scipione 3002a884b43bSJohn Scipione rgb_color 3003a884b43bSJohn Scipione BControlLook::_FrameLightColor(const rgb_color& base, uint32 flags) 3004a884b43bSJohn Scipione { 3005a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) 3006a884b43bSJohn Scipione return ui_color(B_KEYBOARD_NAVIGATION_COLOR); 3007a884b43bSJohn Scipione 3008a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) 3009a884b43bSJohn Scipione return _FrameShadowColor(base, flags & ~B_ACTIVATED); 3010a884b43bSJohn Scipione 3011a884b43bSJohn Scipione rgb_color frameLightColor; 3012a884b43bSJohn Scipione 3013a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 3014a884b43bSJohn Scipione // TODO: B_BLEND_FRAME 3015a884b43bSJohn Scipione frameLightColor = tint_color(base, 1.145); 3016a884b43bSJohn Scipione 3017a884b43bSJohn Scipione if ((flags & B_DEFAULT_BUTTON) != 0) 3018a884b43bSJohn Scipione frameLightColor = tint_color(frameLightColor, 1.14); 3019a884b43bSJohn Scipione } else { 3020a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) 3021a884b43bSJohn Scipione frameLightColor = (rgb_color){ 0, 0, 0, 75 }; 3022a884b43bSJohn Scipione else 3023a884b43bSJohn Scipione frameLightColor = tint_color(base, 1.33); 3024a884b43bSJohn Scipione 3025a884b43bSJohn Scipione if ((flags & B_DEFAULT_BUTTON) != 0) 3026a884b43bSJohn Scipione frameLightColor = tint_color(frameLightColor, 1.35); 3027a884b43bSJohn Scipione } 3028a884b43bSJohn Scipione 3029a884b43bSJohn Scipione return frameLightColor; 3030a884b43bSJohn Scipione } 3031a884b43bSJohn Scipione 3032a884b43bSJohn Scipione 3033a884b43bSJohn Scipione rgb_color 3034a884b43bSJohn Scipione BControlLook::_FrameShadowColor(const rgb_color& base, uint32 flags) 3035a884b43bSJohn Scipione { 3036a884b43bSJohn Scipione if ((flags & B_FOCUSED) != 0) 3037a884b43bSJohn Scipione return ui_color(B_KEYBOARD_NAVIGATION_COLOR); 3038a884b43bSJohn Scipione 3039a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) 3040a884b43bSJohn Scipione return _FrameLightColor(base, flags & ~B_ACTIVATED); 3041a884b43bSJohn Scipione 3042a884b43bSJohn Scipione rgb_color frameShadowColor; 3043a884b43bSJohn Scipione 3044a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 3045a884b43bSJohn Scipione // TODO: B_BLEND_FRAME 3046a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.24); 3047a884b43bSJohn Scipione 3048a884b43bSJohn Scipione if ((flags & B_DEFAULT_BUTTON) != 0) { 3049a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.145); 3050a884b43bSJohn Scipione frameShadowColor = tint_color(frameShadowColor, 1.12); 3051a884b43bSJohn Scipione } 3052a884b43bSJohn Scipione } else { 3053a884b43bSJohn Scipione if ((flags & B_DEFAULT_BUTTON) != 0) { 3054a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) 3055a884b43bSJohn Scipione frameShadowColor = (rgb_color){ 0, 0, 0, 75 }; 3056a884b43bSJohn Scipione else 3057a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.33); 3058a884b43bSJohn Scipione 3059a884b43bSJohn Scipione frameShadowColor = tint_color(frameShadowColor, 1.5); 3060a884b43bSJohn Scipione } else { 3061a884b43bSJohn Scipione if ((flags & B_BLEND_FRAME) != 0) 3062a884b43bSJohn Scipione frameShadowColor = (rgb_color){ 0, 0, 0, 95 }; 3063a884b43bSJohn Scipione else 3064a884b43bSJohn Scipione frameShadowColor = tint_color(base, 1.47); 3065a884b43bSJohn Scipione } 3066a884b43bSJohn Scipione } 3067a884b43bSJohn Scipione 3068a884b43bSJohn Scipione return frameShadowColor; 3069a884b43bSJohn Scipione } 3070a884b43bSJohn Scipione 3071a884b43bSJohn Scipione 3072a884b43bSJohn Scipione rgb_color 3073a884b43bSJohn Scipione BControlLook::_BevelLightColor(const rgb_color& base, uint32 flags) 3074a884b43bSJohn Scipione { 3075a884b43bSJohn Scipione rgb_color bevelLightColor = tint_color(base, 0.2); 3076a884b43bSJohn Scipione 3077a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 3078a884b43bSJohn Scipione bevelLightColor = tint_color(base, B_LIGHTEN_1_TINT); 3079a884b43bSJohn Scipione 3080a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) 3081a884b43bSJohn Scipione bevelLightColor = tint_color(base, B_DARKEN_1_TINT); 3082a884b43bSJohn Scipione 3083a884b43bSJohn Scipione return bevelLightColor; 3084a884b43bSJohn Scipione } 3085a884b43bSJohn Scipione 3086a884b43bSJohn Scipione 3087a884b43bSJohn Scipione rgb_color 3088a884b43bSJohn Scipione BControlLook::_BevelShadowColor(const rgb_color& base, uint32 flags) 3089a884b43bSJohn Scipione { 3090a884b43bSJohn Scipione rgb_color bevelShadowColor = tint_color(base, 1.08); 3091a884b43bSJohn Scipione 3092a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) 3093a884b43bSJohn Scipione bevelShadowColor = base; 3094a884b43bSJohn Scipione 3095a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) 3096a884b43bSJohn Scipione bevelShadowColor = tint_color(base, B_DARKEN_1_TINT); 3097a884b43bSJohn Scipione 3098a884b43bSJohn Scipione return bevelShadowColor; 3099a884b43bSJohn Scipione } 3100a884b43bSJohn Scipione 3101a884b43bSJohn Scipione 3102a884b43bSJohn Scipione void 3103a884b43bSJohn Scipione BControlLook::_FillGradient(BView* view, const BRect& rect, 3104a884b43bSJohn Scipione const rgb_color& base, float topTint, float bottomTint, 3105a884b43bSJohn Scipione enum orientation orientation) 3106a884b43bSJohn Scipione { 3107a884b43bSJohn Scipione BGradientLinear gradient; 3108a884b43bSJohn Scipione _MakeGradient(gradient, rect, base, topTint, bottomTint, orientation); 3109a884b43bSJohn Scipione view->FillRect(rect, gradient); 3110a884b43bSJohn Scipione } 3111a884b43bSJohn Scipione 3112a884b43bSJohn Scipione 3113a884b43bSJohn Scipione void 3114a884b43bSJohn Scipione BControlLook::_FillGlossyGradient(BView* view, const BRect& rect, 3115a884b43bSJohn Scipione const rgb_color& base, float topTint, float middle1Tint, 3116a884b43bSJohn Scipione float middle2Tint, float bottomTint, enum orientation orientation) 3117a884b43bSJohn Scipione { 3118a884b43bSJohn Scipione BGradientLinear gradient; 3119a884b43bSJohn Scipione _MakeGlossyGradient(gradient, rect, base, topTint, middle1Tint, 3120a884b43bSJohn Scipione middle2Tint, bottomTint, orientation); 3121a884b43bSJohn Scipione view->FillRect(rect, gradient); 3122a884b43bSJohn Scipione } 3123a884b43bSJohn Scipione 3124a884b43bSJohn Scipione 3125a884b43bSJohn Scipione void 3126a884b43bSJohn Scipione BControlLook::_MakeGradient(BGradientLinear& gradient, const BRect& rect, 3127a884b43bSJohn Scipione const rgb_color& base, float topTint, float bottomTint, 3128a884b43bSJohn Scipione enum orientation orientation) const 3129a884b43bSJohn Scipione { 3130a884b43bSJohn Scipione gradient.AddColor(tint_color(base, topTint), 0); 3131a884b43bSJohn Scipione gradient.AddColor(tint_color(base, bottomTint), 255); 31322f86ba45SStephan Aßmus gradient.SetStart(rect.LeftTop()); 3133a884b43bSJohn Scipione if (orientation == B_HORIZONTAL) 3134a884b43bSJohn Scipione gradient.SetEnd(rect.LeftBottom()); 3135a884b43bSJohn Scipione else 3136a884b43bSJohn Scipione gradient.SetEnd(rect.RightTop()); 3137a884b43bSJohn Scipione } 31382f86ba45SStephan Aßmus 31392f86ba45SStephan Aßmus 3140a884b43bSJohn Scipione void 3141a884b43bSJohn Scipione BControlLook::_MakeGlossyGradient(BGradientLinear& gradient, const BRect& rect, 3142a884b43bSJohn Scipione const rgb_color& base, float topTint, float middle1Tint, 3143a884b43bSJohn Scipione float middle2Tint, float bottomTint, 3144a884b43bSJohn Scipione enum orientation orientation) const 3145a884b43bSJohn Scipione { 3146a884b43bSJohn Scipione gradient.AddColor(tint_color(base, topTint), 0); 3147a884b43bSJohn Scipione gradient.AddColor(tint_color(base, middle1Tint), 132); 3148a884b43bSJohn Scipione gradient.AddColor(tint_color(base, middle2Tint), 136); 3149a884b43bSJohn Scipione gradient.AddColor(tint_color(base, bottomTint), 255); 3150a884b43bSJohn Scipione gradient.SetStart(rect.LeftTop()); 3151a884b43bSJohn Scipione if (orientation == B_HORIZONTAL) 3152a884b43bSJohn Scipione gradient.SetEnd(rect.LeftBottom()); 3153a884b43bSJohn Scipione else 3154a884b43bSJohn Scipione gradient.SetEnd(rect.RightTop()); 3155a884b43bSJohn Scipione } 3156a884b43bSJohn Scipione 3157a884b43bSJohn Scipione 3158a884b43bSJohn Scipione void 3159a884b43bSJohn Scipione BControlLook::_MakeButtonGradient(BGradientLinear& gradient, BRect& rect, 3160a884b43bSJohn Scipione const rgb_color& base, uint32 flags, enum orientation orientation) const 3161a884b43bSJohn Scipione { 3162a884b43bSJohn Scipione float topTint = 0.49; 3163a884b43bSJohn Scipione float middleTint1 = 0.62; 3164a884b43bSJohn Scipione float middleTint2 = 0.76; 3165a884b43bSJohn Scipione float bottomTint = 0.90; 3166a884b43bSJohn Scipione 3167a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) { 3168a884b43bSJohn Scipione topTint = 1.11; 3169a884b43bSJohn Scipione bottomTint = 1.08; 3170a884b43bSJohn Scipione } 3171a884b43bSJohn Scipione 3172a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 3173a884b43bSJohn Scipione topTint = (topTint + B_NO_TINT) / 2; 3174a884b43bSJohn Scipione middleTint1 = (middleTint1 + B_NO_TINT) / 2; 3175a884b43bSJohn Scipione middleTint2 = (middleTint2 + B_NO_TINT) / 2; 3176a884b43bSJohn Scipione bottomTint = (bottomTint + B_NO_TINT) / 2; 3177a884b43bSJohn Scipione } else if ((flags & B_HOVER) != 0) { 3178a884b43bSJohn Scipione static const float kHoverTintFactor = 0.85; 3179a884b43bSJohn Scipione topTint *= kHoverTintFactor; 3180a884b43bSJohn Scipione middleTint1 *= kHoverTintFactor; 3181a884b43bSJohn Scipione middleTint2 *= kHoverTintFactor; 3182a884b43bSJohn Scipione bottomTint *= kHoverTintFactor; 3183a884b43bSJohn Scipione } 3184a884b43bSJohn Scipione 3185a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) { 3186a884b43bSJohn Scipione _MakeGradient(gradient, rect, base, topTint, bottomTint, orientation); 3187a884b43bSJohn Scipione } else { 3188a884b43bSJohn Scipione _MakeGlossyGradient(gradient, rect, base, topTint, middleTint1, 3189a884b43bSJohn Scipione middleTint2, bottomTint, orientation); 3190a884b43bSJohn Scipione } 3191a884b43bSJohn Scipione } 3192a884b43bSJohn Scipione 3193a884b43bSJohn Scipione 3194a884b43bSJohn Scipione 3195a884b43bSJohn Scipione bool 3196a884b43bSJohn Scipione BControlLook::_RadioButtonAndCheckBoxMarkColor(const rgb_color& base, 3197a884b43bSJohn Scipione rgb_color& color, uint32 flags) const 3198a884b43bSJohn Scipione { 3199a884b43bSJohn Scipione if ((flags & (B_ACTIVATED | B_CLICKED)) == 0) { 3200a884b43bSJohn Scipione // no mark to be drawn at all 3201a884b43bSJohn Scipione return false; 3202a884b43bSJohn Scipione } 3203a884b43bSJohn Scipione 32044bb5af76SJohn Scipione color = ui_color(B_CONTROL_MARK_COLOR); 3205a884b43bSJohn Scipione 3206a884b43bSJohn Scipione float mix = 1.0; 3207a884b43bSJohn Scipione 3208a884b43bSJohn Scipione if ((flags & B_DISABLED) != 0) { 3209a884b43bSJohn Scipione // activated, but disabled 3210a884b43bSJohn Scipione mix = 0.4; 3211a884b43bSJohn Scipione } else if ((flags & B_CLICKED) != 0) { 3212a884b43bSJohn Scipione if ((flags & B_ACTIVATED) != 0) { 3213a884b43bSJohn Scipione // loosing activation 3214a884b43bSJohn Scipione mix = 0.7; 3215a884b43bSJohn Scipione } else { 3216a884b43bSJohn Scipione // becoming activated 3217a884b43bSJohn Scipione mix = 0.3; 3218a884b43bSJohn Scipione } 3219a884b43bSJohn Scipione } else { 3220a884b43bSJohn Scipione // simply activated 3221a884b43bSJohn Scipione } 3222a884b43bSJohn Scipione 3223a884b43bSJohn Scipione color.red = uint8(color.red * mix + base.red * (1.0 - mix)); 3224a884b43bSJohn Scipione color.green = uint8(color.green * mix + base.green * (1.0 - mix)); 3225a884b43bSJohn Scipione color.blue = uint8(color.blue * mix + base.blue * (1.0 - mix)); 3226a884b43bSJohn Scipione 3227a884b43bSJohn Scipione return true; 32282f86ba45SStephan Aßmus } 32292f86ba45SStephan Aßmus 32302f86ba45SStephan Aßmus 32312f86ba45SStephan Aßmus // NOTE: May come from a add-on in the future. Initialized in 32322f86ba45SStephan Aßmus // InterfaceDefs.cpp 32332f86ba45SStephan Aßmus BControlLook* be_control_look = NULL; 32342f86ba45SStephan Aßmus 3235a884b43bSJohn Scipione 32362f86ba45SStephan Aßmus } // namespace BPrivate 3237