-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separate seek sliders for each animation type
- Loading branch information
1 parent
5b3a90e
commit 3b36dfa
Showing
7 changed files
with
452 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
from PySide6.QtGui import * | ||
from PySide6.QtCore import * | ||
from PySide6.QtWidgets import * | ||
|
||
from gcft_ui.uic.ui_anim_control import Ui_AnimControl | ||
|
||
class AnimControl(QGroupBox): | ||
anim_type_paused_changed = Signal(str, bool) | ||
anim_type_slider_frame_changed = Signal(str, int) | ||
anim_type_detached = Signal(str) | ||
|
||
def __init__(self, parent=None): | ||
super().__init__(parent) | ||
self.ui = Ui_AnimControl() | ||
self.ui.setupUi(self) | ||
|
||
self.paused = False | ||
self.duration = 0 | ||
|
||
self.ui.pause_button.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_MediaPlay)) | ||
self.ui.pause_button.clicked.connect(self.toggle_anim_paused) | ||
self.ui.seek_slider.valueChanged.connect(self.update_anim_frame_by_type) | ||
self.ui.detach_button.setIcon(self.style().standardIcon(QStyle.StandardPixmap.SP_TitleBarCloseButton)) | ||
self.ui.detach_button.clicked.connect(self.detach_anim) | ||
|
||
self.update_anim_pause_button_icon() | ||
|
||
self.hide() | ||
|
||
def toggle_anim_paused(self): | ||
if self.paused and self.ui.seek_slider.value() >= self.ui.seek_slider.maximum(): | ||
# If paused at the end of the animation, restart from the beginning. | ||
self.ui.seek_slider.setValue(0) | ||
self.paused = not self.paused | ||
self.anim_type_paused_changed.emit(self.property("anim_type"), self.paused) | ||
self.update_anim_pause_button_icon() | ||
|
||
def update_anim_frame_by_type(self, frame: int): | ||
self.anim_type_slider_frame_changed.emit(self.property("anim_type"), frame) | ||
self.paused = True | ||
self.update_anim_pause_button_icon() | ||
|
||
def detach_anim(self): | ||
self.anim_type_detached.emit(self.property("anim_type")) | ||
self.hide() | ||
|
||
def update_anim_pause_button_icon(self): | ||
if self.paused: | ||
self.ui.pause_button.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) | ||
else: | ||
self.ui.pause_button.setIcon(self.style().standardIcon(QStyle.SP_MediaPause)) | ||
|
||
def update_slider_from_anim_frame(self, frame: float): | ||
self.ui.seek_slider.blockSignals(True) | ||
self.ui.seek_slider.setValue(frame) | ||
self.ui.seek_slider.blockSignals(False) | ||
if frame >= self.duration: | ||
self.paused = True | ||
self.anim_type_paused_changed.emit(self.property("anim_type"), self.paused) | ||
self.update_anim_pause_button_icon() | ||
|
||
def load_anim(self, duration: int, anim_format_name: str, anim_name: str): | ||
self.duration = duration | ||
|
||
max_frame = self.duration-1 | ||
if max_frame < 0: | ||
max_frame = 0 | ||
|
||
title = anim_format_name | ||
if anim_name: | ||
title += f": {anim_name}" | ||
self.setTitle(title) | ||
|
||
self.ui.seek_slider.setMinimum(0) | ||
self.ui.seek_slider.setMaximum(max_frame) | ||
self.ui.seek_slider.setValue(0) | ||
|
||
self.paused = False | ||
self.anim_type_paused_changed.emit(self.property("anim_type"), self.paused) | ||
self.update_anim_pause_button_icon() | ||
|
||
self.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>AnimControl</class> | ||
<widget class="QGroupBox" name="AnimControl"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>44</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QPushButton" name="pause_button"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>30</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QSlider" name="seek_slider"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="detach_button"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>30</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
<property name="icon"> | ||
<iconset theme="accessories-calculator"/> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.