1 /* 2 * Copyright 2009-2020 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 DrawScrollBarBorder(BView* view, 161 BRect rect, const BRect& updateRect, 162 const rgb_color& base, uint32 flags, 163 orientation orientation); 164 virtual void DrawScrollBarButton(BView* view, 165 BRect rect, const BRect& updateRect, 166 const rgb_color& base, uint32 flags, 167 int32 direction, orientation orientation, 168 bool down = false); 169 virtual void DrawScrollBarBackground(BView* view, 170 BRect& rect1, BRect& rect2, 171 const BRect& updateRect, 172 const rgb_color& base, uint32 flags, 173 orientation orientation); 174 virtual void DrawScrollBarBackground(BView* view, 175 BRect& rect, const BRect& updateRect, 176 const rgb_color& base, uint32 flags, 177 orientation orientation); 178 virtual void DrawScrollBarThumb(BView* view, 179 BRect& rect, const BRect& updateRect, 180 const rgb_color& base, uint32 flags, 181 orientation orientation, 182 uint32 knobStyle = B_KNOB_NONE); 183 184 virtual void DrawScrollViewFrame(BView* view, 185 BRect& rect, const BRect& updateRect, 186 BRect verticalScrollBarFrame, 187 BRect horizontalScrollBarFrame, 188 const rgb_color& base, 189 border_style borderStyle, 190 uint32 flags = 0, 191 uint32 borders = B_ALL_BORDERS); 192 193 virtual void DrawArrowShape(BView* view, 194 BRect& rect, const BRect& updateRect, 195 const rgb_color& base, uint32 direction, 196 uint32 flags = 0, 197 float tint = B_DARKEN_MAX_TINT); 198 199 virtual rgb_color SliderBarColor(const rgb_color& base); 200 201 virtual void DrawSliderBar(BView* view, BRect rect, 202 const BRect& updateRect, 203 const rgb_color& base, 204 rgb_color leftFillColor, 205 rgb_color rightFillColor, 206 float sliderScale, uint32 flags, 207 orientation orientation); 208 virtual void DrawSliderBar(BView* view, BRect rect, 209 const BRect& updateRect, 210 const rgb_color& base, rgb_color fillColor, 211 uint32 flags, orientation orientation); 212 213 virtual void DrawSliderThumb(BView* view, BRect& rect, 214 const BRect& updateRect, 215 const rgb_color& base, uint32 flags, 216 orientation orientation); 217 218 virtual void DrawSliderTriangle(BView* view, BRect& rect, 219 const BRect& updateRect, 220 const rgb_color& base, uint32 flags, 221 orientation orientation); 222 virtual void DrawSliderTriangle(BView* view, BRect& rect, 223 const BRect& updateRect, 224 const rgb_color& base, 225 const rgb_color& fill, uint32 flags, 226 orientation orientation); 227 228 virtual void DrawSliderHashMarks(BView* view, BRect& rect, 229 const BRect& updateRect, 230 const rgb_color& base, int32 count, 231 hash_mark_location location, 232 uint32 flags, orientation orientation); 233 234 virtual void DrawTabFrame(BView* view, BRect& rect, 235 const BRect& updateRect, 236 const rgb_color& base, uint32 flags = 0, 237 uint32 borders = B_ALL_BORDERS, 238 border_style borderStyle = B_FANCY_BORDER, 239 uint32 side = B_TOP_BORDER); 240 virtual void DrawActiveTab(BView* view, BRect& rect, 241 const BRect& updateRect, 242 const rgb_color& base, uint32 flags = 0, 243 uint32 borders = B_ALL_BORDERS, 244 uint32 side = B_TOP_BORDER, 245 int32 index = 0, int32 selected = -1, 246 int32 first = 0, int32 last = 0); 247 virtual void DrawInactiveTab(BView* view, BRect& rect, 248 const BRect& updateRect, 249 const rgb_color& base, uint32 flags = 0, 250 uint32 borders = B_ALL_BORDERS, 251 uint32 side = B_TOP_BORDER, 252 int32 index = 0, int32 selected = -1, 253 int32 first = 0, int32 last = 0); 254 255 virtual void DrawSplitter(BView* view, BRect& rect, 256 const BRect& updateRect, 257 const rgb_color& base, 258 orientation orientation, 259 uint32 flags = 0, 260 uint32 borders = B_ALL_BORDERS); 261 262 // various borders 263 264 virtual void DrawBorder(BView* view, BRect& rect, 265 const BRect& updateRect, 266 const rgb_color& base, 267 border_style borderStyle, uint32 flags = 0, 268 uint32 borders = B_ALL_BORDERS); 269 270 virtual void DrawRaisedBorder(BView* view, BRect& rect, 271 const BRect& updateRect, 272 const rgb_color& base, uint32 flags = 0, 273 uint32 borders = B_ALL_BORDERS); 274 275 virtual void DrawGroupFrame(BView* view, BRect& rect, 276 const BRect& updateRect, 277 const rgb_color& base, 278 uint32 borders = B_ALL_BORDERS); 279 280 virtual void DrawTextControlBorder(BView* view, BRect& rect, 281 const BRect& updateRect, 282 const rgb_color& base, uint32 flags = 0, 283 uint32 borders = B_ALL_BORDERS); 284 285 // aligned labels 286 287 virtual void DrawLabel(BView* view, const char* label, 288 BRect rect, const BRect& updateRect, 289 const rgb_color& base, uint32 flags, 290 const rgb_color* textColor = NULL); 291 virtual void DrawLabel(BView* view, const char* label, 292 BRect rect, const BRect& updateRect, 293 const rgb_color& base, uint32 flags, 294 const BAlignment& alignment, 295 const rgb_color* textColor = NULL); 296 // TODO: Would be nice to have a (non-virtual) version of this method 297 // which takes an array of labels and locations. That would save some 298 // setup with the view graphics state. 299 virtual void DrawLabel(BView* view, const char* label, 300 const rgb_color& base, uint32 flags, 301 const BPoint& where, 302 const rgb_color* textColor = NULL); 303 304 virtual void DrawLabel(BView* view, const char* label, 305 const BBitmap* icon, BRect rect, 306 const BRect& updateRect, 307 const rgb_color& base, uint32 flags, 308 const BAlignment& alignment, 309 const rgb_color* textColor = NULL); 310 311 virtual void GetFrameInsets(frame_type frameType, 312 uint32 flags, float& _left, float& _top, 313 float& _right, float& _bottom); 314 virtual void GetBackgroundInsets( 315 background_type backgroundType, 316 uint32 flags, float& _left, float& _top, 317 float& _right, float& _bottom); 318 319 virtual void DrawButtonWithPopUpBackground(BView* view, 320 BRect& rect, const BRect& updateRect, 321 const rgb_color& base, 322 uint32 flags = 0, 323 uint32 borders = B_ALL_BORDERS, 324 orientation orientation = B_HORIZONTAL); 325 virtual void DrawButtonWithPopUpBackground(BView* view, 326 BRect& rect, const BRect& updateRect, 327 float radius, 328 const rgb_color& base, 329 uint32 flags = 0, 330 uint32 borders = B_ALL_BORDERS, 331 orientation orientation = B_HORIZONTAL); 332 virtual void DrawButtonWithPopUpBackground(BView* view, 333 BRect& rect, const BRect& updateRect, 334 float leftTopRadius, 335 float rightTopRadius, 336 float leftBottomRadius, 337 float rightBottomRadius, 338 const rgb_color& base, 339 uint32 flags = 0, 340 uint32 borders = B_ALL_BORDERS, 341 orientation orientation = B_HORIZONTAL); 342 virtual float GetScrollBarWidth( 343 orientation orientation = B_VERTICAL); 344 345 protected: 346 void _DrawButtonFrame(BView* view, BRect& rect, 347 const BRect& updateRect, 348 float leftTopRadius, 349 float rightTopRadius, 350 float leftBottomRadius, 351 float rightBottomRadius, 352 const rgb_color& base, 353 const rgb_color& background, 354 float contrast, float brightness = 1.0, 355 uint32 flags = 0, 356 uint32 borders = B_ALL_BORDERS); 357 358 void _DrawOuterResessedFrame(BView* view, 359 BRect& rect, const rgb_color& base, 360 float contrast = 1.0f, 361 float brightness = 1.0f, 362 uint32 flags = 0, 363 uint32 borders = B_ALL_BORDERS); 364 365 void _DrawFrame(BView* view, BRect& rect, 366 const rgb_color& left, 367 const rgb_color& top, 368 const rgb_color& right, 369 const rgb_color& bottom, 370 uint32 borders = B_ALL_BORDERS); 371 void _DrawFrame(BView* view, BRect& rect, 372 const rgb_color& left, 373 const rgb_color& top, 374 const rgb_color& right, 375 const rgb_color& bottom, 376 const rgb_color& rightTop, 377 const rgb_color& leftBottom, 378 uint32 borders = B_ALL_BORDERS); 379 380 void _DrawButtonBackground(BView* view, BRect& rect, 381 const BRect& updateRect, 382 float leftTopRadius, 383 float rightTopRadius, 384 float leftBottomRadius, 385 float rightBottomRadius, 386 const rgb_color& base, 387 bool popupIndicator = false, 388 uint32 flags = 0, 389 uint32 borders = B_ALL_BORDERS, 390 orientation orientation = B_HORIZONTAL); 391 void _DrawFlatButtonBackground(BView* view, 392 BRect& rect, const BRect& updateRect, 393 const rgb_color& base, 394 bool popupIndicator = false, 395 uint32 flags = 0, 396 uint32 borders = B_ALL_BORDERS, 397 orientation orientation = B_HORIZONTAL); 398 void _DrawNonFlatButtonBackground(BView* view, 399 BRect& rect, const BRect& updateRect, 400 BRegion& clipping, 401 float leftTopRadius, 402 float rightTopRadius, 403 float leftBottomRadius, 404 float rightBottomRadius, 405 const rgb_color& base, 406 bool popupIndicator = false, 407 uint32 flags = 0, 408 uint32 borders = B_ALL_BORDERS, 409 orientation orientation = B_HORIZONTAL); 410 411 void _DrawPopUpMarker(BView* view, const BRect& rect, 412 const rgb_color& base, uint32 flags); 413 414 void _DrawMenuFieldBackgroundOutside(BView* view, 415 BRect& rect, const BRect& updateRect, 416 float leftTopRadius, 417 float rightTopRadius, 418 float leftBottomRadius, 419 float rightBottomRadius, 420 const rgb_color& base, 421 bool popupIndicator = false, 422 uint32 flags = 0); 423 424 void _DrawMenuFieldBackgroundInside(BView* view, 425 BRect& rect, const BRect& updateRect, 426 float leftTopRadius, 427 float rightTopRadius, 428 float leftBottomRadius, 429 float rightBottomRadius, 430 const rgb_color& base, uint32 flags = 0, 431 uint32 borders = B_ALL_BORDERS); 432 433 // Rounded corner methods 434 void _DrawRoundCornerLeftTop(BView* view, 435 BRect& cornerRect, const BRect& updateRect, 436 const rgb_color& background, 437 const rgb_color& edgeColor, 438 const rgb_color& frameColor, 439 const rgb_color& bevelColor, 440 const BGradientLinear& fillGradient); 441 442 void _DrawRoundCornerFrameLeftTop(BView* view, 443 BRect& cornerRect, const BRect& updateRect, 444 const rgb_color& background, 445 const rgb_color& edgeColor, 446 const rgb_color& frameColor); 447 448 void _DrawRoundCornerBackgroundLeftTop(BView* view, 449 BRect& cornerRect, const BRect& updateRect, 450 const rgb_color& bevelColor, 451 const BGradientLinear& fillGradient); 452 453 void _DrawRoundCornerRightTop(BView* view, 454 BRect& cornerRect, const BRect& updateRect, 455 const rgb_color& background, 456 const rgb_color& edgeTopColor, 457 const rgb_color& edgeRightColor, 458 const rgb_color& frameTopColor, 459 const rgb_color& frameRightColor, 460 const rgb_color& bevelTopColor, 461 const rgb_color& bevelRightColor, 462 const BGradientLinear& fillGradient); 463 464 void _DrawRoundCornerFrameRightTop(BView* view, 465 BRect& cornerRect, const BRect& updateRect, 466 const rgb_color& background, 467 const rgb_color& edgeTopColor, 468 const rgb_color& edgeRightColor, 469 const rgb_color& frameTopColor, 470 const rgb_color& frameRightColor); 471 472 void _DrawRoundCornerBackgroundRightTop(BView* view, 473 BRect& cornerRect, const BRect& updateRect, 474 const rgb_color& bevelTopColor, 475 const rgb_color& bevelRightColor, 476 const BGradientLinear& fillGradient); 477 478 void _DrawRoundCornerLeftBottom(BView* view, 479 BRect& cornerRect, const BRect& updateRect, 480 const rgb_color& background, 481 const rgb_color& edgeLeftColor, 482 const rgb_color& edgeBottomColor, 483 const rgb_color& frameLeftColor, 484 const rgb_color& frameBottomColor, 485 const rgb_color& bevelLeftColor, 486 const rgb_color& bevelBottomColor, 487 const BGradientLinear& fillGradient); 488 489 void _DrawRoundCornerFrameLeftBottom(BView* view, 490 BRect& cornerRect, const BRect& updateRect, 491 const rgb_color& background, 492 const rgb_color& edgeLeftColor, 493 const rgb_color& edgeBottomColor, 494 const rgb_color& frameLeftColor, 495 const rgb_color& frameBottomColor); 496 497 void _DrawRoundCornerBackgroundLeftBottom(BView* view, 498 BRect& cornerRect, const BRect& updateRect, 499 const rgb_color& bevelLeftColor, 500 const rgb_color& bevelBottomColor, 501 const BGradientLinear& fillGradient); 502 503 void _DrawRoundCornerRightBottom(BView* view, 504 BRect& cornerRect, const BRect& updateRect, 505 const rgb_color& background, 506 const rgb_color& edgeColor, 507 const rgb_color& frameColor, 508 const rgb_color& bevelColor, 509 const BGradientLinear& fillGradient); 510 511 void _DrawRoundCornerFrameRightBottom(BView* view, 512 BRect& cornerRect, const BRect& updateRect, 513 const rgb_color& background, 514 const rgb_color& edgeColor, 515 const rgb_color& frameColor); 516 517 void _DrawRoundCornerBackgroundRightBottom( 518 BView* view, 519 BRect& cornerRect, const BRect& updateRect, 520 const rgb_color& bevelColor, 521 const BGradientLinear& fillGradient); 522 523 void _DrawRoundBarCorner(BView* view, BRect& rect, 524 const BRect& updateRect, 525 const rgb_color& edgeLightColor, 526 const rgb_color& edgeShadowColor, 527 const rgb_color& frameLightColor, 528 const rgb_color& frameShadowColor, 529 const rgb_color& fillLightColor, 530 const rgb_color& fillShadowColor, 531 float leftInset, float topInset, 532 float rightInset, float bottomInset, 533 orientation orientation); 534 535 // Border color methods 536 rgb_color _EdgeLightColor(const rgb_color& base, 537 float contrast, float brightness, 538 uint32 flags); 539 540 rgb_color _EdgeShadowColor(const rgb_color& base, 541 float contrast, float brightness, 542 uint32 flags); 543 544 rgb_color _FrameLightColor(const rgb_color& base, 545 uint32 flags); 546 547 rgb_color _FrameShadowColor(const rgb_color& base, 548 uint32 flags); 549 550 rgb_color _BevelLightColor(const rgb_color& base, 551 uint32 flags); 552 553 rgb_color _BevelShadowColor(const rgb_color& base, 554 uint32 flags); 555 556 // Background gradient methods 557 void _FillGradient(BView* view, const BRect& rect, 558 const rgb_color& base, float topTint, 559 float bottomTint, 560 orientation orientation = B_HORIZONTAL); 561 562 void _FillGlossyGradient(BView* view, 563 const BRect& rect, const rgb_color& base, 564 float topTint, float middle1Tint, 565 float middle2Tint, float bottomTint, 566 orientation orientation = B_HORIZONTAL); 567 568 void _MakeGradient(BGradientLinear& gradient, 569 const BRect& rect, const rgb_color& base, 570 float topTint, float bottomTint, 571 orientation orientation = B_HORIZONTAL) const; 572 573 void _MakeGlossyGradient(BGradientLinear& gradient, 574 const BRect& rect, const rgb_color& base, 575 float topTint, float middle1Tint, 576 float middle2Tint, float bottomTint, 577 orientation orientation = B_HORIZONTAL) const; 578 579 void _MakeButtonGradient(BGradientLinear& gradient, 580 BRect& rect, const rgb_color& base, 581 uint32 flags, orientation orientation = B_HORIZONTAL) const; 582 583 bool _RadioButtonAndCheckBoxMarkColor( 584 const rgb_color& base, rgb_color& color, 585 uint32 flags) const; 586 587 private: 588 bool fCachedOutline; 589 }; 590 591 592 } // namespace BPrivate 593 594 #endif // _HAIKU_CONTROL_LOOK_H 595