Skip to content

Commit

Permalink
Merge pull request #91 from wojtryb/development
Browse files Browse the repository at this point in the history
Deploy 1.5.4
  • Loading branch information
wojtryb authored Jul 12, 2024
2 parents d70c14e + 2bc72b4 commit d560b58
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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/)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion shortcut_composer/INFO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions shortcut_composer/api_krita/enums/blending_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions shortcut_composer/core_components/controllers/core_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -141,15 +143,15 @@ 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`
- Setting a value greater than currently remembered performs `redo`
- Each Undo and redo change remembered position by 1
"""

TYPE = int
TYPE = float
DEFAULT_VALUE = 0
MIN_VALUE = 0
MAX_VALUE = 10_000
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions shortcut_composer/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<body>

<h1 id="shortcut-composer-v1-5-3-">Shortcut composer <strong>v1.5.3</strong></h1>
<h1 id="shortcut-composer-v1-5-4-">Shortcut composer <strong>v1.5.4</strong></h1>
<hr>
<p><strong><code>Extension</code></strong> for painting application <strong><code>Krita</code></strong>, which allows to create custom, complex <strong><code>keyboard shortcuts</code></strong>.</p>
<p>The plugin adds new shortcuts of the following types:</p>
Expand All @@ -23,7 +23,7 @@ <h1 id="shortcut-composer-v1-5-3-">Shortcut composer <strong>v1.5.3</strong></h1
</ul>
<h2 id="requirements">Requirements</h2>
<ul>
<li>Version of krita on plugin release: <strong>5.2.2</strong></li>
<li>Version of krita on plugin release: <strong>5.2.3</strong></li>
<li>Required version of krita: <strong>5.2.2</strong> or later</li>
</ul>
<p>OS support state:</p>
Expand Down
18 changes: 9 additions & 9 deletions shortcut_composer/templates/pie_menu_utils/pie_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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(),
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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."""
Expand Down
12 changes: 9 additions & 3 deletions shortcut_composer/templates/pie_menu_utils/pie_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

0 comments on commit d560b58

Please sign in to comment.