Skip to content

Commit

Permalink
Fix UndoController not working due to rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtryb committed Jul 11, 2024
1 parent 35a413b commit b0d2dba
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,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 @@ -162,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

0 comments on commit b0d2dba

Please sign in to comment.