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 343 protected: 344 void _DrawButtonFrame(BView* view, BRect& rect, 345 const BRect& updateRect, 346 float leftTopRadius, 347 float rightTopRadius, 348 float leftBottomRadius, 349 float rightBottomRadius, 350 const rgb_color& base, 351 const rgb_color& background, 352 float contrast, float brightness = 1.0, 353 uint32 flags = 0, 354 uint32 borders = B_ALL_BORDERS); 355 356 void _DrawOuterResessedFrame(BView* view, 357 BRect& rect, const rgb_color& base, 358 float contrast = 1.0f, 359 float brightness = 1.0f, 360 uint32 flags = 0, 361 uint32 borders = B_ALL_BORDERS); 362 363 void _DrawFrame(BView* view, BRect& rect, 364 const rgb_color& left, 365 const rgb_color& top, 366 const rgb_color& right, 367 const rgb_color& bottom, 368 uint32 borders = B_ALL_BORDERS); 369 void _DrawFrame(BView* view, BRect& rect, 370 const rgb_color& left, 371 const rgb_color& top, 372 const rgb_color& right, 373 const rgb_color& bottom, 374 const rgb_color& rightTop, 375 const rgb_color& leftBottom, 376 uint32 borders = B_ALL_BORDERS); 377 378 void _DrawButtonBackground(BView* view, BRect& rect, 379 const BRect& updateRect, 380 float leftTopRadius, 381 float rightTopRadius, 382 float leftBottomRadius, 383 float rightBottomRadius, 384 const rgb_color& base, 385 bool popupIndicator = false, 386 uint32 flags = 0, 387 uint32 borders = B_ALL_BORDERS, 388 orientation orientation = B_HORIZONTAL); 389 void _DrawFlatButtonBackground(BView* view, 390 BRect& rect, const BRect& updateRect, 391 const rgb_color& base, 392 bool popupIndicator = false, 393 uint32 flags = 0, 394 uint32 borders = B_ALL_BORDERS, 395 orientation orientation = B_HORIZONTAL); 396 void _DrawNonFlatButtonBackground(BView* view, 397 BRect& rect, const BRect& updateRect, 398 BRegion& clipping, 399 float leftTopRadius, 400 float rightTopRadius, 401 float leftBottomRadius, 402 float rightBottomRadius, 403 const rgb_color& base, 404 bool popupIndicator = false, 405 uint32 flags = 0, 406 uint32 borders = B_ALL_BORDERS, 407 orientation orientation = B_HORIZONTAL); 408 409 void _DrawPopUpMarker(BView* view, const BRect& rect, 410 const rgb_color& base, uint32 flags); 411 412 void _DrawMenuFieldBackgroundOutside(BView* view, 413 BRect& rect, const BRect& updateRect, 414 float leftTopRadius, 415 float rightTopRadius, 416 float leftBottomRadius, 417 float rightBottomRadius, 418 const rgb_color& base, 419 bool popupIndicator = false, 420 uint32 flags = 0); 421 422 void _DrawMenuFieldBackgroundInside(BView* view, 423 BRect& rect, const BRect& updateRect, 424 float leftTopRadius, 425 float rightTopRadius, 426 float leftBottomRadius, 427 float rightBottomRadius, 428 const rgb_color& base, uint32 flags = 0, 429 uint32 borders = B_ALL_BORDERS); 430 431 // Rounded corner methods 432 void _DrawRoundCornerLeftTop(BView* view, 433 BRect& cornerRect, const BRect& updateRect, 434 const rgb_color& background, 435 const rgb_color& edgeColor, 436 const rgb_color& frameColor, 437 const rgb_color& bevelColor, 438 const BGradientLinear& fillGradient); 439 440 void _DrawRoundCornerFrameLeftTop(BView* view, 441 BRect& cornerRect, const BRect& updateRect, 442 const rgb_color& background, 443 const rgb_color& edgeColor, 444 const rgb_color& frameColor); 445 446 void _DrawRoundCornerBackgroundLeftTop(BView* view, 447 BRect& cornerRect, const BRect& updateRect, 448 const rgb_color& bevelColor, 449 const BGradientLinear& fillGradient); 450 451 void _DrawRoundCornerRightTop(BView* view, 452 BRect& cornerRect, const BRect& updateRect, 453 const rgb_color& background, 454 const rgb_color& edgeTopColor, 455 const rgb_color& edgeRightColor, 456 const rgb_color& frameTopColor, 457 const rgb_color& frameRightColor, 458 const rgb_color& bevelTopColor, 459 const rgb_color& bevelRightColor, 460 const BGradientLinear& fillGradient); 461 462 void _DrawRoundCornerFrameRightTop(BView* view, 463 BRect& cornerRect, const BRect& updateRect, 464 const rgb_color& background, 465 const rgb_color& edgeTopColor, 466 const rgb_color& edgeRightColor, 467 const rgb_color& frameTopColor, 468 const rgb_color& frameRightColor); 469 470 void _DrawRoundCornerBackgroundRightTop(BView* view, 471 BRect& cornerRect, const BRect& updateRect, 472 const rgb_color& bevelTopColor, 473 const rgb_color& bevelRightColor, 474 const BGradientLinear& fillGradient); 475 476 void _DrawRoundCornerLeftBottom(BView* view, 477 BRect& cornerRect, const BRect& updateRect, 478 const rgb_color& background, 479 const rgb_color& edgeLeftColor, 480 const rgb_color& edgeBottomColor, 481 const rgb_color& frameLeftColor, 482 const rgb_color& frameBottomColor, 483 const rgb_color& bevelLeftColor, 484 const rgb_color& bevelBottomColor, 485 const BGradientLinear& fillGradient); 486 487 void _DrawRoundCornerFrameLeftBottom(BView* view, 488 BRect& cornerRect, const BRect& updateRect, 489 const rgb_color& background, 490 const rgb_color& edgeLeftColor, 491 const rgb_color& edgeBottomColor, 492 const rgb_color& frameLeftColor, 493 const rgb_color& frameBottomColor); 494 495 void _DrawRoundCornerBackgroundLeftBottom(BView* view, 496 BRect& cornerRect, const BRect& updateRect, 497 const rgb_color& bevelLeftColor, 498 const rgb_color& bevelBottomColor, 499 const BGradientLinear& fillGradient); 500 501 void _DrawRoundCornerRightBottom(BView* view, 502 BRect& cornerRect, const BRect& updateRect, 503 const rgb_color& background, 504 const rgb_color& edgeColor, 505 const rgb_color& frameColor, 506 const rgb_color& bevelColor, 507 const BGradientLinear& fillGradient); 508 509 void _DrawRoundCornerFrameRightBottom(BView* view, 510 BRect& cornerRect, const BRect& updateRect, 511 const rgb_color& background, 512 const rgb_color& edgeColor, 513 const rgb_color& frameColor); 514 515 void _DrawRoundCornerBackgroundRightBottom( 516 BView* view, 517 BRect& cornerRect, const BRect& updateRect, 518 const rgb_color& bevelColor, 519 const BGradientLinear& fillGradient); 520 521 void _DrawRoundBarCorner(BView* view, BRect& rect, 522 const BRect& updateRect, 523 const rgb_color& edgeLightColor, 524 const rgb_color& edgeShadowColor, 525 const rgb_color& frameLightColor, 526 const rgb_color& frameShadowColor, 527 const rgb_color& fillLightColor, 528 const rgb_color& fillShadowColor, 529 float leftInset, float topInset, 530 float rightInset, float bottomInset, 531 orientation orientation); 532 533 // Border color methods 534 rgb_color _EdgeLightColor(const rgb_color& base, 535 float contrast, float brightness, 536 uint32 flags); 537 538 rgb_color _EdgeShadowColor(const rgb_color& base, 539 float contrast, float brightness, 540 uint32 flags); 541 542 rgb_color _FrameLightColor(const rgb_color& base, 543 uint32 flags); 544 545 rgb_color _FrameShadowColor(const rgb_color& base, 546 uint32 flags); 547 548 rgb_color _BevelLightColor(const rgb_color& base, 549 uint32 flags); 550 551 rgb_color _BevelShadowColor(const rgb_color& base, 552 uint32 flags); 553 554 // Background gradient methods 555 void _FillGradient(BView* view, const BRect& rect, 556 const rgb_color& base, float topTint, 557 float bottomTint, 558 orientation orientation = B_HORIZONTAL); 559 560 void _FillGlossyGradient(BView* view, 561 const BRect& rect, const rgb_color& base, 562 float topTint, float middle1Tint, 563 float middle2Tint, float bottomTint, 564 orientation orientation = B_HORIZONTAL); 565 566 void _MakeGradient(BGradientLinear& gradient, 567 const BRect& rect, const rgb_color& base, 568 float topTint, float bottomTint, 569 orientation orientation = B_HORIZONTAL) const; 570 571 void _MakeGlossyGradient(BGradientLinear& gradient, 572 const BRect& rect, const rgb_color& base, 573 float topTint, float middle1Tint, 574 float middle2Tint, float bottomTint, 575 orientation orientation = B_HORIZONTAL) const; 576 577 void _MakeButtonGradient(BGradientLinear& gradient, 578 BRect& rect, const rgb_color& base, 579 uint32 flags, orientation orientation = B_HORIZONTAL) const; 580 581 bool _RadioButtonAndCheckBoxMarkColor( 582 const rgb_color& base, rgb_color& color, 583 uint32 flags) const; 584 585 private: 586 bool fCachedOutline; 587 }; 588 589 590 } // namespace BPrivate 591 592 #endif // _HAIKU_CONTROL_LOOK_H 593