Skip to content

Commit 64b91f6

Browse files
author
Earth1283
committed
redesigned ui
1 parent 312e19d commit 64b91f6

4 files changed

Lines changed: 146 additions & 96 deletions

File tree

pymcl/animated_widgets.py

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,36 @@ def __init__(self, text="", parent=None, is_secondary=False, is_destructive=Fals
77
super().__init__(text, parent)
88
self.setCursor(Qt.CursorShape.PointingHandCursor)
99

10-
self.default_color = QColor("#4a9eff")
11-
self.hover_color = QColor("#5badff")
12-
self.pressed_color = QColor("#3a8eef")
10+
self.default_color = QColor("#3b82f6") # Vibrant Blue
11+
self.hover_color = QColor("#60a5fa") # Lighter Blue
12+
self.pressed_color = QColor("#2563eb") # Darker Blue
1313

1414
if is_secondary:
15-
self.default_color = QColor("#3c3c3c")
16-
self.hover_color = QColor("#4a4a4a")
17-
self.pressed_color = QColor("#303030")
15+
self.default_color = QColor(255, 255, 255, 13) # rgba(255,255,255,0.05)
16+
self.hover_color = QColor(255, 255, 255, 26) # rgba(255,255,255,0.1)
17+
self.pressed_color = QColor(255, 255, 255, 5) # rgba(255,255,255,0.02)
1818
elif is_destructive:
19-
self.default_color = QColor(200, 50, 50)
20-
self.hover_color = QColor(220, 70, 70)
21-
self.pressed_color = QColor(180, 40, 40)
19+
self.default_color = QColor(239, 68, 68) # Red-500
20+
self.hover_color = QColor(248, 113, 113) # Red-400
21+
self.pressed_color = QColor(220, 38, 38) # Red-600
2222

2323
self._bg_color = self.default_color
24+
25+
# Add Drop Shadow Glow Effect
26+
self._shadow_blur = 5.0
27+
self._shadow_effect = QGraphicsDropShadowEffect(self)
28+
self._shadow_effect.setBlurRadius(self._shadow_blur)
29+
30+
# Set shadow color based on button type
31+
if is_secondary:
32+
self._shadow_effect.setColor(QColor(0, 0, 0, 0)) # No glow for secondary
33+
elif is_destructive:
34+
self._shadow_effect.setColor(QColor(239, 68, 68, 120))
35+
else:
36+
self._shadow_effect.setColor(QColor(59, 130, 246, 120)) # Blue glow
37+
38+
self._shadow_effect.setOffset(0, 0) # Center the glow
39+
self.setGraphicsEffect(self._shadow_effect)
2440

2541
# Stylesheet base - we handle background color via animation,
2642
# so remove background-color from stylesheet if we want pure py animation,
@@ -46,37 +62,59 @@ def _get_bg_color(self):
4662

4763
def _set_bg_color(self, color):
4864
self._bg_color = color
65+
66+
# We handle secondary buttons differently to allow transparent backgrounds
67+
if color.alpha() < 255:
68+
# We use rgba string formatting for transparency
69+
bg_string = f"rgba({color.red()}, {color.green()}, {color.blue()}, {color.alpha() / 255.0:.2f})"
70+
else:
71+
bg_string = color.name()
72+
4973
self.setStyleSheet(f"""
5074
QPushButton {{
51-
background-color: {color.name()};
75+
background-color: {bg_string};
5276
color: white;
53-
border-radius: 8px;
54-
padding: 0 20px;
77+
border-radius: 12px;
78+
padding: 0 24px;
5579
font-size: 15px;
56-
font-weight: 600;
57-
border: none;
80+
font-weight: 700;
81+
border: 1px solid rgba(255,255,255,0.1);
5882
}}
5983
""")
6084

6185
bg_color = pyqtProperty(QColor, _get_bg_color, _set_bg_color)
86+
87+
def _get_shadow_blur(self):
88+
return self._shadow_blur
89+
90+
def _set_shadow_blur(self, radius):
91+
self._shadow_blur = radius
92+
self._shadow_effect.setBlurRadius(radius)
93+
94+
shadow_blur = pyqtProperty(float, _get_shadow_blur, _set_shadow_blur)
6295

6396
def enterEvent(self, event):
6497
self.animate_color(self.hover_color)
98+
self.animate_glow(25.0) # Intensify glow
6599
super().enterEvent(event)
66100

67101
def leaveEvent(self, event):
68102
self.animate_color(self.default_color)
103+
self.animate_glow(5.0) # Reduce glow
69104
super().leaveEvent(event)
70105

71106
def mousePressEvent(self, event):
72107
self.animate_color(self.pressed_color)
108+
self.animate_glow(10.0)
73109
super().mousePressEvent(event)
74110

75111
def mouseReleaseEvent(self, event):
76112
if self.underMouse():
77113
self.animate_color(self.hover_color)
114+
self.animate_glow(25.0)
78115
else:
79116
self.animate_color(self.default_color)
117+
self.animate_glow(5.0)
80118
super().mouseReleaseEvent(event)
81119

82120
def animate_color(self, target_color):
@@ -86,6 +124,13 @@ def animate_color(self, target_color):
86124
self.anim.setEndValue(target_color)
87125
self.anim.start()
88126

127+
def animate_glow(self, target_radius):
128+
self.glow_anim = QPropertyAnimation(self, b"shadow_blur")
129+
self.glow_anim.setDuration(200)
130+
self.glow_anim.setStartValue(self._shadow_blur)
131+
self.glow_anim.setEndValue(target_radius)
132+
self.glow_anim.start()
133+
89134

90135
class ShakeWidget(QObject): # Mixin or helper?
91136
pass # implementing directly in widget for now for simplicity

pymcl/launch_page.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def __init__(self, parent=None):
2626

2727
container = QWidget()
2828
layout = QVBoxLayout(container)
29-
layout.setContentsMargins(20, 20, 20, 20)
30-
layout.setSpacing(10)
29+
layout.setContentsMargins(30, 30, 30, 30)
30+
layout.setSpacing(12)
3131

3232
self.auth_method_label = QLabel("AUTHENTICATION")
3333
self.auth_method_label.setObjectName("section_label")
@@ -41,7 +41,7 @@ def __init__(self, parent=None):
4141
self.auth_method_combo.setToolTip("Choose 'Microsoft' for online play or 'Offline' for local play.")
4242
layout.addWidget(self.auth_method_combo)
4343

44-
layout.addSpacing(15)
44+
layout.addSpacing(25)
4545

4646
self.username_label = QLabel("USERNAME")
4747
self.username_label.setObjectName("section_label")
@@ -61,7 +61,7 @@ def __init__(self, parent=None):
6161
self.microsoft_login_button.setToolTip("Sign in with your Microsoft account to play online.")
6262
layout.addWidget(self.microsoft_login_button)
6363

64-
layout.addSpacing(15)
64+
layout.addSpacing(25)
6565

6666
version_label = QLabel("MINECRAFT VERSION")
6767
version_label.setObjectName("section_label")
@@ -75,7 +75,7 @@ def __init__(self, parent=None):
7575
self.version_combo.setToolTip("Select the Minecraft version to launch.")
7676
layout.addWidget(self.version_combo)
7777

78-
layout.addSpacing(15)
78+
layout.addSpacing(25)
7979

8080
mod_layout = QHBoxLayout()
8181
mod_layout.setSpacing(15)
@@ -99,7 +99,7 @@ def __init__(self, parent=None):
9999

100100
layout.addLayout(mod_layout)
101101

102-
layout.addSpacing(15)
102+
layout.addSpacing(30)
103103

104104
self.launch_button = AnimatedButton("🚀 LAUNCH GAME")
105105
self.launch_button.setMinimumHeight(55)

pymcl/main_window.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def init_ui(self):
141141
left_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
142142
left_scroll.setFrameShape(QFrame.Shape.NoFrame)
143143
left_scroll.setStyleSheet("background: transparent;") # Transparent background
144+
left_scroll.setMinimumWidth(220)
144145

145146
# Left navigation container
146147
left_widget = QWidget()
@@ -156,7 +157,7 @@ def init_ui(self):
156157
title_frame.setObjectName("title_frame")
157158
title_frame_layout = QVBoxLayout(title_frame)
158159
title_frame_layout.setSpacing(0)
159-
title_frame_layout.setContentsMargins(20, 20, 20, 20)
160+
title_frame_layout.setContentsMargins(15, 20, 15, 30)
160161

161162
title_label = QLabel(APP_NAME)
162163
title_label.setObjectName("title_label")
@@ -393,15 +394,15 @@ def apply_styles(self):
393394

394395
def add_shadow_effects(self):
395396
shadow = QGraphicsDropShadowEffect()
396-
shadow.setBlurRadius(30)
397-
shadow.setColor(QColor(0, 0, 0, 100))
398-
shadow.setOffset(0, 5)
397+
shadow.setBlurRadius(40)
398+
shadow.setColor(QColor(0, 0, 0, 150))
399+
shadow.setOffset(0, 8)
399400
self.findChild(QFrame, "central_widget_frame").setGraphicsEffect(shadow)
400401

401402
title_shadow = QGraphicsDropShadowEffect()
402-
title_shadow.setBlurRadius(20)
403-
title_shadow.setColor(QColor(0, 0, 0, 80))
404-
title_shadow.setOffset(0, 3)
403+
title_shadow.setBlurRadius(25)
404+
title_shadow.setColor(QColor(0, 0, 0, 100))
405+
title_shadow.setOffset(0, 4)
405406
self.findChild(QFrame, "title_frame").setGraphicsEffect(title_shadow)
406407

407408
def init_background_images(self):

0 commit comments

Comments
 (0)