1 /* 2 * Copyright 2009-2017, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _HAIKU_CONTROL_LOOK_H 6 #define _HAIKU_CONTROL_LOOK_H 7 8 9 #include <ControlLook.h> 10 11 12 class BBitmap; 13 class BControl; 14 class BGradientLinear; 15 class BView; 16 17 18 namespace BPrivate { 19 20 21 class HaikuControlLook : public BControlLook { 22 public: 23 HaikuControlLook(); 24 virtual ~HaikuControlLook(); 25 26 virtual BAlignment DefaultLabelAlignment() const; 27 virtual float DefaultLabelSpacing() const; 28 29 virtual float DefaultItemSpacing() const; 30 31 static float ComposeSpacing(float spacing); 32 33 virtual uint32 Flags(BControl* control) const; 34 35 virtual void DrawButtonFrame(BView* view, BRect& rect, 36 const BRect& updateRect, 37 const rgb_color& base, 38 const rgb_color& background, 39 uint32 flags = 0, 40 uint32 borders = B_ALL_BORDERS); 41 virtual void DrawButtonFrame(BView* view, BRect& rect, 42 const BRect& updateRect, 43 float radius, 44 const rgb_color& base, 45 const rgb_color& background, 46 uint32 flags = 0, 47 uint32 borders = B_ALL_BORDERS); 48 virtual void DrawButtonFrame(BView* view, BRect& rect, 49 const BRect& updateRect, 50 float leftTopRadius, 51 float rightTopRadius, 52 float leftBottomRadius, 53 float rightBottomRadius, 54 const rgb_color& base, 55 const rgb_color& background, 56 uint32 flags = 0, 57 uint32 borders = B_ALL_BORDERS); 58 59 virtual void DrawButtonBackground(BView* view, BRect& rect, 60 const BRect& updateRect, 61 const rgb_color& base, 62 uint32 flags = 0, 63 uint32 borders = B_ALL_BORDERS, 64 orientation orientation = B_HORIZONTAL); 65 virtual void DrawButtonBackground(BView* view, BRect& rect, 66 const BRect& updateRect, 67 float radius, 68 const rgb_color& base, 69 uint32 flags = 0, 70 uint32 borders = B_ALL_BORDERS, 71 orientation orientation = B_HORIZONTAL); 72 virtual void DrawButtonBackground(BView* view, BRect& rect, 73 const BRect& updateRect, 74 float leftTopRadius, 75 float rightTopRadius, 76 float leftBottomRadius, 77 float rightBottomRadius, 78 const rgb_color& base, 79 uint32 flags = 0, 80 uint32 borders = B_ALL_BORDERS, 81 orientation orientation = B_HORIZONTAL); 82 83 virtual void DrawMenuBarBackground(BView* view, BRect& rect, 84 const BRect& updateRect, 85 const rgb_color& base, 86 uint32 flags = 0, 87 uint32 borders = B_ALL_BORDERS); 88 89 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 90 const BRect& updateRect, 91 const rgb_color& base, 92 const rgb_color& background, 93 uint32 flags = 0, 94 uint32 borders = B_ALL_BORDERS); 95 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 96 const BRect& updateRect, 97 float radius, 98 const rgb_color& base, 99 const rgb_color& background, 100 uint32 flags = 0, 101 uint32 borders = B_ALL_BORDERS); 102 virtual void DrawMenuFieldFrame(BView* view, BRect& rect, 103 const BRect& updateRect, 104 float leftTopRadius, 105 float rightTopRadius, 106 float leftBottomRadius, 107 float rightBottomRadius, 108 const rgb_color& base, 109 const rgb_color& background, 110 uint32 flags = 0, 111 uint32 borders = B_ALL_BORDERS); 112 113 virtual void DrawMenuFieldBackground(BView* view, 114 BRect& rect, const BRect& updateRect, 115 const rgb_color& base, bool popupIndicator, 116 uint32 flags = 0); 117 virtual void DrawMenuFieldBackground(BView* view, 118 BRect& rect, const BRect& updateRect, 119 float radius, const rgb_color& base, 120 bool popupIndicator, uint32 flags = 0); 121 virtual void DrawMenuFieldBackground(BView* view, 122 BRect& rect, const BRect& updateRect, 123 float leftTopRadius, 124 float rightTopRadius, 125 float leftBottomRadius, 126 float rightBottomRadius, 127 const rgb_color& base, 128 bool popupIndicator, uint32 flags = 0); 129 virtual void DrawMenuFieldBackground(BView* view, 130 BRect& rect, const BRect& updateRect, 131 const rgb_color& base, uint32 flags = 0, 132 uint32 borders = B_ALL_BORDERS); 133 134 virtual void DrawMenuBackground(BView* view, 135 BRect& rect, const BRect& updateRect, 136 const rgb_color& base, uint32 flags = 0, 137 uint32 borders = B_ALL_BORDERS); 138 139 virtual void DrawMenuItemBackground(BView* view, 140 BRect& rect, const BRect& updateRect, 141 const rgb_color& base, uint32 flags = 0, 142 uint32 borders = B_ALL_BORDERS); 143 144 virtual void DrawStatusBar(BView* view, BRect& rect, 145 const BRect& updateRect, 146 const rgb_color& base, 147 const rgb_color& barColor, 148 float progressPosition); 149 150 virtual void DrawCheckBox(BView* view, BRect& rect, 151 const BRect& updateRect, 152 const rgb_color& base, 153 uint32 flags = 0); 154 155 virtual void DrawRadioButton(BView* view, BRect& rect, 156 const BRect& updateRect, 157 const rgb_color& base, 158 uint32 flags = 0); 159 160 virtual void DrawScrollBarBackground(BView* view, 161 BRect& rect1, BRect& rect2, 162 const BRect& updateRect, 163 const rgb_color& base, uint32 flags, 164 orientation orientation); 165 virtual void DrawScrollBarBackground(BView* view, 166 BRect& rect, const BRect& updateRect, 167 const rgb_color& base, uint32 flags, 168 orientation orientation); 169 170 virtual void DrawScrollViewFrame(BView* view, 171 BRect& rect, const BRect& updateRect, 172 BRect verticalScrollBarFrame, 173 BRect horizontalScrollBarFrame, 174 const rgb_color& base, 175 border_style borderStyle, 176 uint32 flags = 0, 177 uint32 borders = B_ALL_BORDERS); 178 179 virtual void DrawArrowShape(BView* view, 180 BRect& rect, const BRect& updateRect, 181 const rgb_color& base, uint32 direction, 182 uint32 flags = 0, 183 float tint = B_DARKEN_MAX_TINT); 184 185 virtual rgb_color SliderBarColor(const rgb_color& base); 186 187 virtual void DrawSliderBar(BView* view, BRect rect, 188 const BRect& updateRect, 189 const rgb_color& base, 190 rgb_color leftFillColor, 191 rgb_color rightFillColor, 192 float sliderScale, uint32 flags, 193 orientation orientation); 194 virtual void DrawSliderBar(BView* view, BRect rect, 195 const BRect& updateRect, 196 const rgb_color& base, rgb_color fillColor, 197 uint32 flags, orientation orientation); 198 199 virtual void DrawSliderThumb(BView* view, BRect& rect, 200 const BRect& updateRect, 201 const rgb_color& base, uint32 flags, 202 orientation orientation); 203 204 virtual void DrawSliderTriangle(BView* view, BRect& rect, 205 const BRect& updateRect, 206 const rgb_color& base, uint32 flags, 207 orientation orientation); 208 virtual void DrawSliderTriangle(BView* view, BRect& rect, 209 const BRect& updateRect, 210 const rgb_color& base, 211 const rgb_color& fill, uint32 flags, 212 orientation orientation); 213 214 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 215 const BRect& updateRect, 216 const rgb_color& base, int32 count, 217 hash_mark_location location, 218 uint32 flags, orientation orientation); 219 220 virtual void DrawTabFrame(BView* view, BRect& rect, 221 const BRect& updateRect, 222 const rgb_color& base, uint32 flags = 0, 223 uint32 borders = B_ALL_BORDERS, 224 border_style borderStyle = B_FANCY_BORDER, 225 uint32 side = B_TOP_BORDER); 226 virtual void DrawActiveTab(BView* view, BRect& rect, 227 const BRect& updateRect, 228 const rgb_color& base, uint32 flags = 0, 229 uint32 borders = B_ALL_BORDERS, 230 uint32 side = B_TOP_BORDER); 231 virtual void DrawInactiveTab(BView* view, BRect& rect, 232 const BRect& updateRect, 233 const rgb_color& base, uint32 flags = 0, 234 uint32 borders = B_ALL_BORDERS, 235 uint32 side = B_TOP_BORDER); 236 237 virtual void DrawSplitter(BView* view, BRect& rect, 238 const BRect& updateRect, 239 const rgb_color& base, 240 orientation orientation, 241 uint32 flags = 0, 242 uint32 borders = B_ALL_BORDERS); 243 244 // various borders 245 246 virtual void DrawBorder(BView* view, BRect& rect, 247 const BRect& updateRect, 248 const rgb_color& base, 249 border_style borderStyle, uint32 flags = 0, 250 uint32 borders = B_ALL_BORDERS); 251 252 virtual void DrawRaisedBorder(BView* view, BRect& rect, 253 const BRect& updateRect, 254 const rgb_color& base, uint32 flags = 0, 255 uint32 borders = B_ALL_BORDERS); 256 257 virtual void DrawGroupFrame(BView* view, BRect& rect, 258 const BRect& updateRect, 259 const rgb_color& base, 260 uint32 borders = B_ALL_BORDERS); 261 262 virtual void DrawTextControlBorder(BView* view, BRect& rect, 263 const BRect& updateRect, 264 const rgb_color& base, uint32 flags = 0, 265 uint32 borders = B_ALL_BORDERS); 266 267 // aligned labels 268 269 virtual void DrawLabel(BView* view, const char* label, 270 BRect rect, const BRect& updateRect, 271 const rgb_color& base, uint32 flags, 272 const rgb_color* textColor = NULL); 273 virtual void DrawLabel(BView* view, const char* label, 274 BRect rect, const BRect& updateRect, 275 const rgb_color& base, uint32 flags, 276 const BAlignment& alignment, 277 const rgb_color* textColor = NULL); 278 // TODO: Would be nice to have a (non-virtual) version of this method 279 // which takes an array of labels and locations. That would save some 280 // setup with the view graphics state. 281 virtual void DrawLabel(BView* view, const char* label, 282 const rgb_color& base, uint32 flags, 283 const BPoint& where, 284 const rgb_color* textColor = NULL); 285 286 virtual void DrawLabel(BView* view, const char* label, 287 const BBitmap* icon, BRect rect, 288 const BRect& updateRect, 289 const rgb_color& base, uint32 flags, 290 const BAlignment& alignment, 291 const rgb_color* textColor = NULL); 292 293 virtual void GetFrameInsets(frame_type frameType, 294 uint32 flags, float& _left, float& _top, 295 float& _right, float& _bottom); 296 virtual void GetBackgroundInsets( 297 background_type backgroundType, 298 uint32 flags, float& _left, float& _top, 299 float& _right, float& _bottom); 300 301 virtual void DrawButtonWithPopUpBackground(BView* view, 302 BRect& rect, const BRect& updateRect, 303 const rgb_color& base, 304 uint32 flags = 0, 305 uint32 borders = B_ALL_BORDERS, 306 orientation orientation = B_HORIZONTAL); 307 virtual void DrawButtonWithPopUpBackground(BView* view, 308 BRect& rect, const BRect& updateRect, 309 float radius, 310 const rgb_color& base, 311 uint32 flags = 0, 312 uint32 borders = B_ALL_BORDERS, 313 orientation orientation = B_HORIZONTAL); 314 virtual void DrawButtonWithPopUpBackground(BView* view, 315 BRect& rect, const BRect& updateRect, 316 float leftTopRadius, 317 float rightTopRadius, 318 float leftBottomRadius, 319 float rightBottomRadius, 320 const rgb_color& base, 321 uint32 flags = 0, 322 uint32 borders = B_ALL_BORDERS, 323 orientation orientation = B_HORIZONTAL); 324 325 protected: 326 void _DrawButtonFrame(BView* view, BRect& rect, 327 const BRect& updateRect, 328 float leftTopRadius, 329 float rightTopRadius, 330 float leftBottomRadius, 331 float rightBottomRadius, 332 const rgb_color& base, 333 const rgb_color& background, 334 float contrast, float brightness = 1.0, 335 uint32 flags = 0, 336 uint32 borders = B_ALL_BORDERS); 337 338 void _DrawOuterResessedFrame(BView* view, 339 BRect& rect, const rgb_color& base, 340 float contrast = 1.0f, 341 float brightness = 1.0f, 342 uint32 flags = 0, 343 uint32 borders = B_ALL_BORDERS); 344 345 void _DrawFrame(BView* view, BRect& rect, 346 const rgb_color& left, 347 const rgb_color& top, 348 const rgb_color& right, 349 const rgb_color& bottom, 350 uint32 borders = B_ALL_BORDERS); 351 void _DrawFrame(BView* view, BRect& rect, 352 const rgb_color& left, 353 const rgb_color& top, 354 const rgb_color& right, 355 const rgb_color& bottom, 356 const rgb_color& rightTop, 357 const rgb_color& leftBottom, 358 uint32 borders = B_ALL_BORDERS); 359 360 void _DrawButtonBackground(BView* view, BRect& rect, 361 const BRect& updateRect, 362 float leftTopRadius, 363 float rightTopRadius, 364 float leftBottomRadius, 365 float rightBottomRadius, 366 const rgb_color& base, 367 bool popupIndicator = false, 368 uint32 flags = 0, 369 uint32 borders = B_ALL_BORDERS, 370 orientation orientation = B_HORIZONTAL); 371 void _DrawFlatButtonBackground(BView* view, 372 BRect& rect, const BRect& updateRect, 373 const rgb_color& base, 374 bool popupIndicator = false, 375 uint32 flags = 0, 376 uint32 borders = B_ALL_BORDERS, 377 orientation orientation = B_HORIZONTAL); 378 void _DrawNonFlatButtonBackground(BView* view, 379 BRect& rect, const BRect& updateRect, 380 BRegion& clipping, 381 float leftTopRadius, 382 float rightTopRadius, 383 float leftBottomRadius, 384 float rightBottomRadius, 385 const rgb_color& base, 386 bool popupIndicator = false, 387 uint32 flags = 0, 388 uint32 borders = B_ALL_BORDERS, 389 orientation orientation = B_HORIZONTAL); 390 391 void _DrawPopUpMarker(BView* view, const BRect& rect, 392 const rgb_color& base, uint32 flags); 393 394 void _DrawMenuFieldBackgroundOutside(BView* view, 395 BRect& rect, const BRect& updateRect, 396 float leftTopRadius, 397 float rightTopRadius, 398 float leftBottomRadius, 399 float rightBottomRadius, 400 const rgb_color& base, 401 bool popupIndicator = false, 402 uint32 flags = 0); 403 404 void _DrawMenuFieldBackgroundInside(BView* view, 405 BRect& rect, const BRect& updateRect, 406 float leftTopRadius, 407 float rightTopRadius, 408 float leftBottomRadius, 409 float rightBottomRadius, 410 const rgb_color& base, uint32 flags = 0, 411 uint32 borders = B_ALL_BORDERS); 412 413 // Rounded corner methods 414 void _DrawRoundCornerLeftTop(BView* view, 415 BRect& cornerRect, const BRect& updateRect, 416 const rgb_color& background, 417 const rgb_color& edgeColor, 418 const rgb_color& frameColor, 419 const rgb_color& bevelColor, 420 const BGradientLinear& fillGradient); 421 422 void _DrawRoundCornerFrameLeftTop(BView* view, 423 BRect& cornerRect, const BRect& updateRect, 424 const rgb_color& background, 425 const rgb_color& edgeColor, 426 const rgb_color& frameColor); 427 428 void _DrawRoundCornerBackgroundLeftTop(BView* view, 429 BRect& cornerRect, const BRect& updateRect, 430 const rgb_color& bevelColor, 431 const BGradientLinear& fillGradient); 432 433 void _DrawRoundCornerRightTop(BView* view, 434 BRect& cornerRect, const BRect& updateRect, 435 const rgb_color& background, 436 const rgb_color& edgeTopColor, 437 const rgb_color& edgeRightColor, 438 const rgb_color& frameTopColor, 439 const rgb_color& frameRightColor, 440 const rgb_color& bevelTopColor, 441 const rgb_color& bevelRightColor, 442 const BGradientLinear& fillGradient); 443 444 void _DrawRoundCornerFrameRightTop(BView* view, 445 BRect& cornerRect, const BRect& updateRect, 446 const rgb_color& background, 447 const rgb_color& edgeTopColor, 448 const rgb_color& edgeRightColor, 449 const rgb_color& frameTopColor, 450 const rgb_color& frameRightColor); 451 452 void _DrawRoundCornerBackgroundRightTop(BView* view, 453 BRect& cornerRect, const BRect& updateRect, 454 const rgb_color& bevelTopColor, 455 const rgb_color& bevelRightColor, 456 const BGradientLinear& fillGradient); 457 458 void _DrawRoundCornerLeftBottom(BView* view, 459 BRect& cornerRect, const BRect& updateRect, 460 const rgb_color& background, 461 const rgb_color& edgeLeftColor, 462 const rgb_color& edgeBottomColor, 463 const rgb_color& frameLeftColor, 464 const rgb_color& frameBottomColor, 465 const rgb_color& bevelLeftColor, 466 const rgb_color& bevelBottomColor, 467 const BGradientLinear& fillGradient); 468 469 void _DrawRoundCornerFrameLeftBottom(BView* view, 470 BRect& cornerRect, const BRect& updateRect, 471 const rgb_color& background, 472 const rgb_color& edgeLeftColor, 473 const rgb_color& edgeBottomColor, 474 const rgb_color& frameLeftColor, 475 const rgb_color& frameBottomColor); 476 477 void _DrawRoundCornerBackgroundLeftBottom(BView* view, 478 BRect& cornerRect, const BRect& updateRect, 479 const rgb_color& bevelLeftColor, 480 const rgb_color& bevelBottomColor, 481 const BGradientLinear& fillGradient); 482 483 void _DrawRoundCornerRightBottom(BView* view, 484 BRect& cornerRect, const BRect& updateRect, 485 const rgb_color& background, 486 const rgb_color& edgeColor, 487 const rgb_color& frameColor, 488 const rgb_color& bevelColor, 489 const BGradientLinear& fillGradient); 490 491 void _DrawRoundCornerFrameRightBottom(BView* view, 492 BRect& cornerRect, const BRect& updateRect, 493 const rgb_color& background, 494 const rgb_color& edgeColor, 495 const rgb_color& frameColor); 496 497 void _DrawRoundCornerBackgroundRightBottom( 498 BView* view, 499 BRect& cornerRect, const BRect& updateRect, 500 const rgb_color& bevelColor, 501 const BGradientLinear& fillGradient); 502 503 void _DrawRoundBarCorner(BView* view, BRect& rect, 504 const BRect& updateRect, 505 const rgb_color& edgeLightColor, 506 const rgb_color& edgeShadowColor, 507 const rgb_color& frameLightColor, 508 const rgb_color& frameShadowColor, 509 const rgb_color& fillLightColor, 510 const rgb_color& fillShadowColor, 511 float leftInset, float topInset, 512 float rightInset, float bottomInset, 513 orientation orientation); 514 515 // Border color methods 516 rgb_color _EdgeLightColor(const rgb_color& base, 517 float contrast, float brightness, 518 uint32 flags); 519 520 rgb_color _EdgeShadowColor(const rgb_color& base, 521 float contrast, float brightness, 522 uint32 flags); 523 524 rgb_color _FrameLightColor(const rgb_color& base, 525 uint32 flags); 526 527 rgb_color _FrameShadowColor(const rgb_color& base, 528 uint32 flags); 529 530 rgb_color _BevelLightColor(const rgb_color& base, 531 uint32 flags); 532 533 rgb_color _BevelShadowColor(const rgb_color& base, 534 uint32 flags); 535 536 // Background gradient methods 537 void _FillGradient(BView* view, const BRect& rect, 538 const rgb_color& base, float topTint, 539 float bottomTint, 540 orientation orientation = B_HORIZONTAL); 541 542 void _FillGlossyGradient(BView* view, 543 const BRect& rect, const rgb_color& base, 544 float topTint, float middle1Tint, 545 float middle2Tint, float bottomTint, 546 orientation orientation = B_HORIZONTAL); 547 548 void _MakeGradient(BGradientLinear& gradient, 549 const BRect& rect, const rgb_color& base, 550 float topTint, float bottomTint, 551 orientation orientation = B_HORIZONTAL) const; 552 553 void _MakeGlossyGradient(BGradientLinear& gradient, 554 const BRect& rect, const rgb_color& base, 555 float topTint, float middle1Tint, 556 float middle2Tint, float bottomTint, 557 orientation orientation = B_HORIZONTAL) const; 558 559 void _MakeButtonGradient(BGradientLinear& gradient, 560 BRect& rect, const rgb_color& base, 561 uint32 flags, orientation orientation = B_HORIZONTAL) const; 562 563 bool _RadioButtonAndCheckBoxMarkColor( 564 const rgb_color& base, rgb_color& color, 565 uint32 flags) const; 566 567 private: 568 bool fCachedOutline; 569 }; 570 571 572 } // namespace BPrivate 573 574 #endif // _HAIKU_CONTROL_LOOK_H 575