1 #ifndef oxygencachekey_h 2 #define oxygencachekey_h 3 4 /* 5 * this file is part of the oxygen gtk engine 6 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or( at your option ) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free 20 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 21 * MA 02110-1301, USA. 22 */ 23 24 #include "oxygenrgba.h" 25 #include "oxygenwindecooptions.h" 26 27 namespace Oxygen 28 { 29 30 //! key for separators 31 /*! keys are used to store tilesets into cache */ 32 class SeparatorKey 33 { 34 public: 35 36 //! constructor SeparatorKey(const ColorUtils::Rgba & color,bool vertical,int size)37 SeparatorKey( const ColorUtils::Rgba& color, bool vertical, int size ): 38 _color( color.toInt() ), 39 _vertical( vertical ), 40 _size( size ) 41 {} 42 43 //! equal to operator 44 bool operator == (const SeparatorKey& other ) const 45 { 46 return 47 _color == other._color && 48 _vertical == other._vertical && 49 _size == other._size; 50 } 51 52 //! less than operator 53 bool operator < (const SeparatorKey& other ) const 54 { 55 if( _color != other._color ) return _color < other._color; 56 else if( _vertical != other._vertical ) return _vertical < other._vertical; 57 else return _size < other._size; 58 } 59 60 private: 61 62 guint32 _color; 63 bool _vertical; 64 int _size; 65 66 //! streamer 67 friend std::ostream& operator << ( std::ostream& out, const SeparatorKey& key ) 68 { 69 out << "SeparatorKey - color: " << key._color << " shade: " << key._vertical << " size: " << key._size; 70 return out; 71 } 72 73 }; 74 75 //! key for focused slabs 76 class SlabKey 77 { 78 public: 79 80 //! constructor SlabKey(const ColorUtils::Rgba & color,double shade,int size)81 SlabKey( const ColorUtils::Rgba& color, double shade, int size ): 82 _color( color.toInt() ), 83 _glow( 0 ), 84 _shade( shade ), 85 _size( size ) 86 {} 87 88 //! constructor SlabKey(const ColorUtils::Rgba & color,const ColorUtils::Rgba & glow,double shade,int size)89 SlabKey( const ColorUtils::Rgba& color, const ColorUtils::Rgba& glow, double shade, int size ): 90 _color( color.toInt() ), 91 _glow( glow.toInt() ), 92 _shade( shade ), 93 _size( size ) 94 {} 95 96 //! equal to operator 97 bool operator == (const SlabKey& other ) const 98 { 99 return 100 _color == other._color && 101 _glow == other._glow && 102 _shade == other._shade && 103 _size == other._size; 104 } 105 106 //! less than operator 107 bool operator < (const SlabKey& other ) const 108 { 109 if( _color != other._color ) return _color < other._color; 110 else if( _glow != other._glow ) return _glow < other._glow; 111 else if( _shade != other._shade ) return _shade < other._shade; 112 else return _size < other._size; 113 } 114 115 private: 116 117 guint32 _color; 118 guint32 _glow; 119 double _shade; 120 int _size; 121 122 //! streamer 123 friend std::ostream& operator << ( std::ostream& out, const SlabKey& key ) 124 { 125 out << "SlabKey - color: " << key._color << " glow: " << key._glow << " shade: " << key._shade << " size: " << key._size; 126 return out; 127 } 128 }; 129 130 class SliderSlabKey 131 { 132 public: 133 134 //! constructor SliderSlabKey(const ColorUtils::Rgba & color,const ColorUtils::Rgba & glow,bool sunken,double shade,int size)135 SliderSlabKey( const ColorUtils::Rgba& color, const ColorUtils::Rgba& glow, bool sunken, double shade, int size ): 136 _color( color.toInt() ), 137 _glow( glow.toInt() ), 138 _sunken( sunken ), 139 _shade( shade ), 140 _size( size ) 141 {} 142 143 //! equal to operator 144 bool operator == (const SliderSlabKey& other ) const 145 { 146 return 147 _color == other._color && 148 _glow == other._glow && 149 _sunken == other._sunken && 150 _shade == other._shade && 151 _size == other._size; 152 } 153 154 //! less than operator 155 bool operator < (const SliderSlabKey& other ) const 156 { 157 if( _color != other._color ) return _color < other._color; 158 else if( _glow != other._glow ) return _glow < other._glow; 159 else if( _sunken != other._sunken ) return _sunken < other._sunken; 160 else if( _shade != other._shade ) return _shade < other._shade; 161 else return _size < other._size; 162 } 163 164 private: 165 166 guint32 _color; 167 guint32 _glow; 168 bool _sunken; 169 double _shade; 170 int _size; 171 172 //! streamer 173 friend std::ostream& operator << ( std::ostream& out, const SliderSlabKey& key ) 174 { 175 out << "SliderSlabKey -" 176 << " color: " << key._color 177 << " glow: " << key._glow 178 << " sunken: " << key._sunken 179 << " shade: " << key._shade 180 << " size: " << key._size; 181 return out; 182 } 183 }; 184 185 //! key for holes 186 class HoleFocusedKey 187 { 188 public: 189 190 //! constructor HoleFocusedKey(const ColorUtils::Rgba & color,const ColorUtils::Rgba & fill,const ColorUtils::Rgba & glow,int size,bool contrast)191 HoleFocusedKey( const ColorUtils::Rgba& color, const ColorUtils::Rgba& fill, const ColorUtils::Rgba& glow, int size, bool contrast ): 192 _color( color.toInt() ), 193 _fill( fill.toInt() ), 194 _glow( glow.toInt() ), 195 _size( size ), 196 _filled( fill.isValid() ), 197 _contrast( contrast ) 198 {} 199 200 //! equal to operator 201 bool operator == (const HoleFocusedKey& other ) const 202 { 203 return 204 _color == other._color && 205 _glow == other._glow && 206 _size == other._size && 207 _filled == other._filled && 208 (_fill == other._fill || !_filled ) && 209 _contrast == other._contrast; 210 } 211 212 //! less than operator 213 bool operator < (const HoleFocusedKey& other ) const 214 { 215 if( _color != other._color ) return _color < other._color; 216 if( _glow != other._glow ) return _glow < other._glow; 217 else if( _size != other._size ) return _size < other._size; 218 else if( _filled != other._filled ) return !_filled; 219 else if( _filled && _fill != other._fill ) return _fill < other._fill; 220 else if( _contrast != other._contrast ) return _contrast < other._contrast; 221 else return false; 222 } 223 224 private: 225 226 guint32 _color; 227 guint32 _fill; 228 guint32 _glow; 229 int _size; 230 bool _filled; 231 bool _contrast; 232 233 //! streamer 234 friend std::ostream& operator << ( std::ostream& out, const HoleFocusedKey& key ) 235 { 236 out 237 << "HoleFocusedKey -" 238 << " color: " << key._color << " glow: " << key._glow << " fill: " << key._fill 239 << " size: " << key._size << " filled: " << key._filled << " contrast: " << key._contrast; 240 return out; 241 } 242 243 }; 244 245 //! key for flat holes 246 class HoleFlatKey 247 { 248 public: 249 250 //! constructor HoleFlatKey(const ColorUtils::Rgba & color,double shade,bool fill,int size)251 HoleFlatKey( const ColorUtils::Rgba& color, double shade, bool fill, int size ): 252 _color( color.toInt() ), 253 _shade( shade ), 254 _fill( fill ), 255 _size( size ) 256 {} 257 258 //! equal to operator 259 bool operator == (const HoleFlatKey& other ) const 260 { 261 return 262 _color == other._color && 263 _shade == other._shade && 264 _fill == other._fill && 265 _size == other._size; 266 } 267 268 //! less than operator 269 bool operator < (const HoleFlatKey& other ) const 270 { 271 if( _color != other._color ) return _color < other._color; 272 else if( _shade != other._shade ) return _shade < other._shade; 273 else if( _fill != other._fill ) return _fill < other._fill; 274 else return _size < other._size; 275 } 276 277 private: 278 279 guint32 _color; 280 double _shade; 281 bool _fill; 282 int _size; 283 284 //! streamer 285 friend std::ostream& operator << ( std::ostream& out, const HoleFlatKey& key ) 286 { 287 out 288 << "HoleFlatKey -" 289 << " color: " << key._color 290 << " shade: " << key._shade 291 << " fill: " << (key._fill ? "true":"false") 292 << " size: " << key._size; 293 294 return out; 295 } 296 297 }; 298 299 //! key for scroll holes 300 class ScrollHoleKey 301 { 302 public: 303 304 //! constructor ScrollHoleKey(const ColorUtils::Rgba & color,bool vertical,bool smallShadow)305 ScrollHoleKey( const ColorUtils::Rgba& color, bool vertical, bool smallShadow ): 306 _color( color.toInt() ), 307 _vertical( vertical ), 308 _smallShadow( smallShadow ) 309 {} 310 311 //! equal to operator 312 bool operator == (const ScrollHoleKey& other ) const 313 { 314 return 315 _color == other._color && 316 _vertical == other._vertical && 317 _smallShadow == other._smallShadow; 318 } 319 320 //! less than operator 321 bool operator < (const ScrollHoleKey& other ) const 322 { 323 if( _color != other._color ) return _color < other._color; 324 else if( _vertical != other._vertical ) return _vertical < other._vertical; 325 else return _smallShadow < other._smallShadow; 326 } 327 328 private: 329 330 guint32 _color; 331 bool _vertical; 332 bool _smallShadow; 333 334 //! streamer 335 friend std::ostream& operator << ( std::ostream& out, const ScrollHoleKey& key ) 336 { 337 out << "ScrollHoleKey -" 338 << " color: " << key._color 339 << " vertical: " << (key._vertical ? "true":"false") 340 << " smallShadow: " << (key._smallShadow ? "true":"false"); 341 return out; 342 } 343 344 }; 345 346 //! key for scrollbar handles 347 class ScrollHandleKey 348 { 349 public: 350 351 //! constructor ScrollHandleKey(const ColorUtils::Rgba & color,const ColorUtils::Rgba & glow,int size)352 ScrollHandleKey( const ColorUtils::Rgba& color, const ColorUtils::Rgba& glow, int size ): 353 _color( color.toInt() ), 354 _glow( glow.toInt() ), 355 _size( size ) 356 {} 357 358 //! equal to operator 359 bool operator == (const ScrollHandleKey& other ) const 360 { 361 return 362 _color == other._color && 363 _glow == other._glow && 364 _size == other._size; 365 } 366 367 //! less than operator 368 bool operator < (const ScrollHandleKey& other ) const 369 { 370 if( _color != other._color ) return _color < other._color; 371 else if( _glow != other._glow ) return _glow < other._glow; 372 else return _size < other._size; 373 } 374 375 private: 376 377 guint32 _color; 378 guint32 _glow; 379 int _size; 380 381 //! streamer 382 friend std::ostream& operator << ( std::ostream& out, const ScrollHandleKey& key ) 383 { 384 out << "ScrollHandleKey -" 385 << " color: " << key._color 386 << " glow: " << key._glow 387 << " size: " << key._size; 388 return out; 389 } 390 391 }; 392 393 //@} 394 395 //! key for focused slits 396 class SlitFocusedKey 397 { 398 public: 399 400 //! constructor SlitFocusedKey(const ColorUtils::Rgba & color)401 SlitFocusedKey( const ColorUtils::Rgba& color ): 402 _color( color.toInt() ) 403 {} 404 405 //! equal to operator 406 bool operator == (const SlitFocusedKey& other ) const 407 { return _color == other._color; } 408 409 //! less than operator 410 bool operator < (const SlitFocusedKey& other ) const 411 { return _color < other._color; } 412 413 private: 414 415 guint32 _color; 416 417 //! streamer 418 friend std::ostream& operator << ( std::ostream& out, const SlitFocusedKey& key ) 419 { 420 out << "SlitFocusedKey - color: " << key._color; 421 return out; 422 } 423 424 }; 425 426 //@} 427 428 //! key for docks 429 class DockFrameKey 430 { 431 public: 432 433 //! constructor DockFrameKey(const ColorUtils::Rgba & top,const ColorUtils::Rgba & bottom)434 DockFrameKey( const ColorUtils::Rgba& top, const ColorUtils::Rgba& bottom ): 435 _top( top.toInt() ), 436 _bottom( bottom.toInt() ) 437 {} 438 439 //! equal to operator 440 bool operator == (const DockFrameKey& other ) const 441 { 442 return 443 _top == other._top && 444 _bottom == other._bottom; 445 } 446 447 //! less than operator 448 bool operator < (const DockFrameKey& other ) const 449 { 450 if( _top != other._top ) return _top < other._top; 451 else return _bottom < other._bottom; 452 } 453 454 private: 455 456 guint32 _top; 457 guint32 _bottom; 458 459 //! streamer 460 friend std::ostream& operator << ( std::ostream& out, const DockFrameKey& key ) 461 { 462 out << "DockFrameKey - top color: " << key._top << " bottom color: " << key._bottom; 463 return out; 464 } 465 466 }; 467 468 //! key for grooves 469 class GrooveKey 470 { 471 public: 472 473 //! constructor GrooveKey(const ColorUtils::Rgba & color,int size)474 GrooveKey( const ColorUtils::Rgba& color, int size ): 475 _color( color.toInt() ), 476 _size( size ) 477 {} 478 479 //! equal to operator 480 bool operator == (const GrooveKey& other ) const 481 { 482 return 483 _color == other._color && 484 _size == other._size; 485 } 486 487 //! less than operator 488 bool operator < (const GrooveKey& other ) const 489 { 490 if( _color != other._color ) return _color < other._color; 491 else return _size < other._size; 492 } 493 494 private: 495 496 guint32 _color; 497 int _size; 498 499 //! streamer 500 friend std::ostream& operator << ( std::ostream& out, const GrooveKey& key ) 501 { 502 out << "GrooveKey - color: " << key._color << " size: " << key._size; 503 return out; 504 } 505 506 }; 507 508 //! key for selection rects 509 class SelectionKey 510 { 511 public: 512 513 //! constructor SelectionKey(const ColorUtils::Rgba & color,int size,bool custom)514 SelectionKey( const ColorUtils::Rgba& color, int size, bool custom ): 515 _color( color.toInt() ), 516 _size( size ), 517 _custom( custom ) 518 {} 519 520 //! equal to operator 521 bool operator == (const SelectionKey& other ) const 522 { 523 return 524 _color == other._color && 525 _size == other._size && 526 _custom == other._custom; 527 } 528 529 //! less than operator 530 bool operator < (const SelectionKey& other ) const 531 { 532 533 if( _color != other._color ) return _color < other._color; 534 else if( _size != other._size ) return _size < other._size; 535 else return _custom < other._custom; 536 537 } 538 539 private: 540 541 guint32 _color; 542 int _size; 543 bool _custom; 544 545 //! streamer 546 friend std::ostream& operator << ( std::ostream& out, const SelectionKey& key ) 547 { 548 out << "SelectionKey - color: " << key._color << " size: " << key._size << " custom: " << ( key._custom ? "true":"false" ); 549 return out; 550 } 551 552 }; 553 554 //! key for progressbar indicator 555 class ProgressBarIndicatorKey 556 { 557 public: 558 559 //! constructor ProgressBarIndicatorKey(const ColorUtils::Rgba & color,const ColorUtils::Rgba & glow,int width,int height)560 ProgressBarIndicatorKey( const ColorUtils::Rgba& color, const ColorUtils::Rgba& glow, int width, int height ): 561 _color( color.toInt() ), 562 _glow( glow.toInt() ), 563 _width( width ), 564 _height( height ) 565 {} 566 567 //! equal to operator 568 bool operator == (const ProgressBarIndicatorKey& other ) const 569 { 570 return 571 _color == other._color && 572 _glow == other._glow && 573 _width == other._width && 574 _height == other._height; 575 } 576 577 //! less than operator 578 bool operator < (const ProgressBarIndicatorKey& other ) const 579 { 580 if( _color != other._color ) return _color < other._color; 581 else if( _glow != other._glow ) return _glow < other._glow; 582 else if( _width != other._width ) return _width < other._width; 583 else return _height < other._height; 584 } 585 586 private: 587 588 guint32 _color; 589 guint32 _glow; 590 int _width; 591 int _height; 592 593 //! streamer 594 friend std::ostream& operator << ( std::ostream& out, const ProgressBarIndicatorKey& key ) 595 { 596 out << "ProgressBarIndicatorKey - color: " << key._color << " glow: " << key._glow << " width: " << key._width << " height: " << key._height; 597 return out; 598 } 599 }; 600 601 //! key for windeco buttons 602 /*! keys are used to store tilesets into cache */ 603 class WindecoButtonKey 604 { 605 public: 606 607 //! constructor WindecoButtonKey(const ColorUtils::Rgba & color,int size,bool pressed)608 WindecoButtonKey( const ColorUtils::Rgba& color, int size, bool pressed ): 609 _color( color.toInt() ), 610 _size( size ), 611 _pressed( pressed ) 612 {} 613 614 //! equal to operator 615 bool operator == (const WindecoButtonKey& other ) const 616 { 617 return 618 _color == other._color && 619 _size == other._size && 620 _pressed == other._pressed; 621 } 622 623 //! less than operator 624 bool operator < (const WindecoButtonKey& other ) const 625 { 626 if( _color != other._color ) return _color < other._color; 627 else if( _size != other._size ) return _size < other._size; 628 else return _pressed < other._pressed; 629 } 630 631 private: 632 633 guint32 _color; 634 int _size; 635 bool _pressed; 636 637 //! streamer 638 friend std::ostream& operator << ( std::ostream& out, const WindecoButtonKey& key ) 639 { 640 out << "WindecoButtonKey - color: " << key._color << " size: " << key._size << " pressed: " << key._pressed; 641 return out; 642 } 643 644 }; 645 646 //! key for windeco buttons 647 /*! keys are used to store tilesets into cache */ 648 class WindecoButtonGlowKey 649 { 650 public: 651 652 //! constructor WindecoButtonGlowKey(const ColorUtils::Rgba & color,int size)653 WindecoButtonGlowKey( const ColorUtils::Rgba& color, int size ): 654 _color( color.toInt() ), 655 _size( size ) 656 {} 657 658 //! equal to operator 659 bool operator == (const WindecoButtonGlowKey& other ) const 660 { 661 return 662 _color == other._color && 663 _size == other._size; 664 } 665 666 //! less than operator 667 bool operator < (const WindecoButtonGlowKey& other ) const 668 { 669 if( _color != other._color ) return _color < other._color; 670 else return _size < other._size; 671 } 672 673 private: 674 675 guint32 _color; 676 int _size; 677 678 //! streamer 679 friend std::ostream& operator << ( std::ostream& out, const WindecoButtonGlowKey& key ) 680 { 681 out << "WindecoButtonGlowKey - color: " << key._color << " size: " << key._size; 682 return out; 683 } 684 685 }; 686 687 //! key for window shadows 688 /*! keys are used to store tilesets into cache */ 689 class WindowShadowKey 690 { 691 692 public: 693 694 //! explicit constructor WindowShadowKey(void)695 explicit WindowShadowKey( void ): 696 active(false), 697 useOxygenShadows(true), 698 isShade(false), 699 hasTitleOutline(false), 700 hasTopBorder( true ), 701 hasBottomBorder( true ) 702 {} 703 704 //! equal to operator 705 bool operator == (const WindowShadowKey& other) const 706 { 707 return 708 ( active == other.active ) && 709 ( useOxygenShadows == other.useOxygenShadows ) && 710 ( isShade == other.isShade ) && 711 ( hasTitleOutline == other.hasTitleOutline ) && 712 ( hasTopBorder == other.hasTopBorder ) && 713 ( hasBottomBorder == other.hasBottomBorder ); 714 715 } 716 717 //! less than operator 718 bool operator < (const WindowShadowKey& other) const 719 { 720 if( active != other.active ) return active < other.active; 721 else if( useOxygenShadows != other.useOxygenShadows ) return useOxygenShadows < other.useOxygenShadows; 722 else if( isShade != other.isShade ) return isShade < other.isShade; 723 else if( hasTitleOutline != other.hasTitleOutline ) return hasTitleOutline < other.hasTitleOutline; 724 else if( hasTopBorder != other.hasTopBorder ) return hasTopBorder < other.hasTopBorder; 725 else return hasBottomBorder < other.hasBottomBorder; 726 } 727 728 bool active; 729 bool useOxygenShadows; 730 bool isShade; 731 bool hasTitleOutline; 732 bool hasTopBorder; 733 bool hasBottomBorder; 734 735 }; 736 737 //! key for window background vertical gradient 738 class VerticalGradientKey 739 { 740 public: 741 742 //! constructor VerticalGradientKey(const ColorUtils::Rgba & color,int size)743 VerticalGradientKey( const ColorUtils::Rgba& color, int size ): 744 _color( color.toInt() ), 745 _size( size ) 746 {} 747 748 //! equal to operator 749 bool operator == (const VerticalGradientKey& other ) const 750 { 751 return 752 _color == other._color && 753 _size == other._size; 754 } 755 756 //! less than operator 757 bool operator < (const VerticalGradientKey& other ) const 758 { 759 if( _color != other._color ) return _color < other._color; 760 else return _size < other._size; 761 } 762 763 private: 764 765 guint32 _color; 766 int _size; 767 768 //! streamer 769 friend std::ostream& operator << ( std::ostream& out, const VerticalGradientKey& key ) 770 { 771 out << "VerticalGradientKey - color: " << key._color << " size: " << key._size; 772 return out; 773 } 774 775 }; 776 777 //! key for window background radial gradient 778 typedef VerticalGradientKey RadialGradientKey; 779 780 //! key for left windeco border 781 class WindecoBorderKey 782 { 783 public: 784 785 //! constructor WindecoBorderKey(WinDeco::Options wopt,const int width,const int height,bool gradient)786 WindecoBorderKey( WinDeco::Options wopt, const int width, const int height, bool gradient ): 787 _wopt(wopt), 788 _width(width), 789 _height(height), 790 _gradient(gradient) 791 {} 792 793 //! equal to operator 794 bool operator == (const WindecoBorderKey& other) const 795 { 796 return _width == other._width && 797 _height == other._height && 798 _wopt == other._wopt && 799 _gradient == other._gradient; 800 } 801 802 //! less than operator 803 bool operator < (const WindecoBorderKey& other) const 804 { 805 if( _width != other._width ) return _width < other._width; 806 else if( _height != other._height ) return _height < other._height; 807 else if( _gradient != other._gradient ) return _gradient < other._gradient; 808 else return _wopt < other._wopt; 809 } 810 811 private: 812 813 WinDeco::Options _wopt; 814 int _width; 815 int _height; 816 bool _gradient; 817 }; 818 819 //! key for other windeco borders 820 typedef WindecoBorderKey WindecoLeftBorderKey; 821 typedef WindecoBorderKey WindecoRightBorderKey; 822 typedef WindecoBorderKey WindecoTopBorderKey; 823 typedef WindecoBorderKey WindecoBottomBorderKey; 824 825 //! key for dock widget button 826 class DockWidgetButtonKey 827 { 828 public: 829 830 //! constructor DockWidgetButtonKey(const ColorUtils::Rgba & base,bool pressed,int size)831 DockWidgetButtonKey( const ColorUtils::Rgba& base, bool pressed, int size ): 832 _base(base.toInt()), 833 _pressed(pressed), 834 _size(size) 835 {} 836 837 //! equal to operator 838 bool operator == (const DockWidgetButtonKey& other) const 839 { 840 return _base == other._base && 841 _pressed == other._pressed && 842 _size == other._size; 843 } 844 845 //! less than operator 846 bool operator < (const DockWidgetButtonKey& other) const 847 { 848 if( _base != other._base ) return _base < other._base; 849 else if( _pressed != other._pressed ) return _pressed < other._pressed; 850 else return _size < other._size; 851 } 852 853 private: 854 855 guint32 _base; 856 bool _pressed; 857 int _size; 858 }; 859 860 } 861 862 #endif 863