From 8756529c13850cba23cdb3c43fab6f8ed20bae01 Mon Sep 17 00:00:00 2001 From: Dmitry Litvinov Date: Thu, 20 Nov 2025 18:53:48 +0300 Subject: [PATCH] Add floating menu styles and icon sizes Introduced new constants for floating menu dimensions and colors in `constants.py`. Updated styles for buttons, separators, and combo boxes to utilize these constants for consistency. Adjusted icon sizes for various combo boxes in the floating menu widgets to enhance UI appearance. --- beeref/assets/icons/grayscale.svg | 8 +++- beeref/assets/icons/opacity.svg | 2 +- beeref/constants.py | 66 +++++++++++++++++----------- beeref/widgets/draw_floating_menu.py | 1 + beeref/widgets/floating_menu.py | 1 + beeref/widgets/gif_floating_menu.py | 1 + beeref/widgets/text_floating_menu.py | 3 +- 7 files changed, 53 insertions(+), 29 deletions(-) diff --git a/beeref/assets/icons/grayscale.svg b/beeref/assets/icons/grayscale.svg index 7675bb8..2fbc692 100644 --- a/beeref/assets/icons/grayscale.svg +++ b/beeref/assets/icons/grayscale.svg @@ -1,4 +1,8 @@ - - + + + + + + diff --git a/beeref/assets/icons/opacity.svg b/beeref/assets/icons/opacity.svg index 64709e0..a910fc4 100644 --- a/beeref/assets/icons/opacity.svg +++ b/beeref/assets/icons/opacity.svg @@ -1,3 +1,3 @@ - + diff --git a/beeref/constants.py b/beeref/constants.py index 269d075..dde1f06 100644 --- a/beeref/constants.py +++ b/beeref/constants.py @@ -21,6 +21,14 @@ COPYRIGHT = 'Copyright © 2021-2024 Rebecca Breu' CHANGED_SYMBOL = '✎' +# Floating Menu Sizes +FLOATING_MENU_BUTTON_SIZE = 32 +FLOATING_MENU_ICON_SIZE = 32 +FLOATING_MENU_BUTTON_PADDING = 4 +FLOATING_MENU_CORNER_RADIUS = 4 +FLOATING_MENU_BASE_CORNER_RADIUS = 8 +FLOATING_MENU_BOTTOM_MARGIN = 8 + COLORS = { # Qt: 'Active:Base': (60, 60, 60), @@ -44,6 +52,11 @@ COLORS = { 'Scene:Selection': (116, 234, 231), 'Scene:Canvas': (60, 60, 60), 'Scene:Text': (200, 200, 200), + + # Floating Menu specific: + 'FloatingMenu:ButtonBackground': (255, 255, 255, 30), + 'FloatingMenu:Border': (255, 255, 255, 10), + 'FloatingMenu:SeparatorBackground': (255, 255, 255, 8), } @@ -92,7 +105,7 @@ def get_floating_menu_base_style(): return f""" QWidget#FloatingMenu {{ background-color: {_css_color(bg)}; - border-radius: 8px; + border-radius: {FLOATING_MENU_BASE_CORNER_RADIUS}px; border: 1px solid {_css_color(border)}; }} """ @@ -100,23 +113,26 @@ def get_floating_menu_base_style(): def get_floating_menu_button_style(): """Push button styling for floating menus.""" - background_color = (255, 255, 255, 30) - border_color = (255, 255, 255, 10) + background_color = COLORS['FloatingMenu:ButtonBackground'] + border_color = COLORS['FloatingMenu:Border'] inactive = COLORS['Disabled:Text'] active = COLORS['Active:Text'] accent = COLORS['Active:Highlight'] + size = FLOATING_MENU_BUTTON_SIZE + padding = FLOATING_MENU_BUTTON_PADDING + radius = FLOATING_MENU_CORNER_RADIUS return f""" QWidget#FloatingMenu QPushButton[floatingButton="true"] {{ background-color: {_css_color(background_color)}; color: {_css_color(inactive)}; border: 1px solid {_css_color(border_color)}; - border-radius: 4px; - padding: 4px 10px; + border-radius: {radius}px; + padding: {padding}px; font-weight: 600; - min-width: 12px; - min-height: 28px; - max-height: 28px; + min-width: {size}px; + min-height: {size}px; + max-height: {size}px; }} QWidget#FloatingMenu QPushButton[floatingButton="true"]:hover, @@ -134,14 +150,14 @@ def get_floating_menu_button_style(): def get_floating_menu_separator_style(): """Separator styling for floating menus.""" - border_color = (255, 255, 255, 10) - r, g, b = border_color[:3] + separator_bg = COLORS['FloatingMenu:SeparatorBackground'] + size = FLOATING_MENU_BUTTON_SIZE return f""" QWidget#FloatingMenu QFrame#FloatingMenuSeparator {{ - background-color: rgba({r}, {g}, {b}, 30); - min-height: 28px; - max-height: 28px; + background-color: {_css_color(separator_bg)}; + min-height: {size}px; + max-height: {size}px; }} """ @@ -150,15 +166,16 @@ def get_floating_menu_combo_style(): """Combo-box styling for floating menus.""" from beeref.assets import BeeAssets - bg = COLORS['Active:Button'] + # Use Active:Button for consistency with other UI elements + bg = COLORS['FloatingMenu:ButtonBackground'] active_color = COLORS['Active:Text'] - border_color = (255, 255, 255, 10) - border_r, border_g, border_b = border_color[:3] + size = FLOATING_MENU_BUTTON_SIZE + radius = FLOATING_MENU_CORNER_RADIUS - # Получаем путь к иконке стрелки + # Get arrow icon path assets = BeeAssets() arrow_icon_path = assets.PATH.joinpath('icons', 'small-down.svg') - # Используем прямой путь, экранируя обратные слеши для Windows + # Escape backslashes for Windows compatibility arrow_icon_path_str = str(arrow_icon_path).replace('\\', '/') return f""" @@ -166,18 +183,17 @@ def get_floating_menu_combo_style(): QWidget#FloatingMenu QFontComboBox {{ background-color: {_css_color(bg)}; color: {_css_color(active_color)}; - border: 1px solid rgba({border_r}, {border_g}, {border_b}, 160); - border-radius: 4px; - padding: 4px 12px; + border-radius: {radius}px; + padding: 4px 16px; min-width: 40px; - min-height: 28px; - max-height: 28px; + min-height: {size}px; + max-height: {size}px; }} QWidget#FloatingMenu QComboBox::drop-down, QWidget#FloatingMenu QFontComboBox::drop-down {{ border: none; - width: 16px; + width: 20px; }} QWidget#FloatingMenu QComboBox::down-arrow, @@ -185,7 +201,7 @@ def get_floating_menu_combo_style(): image: url({arrow_icon_path_str}); width: 12px; height: 12px; - margin-right: 4px; + margin-right: 8px; }} QWidget#FloatingMenu QComboBox QAbstractItemView, diff --git a/beeref/widgets/draw_floating_menu.py b/beeref/widgets/draw_floating_menu.py index 9d9ce04..e6ef86b 100644 --- a/beeref/widgets/draw_floating_menu.py +++ b/beeref/widgets/draw_floating_menu.py @@ -101,6 +101,7 @@ class DrawFloatingMenu(FloatingMenu): combo = UpwardComboBox(self) combo.setObjectName("FloatingMenuLineStyle") combo.setMinimumWidth(40) + combo.setIconSize(QtCore.QSize(32, 32)) # Добавляем элементы с иконками combo.addItem(solid_icon, "", 'solid') diff --git a/beeref/widgets/floating_menu.py b/beeref/widgets/floating_menu.py index de0cd1d..f0cedc5 100644 --- a/beeref/widgets/floating_menu.py +++ b/beeref/widgets/floating_menu.py @@ -142,6 +142,7 @@ class FloatingMenu(QtWidgets.QWidget): button.setCheckable(checkable) if icon: button.setIcon(icon) + button.setIconSize(QtCore.QSize(32, 32)) button.setProperty("floatingButton", True) if callback: # Connect directly - button events are handled independently diff --git a/beeref/widgets/gif_floating_menu.py b/beeref/widgets/gif_floating_menu.py index 85c9978..b92eefb 100644 --- a/beeref/widgets/gif_floating_menu.py +++ b/beeref/widgets/gif_floating_menu.py @@ -64,6 +64,7 @@ class GifFloatingMenu(FloatingMenu): self.speed_combo = QtWidgets.QComboBox(self) self.speed_combo.setObjectName("FloatingMenuGifSpeed") self.speed_combo.setMinimumWidth(40) + self.speed_combo.setIconSize(QtCore.QSize(32, 32)) for speed in self.SPEED_VALUES: label = self._format_speed_label(speed) diff --git a/beeref/widgets/text_floating_menu.py b/beeref/widgets/text_floating_menu.py index 952b874..d6c9c47 100644 --- a/beeref/widgets/text_floating_menu.py +++ b/beeref/widgets/text_floating_menu.py @@ -4,7 +4,7 @@ from __future__ import annotations from typing import TYPE_CHECKING -from PyQt6 import QtGui, QtWidgets +from PyQt6 import QtCore, QtGui, QtWidgets from beeref.assets import BeeAssets from beeref.widgets.floating_menu import FloatingMenu @@ -83,6 +83,7 @@ class TextFloatingMenu(FloatingMenu): self.font_combo = QtWidgets.QComboBox(self) self.font_combo.setObjectName("FloatingMenuFontFamily") self.font_combo.setMinimumWidth(40) + self.font_combo.setIconSize(QtCore.QSize(32, 32)) self.font_combo.setEditable(False) self.font_combo.setInsertPolicy( QtWidgets.QComboBox.InsertPolicy.NoInsert)