diff options
author | Daniel Würl <trinity@dwrl.de> | 2025-03-28 22:08:53 +0100 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-04-05 17:03:06 +0900 |
commit | 756e1cd1cae081b3a6fb698dac77ec7402f78ef7 (patch) | |
tree | e1a1be541f7a60cb5372a9ffdf365b87e133f3b2 | |
parent | f9080726ffd29058be233af0b2b830d651ac5bb4 (diff) | |
download | twin-style-dekorator-756e1cd1.tar.gz twin-style-dekorator-756e1cd1.zip |
Implement optional images for inactive states.
Signed-off-by: Daniel Würl <trinity@dwrl.de>
(cherry picked from commit 04e8bbd8b043741500017bcd61cfee8a72be89b6)
-rw-r--r-- | client/deKoratorclient.cpp | 144 | ||||
-rw-r--r-- | client/deKoratorclient.h | 3 |
2 files changed, 92 insertions, 55 deletions
diff --git a/client/deKoratorclient.cpp b/client/deKoratorclient.cpp index 2de0e1f..0e9c694 100644 --- a/client/deKoratorclient.cpp +++ b/client/deKoratorclient.cpp @@ -594,11 +594,18 @@ bool DeKoratorFactory::readConfig() // Load border pixmaps and try to also get pixmaps for inactive state. bool DeKoratorFactory::loadBorderPixmap(decoType borderPart, const TQString& newName, const TQString& oldName) { TQString decoPixDir = DeKoratorFactory::framesPath_; - + bool imgLoaded = DECOARR[ borderPart ][ orig ] ->load( decoPixDir + "/" + newName + "Bg.png" ); - if ( ! imgLoaded ) + if ( imgLoaded ) { + if ( !DECOARR[ borderPart ][ inActOrig ]->load( decoPixDir + "/" + newName + "InactiveBg.png" ) ) + DECOARR[ borderPart ][ inActOrig ] ->load( decoPixDir + "/" + newName + "Bg.png" ); + } + else + { imgLoaded = DECOARR[ borderPart ][ orig ] ->load( decoPixDir + "/" + oldName + "Bg.png" ); - + if ( !DECOARR[ borderPart ][ inActOrig ]->load( decoPixDir + "/" + oldName + "InactiveBg.png" ) ) + DECOARR[ borderPart ][ inActOrig ] ->load( decoPixDir + "/" + oldName + "Bg.png" ); + } if ( imgLoaded ) return true; else @@ -606,6 +613,33 @@ bool DeKoratorFactory::loadBorderPixmap(decoType borderPart, const TQString& new } ////////////////////////////////////////////////////////////////////////////// +// loadButtonPixmap() +// ------------ +// Load button pixmaps and try to also get pixmaps for inactive state. +void DeKoratorFactory::loadButtonPixmap(buttonTypeAll btnType, buttonState btnState, const TQString& imageName) { + TQString btnPixDir = DeKoratorFactory::buttonsPath_; + TQString statePath; + + switch (btnState) { + case regular: + statePath = "/normal/"; + break; + case press: + statePath = "/press/"; + break; + case hover: + statePath = "/hover/"; + break; + } + + bool origLoaded = BUTTONSARR[ btnType ][ btnState ][ normal ] ->load( btnPixDir + statePath + imageName + ".png" ); + if ( !BUTTONSARR[ btnType ][ btnState ][ inAct ]->load( btnPixDir + statePath + imageName + "Inactive.png" ) ) { + BUTTONSARR[ btnType ][ btnState ][ inAct ] ->load( btnPixDir + statePath + imageName + ".png" ); + } +} + + +////////////////////////////////////////////////////////////////////////////// // loadPixmaps() // ------------ // Read in the configuration file @@ -654,61 +688,61 @@ void DeKoratorFactory::loadPixmaps() // buttons - BUTTONSARR[ restore ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonRestore.png" ); - BUTTONSARR[ restore ][ press ][ normal ] ->load( btnPixDir + "/press/buttonRestorePress.png" ); - BUTTONSARR[ restore ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonRestoreHover.png" ); + loadButtonPixmap( restore, regular, "buttonRestore"); + loadButtonPixmap( restore, press, "buttonRestorePress"); + loadButtonPixmap( restore, hover, "buttonRestoreHover"); - BUTTONSARR[ help ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonHelp.png" ); - BUTTONSARR[ help ][ press ][ normal ] ->load( btnPixDir + "/press/buttonHelpPress.png" ); - BUTTONSARR[ help ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonHelpHover.png" ); + loadButtonPixmap( help, regular, "buttonHelp"); + loadButtonPixmap( help, press, "buttonHelpPress"); + loadButtonPixmap( help, hover, "buttonHelpHover"); - BUTTONSARR[ max ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonMax.png" ); - BUTTONSARR[ max ][ press ][ normal ] ->load( btnPixDir + "/press/buttonMaxPress.png" ); - BUTTONSARR[ max ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonMaxHover.png" ); + loadButtonPixmap( max, regular, "buttonMax"); + loadButtonPixmap( max, press, "buttonMaxPress"); + loadButtonPixmap( max, hover, "buttonMaxHover"); - BUTTONSARR[ min ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonMin.png" ); - BUTTONSARR[ min ][ press ][ normal ] ->load( btnPixDir + "/press/buttonMinPress.png" ); - BUTTONSARR[ min ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonMinHover.png" ); + loadButtonPixmap( min, regular, "buttonMin"); + loadButtonPixmap( min, press, "buttonMinPress"); + loadButtonPixmap( min, hover, "buttonMinHover"); - BUTTONSARR[ close ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonClose.png" ); - BUTTONSARR[ close ][ press ][ normal ] ->load( btnPixDir + "/press/buttonClosePress.png" ); - BUTTONSARR[ close ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonCloseHover.png" ); + loadButtonPixmap( close, regular, "buttonClose"); + loadButtonPixmap( close, press, "buttonClosePress"); + loadButtonPixmap( close, hover, "buttonCloseHover"); - BUTTONSARR[ sticky ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonSticky.png" ); - BUTTONSARR[ sticky ][ press ][ normal ] ->load( btnPixDir + "/press/buttonStickyDownPress.png" ); - BUTTONSARR[ sticky ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonStickyHover.png" ); + loadButtonPixmap( sticky, regular, "buttonSticky"); + loadButtonPixmap( sticky, press, "buttonStickyDownPress"); + loadButtonPixmap( sticky, hover, "buttonStickyHover"); - BUTTONSARR[ stickydown ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonStickyDown.png" ); - BUTTONSARR[ stickydown ][ press ][ normal ] ->load( btnPixDir + "/press/buttonStickyDownPress.png" ); - BUTTONSARR[ stickydown ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonStickyDownHover.png" ); + loadButtonPixmap( stickydown, regular, "buttonStickyDown"); + loadButtonPixmap( stickydown, press, "buttonStickyDownPress"); + loadButtonPixmap( stickydown, hover, "buttonStickyDownHover"); - BUTTONSARR[ above ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonAbove.png" ); - BUTTONSARR[ above ][ press ][ normal ] ->load( btnPixDir + "/press/buttonAbovePress.png" ); - BUTTONSARR[ above ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonAboveHover.png" ); + loadButtonPixmap( above, regular, "buttonAbove"); + loadButtonPixmap( above, press, "buttonAbovePress"); + loadButtonPixmap( above, hover, "buttonAboveHover"); - BUTTONSARR[ abovedown ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonAboveDown.png" ); - BUTTONSARR[ abovedown ][ press ][ normal ] ->load( btnPixDir + "/press/buttonAboveDownPress.png" ); - BUTTONSARR[ abovedown ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonAboveDownHover.png" ); + loadButtonPixmap( abovedown, regular, "buttonAboveDown"); + loadButtonPixmap( abovedown, press, "buttonAboveDownPress"); + loadButtonPixmap( abovedown, hover, "buttonAboveDownHover"); - BUTTONSARR[ below ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonBelow.png" ); - BUTTONSARR[ below ][ press ][ normal ] ->load( btnPixDir + "/press/buttonBelowPress.png" ); - BUTTONSARR[ below ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonBelowHover.png" ); + loadButtonPixmap( below, regular, "buttonBelow"); + loadButtonPixmap( below, press, "buttonBelowPress"); + loadButtonPixmap( below, hover, "buttonBelowHover"); - BUTTONSARR[ belowdown ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonBelowDown.png" ); - BUTTONSARR[ belowdown ][ press ][ normal ] ->load( btnPixDir + "/press/buttonBelowDownPress.png" ); - BUTTONSARR[ belowdown ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonBelowDownHover.png" ); + loadButtonPixmap( belowdown, regular, "buttonBelowDown"); + loadButtonPixmap( belowdown, press, "buttonBelowDownPress"); + loadButtonPixmap( belowdown, hover, "buttonBelowDownHover"); - BUTTONSARR[ shade ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonShade.png" ); - BUTTONSARR[ shade ][ press ][ normal ] ->load( btnPixDir + "/press/buttonShadePress.png" ); - BUTTONSARR[ shade ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonShadeHover.png" ); + loadButtonPixmap( shade, regular, "buttonShade"); + loadButtonPixmap( shade, press, "buttonShadePress"); + loadButtonPixmap( shade, hover, "buttonShadeHover"); - BUTTONSARR[ shadedown ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonShadeDown.png" ); - BUTTONSARR[ shadedown ][ press ][ normal ] ->load( btnPixDir + "/press/buttonShadeDownPress.png" ); - BUTTONSARR[ shadedown ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonShadeDownHover.png" ); + loadButtonPixmap( shadedown, regular, "buttonShadeDown"); + loadButtonPixmap( shadedown, press, "buttonShadeDownPress"); + loadButtonPixmap( shadedown, hover, "buttonShadeDownHover"); - BUTTONSARR[ menu ][ regular ][ normal ] ->load( btnPixDir + "/normal/buttonMenu.png" ); - BUTTONSARR[ menu ][ press ][ normal ] ->load( btnPixDir + "/press/buttonMenuPress.png" ); - BUTTONSARR[ menu ][ hover ][ normal ] ->load( btnPixDir + "/hover/buttonMenuHover.png" ); + loadButtonPixmap( menu, regular, "buttonMenu"); + loadButtonPixmap( menu, press, "buttonMenuPress"); + loadButtonPixmap( menu, hover, "buttonMenuHover"); //masks @@ -825,7 +859,7 @@ void DeKoratorFactory::colorizeDecoPixmaps( bool isActive ) { for ( i = 0; i < decoCount; i++ ) { - *( DECOARR[ i ][ inActCol ] ) = *( DECOARR[ i ][ orig ] ); + *( DECOARR[ i ][ inActCol ] ) = *( DECOARR[ i ][ inActOrig ] ); colorizePixmap( DECOARR[ i ][ inActCol ], col, DECOCOLORIZE ); } @@ -876,7 +910,7 @@ void DeKoratorFactory::colorizeButtonsPixmaps( bool isActive ) { for ( j = 0; j < buttonStateCount; j++ ) { - *( BUTTONSARR[ i ][ j ][ inActCol ] ) = *( BUTTONSARR[ i ][ j ][ normal ] ); + *( BUTTONSARR[ i ][ j ][ inActCol ] ) = *( BUTTONSARR[ i ][ j ][ inAct ] ); colorizePixmap( BUTTONSARR[ i ][ j ][ inActCol ], cusBtnCol_[ i ], BUTTONSCOLORIZE ); } } @@ -887,7 +921,7 @@ void DeKoratorFactory::colorizeButtonsPixmaps( bool isActive ) { for ( j = 0; j < buttonStateCount; j++ ) { - *( BUTTONSARR[ i ][ j ][ inActCol ] ) = *( BUTTONSARR[ i ][ j ][ normal ] ); + *( BUTTONSARR[ i ][ j ][ inActCol ] ) = *( BUTTONSARR[ i ][ j ][ inAct ] ); colorizePixmap( BUTTONSARR[ i ][ j ][ inActCol ], col, BUTTONSCOLORIZE ); } } @@ -1097,7 +1131,7 @@ void DeKoratorFactory::chooseRightPixmaps() { for ( i = 0; i < decoCount; i++ ) { - DECOPIXINACTARR[ i ] = DECOARR[ i ][ normal ]; + DECOPIXINACTARR[ i ] = DECOARR[ i ][ inAct ]; } } @@ -1142,7 +1176,7 @@ void DeKoratorFactory::chooseRightPixmaps() { for ( j = 0; j < buttonStateCount; j++ ) { - BUTTONPIXINACTARR[ i ][ j ] = BUTTONSARR[ i ][ j ][ normal ]; + BUTTONPIXINACTARR[ i ][ j ] = BUTTONSARR[ i ][ j ][ inAct ]; } } } @@ -1215,7 +1249,7 @@ void DeKoratorFactory::prepareDecoWithBgCol() continue; } - tempPix.resize( DECOARR[ i ][ orig ] ->width(), DECOARR[ i ][ orig ] ->height() ); + tempPix.resize( DECOARR[ i ][ inActOrig ] ->width(), DECOARR[ i ][ inActOrig ] ->height() ); tempPix.fill( col ); @@ -1233,21 +1267,21 @@ void DeKoratorFactory::prepareDecoWithBgCol() for ( i = 0 ; i < decoCount ; i++ ) { if (transparency_) { - DECOARR[ i ][ normal ] = new TQPixmap(*DECOARR[ i ][ orig ]); + DECOARR[ i ][ inAct ] = new TQPixmap(*DECOARR[ i ][ inActOrig ]); continue; } - tempPix.resize( DECOARR[ i ][ orig ] ->width(), DECOARR[ i ][ orig ] ->height() ); + tempPix.resize( DECOARR[ i ][ inActOrig ] ->width(), DECOARR[ i ][ inActOrig ] ->height() ); tempPix.fill( col ); painter.begin( &tempPix ); { - painter.drawPixmap( 0, 0, *( DECOARR[ i ][ orig ] ) ); + painter.drawPixmap( 0, 0, *( DECOARR[ i ][ inActOrig ] ) ); } painter.end(); - *( DECOARR[ i ][ normal ] ) = tempPix; + *( DECOARR[ i ][ inAct ] ) = tempPix; } } diff --git a/client/deKoratorclient.h b/client/deKoratorclient.h index aef01b9..b9f9474 100644 --- a/client/deKoratorclient.h +++ b/client/deKoratorclient.h @@ -126,9 +126,11 @@ enum ButtonType { enum pixType { normal = 0, + inAct, actCol, inActCol, orig, + inActOrig, pixTypeCount }; @@ -155,6 +157,7 @@ public: private: bool readConfig(); bool loadBorderPixmap(decoType borderPart, const TQString& oldName, const TQString& newName); + void loadButtonPixmap(buttonTypeAll btnType, buttonState btnState, const TQString& imageName); void loadPixmaps(); void colorizeDecoPixmaps( bool isActive ); void colorizeButtonsPixmaps( bool isActive ); |