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 virtual void DrawInactiveTab(BView* view, BRect& rect, 246 const BRect& updateRect, 247 const rgb_color& base, uint32 flags = 0, 248 uint32 borders = B_ALL_BORDERS, 249 uint32 side = B_TOP_BORDER); 250 251 virtual void DrawSplitter(BView* view, BRect& rect, 252 const BRect& updateRect, 253 const rgb_color& base, 254 orientation orientation, 255 uint32 flags = 0, 256 uint32 borders = B_ALL_BORDERS); 257 258 // various borders 259 260 virtual void DrawBorder(BView* view, BRect& rect, 261 const BRect& updateRect, 262 const rgb_color& base, 263 border_style borderStyle, uint32 flags = 0, 264 uint32 borders = B_ALL_BORDERS); 265 266 virtual void DrawRaisedBorder(BView* view, BRect& rect, 267 const BRect& updateRect, 268 const rgb_color& base, uint32 flags = 0, 269 uint32 borders = B_ALL_BORDERS); 270 271 virtual void DrawGroupFrame(BView* view, BRect& rect, 272 const BRect& updateRect, 273 const rgb_color& base, 274 uint32 borders = B_ALL_BORDERS); 275 276 virtual void DrawTextControlBorder(BView* view, BRect& rect, 277 const BRect& updateRect, 278 const rgb_color& base, uint32 flags = 0, 279 uint32 borders = B_ALL_BORDERS); 280 281 // aligned labels 282 283 virtual void DrawLabel(BView* view, const char* label, 284 BRect rect, const BRect& updateRect, 285 const rgb_color& base, uint32 flags, 286 const rgb_color* textColor = NULL); 287 virtual void DrawLabel(BView* view, const char* label, 288 BRect rect, const BRect& updateRect, 289 const rgb_color& base, uint32 flags, 290 const BAlignment& alignment, 291 const rgb_color* textColor = NULL); 292 // TODO: Would be nice to have a (non-virtual) version of this method 293 // which takes an array of labels and locations. That would save some 294 // setup with the view graphics state. 295 virtual void DrawLabel(BView* view, const char* label, 296 const rgb_color& base, uint32 flags, 297 const BPoint& where, 298 const rgb_color* textColor = NULL); 299 300 virtual void DrawLabel(BView* view, const char* label, 301 const BBitmap* icon, BRect rect, 302 const BRect& updateRect, 303 const rgb_color& base, uint32 flags, 304 const BAlignment& alignment, 305 const rgb_color* textColor = NULL); 306 307 virtual void GetFrameInsets(frame_type frameType, 308 uint32 flags, float& _left, float& _top, 309 float& _right, float& _bottom); 310 virtual void GetBackgroundInsets( 311 background_type backgroundType, 312 uint32 flags, float& _left, float& _top, 313 float& _right, float& _bottom); 314 315 virtual void DrawButtonWithPopUpBackground(BView* view, 316 BRect& rect, const BRect& updateRect, 317 const rgb_color& base, 318 uint32 flags = 0, 319 uint32 borders = B_ALL_BORDERS, 320 orientation orientation = B_HORIZONTAL); 321 virtual void DrawButtonWithPopUpBackground(BView* view, 322 BRect& rect, const BRect& updateRect, 323 float radius, 324 const rgb_color& base, 325 uint32 flags = 0, 326 uint32 borders = B_ALL_BORDERS, 327 orientation orientation = B_HORIZONTAL); 328 virtual void DrawButtonWithPopUpBackground(BView* view, 329 BRect& rect, const BRect& updateRect, 330 float leftTopRadius, 331 float rightTopRadius, 332 float leftBottomRadius, 333 float rightBottomRadius, 334 const rgb_color& base, 335 uint32 flags = 0, 336 uint32 borders = B_ALL_BORDERS, 337 orientation orientation = B_HORIZONTAL); 338 339 protected: 340 void _DrawButtonFrame(BView* view, BRect& rect, 341 const BRect& updateRect, 342 float leftTopRadius, 343 float rightTopRadius, 344 float leftBottomRadius, 345 float rightBottomRadius, 346 const rgb_color& base, 347 const rgb_color& background, 348 float contrast, float brightness = 1.0, 349 uint32 flags = 0, 350 uint32 borders = B_ALL_BORDERS); 351 352 void _DrawOuterResessedFrame(BView* view, 353 BRect& rect, const rgb_color& base, 354 float contrast = 1.0f, 355 float brightness = 1.0f, 356 uint32 flags = 0, 357 uint32 borders = B_ALL_BORDERS); 358 359 void _DrawFrame(BView* view, BRect& rect, 360 const rgb_color& left, 361 const rgb_color& top, 362 const rgb_color& right, 363 const rgb_color& bottom, 364 uint32 borders = B_ALL_BORDERS); 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 const rgb_color& rightTop, 371 const rgb_color& leftBottom, 372 uint32 borders = B_ALL_BORDERS); 373 374 void _DrawButtonBackground(BView* view, BRect& rect, 375 const BRect& updateRect, 376 float leftTopRadius, 377 float rightTopRadius, 378 float leftBottomRadius, 379 float rightBottomRadius, 380 const rgb_color& base, 381 bool popupIndicator = false, 382 uint32 flags = 0, 383 uint32 borders = B_ALL_BORDERS, 384 orientation orientation = B_HORIZONTAL); 385 void _DrawFlatButtonBackground(BView* view, 386 BRect& rect, const BRect& updateRect, 387 const rgb_color& base, 388 bool popupIndicator = false, 389 uint32 flags = 0, 390 uint32 borders = B_ALL_BORDERS, 391 orientation orientation = B_HORIZONTAL); 392 void _DrawNonFlatButtonBackground(BView* view, 393 BRect& rect, const BRect& updateRect, 394 BRegion& clipping, 395 float leftTopRadius, 396 float rightTopRadius, 397 float leftBottomRadius, 398 float rightBottomRadius, 399 const rgb_color& base, 400 bool popupIndicator = false, 401 uint32 flags = 0, 402 uint32 borders = B_ALL_BORDERS, 403 orientation orientation = B_HORIZONTAL); 404 405 void _DrawPopUpMarker(BView* view, const BRect& rect, 406 const rgb_color& base, uint32 flags); 407 408 void _DrawMenuFieldBackgroundOutside(BView* view, 409 BRect& rect, const BRect& updateRect, 410 float leftTopRadius, 411 float rightTopRadius, 412 float leftBottomRadius, 413 float rightBottomRadius, 414 const rgb_color& base, 415 bool popupIndicator = false, 416 uint32 flags = 0); 417 418 void _DrawMenuFieldBackgroundInside(BView* view, 419 BRect& rect, const BRect& updateRect, 420 float leftTopRadius, 421 float rightTopRadius, 422 float leftBottomRadius, 423 float rightBottomRadius, 424 const rgb_color& base, uint32 flags = 0, 425 uint32 borders = B_ALL_BORDERS); 426 427 // Rounded corner methods 428 void _DrawRoundCornerLeftTop(BView* view, 429 BRect& cornerRect, const BRect& updateRect, 430 const rgb_color& background, 431 const rgb_color& edgeColor, 432 const rgb_color& frameColor, 433 const rgb_color& bevelColor, 434 const BGradientLinear& fillGradient); 435 436 void _DrawRoundCornerFrameLeftTop(BView* view, 437 BRect& cornerRect, const BRect& updateRect, 438 const rgb_color& background, 439 const rgb_color& edgeColor, 440 const rgb_color& frameColor); 441 442 void _DrawRoundCornerBackgroundLeftTop(BView* view, 443 BRect& cornerRect, const BRect& updateRect, 444 const rgb_color& bevelColor, 445 const BGradientLinear& fillGradient); 446 447 void _DrawRoundCornerRightTop(BView* view, 448 BRect& cornerRect, const BRect& updateRect, 449 const rgb_color& background, 450 const rgb_color& edgeTopColor, 451 const rgb_color& edgeRightColor, 452 const rgb_color& frameTopColor, 453 const rgb_color& frameRightColor, 454 const rgb_color& bevelTopColor, 455 const rgb_color& bevelRightColor, 456 const BGradientLinear& fillGradient); 457 458 void _DrawRoundCornerFrameRightTop(BView* view, 459 BRect& cornerRect, const BRect& updateRect, 460 const rgb_color& background, 461 const rgb_color& edgeTopColor, 462 const rgb_color& edgeRightColor, 463 const rgb_color& frameTopColor, 464 const rgb_color& frameRightColor); 465 466 void _DrawRoundCornerBackgroundRightTop(BView* view, 467 BRect& cornerRect, const BRect& updateRect, 468 const rgb_color& bevelTopColor, 469 const rgb_color& bevelRightColor, 470 const BGradientLinear& fillGradient); 471 472 void _DrawRoundCornerLeftBottom(BView* view, 473 BRect& cornerRect, const BRect& updateRect, 474 const rgb_color& background, 475 const rgb_color& edgeLeftColor, 476 const rgb_color& edgeBottomColor, 477 const rgb_color& frameLeftColor, 478 const rgb_color& frameBottomColor, 479 const rgb_color& bevelLeftColor, 480 const rgb_color& bevelBottomColor, 481 const BGradientLinear& fillGradient); 482 483 void _DrawRoundCornerFrameLeftBottom(BView* view, 484 BRect& cornerRect, const BRect& updateRect, 485 const rgb_color& background, 486 const rgb_color& edgeLeftColor, 487 const rgb_color& edgeBottomColor, 488 const rgb_color& frameLeftColor, 489 const rgb_color& frameBottomColor); 490 491 void _DrawRoundCornerBackgroundLeftBottom(BView* view, 492 BRect& cornerRect, const BRect& updateRect, 493 const rgb_color& bevelLeftColor, 494 const rgb_color& bevelBottomColor, 495 const BGradientLinear& fillGradient); 496 497 void _DrawRoundCornerRightBottom(BView* view, 498 BRect& cornerRect, const BRect& updateRect, 499 const rgb_color& background, 500 const rgb_color& edgeColor, 501 const rgb_color& frameColor, 502 const rgb_color& bevelColor, 503 const BGradientLinear& fillGradient); 504 505 void _DrawRoundCornerFrameRightBottom(BView* view, 506 BRect& cornerRect, const BRect& updateRect, 507 const rgb_color& background, 508 const rgb_color& edgeColor, 509 const rgb_color& frameColor); 510 511 void _DrawRoundCornerBackgroundRightBottom( 512 BView* view, 513 BRect& cornerRect, const BRect& updateRect, 514 const rgb_color& bevelColor, 515 const BGradientLinear& fillGradient); 516 517 void _DrawRoundBarCorner(BView* view, BRect& rect, 518 const BRect& updateRect, 519 const rgb_color& edgeLightColor, 520 const rgb_color& edgeShadowColor, 521 const rgb_color& frameLightColor, 522 const rgb_color& frameShadowColor, 523 const rgb_color& fillLightColor, 524 const rgb_color& fillShadowColor, 525 float leftInset, float topInset, 526 float rightInset, float bottomInset, 527 orientation orientation); 528 529 // Border color methods 530 rgb_color _EdgeLightColor(const rgb_color& base, 531 float contrast, float brightness, 532 uint32 flags); 533 534 rgb_color _EdgeShadowColor(const rgb_color& base, 535 float contrast, float brightness, 536 uint32 flags); 537 538 rgb_color _FrameLightColor(const rgb_color& base, 539 uint32 flags); 540 541 rgb_color _FrameShadowColor(const rgb_color& base, 542 uint32 flags); 543 544 rgb_color _BevelLightColor(const rgb_color& base, 545 uint32 flags); 546 547 rgb_color _BevelShadowColor(const rgb_color& base, 548 uint32 flags); 549 550 // Background gradient methods 551 void _FillGradient(BView* view, const BRect& rect, 552 const rgb_color& base, float topTint, 553 float bottomTint, 554 orientation orientation = B_HORIZONTAL); 555 556 void _FillGlossyGradient(BView* view, 557 const BRect& rect, const rgb_color& base, 558 float topTint, float middle1Tint, 559 float middle2Tint, float bottomTint, 560 orientation orientation = B_HORIZONTAL); 561 562 void _MakeGradient(BGradientLinear& gradient, 563 const BRect& rect, const rgb_color& base, 564 float topTint, float bottomTint, 565 orientation orientation = B_HORIZONTAL) const; 566 567 void _MakeGlossyGradient(BGradientLinear& gradient, 568 const BRect& rect, const rgb_color& base, 569 float topTint, float middle1Tint, 570 float middle2Tint, float bottomTint, 571 orientation orientation = B_HORIZONTAL) const; 572 573 void _MakeButtonGradient(BGradientLinear& gradient, 574 BRect& rect, const rgb_color& base, 575 uint32 flags, orientation orientation = B_HORIZONTAL) const; 576 577 bool _RadioButtonAndCheckBoxMarkColor( 578 const rgb_color& base, rgb_color& color, 579 uint32 flags) const; 580 581 private: 582 bool fCachedOutline; 583 }; 584 585 586 } // namespace BPrivate 587 588 #endif // _HAIKU_CONTROL_LOOK_H 589