Expanded Player formatting
This commit is contained in:
1 parent
cc5a116efb
commit
b5211b3446
2 files changed
+69
-68
No files matched your search
@@ -14,7 +14,6 @@ from typing import List
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
from fabric.utils import bulk_connect, invoke_repeater, cooldown
|
from fabric.utils import bulk_connect, invoke_repeater, cooldown
|
||||||
from fabric.widgets.centerbox import CenterBox
|
|
||||||
from fabric.widgets.image import Image
|
from fabric.widgets.image import Image
|
||||||
from fabric.widgets.overlay import Overlay
|
from fabric.widgets.overlay import Overlay
|
||||||
from fabric.widgets.stack import Stack
|
from fabric.widgets.stack import Stack
|
||||||
@@ -193,9 +192,10 @@ class PlayerBoxStack(Box):
|
|||||||
name="macos-album-cover-image",
|
name="macos-album-cover-image",
|
||||||
pixbuf=None,
|
pixbuf=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||||
fallback_cover_path, 80, 80, True
|
fallback_cover_path, 80, 80, True
|
||||||
)
|
)
|
||||||
@@ -203,7 +203,7 @@ class PlayerBoxStack(Box):
|
|||||||
album_cover_image.set_size_request(80, 80)
|
album_cover_image.set_size_request(80, 80)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to load fallback image in no-media box: {e}")
|
logger.warning(f"Failed to load fallback image in no-media box: {e}")
|
||||||
|
|
||||||
album_cover = Box(
|
album_cover = Box(
|
||||||
name="macos-album-image",
|
name="macos-album-image",
|
||||||
children=[album_cover_image],
|
children=[album_cover_image],
|
||||||
@@ -520,7 +520,7 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
self.track_artist = Label(
|
self.track_artist = Label(
|
||||||
label="No Artist",
|
label="No Artist",
|
||||||
name="macos-player-artist",
|
name="macos-player-artist",
|
||||||
justification="left",
|
justification="left",
|
||||||
max_chars_width=30,
|
max_chars_width=30,
|
||||||
ellipsization="end",
|
ellipsization="end",
|
||||||
@@ -534,10 +534,11 @@ class PlayerBox(Box):
|
|||||||
name="macos-album-cover-image",
|
name="macos-album-cover-image",
|
||||||
pixbuf=None,
|
pixbuf=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set fallback image immediately with proper scaling
|
# Set fallback image immediately with proper scaling
|
||||||
try:
|
try:
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||||
self.fallback_cover_path, 80, 80, True
|
self.fallback_cover_path, 80, 80, True
|
||||||
)
|
)
|
||||||
@@ -545,7 +546,7 @@ class PlayerBox(Box):
|
|||||||
self.album_cover_image.set_size_request(80, 80)
|
self.album_cover_image.set_size_request(80, 80)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to load fallback image: {e}")
|
logger.warning(f"Failed to load fallback image: {e}")
|
||||||
|
|
||||||
# Container box for styling with fixed size
|
# Container box for styling with fixed size
|
||||||
self.album_cover = Box(
|
self.album_cover = Box(
|
||||||
name="macos-album-image",
|
name="macos-album-image",
|
||||||
@@ -554,13 +555,16 @@ class PlayerBox(Box):
|
|||||||
self.album_cover.set_size_request(80, 80)
|
self.album_cover.set_size_request(80, 80)
|
||||||
|
|
||||||
self.image_stack = Box(
|
self.image_stack = Box(
|
||||||
h_align="start", v_align="start", name="macos-player-image-stack"
|
h_align="start",
|
||||||
|
v_align="start",
|
||||||
|
h_expand=False, # Fixed width for album art
|
||||||
|
name="macos-player-image-stack"
|
||||||
)
|
)
|
||||||
self.image_stack.children = [*self.image_stack.children, self.album_cover]
|
self.image_stack.children = [*self.image_stack.children, self.album_cover]
|
||||||
|
|
||||||
# Seek bar should not update automatically during user interaction
|
# Seek bar should not update automatically during user interaction
|
||||||
self._user_seeking = False
|
self._user_seeking = False
|
||||||
|
|
||||||
self.seek_bar = Scale(
|
self.seek_bar = Scale(
|
||||||
value=0,
|
value=0,
|
||||||
min_value=0,
|
min_value=0,
|
||||||
@@ -585,7 +589,7 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
self.length_label = Label(
|
self.length_label = Label(
|
||||||
label="0:00",
|
label="0:00",
|
||||||
name="macos-length-label",
|
name="macos-length-label",
|
||||||
justification="right",
|
justification="right",
|
||||||
h_align="end",
|
h_align="end",
|
||||||
)
|
)
|
||||||
@@ -616,26 +620,29 @@ class PlayerBox(Box):
|
|||||||
self.button_box = Box(
|
self.button_box = Box(
|
||||||
name="macos-button-box",
|
name="macos-button-box",
|
||||||
h_align="center",
|
h_align="center",
|
||||||
|
h_expand=True,
|
||||||
spacing=15, # Wider spacing for macOS look
|
spacing=15, # Wider spacing for macOS look
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define controls_box BEFORE using it in track_info
|
# Define controls_box BEFORE using it in track_info
|
||||||
self.controls_box = Box(
|
self.controls_box = Box(
|
||||||
name="macos-player-controls",
|
name="macos-player-controls",
|
||||||
orientation="v",
|
orientation="v",
|
||||||
|
h_expand=True,
|
||||||
spacing=8,
|
spacing=8,
|
||||||
h_align="center",
|
h_align="center",
|
||||||
children=[self.button_box],
|
children=[self.button_box],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Track info with inline controls - more compact layout
|
# Track info with inline controls - expands to fill available space
|
||||||
self.track_info = Box(
|
self.track_info = Box(
|
||||||
name="macos-track-info",
|
name="macos-track-info",
|
||||||
spacing=6, # Reduced spacing
|
spacing=6, # Reduced spacing
|
||||||
orientation="v",
|
orientation="v",
|
||||||
v_align="start",
|
v_align="start",
|
||||||
h_align="start",
|
h_align="fill", # Fill all available horizontal space
|
||||||
h_expand=True,
|
h_expand=True, # Expand horizontally to take maximum space
|
||||||
|
v_expand=True, # Also expand vertically
|
||||||
children=[
|
children=[
|
||||||
self.track_title,
|
self.track_title,
|
||||||
self.track_artist,
|
self.track_artist,
|
||||||
@@ -666,11 +673,11 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
# Player switcher buttons box (compact, minimal space)
|
# Player switcher buttons box (compact, minimal space)
|
||||||
self.stack_buttons_box = Box(
|
self.stack_buttons_box = Box(
|
||||||
h_expand=False,
|
h_expand=False, # Fixed width, don't expand
|
||||||
v_expand=False,
|
v_expand=True,
|
||||||
name="macos-stack-buttons-box",
|
name="macos-stack-buttons-box",
|
||||||
spacing=4, # Reduced spacing
|
spacing=4, # Reduced spacing
|
||||||
orientation="h", # Horizontal layout for compactness
|
orientation="v", # Vertical layout for compactness
|
||||||
h_align="end",
|
h_align="end",
|
||||||
v_align="start",
|
v_align="start",
|
||||||
)
|
)
|
||||||
@@ -690,7 +697,7 @@ class PlayerBox(Box):
|
|||||||
self.player.bind_property("can_pause", self.play_pause_button, "sensitive")
|
self.player.bind_property("can_pause", self.play_pause_button, "sensitive")
|
||||||
|
|
||||||
self.next_button = Button(
|
self.next_button = Button(
|
||||||
name="macos-control-button",
|
name="macos-control-button",
|
||||||
child=self.skip_next_icon,
|
child=self.skip_next_icon,
|
||||||
on_clicked=self._on_player_next,
|
on_clicked=self._on_player_next,
|
||||||
)
|
)
|
||||||
@@ -711,30 +718,15 @@ class PlayerBox(Box):
|
|||||||
self.outer_box = Box(
|
self.outer_box = Box(
|
||||||
name="macos-outer-player-box",
|
name="macos-outer-player-box",
|
||||||
orientation="horizontal",
|
orientation="horizontal",
|
||||||
spacing=15,
|
spacing=15, # Good spacing between elements
|
||||||
h_align="start",
|
h_expand=True,
|
||||||
|
v_expand=True,
|
||||||
|
v_align="center",
|
||||||
|
h_align="fill", # Fill available space
|
||||||
children=[
|
children=[
|
||||||
self.image_stack, # Album art on left
|
self.image_stack, # Album art on left (fixed width)
|
||||||
Box(
|
self.track_info, # Contains title, artist, seek bar AND controls (expands)
|
||||||
name="macos-main-section",
|
self.stack_buttons_box, # Compact switcher in corner (fixed width)
|
||||||
orientation="v",
|
|
||||||
spacing=0,
|
|
||||||
h_expand=True,
|
|
||||||
v_align="center",
|
|
||||||
children=[
|
|
||||||
# Header with player switcher in corner
|
|
||||||
Box(
|
|
||||||
orientation="h",
|
|
||||||
h_expand=True,
|
|
||||||
children=[
|
|
||||||
Box(h_expand=True), # Spacer
|
|
||||||
self.stack_buttons_box, # Compact switcher in corner
|
|
||||||
],
|
|
||||||
),
|
|
||||||
# Main content area
|
|
||||||
self.track_info, # Contains title, artist, seek bar AND controls now
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -806,7 +798,9 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
# Connect click handler to switch to this player
|
# Connect click handler to switch to this player
|
||||||
def make_click_handler(index):
|
def make_click_handler(index):
|
||||||
return lambda *_: self.player_stack.on_player_clicked_by_index(index)
|
return lambda *_: self.player_stack.on_player_clicked_by_index(
|
||||||
|
index
|
||||||
|
)
|
||||||
|
|
||||||
dot_button.connect("clicked", make_click_handler(i))
|
dot_button.connect("clicked", make_click_handler(i))
|
||||||
self.stack_buttons_box.children = [
|
self.stack_buttons_box.children = [
|
||||||
@@ -894,7 +888,7 @@ class PlayerBox(Box):
|
|||||||
def _update_image(self, image_path):
|
def _update_image(self, image_path):
|
||||||
try:
|
try:
|
||||||
from gi.repository import GdkPixbuf
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
if image_path and os.path.isfile(image_path):
|
if image_path and os.path.isfile(image_path):
|
||||||
# Create scaled pixbuf to ensure proper size
|
# Create scaled pixbuf to ensure proper size
|
||||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||||
@@ -918,7 +912,7 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
def _set_image(self, *_):
|
def _set_image(self, *_):
|
||||||
art_url = self.player.arturl
|
art_url = self.player.arturl
|
||||||
|
|
||||||
# If no art URL or empty/None, use fallback
|
# If no art URL or empty/None, use fallback
|
||||||
if not art_url:
|
if not art_url:
|
||||||
self._update_image(None)
|
self._update_image(None)
|
||||||
@@ -1023,7 +1017,7 @@ class PlayerBox(Box):
|
|||||||
|
|
||||||
position = self.player.position
|
position = self.player.position
|
||||||
self.position_label.set_label(self.length_str(position))
|
self.position_label.set_label(self.length_str(position))
|
||||||
|
|
||||||
# Only update seek bar if user is not currently seeking
|
# Only update seek bar if user is not currently seeking
|
||||||
if not self._user_seeking:
|
if not self._user_seeking:
|
||||||
# Clamp position to avoid 32-bit integer overflow
|
# Clamp position to avoid 32-bit integer overflow
|
||||||
@@ -1032,6 +1026,7 @@ class PlayerBox(Box):
|
|||||||
self.seek_bar.set_value(safe_position)
|
self.seek_bar.set_value(safe_position)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _on_seek_start(self, widget, event):
|
def _on_seek_start(self, widget, event):
|
||||||
"""User started seeking - disable automatic updates"""
|
"""User started seeking - disable automatic updates"""
|
||||||
self._user_seeking = True
|
self._user_seeking = True
|
||||||
@@ -1053,7 +1048,7 @@ class PlayerBox(Box):
|
|||||||
try:
|
try:
|
||||||
self.player.position = new_position
|
self.player.position = new_position
|
||||||
self.position_label.set_label(self.length_str(new_position))
|
self.position_label.set_label(self.length_str(new_position))
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# If setting position fails, just update the label
|
# If setting position fails, just update the label
|
||||||
self.position_label.set_label(self.length_str(new_position))
|
self.position_label.set_label(self.length_str(new_position))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
+29
-23
@@ -396,7 +396,7 @@
|
|||||||
min-width: 20px;
|
min-width: 20px;
|
||||||
min-height: 20px;
|
min-height: 20px;
|
||||||
margin: -7px;
|
margin: -7px;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 2px 8px alpha(#000, 0.15),
|
0 2px 8px alpha(#000, 0.15),
|
||||||
0 1px 3px alpha(#000, 0.2);
|
0 1px 3px alpha(#000, 0.2);
|
||||||
transition: all 0.15s ease;
|
transition: all 0.15s ease;
|
||||||
@@ -405,7 +405,7 @@
|
|||||||
#apple-volume-slider slider:hover {
|
#apple-volume-slider slider:hover {
|
||||||
background: linear-gradient(135deg, #ffffff 0%, #f0f1f2 100%);
|
background: linear-gradient(135deg, #ffffff 0%, #f0f1f2 100%);
|
||||||
border-color: #007aff;
|
border-color: #007aff;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 4px 12px alpha(#000, 0.2),
|
0 4px 12px alpha(#000, 0.2),
|
||||||
0 2px 6px alpha(#007aff, 0.3);
|
0 2px 6px alpha(#007aff, 0.3);
|
||||||
min-width: 22px;
|
min-width: 22px;
|
||||||
@@ -418,7 +418,7 @@
|
|||||||
min-width: 21px;
|
min-width: 21px;
|
||||||
min-height: 21px;
|
min-height: 21px;
|
||||||
margin: -7.5px;
|
margin: -7.5px;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 2px 6px alpha(#000, 0.25),
|
0 2px 6px alpha(#000, 0.25),
|
||||||
0 1px 3px alpha(#007aff, 0.4);
|
0 1px 3px alpha(#007aff, 0.4);
|
||||||
}
|
}
|
||||||
@@ -500,7 +500,7 @@
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
min-height: 20px;
|
min-height: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#apple-seek-bar trough {
|
#apple-seek-bar trough {
|
||||||
@@ -526,7 +526,7 @@
|
|||||||
min-width: 12px;
|
min-width: 12px;
|
||||||
min-height: 12px;
|
min-height: 12px;
|
||||||
margin: -4.5px;
|
margin: -4.5px;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 1px 3px alpha(#000, 0.2),
|
0 1px 3px alpha(#000, 0.2),
|
||||||
0 0 0 1px alpha(#fff, 0.8);
|
0 0 0 1px alpha(#fff, 0.8);
|
||||||
transition: all 0.1s ease;
|
transition: all 0.1s ease;
|
||||||
@@ -538,7 +538,7 @@
|
|||||||
min-width: 14px;
|
min-width: 14px;
|
||||||
min-height: 14px;
|
min-height: 14px;
|
||||||
margin: -5.5px;
|
margin: -5.5px;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 2px 6px alpha(#000, 0.25),
|
0 2px 6px alpha(#000, 0.25),
|
||||||
0 0 0 2px alpha(#007aff, 0.3);
|
0 0 0 2px alpha(#007aff, 0.3);
|
||||||
}
|
}
|
||||||
@@ -548,20 +548,20 @@
|
|||||||
min-width: 13px;
|
min-width: 13px;
|
||||||
min-height: 13px;
|
min-height: 13px;
|
||||||
margin: -5px;
|
margin: -5px;
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 1px 3px alpha(#000, 0.3),
|
0 1px 3px alpha(#000, 0.3),
|
||||||
0 0 0 2px alpha(#007aff, 0.5);
|
0 0 0 2px alpha(#007aff, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* macOS-style expanded player - more compact */
|
/* macOS-style expanded player - more compact */
|
||||||
#macos-outer-player-box {
|
#macos-outer-player-box {
|
||||||
min-height: 110px; /* Reduced height */
|
min-height: 110px; /* Reduced height */
|
||||||
min-width: 380px;
|
min-width: 420px; /* Slightly wider to accommodate expanded track info */
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
padding: 15px; /* Reduced padding */
|
padding: 15px; /* Reduced padding */
|
||||||
background-color: alpha(#000, 0.4);
|
background-color: alpha(#000, 0.4);
|
||||||
box-shadow:
|
box-shadow:
|
||||||
0 4px 16px alpha(#000, 0.25),
|
0 4px 16px alpha(#000, 0.25),
|
||||||
inset 0 0 0 1px alpha(#fff, 0.1);
|
inset 0 0 0 1px alpha(#fff, 0.1);
|
||||||
}
|
}
|
||||||
@@ -583,6 +583,12 @@
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Track info container that expands to fill available space */
|
||||||
|
#macos-track-info {
|
||||||
|
margin-left: 15px;
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
#macos-player-title {
|
#macos-player-title {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -601,12 +607,12 @@
|
|||||||
#macos-seek-bar {
|
#macos-seek-bar {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
margin: 8px 0 4px 0;
|
margin: 8px 0 4px 0;
|
||||||
min-height: 20px;
|
min-height: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#macos-seek-bar trough {
|
#macos-seek-bar trough {
|
||||||
min-width: 200px;
|
min-width: 200px;
|
||||||
min-height: 4px;
|
min-height: 2px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background-color: alpha(#fff, 0.25);
|
background-color: alpha(#fff, 0.25);
|
||||||
border: none;
|
border: none;
|
||||||
@@ -645,16 +651,16 @@
|
|||||||
|
|
||||||
/* macOS control buttons - more compact */
|
/* macOS control buttons - more compact */
|
||||||
#macos-button-box {
|
#macos-button-box {
|
||||||
margin-top: 6px; /* Reduced top margin */
|
margin-top: 6px; /* Reduced top margin */
|
||||||
}
|
}
|
||||||
|
|
||||||
#macos-control-button {
|
#macos-control-button {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
min-width: 28px; /* Slightly smaller */
|
min-width: 28px; /* Slightly smaller */
|
||||||
min-height: 28px;
|
min-height: 28px;
|
||||||
padding: 5px; /* Reduced padding */
|
padding: 5px; /* Reduced padding */
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
transition: all 0.15s ease;
|
transition: all 0.15s ease;
|
||||||
}
|
}
|
||||||
@@ -666,11 +672,11 @@
|
|||||||
|
|
||||||
#macos-play-button {
|
#macos-play-button {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
min-width: 36px; /* Slightly smaller */
|
min-width: 36px; /* Slightly smaller */
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
padding: 7px; /* Reduced padding */
|
padding: 7px; /* Reduced padding */
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
transition: all 0.15s ease;
|
transition: all 0.15s ease;
|
||||||
}
|
}
|
||||||
@@ -682,16 +688,16 @@
|
|||||||
|
|
||||||
/* macOS player switcher dots - compact horizontal layout */
|
/* macOS player switcher dots - compact horizontal layout */
|
||||||
#macos-stack-buttons-box {
|
#macos-stack-buttons-box {
|
||||||
margin: 2px 5px; /* Minimal margins */
|
margin: 2px 5px; /* Minimal margins */
|
||||||
}
|
}
|
||||||
|
|
||||||
.macos-switcher-dot {
|
.macos-switcher-dot {
|
||||||
background: alpha(#fff, 0.3);
|
background: alpha(#fff, 0.3);
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
min-width: 6px; /* Smaller dots */
|
min-width: 6px; /* Smaller dots */
|
||||||
min-height: 6px;
|
min-height: 6px;
|
||||||
margin: 2px; /* Reduced margins */
|
margin: 2px; /* Reduced margins */
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,5 +707,5 @@
|
|||||||
|
|
||||||
.macos-switcher-dot.active {
|
.macos-switcher-dot.active {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
box-shadow: 0 0 0 1px alpha(#fff, 0.3); /* Smaller glow */
|
box-shadow: 0 0 0 1px alpha(#fff, 0.3); /* Smaller glow */
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user