diff --git a/README.md b/README.md index 7d7dd4d3..8fa0ec5d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Shortcut composer **v1.5.3** +# Shortcut composer **v1.5.4** [![python](https://img.shields.io/badge/Python-3.10-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org) [![Code style: black](https://img.shields.io/badge/code%20style-autopep8-333333.svg)](https://pypi.org/project/autopep8/) @@ -40,7 +40,7 @@ The plugin adds new shortcuts of the following types: [![PIE MENUS - release video](https://github-production-user-asset-6210df.s3.amazonaws.com/51094047/238179887-87c00d86-0e65-46c2-94c4-52bb02c99501.png)](https://youtu.be/hrjBycVYFZM "PIE MENUS - introducing Shortcut Composer") ## Requirements -- Version of krita on plugin release: **5.2.2** +- Version of krita on plugin release: **5.2.3** - Required version of krita: **5.2.2** or later OS support state: diff --git a/shortcut_composer/INFO.py b/shortcut_composer/INFO.py index aba19f29..913467ff 100644 --- a/shortcut_composer/INFO.py +++ b/shortcut_composer/INFO.py @@ -5,7 +5,7 @@ from api_krita.wrappers import Version -__version__ = Version(1, 5, 3) +__version__ = Version(1, 5, 4) """Version of the Shortcut Composer plugin.""" __required_krita_version__ = Version(5, 2, 2) diff --git a/shortcut_composer/api_krita/enums/blending_mode.py b/shortcut_composer/api_krita/enums/blending_mode.py index 4aa079bb..f0bf2abd 100644 --- a/shortcut_composer/api_krita/enums/blending_mode.py +++ b/shortcut_composer/api_krita/enums/blending_mode.py @@ -145,6 +145,7 @@ class BlendingMode(EnumGroup): _modulo = Group("Modulo") DIVISIVE_MODULO = "divisive_modulo" DIVISIVE_MODULO_CONTINUOUS = "divisive_modulo_continuous" + MODULO = "modulo" MODULO_CONTINUOUS = "modulo_continuous" MODULO_SHIFT = "modulo_shift" MODULO_SHIFT_CONTINUOUS = "modulo_shift_continuous" diff --git a/shortcut_composer/composer_utils/label/label_text_colorizer.py b/shortcut_composer/composer_utils/label/label_text_colorizer.py index 6a5ed2c4..b00fb266 100644 --- a/shortcut_composer/composer_utils/label/label_text_colorizer.py +++ b/shortcut_composer/composer_utils/label/label_text_colorizer.py @@ -31,9 +31,16 @@ class Color(Enum): class LabelTextColorizer(QColor): """Functions that return a color associated with value of property.""" + @staticmethod + def action() -> QColor: + """Return a QColor associated with action.""" + if Krita.is_light_theme_active: + return Color.BLACK.value + return Color.WHITE.value + @classmethod def blending_mode(cls, mode: BlendingMode) -> QColor: - """Return a QColor associated with blending mode. Gray by default.""" + """Return a QColor associated with blending mode.""" if Krita.is_light_theme_active: return cls.BLENDING_MODES_LIGHT[mode].value return cls.BLENDING_MODES_DARK[mode].value diff --git a/shortcut_composer/core_components/controllers/core_controllers.py b/shortcut_composer/core_components/controllers/core_controllers.py index a2b97123..f1b032e5 100644 --- a/shortcut_composer/core_components/controllers/core_controllers.py +++ b/shortcut_composer/core_components/controllers/core_controllers.py @@ -9,7 +9,7 @@ from api_krita import Krita from api_krita.enums import Action, Tool, Toggle, TransformMode from api_krita.actions import TransformModeFinder -from composer_utils.label import LabelText +from composer_utils.label import LabelText, LabelTextColorizer from ..controller_base import Controller, NumericController @@ -68,7 +68,9 @@ def get_label(self, value: Tool) -> QIcon | LabelText: icon = value.icon if not icon.isNull(): return value.icon - return LabelText(value.name[:3]) + return LabelText( + value=value.name[:3], + color=LabelTextColorizer.action()) def get_pretty_name(self, value: Action) -> str: """Forward enums' pretty name.""" @@ -141,7 +143,7 @@ class UndoController(NumericController): """ Gives access to `undo` and `redo` actions. - - Operates on `int` representing position on undo stack + - Operates on `float` representing position on undo stack - Starts from `0` - Controller remembers its position on undo stack. - Setting a value smaller than currently remembered performs `undo` @@ -149,7 +151,7 @@ class UndoController(NumericController): - Each Undo and redo change remembered position by 1 """ - TYPE = int + TYPE = float DEFAULT_VALUE = 0 MIN_VALUE = 0 MAX_VALUE = 10_000 @@ -160,15 +162,15 @@ class UndoController(NumericController): def __init__(self) -> None: self.state = 0 - def get_value(self) -> int: + def get_value(self) -> float: """Return remembered position on undo stack""" return self.state - def set_value(self, value: int) -> None: + def set_value(self, value: float) -> None: """Compares value with remembered position and performs undo/redo.""" - if value == self.state: + if round(value) == self.state: return - elif value > self.state: + elif round(value) > self.state: Krita.trigger_action("edit_redo") self.state += 1 else: diff --git a/shortcut_composer/manual.html b/shortcut_composer/manual.html index 49f26782..a4b9767a 100644 --- a/shortcut_composer/manual.html +++ b/shortcut_composer/manual.html @@ -9,7 +9,7 @@ -

Shortcut composer v1.5.3

+

Shortcut composer v1.5.4


Extension for painting application Krita, which allows to create custom, complex keyboard shortcuts.

The plugin adds new shortcuts of the following types:

@@ -23,7 +23,7 @@

Shortcut composer v1.5.3

Requirements

OS support state:

diff --git a/shortcut_composer/templates/pie_menu_utils/pie_style.py b/shortcut_composer/templates/pie_menu_utils/pie_style.py index 3dbcb8ec..0af9d03f 100644 --- a/shortcut_composer/templates/pie_menu_utils/pie_style.py +++ b/shortcut_composer/templates/pie_menu_utils/pie_style.py @@ -18,14 +18,14 @@ class PieStyle: def __init__( self, - unscaled_label_style: LabelWidgetStyle, + label_style: LabelWidgetStyle, pie_radius_callback: Callable[[], int], deadzone_radius_callback: Callable[[], float], settings_button_radius_callback: Callable[[], int], accept_button_radius_callback: Callable[[], int], background_opacity_callback: Callable[[], int], ) -> None: - self._unscaled_label_style = unscaled_label_style + self._label_style = label_style self._pie_radius_callback = pie_radius_callback self._deadzone_radius_callback = deadzone_radius_callback @@ -56,12 +56,12 @@ def accept_button_radius(self) -> int: @property def widget_radius(self) -> int: """Radius of the entire widget, including base and the icons.""" - return self.pie_radius + self._unscaled_label_style.icon_radius + return self.pie_radius + self._label_style.icon_radius @property def border_thickness(self) -> int: """Thickness of border of the pie.""" - return self._unscaled_label_style.border_thickness + return self._label_style.border_thickness @property def decorator_thickness(self) -> int: @@ -81,12 +81,12 @@ def inner_edge_radius(self) -> int: @property def active_color(self) -> QColor: """Color of active elements.""" - return self._unscaled_label_style.active_color + return self._label_style.active_color @property def background_color(self) -> QColor: """Color of the widget background.""" - opaque = self._unscaled_label_style.background_color + opaque = self._label_style.background_color return QColor( opaque.red(), opaque.green(), @@ -96,17 +96,17 @@ def background_color(self) -> QColor: @property def active_color_dark(self) -> QColor: """Color variation of active element.""" - return self._unscaled_label_style.active_color_dark + return self._label_style.active_color_dark @property def border_color(self) -> QColor: """Color of the active pie border.""" - return self._unscaled_label_style.border_color + return self._label_style.border_color @property def background_decorator_color(self) -> QColor: """Color of decorator near inner edge.""" - color = self._unscaled_label_style.background_color + color = self._label_style.background_color color = QColor(color.red()-5, color.green()-5, color.blue()-5, 60) return color diff --git a/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py b/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py index e4034756..145b0e62 100644 --- a/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py +++ b/shortcut_composer/templates/pie_menu_utils/pie_style_holder.py @@ -30,7 +30,7 @@ def __init__(self, pie_config: PieConfig) -> None: active_color_callback=self._active_color, background_color_callback=self._background_color) self.pie_style = PieStyle( - unscaled_label_style=self.unscaled_label_style, + label_style=self.label_style, pie_radius_callback=self._pie_radius, deadzone_radius_callback=self._deadzone_radius, settings_button_radius_callback=self._settings_button_radius, @@ -59,7 +59,11 @@ def _icon_radius(self) -> int: max_radius = round( self.pie_style.pie_radius * math.pi / len(elements)) - return min(self._unscaled_icon_radius(), max_radius) + desired_radius = round( + self._unscaled_icon_radius() + * self._pie_config.ICON_RADIUS_SCALE.read()) + + return min(desired_radius, max_radius) def _border_thickness(self) -> int: """Return border thickness based on configured value.""" diff --git a/shortcut_composer/templates/pie_menu_utils/pie_widget.py b/shortcut_composer/templates/pie_menu_utils/pie_widget.py index dd7d781d..148905a5 100644 --- a/shortcut_composer/templates/pie_menu_utils/pie_widget.py +++ b/shortcut_composer/templates/pie_menu_utils/pie_widget.py @@ -3,7 +3,7 @@ from typing import TypeVar, Generic -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QPoint from PyQt5.QtGui import ( QDragEnterEvent, QDragLeaveEvent, @@ -67,6 +67,7 @@ def __init__( self._config.PIE_RADIUS_SCALE.register_callback(self._reset) self._config.ICON_RADIUS_SCALE.register_callback(self._reset) + self._config.ORDER.register_callback(self._reset) Config.PIE_GLOBAL_SCALE.register_callback(self._reset) Config.PIE_ICON_GLOBAL_SCALE.register_callback(self._reset) @@ -170,5 +171,10 @@ def _type(self) -> type | None: def _reset(self) -> None: """Set widget geometry according to style.""" - diameter = 2*self._style_holder.pie_style.widget_radius - self.resize(diameter, diameter) + radius = self._style_holder.pie_style.widget_radius + difference = radius - self.width()//2 + new_center = QPoint( + self.center_global.x() - difference, + self.center_global.y()) + self.resize(2*radius, 2*radius) + self.move_center(new_center)