From 6a7d09e2a9ac4e14d183e57bb70798aeccd8d780 Mon Sep 17 00:00:00 2001 From: David Buzatto Date: Sat, 25 Jan 2025 19:23:10 -0300 Subject: [PATCH] IMGUI themes and adjustments --- resources/images/moon.png | Bin 0 -> 1349 bytes resources/images/sun.png | Bin 0 -> 973 bytes resources/images/sunAndMoon.fla | Bin 0 -> 7107 bytes .../jsge/examples/basic/IMGUIExample.java | 35 ++- .../jsge/imgui/GuiDropdownList.java | 3 +- .../com/davidbuzatto/jsge/imgui/GuiTheme.java | 218 ++++++++++++------ 6 files changed, 181 insertions(+), 75 deletions(-) create mode 100644 resources/images/moon.png create mode 100644 resources/images/sun.png create mode 100644 resources/images/sunAndMoon.fla diff --git a/resources/images/moon.png b/resources/images/moon.png new file mode 100644 index 0000000000000000000000000000000000000000..9aebd5395ecc152bcecd4d8f8ece0813d218ea4d GIT binary patch literal 1349 zcmV-L1-kl)P)&noMx&tC+74VL&DleZxw*Nyz4xYOKI8*|oZtPO zlixSz{LVS|94JzxND)hP^tRI3x2e!STe2>#gd+Qqq76Y1B#?*!udhqn1`&DH?u@*L z5MjWT^(-lToH=nhul7w~tw-7;b(Am&!k5Ei7GayR8k7~x3kh{MA&G(5oYP0jFayUQ z<`I`^Y^JFtZpJ66$V3Br^hZRyz2)>s=h>rD>yNxX`@; zMu%2=qz*|;*%SUo7rh7lRFszzf3T$VE@*C~Febz&=6b-&b>Dmp729NDug%gv$g9h>xIITZk%9!Ufw-Aw@sr-#D-2`vh?#!&$9;sWO@QkCE?5@<8 ztl^^~=yhirN<`RtNY>C6($U+hEV^s-g)}&;aaKB%rnW-&ilM!hqg=fy%qD9xu#2dr zh%91m_p8GJuRAm81;Hn~f`YJaLI8RW`PHUqp~M&xvh?V&p~f1V)f|84Rkb-vXV2MZ zeIQ}iwEleY7T!QORjl8-ncdrK4K>(Q_X2bCOHALspEe5I2zeN!u@fV>ftR=8C@W>`&%c%C%^(ir_4{b{ z!{q2y-9|ckTk-m%2wRlY?pxqSB!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y(3K9|V_utiyeG19$PZ9A6 z40bZ%mw&>dUB7ntJvsF5I^os#qjuEVEYju42E=$1&83-rM9dCB8PZp>j{pD{_;O;; z&YIZOfd(%hxWLbVQSZ91GHHBalg7Is@8DA+gu}6Xba9v4naO{d9_*t-VF}H-PSoJrOCq&?v%a zjYMvU_GH2UV_`_Ngo+Uf7o;!~NS1a5Xk*Fc)j(9^THVM-vm( zM?_RFlQIY%MZ_ta&+)zeKKAV4u^!I7odKNq!R}Xeud)yk@gWj!e)xLw{IP5v$M+Xk z5Nioq0WEd(+;J#I68VqIs{Xb6p=WXN7qC5a1^V{+L#2A2J%qy2Bzm2GW!fT{^G-$H v%x8tOkZMSf|NH~;5`O=0KhB&v^G5gzj=EWPUjWMn00000NkvXXu0mjfS)R!y literal 0 HcmV?d00001 diff --git a/resources/images/sunAndMoon.fla b/resources/images/sunAndMoon.fla new file mode 100644 index 0000000000000000000000000000000000000000..bd52e8f1267e9139ba268b287b951285d85bd8d4 GIT binary patch literal 7107 zcmbVRbySq=^Iw4lL}EdtYgr_hl8}%t5m34t7DQ_4Mp~u2L>fU55EKxkBt=-dg$0(7 z5D}2B-*Ua`m2>a+kKdd#=Z&4uJkNV}o;mZGQB}gkA_V|&0f5CQVf}aUb77PK0N`BF zuK@No_Apm3ILr(Vx3jS@bG31F;C6Sg36{TG^@o0jDLf#Jr4#ohu<)UECa` z94u8F9UcC%RlldJ$0?&B@Fxgu_e;*#R92K$mr~c`{%@;u_bPIlQk;r+<^P8nG1?67 zW^QNWa^DqZ54SUOg}MA~j)9B&*Z1N>sP8<&1OSq*002a2bJ=?;vW^yR_Am!mE>C;A z5$#V7^MW8h?*4}i!`5r^UAbhV7% zlI;Xb#qqgVg;`q(v5QNP)*DuZu)VUOW|pvHLS%%hcN1mS7?)2AxYnlnZkY5a{Jb)A`zehz>lV&-bO*ryZstv{S+<4(icVC4-^?u%} zICqk}toZ7p*yrw^7fz6_t_euyRj;pbC|qf4(0>E=U=lRK+11yi;)*LbN8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Q*dOA*tn%VUKU!^O({VP>wR8?}WSX$nw(>0dU;9m*}Ext#|3` zTGhnLY4}uYprnrLJW|!aC`BwQ`iwVnOP=38=%LynHqn=x_T9D!#6|iUABGkCQuvgQxSIN{%60=-UK(OMi~FE-^;u z6gFm-X{3mRFz;+#;6i3FFL!bc!Y`C*H5%iiK|b;2YTemT++A_d|d(Z*uq$Rj;1@_U|U>Q zc2|1>Jc_DA6T}k19V7!*;EHsiriJR!z9~VDZ~%(BZ`gwZh(oK|4YV4oA|kAclc9}} zYvgU)Hy2K1|8yL@77*6wjSb7l0n9gF%L0CI%ME4+(uJ2lROGGQA?jFIYRBl`IV$2k zbja$v|$2h7=moP{HzXu5yCjscF{97c@ z*9&uj3)r8Q=hyRrzz;buLS51NGbLYK@o%%gF6RS+A99XLN9(U9;s1i24-9_DIqW@J z|7Cpe<2(OrfbcgSeffsg3*&^JYyVd#^EWsj%?5sL`Om)QpX*=jZ2opJhIa8Uea`>2 zhjVuGTSy81o$LJhM_*(+zwxqY{J(IYpBwnEk<)Jn-Dn3t2T(sz|3y!Jqwvs!r=KzM zldN1sUo0wrqvO&4{6EqE%%2y%Tr3uTdpYNQKfU~2I$Q)_%-O%e)##@7Kfr(P0EjM3 S&Sz_cfDH85O5waB2K*oAd%$A= literal 0 HcmV?d00001 diff --git a/src/br/com/davidbuzatto/jsge/examples/basic/IMGUIExample.java b/src/br/com/davidbuzatto/jsge/examples/basic/IMGUIExample.java index 257121b..a6baeb1 100644 --- a/src/br/com/davidbuzatto/jsge/examples/basic/IMGUIExample.java +++ b/src/br/com/davidbuzatto/jsge/examples/basic/IMGUIExample.java @@ -18,6 +18,7 @@ import br.com.davidbuzatto.jsge.collision.CollisionUtils; import br.com.davidbuzatto.jsge.core.engine.EngineFrame; +import br.com.davidbuzatto.jsge.image.Image; import br.com.davidbuzatto.jsge.imgui.GuiButton; import br.com.davidbuzatto.jsge.imgui.GuiButtonGroup; import br.com.davidbuzatto.jsge.imgui.GuiCheckBox; @@ -134,6 +135,9 @@ public class IMGUIExample extends EngineFrame { private GuiTheme currentTheme; private ChangeThemeButton changeThemeButton; + private Image sunIcon; + private Image moonIcon; + /** * Cria o exemplo. */ @@ -296,7 +300,12 @@ public void create() { checkVisible = new GuiCheckBox( x, y += vSpacing, 100, 20, "Visible" ); checkVisible.setSelected( true ); checkDrawBounds = new GuiCheckBox( x, y += vSpacing, 100, 20, "Draw bounds" ); - changeThemeButton = new ChangeThemeButton( getScreenWidth() - 60, getScreenHeight() - 60, 50, 50 ); + + changeThemeButton = new ChangeThemeButton( + getScreenWidth() - 60, getScreenHeight() - 60, 50, 50, + loadImage( "resources/images/sun.png" ), + loadImage( "resources/images/moon.png" ) + ); toolTipLabel1 = new GuiToolTip( label1, "Top and Left Label" ); toolTipLabel2 = new GuiToolTip( label2, "Middle and Center Label" ); @@ -316,7 +325,6 @@ public void create() { interactionComponents.add( checkDrawBounds ); interactionComponents.add( changeThemeButton ); - } @Override @@ -495,14 +503,13 @@ public void update( double delta ) { if ( changeThemeButton.isMousePressed() ) { changeThemeButton.darkThemeActive = !changeThemeButton.darkThemeActive; if ( changeThemeButton.darkThemeActive ) { - darkTheme.install( components ); - darkTheme.install( interactionComponents ); currentTheme = darkTheme; } else { - lightTheme.install( components ); - lightTheme.install( interactionComponents ); currentTheme = lightTheme; } + currentTheme.apply( components ); + currentTheme.apply( interactionComponents ); + currentTheme.install(); } if ( isMouseButtonPressed( MOUSE_BUTTON_RIGHT ) ) { @@ -657,17 +664,29 @@ private void drawColoredRectangle( double x, double y, Color color ) { private class ChangeThemeButton extends GuiComponent { private boolean darkThemeActive; + private Image sunIcon; + private Image moonIcon; - public ChangeThemeButton( double x, double y, double width, double height ) { + public ChangeThemeButton( double x, double y, double width, double height, Image sunIcon, Image moonIcon ) { super( x, y, width, height ); + this.sunIcon = sunIcon; + this.moonIcon = moonIcon; } - public ChangeThemeButton( double x, double y, double width, double height, EngineFrame engine ) { + public ChangeThemeButton( double x, double y, double width, double height, Image sunIcon, Image moonIcon, EngineFrame engine ) { super( x, y, width, height, engine ); + this.sunIcon = sunIcon; + this.moonIcon = moonIcon; } @Override public void draw() { + fillRectangle( bounds, backgroundColor ); + if ( darkThemeActive ) { + drawImage( moonIcon, bounds.x, bounds.y ); + } else { + drawImage( sunIcon, bounds.x, bounds.y ); + } drawRectangle( bounds, borderColor ); } diff --git a/src/br/com/davidbuzatto/jsge/imgui/GuiDropdownList.java b/src/br/com/davidbuzatto/jsge/imgui/GuiDropdownList.java index fa15e19..9bafbed 100644 --- a/src/br/com/davidbuzatto/jsge/imgui/GuiDropdownList.java +++ b/src/br/com/davidbuzatto/jsge/imgui/GuiDropdownList.java @@ -19,7 +19,6 @@ import br.com.davidbuzatto.jsge.core.engine.EngineFrame; import br.com.davidbuzatto.jsge.geom.Rectangle; import br.com.davidbuzatto.jsge.math.MathUtils; -import br.com.davidbuzatto.jsge.math.Vector2; import java.awt.Color; import java.util.List; @@ -205,7 +204,7 @@ private void drawDropdownList( Color borderColor, Color containerColor, Color te @Override public void setEnabled( boolean enabled ) { super.setEnabled( enabled ); - itemsList.setEnabled( enabled ); + //itemsList.setEnabled( enabled ); } /** diff --git a/src/br/com/davidbuzatto/jsge/imgui/GuiTheme.java b/src/br/com/davidbuzatto/jsge/imgui/GuiTheme.java index ec022d6..98b0ba7 100644 --- a/src/br/com/davidbuzatto/jsge/imgui/GuiTheme.java +++ b/src/br/com/davidbuzatto/jsge/imgui/GuiTheme.java @@ -22,7 +22,7 @@ import java.util.List; /** - * Classe para criação de temas. + * Classe para criação, gerenciamento e instalação de temas. * * @author Prof. Dr. David Buzatto */ @@ -179,56 +179,128 @@ public static GuiTheme buildDarkTheme() { GuiTheme theme = new GuiTheme(); - theme.backgroundColor = new Color( 201, 201, 201 ); - theme.borderColor = new Color( 131, 131, 131 ); - theme.textColor = new Color( 104, 104, 104 ); + theme.backgroundColor = new Color( 60, 63, 65 ); + theme.borderColor = new Color( 97, 99, 101 ); + theme.textColor = new Color( 187, 187, 187 ); - theme.mouseOverBackgroundColor = new Color( 201, 239, 254 ); - theme.mouseOverBorderColor = new Color( 91, 178, 217 ); - theme.mouseOverTextColor = new Color( 108, 155, 188 ); + theme.mouseOverBackgroundColor = new Color( 80, 83, 85 ); + theme.mouseOverBorderColor = new Color( 118, 120, 122 ); + theme.mouseOverTextColor = new Color( 190, 190, 190 ); - theme.mouseDownBackgroundColor = new Color( 151, 232, 255 ); - theme.mouseDownBorderColor = new Color( 4, 146, 199 ); - theme.mouseDownTextColor = new Color( 54, 139, 175 ); + theme.mouseDownBackgroundColor = new Color( 103, 107, 109 ); + theme.mouseDownBorderColor = new Color( 142, 145, 147 ); + theme.mouseDownTextColor = new Color( 190, 190, 190 ); - theme.disabledBackgroundColor = new Color( 230, 233, 233 ); - theme.disabledBorderColor = new Color( 181, 193, 194 ); - theme.disabledTextColor = new Color( 174, 183, 184 ); + theme.disabledBackgroundColor = new Color( 136, 141, 145 ); + theme.disabledBorderColor = new Color( 159, 165, 168 ); + theme.disabledTextColor = new Color( 199, 201, 203 ); - theme.containerBackgroundColor = new Color( 245, 245, 245 ); - theme.containerBorderColor = new Color( 144, 171, 181 ); - theme.containerTextColor = new Color( 144, 171, 181 ); - theme.containerTitleBarBackgroundColor = new Color( 201, 201, 201 ); - theme.containerTitleBarBorderColor = new Color( 131, 131, 131 ); - theme.containerTitleBarTextColor = new Color( 104, 104, 104 ); + theme.containerBackgroundColor = new Color( 23, 23, 23 ); + theme.containerBorderColor = new Color( 110, 110, 110 ); + theme.containerTextColor = new Color( 110, 110, 110 ); + theme.containerTitleBarBackgroundColor = new Color( 20, 20, 20 ); + theme.containerTitleBarBorderColor = new Color( 80, 80, 80 ); + theme.containerTitleBarTextColor = new Color( 160, 160, 160 ); - theme.disabledContainerBackgroundColor = new Color( 230, 233, 233 ); - theme.disabledContainerBorderColor = new Color( 181, 193, 194 ); - theme.disabledContainerTextColor = new Color( 181, 193, 194 ); - theme.disabledContainerTitleBarBackgroundColor = new Color( 230, 233, 233 ); - theme.disabledContainerTitleBarBorderColor = new Color( 181, 193, 194 ); - theme.disabledContainerTitleBarTextColor = new Color( 181, 193, 194 ); + theme.disabledContainerBackgroundColor = new Color( 136, 141, 145 ); + theme.disabledContainerBorderColor = new Color( 159, 165, 168 ); + theme.disabledContainerTextColor = new Color( 199, 201, 203 ); + theme.disabledContainerTitleBarBackgroundColor = new Color( 136, 141, 145 ); + theme.disabledContainerTitleBarBorderColor = new Color( 159, 165, 168 ); + theme.disabledContainerTitleBarTextColor = new Color( 199, 201, 203 ); - theme.progressBarProgressFillColor = new Color( 151, 232, 255 ); + theme.progressBarProgressFillColor = new Color( 180, 180, 180 ); - theme.listContainerBackgroundColor = new Color( 245, 245, 245 ); - theme.disabledListContainerBackgroundColor = new Color( 245, 245, 245 ); + theme.listContainerBackgroundColor = new Color( 60, 63, 65 ); + theme.disabledListContainerBackgroundColor = new Color( 121, 128, 132 ); - theme.scrollBarTrackColor = new Color( 220, 220, 220 ); - theme.disabledScrollBarTrackColor = new Color( 220, 220, 220 ); + theme.scrollBarTrackColor = new Color( 180, 180, 180 ); + theme.disabledScrollBarTrackColor = new Color( 180, 180, 180 ); theme.colorPickerDisabledOverlayColor = ColorUtils.fade( EngineFrame.LIGHTGRAY, 0.5 ); theme.dialogOverlayColor = new Color( 0, 0, 0, 100 ); - theme.toolTipBackgroundColor = new Color( 230, 233, 233 ); - theme.toolTipBorderColor = new Color( 181, 193, 194 ); - theme.toolTipTextColor = new Color( 130, 130, 130 ); + theme.toolTipBackgroundColor = new Color( 30, 32, 33 ); + theme.toolTipBorderColor = new Color( 130, 130, 130 ); + theme.toolTipTextColor = new Color( 187, 187, 187 ); return theme; } + /** + * Cria um novo tema usando uma cor básica e sua inversa para destaques. + * + * @param color A cor. + * @return Um tema de cor base. + */ + public static GuiTheme buildColoredTheme( Color color ) { + + GuiTheme theme = new GuiTheme(); + Color inv = ColorUtils.colorInvert( color ); + Color cw = ColorUtils.lerp( color, Color.WHITE, 0.5 ); + Color cb = ColorUtils.lerp( color, Color.BLACK, 0.5 ); + + theme.backgroundColor = ColorUtils.colorBrightness( color, .1 ); + theme.borderColor = ColorUtils.colorBrightness( color, -.2 ); + theme.textColor = ColorUtils.colorBrightness( color, -.3 ); + + theme.mouseOverBackgroundColor = ColorUtils.colorBrightness( inv, .2 ); + theme.mouseOverBorderColor = ColorUtils.colorBrightness( inv, -.3 ); + theme.mouseOverTextColor = ColorUtils.colorBrightness( inv, .7 ); + + theme.mouseDownBackgroundColor = ColorUtils.colorBrightness( inv, -.1 ); + theme.mouseDownBorderColor = ColorUtils.colorBrightness( inv, -.25 ); + theme.mouseDownTextColor = ColorUtils.colorBrightness( inv, .7 ); + + theme.disabledBackgroundColor = ColorUtils.colorBrightness( cw, -.1 ); + theme.disabledBorderColor = ColorUtils.colorBrightness( cw, -.2 ); + theme.disabledTextColor = ColorUtils.colorBrightness( cw, .8 ); + + theme.containerBackgroundColor = ColorUtils.colorBrightness( cw, .1 ); + theme.containerBorderColor = ColorUtils.colorBrightness( cw, -.2 );; + theme.containerTextColor = ColorUtils.colorBrightness( cw, -.4 ); + theme.containerTitleBarBackgroundColor = ColorUtils.colorBrightness( cb, .1 ); + theme.containerTitleBarBorderColor = ColorUtils.colorBrightness( cb, -.2 ); + theme.containerTitleBarTextColor = ColorUtils.colorBrightness( cw, .2 ); + + theme.disabledContainerBackgroundColor = ColorUtils.colorBrightness( cw, -.1 ); + theme.disabledContainerBorderColor = ColorUtils.colorBrightness( cw, -.2 ); + theme.disabledContainerTextColor = ColorUtils.colorBrightness( cw, .8 ); + theme.disabledContainerTitleBarBackgroundColor = ColorUtils.colorBrightness( cw, -.3 ); + theme.disabledContainerTitleBarBorderColor = ColorUtils.colorBrightness( cw, -.4 ); + theme.disabledContainerTitleBarTextColor = ColorUtils.colorBrightness( cw, .8 ); + + theme.progressBarProgressFillColor = ColorUtils.colorBrightness( inv, -.1 ); + + theme.listContainerBackgroundColor = ColorUtils.colorBrightness( color, .3 ); + theme.disabledListContainerBackgroundColor = ColorUtils.colorBrightness( cw, -.1 ); + + theme.scrollBarTrackColor = ColorUtils.colorBrightness( cw, -.1 ); + theme.disabledScrollBarTrackColor = ColorUtils.colorBrightness( cw, -.1 ); + + theme.colorPickerDisabledOverlayColor = ColorUtils.fade( EngineFrame.LIGHTGRAY, 0.5 ); + + theme.dialogOverlayColor = new Color( 0, 0, 0, 100 ); + + theme.toolTipBackgroundColor = ColorUtils.colorBrightness( cb, .1 ); + theme.toolTipBorderColor = ColorUtils.colorBrightness( cb, -.2 ); + theme.toolTipTextColor = ColorUtils.colorBrightness( cw, .2 ); + + return theme; + + } + + /** + * Cria um tema "vazio", usando a cor cinza. + * + * @return O tema cinza. + */ + public static GuiTheme buildEmptyTheme() { + return buildColoredTheme( EngineFrame.LIGHTGRAY ); + } + /** * Instala o tema globalmente. Deve ser usado antes de se inciciar a criação * dos componentes. @@ -284,50 +356,66 @@ public void install() { } /** - * Instala o tema globalmente, para os novos componentes que forem criados, - * e nos componentes passados que já foram criados. + * Aplica o tema nos componentes passados. * * @param components Os componentes. */ - public void install( List components ) { - install(); + public void apply( List components ) { for ( GuiComponent c : components ) { - install( c ); + apply( c ); } } /** - * Instala o tema globalmente, para os novos componentes que forem criados, - * e nos componentes passados que já foram criados. + * Aplica o tema nos componentes passados. * * @param components Os componentes. */ - public void install( GuiComponent... components ) { - install(); + public void apply( GuiComponent... components ) { for ( GuiComponent c : components ) { - install( c ); + apply( c ); } } /** - * Instala o tema em um componente e em seus subcomponentes se necessário. + * Instala o tema globalmente e o aplica nos componentes passados. + * + * @param components Os componentes. + */ + public void installAndApply( List components ) { + install(); + apply( components ); + } + + /** + * Instala o tema globalmente e o aplica nos componentes passados. + * + * @param components Os componentes. + */ + public void installAndApply( GuiComponent... components ) { + install(); + apply( components ); + } + + /** + * Aplica o tema em um componente e em seus subcomponentes se necessário. * * @param component O componente. */ - private void install( GuiComponent component ) { + public void apply( GuiComponent component ) { component.setBackgroundColor( backgroundColor ); component.setBorderColor( borderColor ); component.setTextColor( textColor ); if ( component instanceof GuiColorPicker c ) { - install( c.hueSlider ); - install( c.alphaSlider ); + apply( c.hueSlider ); + apply( c.alphaSlider ); } else if ( component instanceof GuiDropdownList c ) { - install( c.itemsList ); + apply( c.itemsList ); } else if ( component instanceof GuiGlue c ) { - install( c.baseComponent ); - install( c.children ); + apply( c.baseComponent ); + GuiTheme.this.installAndApply( c.children ); } else if ( component instanceof GuiGroup c ) { c.setBorderColor( containerBorderColor ); c.setTextColor( containerTextColor ); @@ -337,7 +425,7 @@ private void install( GuiComponent component ) { } else if ( component instanceof GuiList c ) { c.setBackgroundColor( listContainerBackgroundColor ); c.setScrollBarTrackColor( scrollBarTrackColor ); - install( c.scrollBar ); + apply( c.scrollBar ); } else if ( component instanceof GuiPanel c ) { c.setBackgroundColor( containerBackgroundColor ); c.setBorderColor( containerBorderColor ); @@ -349,11 +437,11 @@ private void install( GuiComponent component ) { } else if ( component instanceof GuiSlider c ) { c.setBackgroundColor( containerBackgroundColor ); c.setTrackFillColor( mouseOverBackgroundColor ); - install( c.sliderButton ); + apply( c.sliderButton ); } else if ( component instanceof GuiSpinner c ) { c.setBackgroundColor( containerBackgroundColor ); - install( c.leftButton ); - install( c.rightButton ); + apply( c.leftButton ); + apply( c.rightButton ); } else if ( component instanceof GuiTextField c ) { c.setBackgroundColor( containerBackgroundColor ); } else if ( component instanceof GuiToolTip c ) { @@ -361,25 +449,25 @@ private void install( GuiComponent component ) { c.setBorderColor( toolTipBorderColor ); c.setTextColor( toolTipTextColor ); } else if ( component instanceof GuiWindow c ) { - install( c.closeButton ); + apply( c.closeButton ); c.setBackgroundColor( containerBackgroundColor ); c.setBorderColor( containerBorderColor ); c.setTitleBarBackgroundColor( containerTitleBarBackgroundColor ); c.setTitleBarBorderColor( containerTitleBarBorderColor ); c.setTitleBarTextColor( containerTitleBarTextColor ); if ( c instanceof GuiConfirmDialog d ) { - install( d.messageLabel ); - install( d.button1 ); - install( d.button2 ); - install( d.button3 ); + apply( d.messageLabel ); + apply( d.button1 ); + apply( d.button2 ); + apply( d.button3 ); } else if ( c instanceof GuiInputDialog d ) { - install( d.messageLabel ); - install( d.okButton ); - install( d.cancelButton ); - install( d.textField ); + apply( d.messageLabel ); + apply( d.okButton ); + apply( d.cancelButton ); + apply( d.textField ); } else if ( c instanceof GuiMessageDialog d ) { - install( d.messageLabel ); - install( d.okButton ); + apply( d.messageLabel ); + apply( d.okButton ); } }