1919import net .minecraft .client .gui .Click ;
2020
2121public class WCatppuccinWindow extends WWindow implements CatppuccinWidget {
22- private final int shadowOffset = 2 ;
22+ private static final int SHADOW_OFFSET = 2 ;
2323
2424 private CatppuccinModulesScreen modulesScreen ;
2525 private boolean shouldSnap = false ;
@@ -57,15 +57,21 @@ public void initSnapping(CatppuccinModulesScreen modulesScreen, int gridSize) {
5757 @ Override
5858 protected void onRender (GuiRenderer renderer , double mouseX , double mouseY , double delta ) {
5959 CatppuccinGuiTheme theme = theme ();
60- Color shadowColor = ColorUtils .withAlpha (theme .crustColor (), 0.4 );
6160 Color backgroundColor = ColorUtils .withAlpha (theme .mantleColor (), theme .windowOpacity ());
6261
62+ int shadowOffset = getShadowOffset ();
63+
6364 // Shadow rectangle
64- roundedRect ().pos (x - shadowOffset , y - shadowOffset )
65- .size (width + shadowOffset * 2 , (expanded || animation .isRunning () ? height : header .height ) + shadowOffset * 2 )
66- .radius (radius () + shadowOffset )
67- .color (shadowColor )
68- .render ();
65+ if (theme .windowShadow .get ()) {
66+ Color shadowColor = ColorUtils .withAlpha (theme .crustColor (), 0.4 );
67+
68+ roundedRect ().pos (x - shadowOffset , y - shadowOffset )
69+ .size (width + shadowOffset * 2 , (expanded || animation .isRunning () ? height : header .height ) + shadowOffset * 2 )
70+ .radius (radius () + shadowOffset )
71+ .color (shadowColor )
72+ .render ();
73+
74+ }
6975
7076 // Inner rectangle
7177 if (expanded || animation .isRunning ())
@@ -83,13 +89,16 @@ public boolean render(GuiRenderer renderer, double mouseX, double mouseY, double
8389 double progress = animation .getProgress ();
8490 boolean useScissor = animation .isRunning ();
8591
86- if (useScissor )
92+ if (useScissor ) {
93+ int shadowOffset = getShadowOffset ();
94+
8795 renderer .scissorStart (
8896 x - shadowOffset ,
8997 y - shadowOffset ,
9098 width + shadowOffset * 2 ,
9199 (height - header .height ) * progress + header .height + shadowOffset * 2
92100 );
101+ }
93102
94103 boolean toReturn = super .render (renderer , mouseX , mouseY , delta );
95104
@@ -269,4 +278,8 @@ public void setIndicator(boolean open) {
269278 private double snapToGrid (double value ) {
270279 return (Math .round (value / gridSize ) * gridSize );
271280 }
281+
282+ private int getShadowOffset () {
283+ return theme ().windowShadow .get () ? SHADOW_OFFSET : 0 ;
284+ }
272285}
0 commit comments