@@ -14,22 +14,23 @@ SOURCES = main.cpp canvastestapp.cpp \ | |||||
patchcanvas.cpp \ | patchcanvas.cpp \ | ||||
patchcanvas-theme.cpp \ | patchcanvas-theme.cpp \ | ||||
patchscene.cpp \ | patchscene.cpp \ | ||||
canvasbox.cpp \ | |||||
canvasportglow.cpp \ | |||||
canvasboxshadow.cpp \ | |||||
canvasicon.cpp \ | |||||
canvasfadeanimation.cpp \ | canvasfadeanimation.cpp \ | ||||
canvasline.cpp \ | canvasline.cpp \ | ||||
canvasport.cpp \ | |||||
canvasbezierline.cpp \ | canvasbezierline.cpp \ | ||||
canvaslinemov.cpp \ | canvaslinemov.cpp \ | ||||
canvasbezierlinemov.cpp | |||||
canvasbezierlinemov.cpp \ | |||||
canvasport.cpp \ | |||||
canvasbox.cpp \ | |||||
canvasicon.cpp \ | |||||
canvasboxshadow.cpp \ | |||||
canvasportglow.cpp | |||||
HEADERS = canvastestapp.h \ | HEADERS = canvastestapp.h \ | ||||
patchcanvas.h \ | patchcanvas.h \ | ||||
patchcanvas-api.h \ | patchcanvas-api.h \ | ||||
patchcanvas-theme.h \ | patchcanvas-theme.h \ | ||||
patchscene.h \ | patchscene.h \ | ||||
canvasfadeanimation.h \ | |||||
abstractcanvasline.h \ | abstractcanvasline.h \ | ||||
canvasline.h \ | canvasline.h \ | ||||
canvasbezierline.h \ | canvasbezierline.h \ | ||||
@@ -39,8 +40,7 @@ HEADERS = canvastestapp.h \ | |||||
canvasbox.h \ | canvasbox.h \ | ||||
canvasicon.h \ | canvasicon.h \ | ||||
canvasboxshadow.h \ | canvasboxshadow.h \ | ||||
canvasportglow.h \ | |||||
canvasfadeanimation.h | |||||
canvasportglow.h | |||||
FORMS = canvastestapp.ui | FORMS = canvastestapp.ui | ||||
@@ -141,7 +141,11 @@ CanvasPort* CanvasBox::addPortFromGroup(int port_id, QString port_name, PortMode | |||||
if (m_port_list_ids.count() == 0) | if (m_port_list_ids.count() == 0) | ||||
{ | { | ||||
if (options.auto_hide_groups) | if (options.auto_hide_groups) | ||||
{ | |||||
if (options.eyecandy) | |||||
CanvasItemFX(this, true); | |||||
setVisible(true); | setVisible(true); | ||||
} | |||||
} | } | ||||
CanvasPort* new_widget = new CanvasPort(port_id, port_name, port_mode, port_type, this); | CanvasPort* new_widget = new CanvasPort(port_id, port_name, port_mode, port_type, this); | ||||
@@ -178,7 +182,12 @@ void CanvasBox::removePortFromGroup(int port_id) | |||||
else if (isVisible()) | else if (isVisible()) | ||||
{ | { | ||||
if (options.auto_hide_groups) | if (options.auto_hide_groups) | ||||
setVisible(false); | |||||
{ | |||||
if (options.eyecandy) | |||||
CanvasItemFX(this, false); | |||||
else | |||||
setVisible(false); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -29,6 +29,11 @@ CanvasFadeAnimation::CanvasFadeAnimation(QGraphicsItem* item, bool show, QObject | |||||
m_item = item; | m_item = item; | ||||
} | } | ||||
QGraphicsItem* CanvasFadeAnimation::item() | |||||
{ | |||||
return m_item; | |||||
} | |||||
void CanvasFadeAnimation::setDuration(int time) | void CanvasFadeAnimation::setDuration(int time) | ||||
{ | { | ||||
if (m_show == false && m_item->opacity() == 0.0) | if (m_show == false && m_item->opacity() == 0.0) | ||||
@@ -31,6 +31,7 @@ class CanvasFadeAnimation : public QAbstractAnimation | |||||
public: | public: | ||||
CanvasFadeAnimation(QGraphicsItem* item, bool show, QObject* parent=0); | CanvasFadeAnimation(QGraphicsItem* item, bool show, QObject* parent=0); | ||||
QGraphicsItem* item(); | |||||
void setDuration(int time); | void setDuration(int time); | ||||
virtual int duration() const; | virtual int duration() const; | ||||
@@ -21,14 +21,43 @@ | |||||
#include <QtCore/QTimer> | #include <QtCore/QTimer> | ||||
#include <QtGui/QAction> | #include <QtGui/QAction> | ||||
#include "abstractcanvasline.h" | |||||
#include "canvasbox.h" | |||||
#include "canvasport.h" | |||||
#include "canvasfadeanimation.h" | |||||
#include "canvasline.h" | #include "canvasline.h" | ||||
#include "canvasbezierline.h" | #include "canvasbezierline.h" | ||||
#include "canvasport.h" | |||||
#include "canvasbox.h" | |||||
CanvasObject::CanvasObject(QObject* parent) : QObject(parent) {} | CanvasObject::CanvasObject(QObject* parent) : QObject(parent) {} | ||||
void CanvasObject::AnimationIdle() | |||||
{ | |||||
PatchCanvas::CanvasFadeAnimation* animation = (PatchCanvas::CanvasFadeAnimation*)sender(); | |||||
if (animation) | |||||
PatchCanvas::CanvasRemoveAnimation(animation); | |||||
} | |||||
void CanvasObject::AnimationHide() | |||||
{ | |||||
PatchCanvas::CanvasFadeAnimation* animation = (PatchCanvas::CanvasFadeAnimation*)sender(); | |||||
if (animation) | |||||
{ | |||||
if (animation->item()) | |||||
animation->item()->hide(); | |||||
PatchCanvas::CanvasRemoveAnimation(animation); | |||||
} | |||||
} | |||||
void CanvasObject::AnimationDestroy() | |||||
{ | |||||
PatchCanvas::CanvasFadeAnimation* animation = (PatchCanvas::CanvasFadeAnimation*)sender(); | |||||
if (animation) | |||||
{ | |||||
if (animation->item()) | |||||
PatchCanvas::CanvasRemoveItemFX(animation->item()); | |||||
PatchCanvas::CanvasRemoveAnimation(animation); | |||||
} | |||||
} | |||||
void CanvasObject::CanvasPostponedGroups() | void CanvasObject::CanvasPostponedGroups() | ||||
{ | { | ||||
PatchCanvas::CanvasPostponedGroups(); | PatchCanvas::CanvasPostponedGroups(); | ||||
@@ -190,6 +219,7 @@ void init(PatchScene* scene, Callback callback, bool debug) | |||||
canvas.group_list.clear(); | canvas.group_list.clear(); | ||||
canvas.port_list.clear(); | canvas.port_list.clear(); | ||||
canvas.connection_list.clear(); | canvas.connection_list.clear(); | ||||
canvas.animation_list.clear(); | |||||
if (!canvas.qobject) canvas.qobject = new CanvasObject(); | if (!canvas.qobject) canvas.qobject = new CanvasObject(); | ||||
if (!canvas.settings) canvas.settings = new QSettings(PATCHCANVAS_ORGANISATION_NAME, "PatchCanvas"); | if (!canvas.settings) canvas.settings = new QSettings(PATCHCANVAS_ORGANISATION_NAME, "PatchCanvas"); | ||||
@@ -314,6 +344,9 @@ void addGroup(int group_id, QString group_name, SplitOption split, Icon icon) | |||||
canvas.last_z_value += 1; | canvas.last_z_value += 1; | ||||
group_sbox->setZValue(canvas.last_z_value); | group_sbox->setZValue(canvas.last_z_value); | ||||
if (options.auto_hide_groups == false && options.eyecandy) | |||||
CanvasItemFX(group_sbox, true); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -334,6 +367,9 @@ void addGroup(int group_id, QString group_name, SplitOption split, Icon icon) | |||||
canvas.group_list.append(group_dict); | canvas.group_list.append(group_dict); | ||||
if (options.auto_hide_groups == false && options.eyecandy) | |||||
CanvasItemFX(group_box, true); | |||||
QTimer::singleShot(0, canvas.scene, SLOT(update())); | QTimer::singleShot(0, canvas.scene, SLOT(update())); | ||||
} | } | ||||
@@ -358,9 +394,16 @@ void removeGroup(int group_id) | |||||
canvas.settings->setValue(QString("CanvasPositions/%1_SPLIT").arg(group_name), SPLIT_YES); | canvas.settings->setValue(QString("CanvasPositions/%1_SPLIT").arg(group_name), SPLIT_YES); | ||||
} | } | ||||
s_item->removeIconFromScene(); | |||||
canvas.scene->removeItem(s_item); | |||||
delete s_item; | |||||
if (options.eyecandy) | |||||
{ | |||||
CanvasItemFX(s_item, false, true); | |||||
} | |||||
else | |||||
{ | |||||
s_item->removeIconFromScene(); | |||||
canvas.scene->removeItem(s_item); | |||||
delete s_item; | |||||
} | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -371,9 +414,16 @@ void removeGroup(int group_id) | |||||
} | } | ||||
} | } | ||||
item->removeIconFromScene(); | |||||
canvas.scene->removeItem(item); | |||||
delete item; | |||||
if (options.eyecandy) | |||||
{ | |||||
CanvasItemFX(item, false, true); | |||||
} | |||||
else | |||||
{ | |||||
item->removeIconFromScene(); | |||||
canvas.scene->removeItem(item); | |||||
delete item; | |||||
} | |||||
canvas.group_list.takeAt(i); | canvas.group_list.takeAt(i); | ||||
@@ -695,6 +745,9 @@ void addPort(int group_id, int port_id, QString port_name, PortMode port_mode, P | |||||
return; | return; | ||||
} | } | ||||
if (options.eyecandy) | |||||
CanvasItemFX(port_widget, true); | |||||
port_dict_t port_dict; | port_dict_t port_dict; | ||||
port_dict.group_id = group_id; | port_dict.group_id = group_id; | ||||
port_dict.port_id = port_id; | port_dict.port_id = port_id; | ||||
@@ -804,6 +857,12 @@ void connectPorts(int connection_id, int port_out_id, int port_in_id) | |||||
canvas.connection_list.append(connection_dict); | canvas.connection_list.append(connection_dict); | ||||
if (options.eyecandy) | |||||
{ | |||||
QGraphicsItem* item = (options.use_bezier_lines) ? (QGraphicsItem*)(CanvasBezierLine*)connection_dict.widget : (QGraphicsItem*)(CanvasLine*)connection_dict.widget; | |||||
CanvasItemFX(item, true); | |||||
} | |||||
QTimer::singleShot(0, canvas.scene, SLOT(update())); | QTimer::singleShot(0, canvas.scene, SLOT(update())); | ||||
} | } | ||||
@@ -867,7 +926,13 @@ void disconnectPorts(int connection_id) | |||||
((CanvasBox*)item1->parentItem())->removeLineFromGroup(connection_id); | ((CanvasBox*)item1->parentItem())->removeLineFromGroup(connection_id); | ||||
((CanvasBox*)item2->parentItem())->removeLineFromGroup(connection_id); | ((CanvasBox*)item2->parentItem())->removeLineFromGroup(connection_id); | ||||
line->deleteFromScene(); | |||||
if (options.eyecandy) | |||||
{ | |||||
QGraphicsItem* item = (options.use_bezier_lines) ? (QGraphicsItem*)(CanvasBezierLine*)line : (QGraphicsItem*)(CanvasLine*)line; | |||||
CanvasItemFX(item, false, true); | |||||
} | |||||
else | |||||
line->deleteFromScene(); | |||||
QTimer::singleShot(0, canvas.scene, SLOT(update())); | QTimer::singleShot(0, canvas.scene, SLOT(update())); | ||||
} | } | ||||
@@ -1003,6 +1068,21 @@ int CanvasGetConnectedPort(int connection_id, int port_id) | |||||
return 0; | return 0; | ||||
} | } | ||||
void CanvasRemoveAnimation(CanvasFadeAnimation* f_animation) | |||||
{ | |||||
if (canvas.debug) | |||||
qDebug("PatchCanvas::CanvasRemoveAnimation(%p)", f_animation); | |||||
foreach2 (const animation_dict_t& animation, canvas.animation_list) | |||||
if (animation.animation == f_animation) | |||||
{ | |||||
delete animation.animation; | |||||
canvas.animation_list.takeAt(i); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
void CanvasPostponedGroups() | void CanvasPostponedGroups() | ||||
{ | { | ||||
if (canvas.debug) | if (canvas.debug) | ||||
@@ -1017,4 +1097,77 @@ void CanvasCallback(CallbackAction action, int value1, int value2, QString value | |||||
canvas.callback(action, value1, value2, value_str); | canvas.callback(action, value1, value2, value_str); | ||||
} | } | ||||
void CanvasItemFX(QGraphicsItem* item, bool show, bool destroy) | |||||
{ | |||||
if (canvas.debug) | |||||
qDebug("PatchCanvas::CanvasItemFX(%p, %s, %s)", item, bool2str(show), bool2str(destroy)); | |||||
// Check if item already has an animationItemFX | |||||
foreach2 (const animation_dict_t& animation, canvas.animation_list) | |||||
if (animation.item == item) | |||||
{ | |||||
if (animation.animation) | |||||
{ | |||||
animation.animation->stop(); | |||||
delete animation.animation; | |||||
} | |||||
canvas.animation_list.takeAt(i); | |||||
break; | |||||
} | |||||
} | |||||
CanvasFadeAnimation* animation = new CanvasFadeAnimation(item, show); | |||||
animation->setDuration(show ? 750 : 500); | |||||
animation_dict_t animation_dict; | |||||
animation_dict.animation = animation; | |||||
animation_dict.item = item; | |||||
canvas.animation_list.append(animation_dict); | |||||
if (show) | |||||
{ | |||||
QObject::connect(animation, SIGNAL(finished()), canvas.qobject, SLOT(AnimationIdle())); | |||||
} | |||||
else | |||||
{ | |||||
if (destroy) | |||||
QObject::connect(animation, SIGNAL(finished()), canvas.qobject, SLOT(AnimationDestroy())); | |||||
else | |||||
QObject::connect(animation, SIGNAL(finished()), canvas.qobject, SLOT(AnimationHide())); | |||||
} | |||||
animation->start(); | |||||
} | |||||
void CanvasRemoveItemFX(QGraphicsItem* item) | |||||
{ | |||||
if (canvas.debug) | |||||
qDebug("PatchCanvas::CanvasRemoveItemFX(%p)", item); | |||||
switch (item->type()) | |||||
{ | |||||
case CanvasBoxType: | |||||
{ | |||||
CanvasBox* box = (CanvasBox*)item; | |||||
box->removeIconFromScene(); | |||||
canvas.scene->removeItem(box); | |||||
delete box; | |||||
} | |||||
case CanvasPortType: | |||||
{ | |||||
CanvasPort* port = (CanvasPort*)item; | |||||
canvas.scene->removeItem(port); | |||||
delete port; | |||||
} | |||||
case CanvasLineType: | |||||
case CanvasBezierLineType: | |||||
{ | |||||
AbstractCanvasLine* line = (AbstractCanvasLine*)item; | |||||
line->deleteFromScene(); | |||||
} | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
END_NAMESPACE_PATCHCANVAS | END_NAMESPACE_PATCHCANVAS |
@@ -35,6 +35,9 @@ public: | |||||
CanvasObject(QObject* parent=0); | CanvasObject(QObject* parent=0); | ||||
public slots: | public slots: | ||||
void AnimationIdle(); | |||||
void AnimationHide(); | |||||
void AnimationDestroy(); | |||||
void CanvasPostponedGroups(); | void CanvasPostponedGroups(); | ||||
void PortContextMenuDisconnect(); | void PortContextMenuDisconnect(); | ||||
}; | }; | ||||
@@ -42,6 +45,7 @@ public slots: | |||||
START_NAMESPACE_PATCHCANVAS | START_NAMESPACE_PATCHCANVAS | ||||
class AbstractCanvasLine; | class AbstractCanvasLine; | ||||
class CanvasFadeAnimation; | |||||
class CanvasBox; | class CanvasBox; | ||||
class CanvasPort; | class CanvasPort; | ||||
class Theme; | class Theme; | ||||
@@ -82,6 +86,11 @@ struct connection_dict_t { | |||||
AbstractCanvasLine* widget; | AbstractCanvasLine* widget; | ||||
}; | }; | ||||
struct animation_dict_t { | |||||
CanvasFadeAnimation* animation; | |||||
QGraphicsItem* item; | |||||
}; | |||||
// Main Canvas object | // Main Canvas object | ||||
class Canvas { | class Canvas { | ||||
public: | public: | ||||
@@ -98,6 +107,7 @@ public: | |||||
QList<group_dict_t> group_list; | QList<group_dict_t> group_list; | ||||
QList<port_dict_t> port_list; | QList<port_dict_t> port_list; | ||||
QList<connection_dict_t> connection_list; | QList<connection_dict_t> connection_list; | ||||
QList<animation_dict_t> animation_list; | |||||
CanvasObject* qobject; | CanvasObject* qobject; | ||||
QSettings* settings; | QSettings* settings; | ||||
Theme* theme; | Theme* theme; | ||||
@@ -116,8 +126,11 @@ QPointF CanvasGetNewGroupPos(bool horizontal=false); | |||||
QString CanvasGetFullPortName(int port_id); | QString CanvasGetFullPortName(int port_id); | ||||
QList<int> CanvasGetPortConnectionList(int port_id); | QList<int> CanvasGetPortConnectionList(int port_id); | ||||
int CanvasGetConnectedPort(int connection_id, int port_id); | int CanvasGetConnectedPort(int connection_id, int port_id); | ||||
void CanvasRemoveAnimation(CanvasFadeAnimation* f_animation); | |||||
void CanvasPostponedGroups(); | void CanvasPostponedGroups(); | ||||
void CanvasCallback(CallbackAction action, int value1, int value2, QString value_str); | void CanvasCallback(CallbackAction action, int value1, int value2, QString value_str); | ||||
void CanvasItemFX(QGraphicsItem* item, bool show, bool destroy=false); | |||||
void CanvasRemoveItemFX(QGraphicsItem* item); | |||||
// global objects | // global objects | ||||
extern Canvas canvas; | extern Canvas canvas; | ||||
@@ -135,6 +135,12 @@ class connection_dict_t(object): | |||||
'widget' | 'widget' | ||||
] | ] | ||||
class animation_dict_t(object): | |||||
__slots__ = [ | |||||
'animation', | |||||
'item' | |||||
] | |||||
# Main Canvas object | # Main Canvas object | ||||
class Canvas(object): | class Canvas(object): | ||||
__slots__ = [ | __slots__ = [ | ||||
@@ -148,6 +154,7 @@ class Canvas(object): | |||||
'group_list', | 'group_list', | ||||
'port_list', | 'port_list', | ||||
'connection_list', | 'connection_list', | ||||
'animation_list', | |||||
'qobject', | 'qobject', | ||||
'settings', | 'settings', | ||||
'theme', | 'theme', | ||||
@@ -161,6 +168,28 @@ class CanvasObject(QObject): | |||||
def __init__(self, parent=None): | def __init__(self, parent=None): | ||||
QObject.__init__(self, parent) | QObject.__init__(self, parent) | ||||
@pyqtSlot() | |||||
def AnimationIdle(self): | |||||
animation = self.sender() | |||||
if (animation): | |||||
CanvasRemoveAnimation(animation) | |||||
@pyqtSlot() | |||||
def AnimationHide(self): | |||||
animation = self.sender() | |||||
if (animation): | |||||
if (animation.item()): | |||||
animation.item().hide() | |||||
CanvasRemoveAnimation(animation) | |||||
@pyqtSlot() | |||||
def AnimationDestroy(self): | |||||
animation = self.sender() | |||||
if (animation): | |||||
if (animation.item()): | |||||
CanvasRemoveItemFX(animation.item()) | |||||
CanvasRemoveAnimation(animation) | |||||
@pyqtSlot() | @pyqtSlot() | ||||
def CanvasPostponedGroups(self): | def CanvasPostponedGroups(self): | ||||
CanvasPostponedGroups() | CanvasPostponedGroups() | ||||
@@ -285,6 +314,7 @@ def init(scene, callback, debug=False): | |||||
canvas.group_list = [] | canvas.group_list = [] | ||||
canvas.port_list = [] | canvas.port_list = [] | ||||
canvas.connection_list = [] | canvas.connection_list = [] | ||||
canvas.animation_list = [] | |||||
if (not canvas.qobject): canvas.qobject = CanvasObject() | if (not canvas.qobject): canvas.qobject = CanvasObject() | ||||
if (not canvas.settings): canvas.settings = QSettings(PATCHCANVAS_ORGANISATION_NAME, "PatchCanvas") | if (not canvas.settings): canvas.settings = QSettings(PATCHCANVAS_ORGANISATION_NAME, "PatchCanvas") | ||||
@@ -394,6 +424,9 @@ def addGroup(group_id, group_name, split=SPLIT_UNDEF, icon=ICON_APPLICATION): | |||||
canvas.last_z_value += 1 | canvas.last_z_value += 1 | ||||
group_sbox.setZValue(canvas.last_z_value) | group_sbox.setZValue(canvas.last_z_value) | ||||
if (options.auto_hide_groups == False and options.eyecandy): | |||||
CanvasItemFX(group_sbox, True) | |||||
else: | else: | ||||
group_box.setSplit(False) | group_box.setSplit(False) | ||||
@@ -409,6 +442,9 @@ def addGroup(group_id, group_name, split=SPLIT_UNDEF, icon=ICON_APPLICATION): | |||||
canvas.group_list.append(group_dict) | canvas.group_list.append(group_dict) | ||||
if (options.auto_hide_groups == False and options.eyecandy): | |||||
CanvasItemFX(group_box, True) | |||||
QTimer.singleShot(0, canvas.scene, SLOT("update()")) | QTimer.singleShot(0, canvas.scene, SLOT("update()")) | ||||
def removeGroup(group_id): | def removeGroup(group_id): | ||||
@@ -428,18 +464,24 @@ def removeGroup(group_id): | |||||
canvas.settings.setValue("CanvasPositions/%s_INPUT" % (group_name), s_item.pos()) | canvas.settings.setValue("CanvasPositions/%s_INPUT" % (group_name), s_item.pos()) | ||||
canvas.settings.setValue("CanvasPositions/%s_SPLIT" % (group_name), SPLIT_YES) | canvas.settings.setValue("CanvasPositions/%s_SPLIT" % (group_name), SPLIT_YES) | ||||
s_item.removeIconFromScene() | |||||
canvas.scene.removeItem(s_item) | |||||
del s_item | |||||
if (options.eyecandy): | |||||
CanvasItemFX(s_item, False, True) | |||||
else: | |||||
s_item.removeIconFromScene() | |||||
canvas.scene.removeItem(s_item) | |||||
del s_item | |||||
else: | else: | ||||
if (features.handle_group_pos): | if (features.handle_group_pos): | ||||
canvas.settings.setValue("CanvasPositions/%s" % (group_name), item.pos()) | canvas.settings.setValue("CanvasPositions/%s" % (group_name), item.pos()) | ||||
canvas.settings.setValue("CanvasPositions/%s_SPLIT" % (group_name), SPLIT_NO) | canvas.settings.setValue("CanvasPositions/%s_SPLIT" % (group_name), SPLIT_NO) | ||||
item.removeIconFromScene() | |||||
canvas.scene.removeItem(item) | |||||
del item | |||||
if (options.eyecandy): | |||||
CanvasItemFX(item, False, True) | |||||
else: | |||||
item.removeIconFromScene() | |||||
canvas.scene.removeItem(item) | |||||
del item | |||||
canvas.group_list.remove(group) | canvas.group_list.remove(group) | ||||
@@ -684,6 +726,9 @@ def addPort(group_id, port_id, port_name, port_mode, port_type): | |||||
qCritical("patchcanvas::addPort(%i, %i, %s, %s, %s) - Unable to find parent group" % (group_id, port_id, port_name.encode(), port_mode2str(port_mode), port_type2str(port_type))) | qCritical("patchcanvas::addPort(%i, %i, %s, %s, %s) - Unable to find parent group" % (group_id, port_id, port_name.encode(), port_mode2str(port_mode), port_type2str(port_type))) | ||||
return | return | ||||
if (options.eyecandy): | |||||
CanvasItemFX(port_widget, True) | |||||
port_dict = port_dict_t() | port_dict = port_dict_t() | ||||
port_dict.group_id = group_id | port_dict.group_id = group_id | ||||
port_dict.port_id = port_id | port_dict.port_id = port_id | ||||
@@ -773,6 +818,10 @@ def connectPorts(connection_id, port_out_id, port_in_id): | |||||
canvas.connection_list.append(connection_dict) | canvas.connection_list.append(connection_dict) | ||||
if (options.eyecandy): | |||||
item = connection_dict.widget | |||||
CanvasItemFX(item, True) | |||||
QTimer.singleShot(0, canvas.scene, SLOT("update()")) | QTimer.singleShot(0, canvas.scene, SLOT("update()")) | ||||
def disconnectPorts(connection_id): | def disconnectPorts(connection_id): | ||||
@@ -817,7 +866,10 @@ def disconnectPorts(connection_id): | |||||
item1.parentItem().removeLineFromGroup(connection_id) | item1.parentItem().removeLineFromGroup(connection_id) | ||||
item2.parentItem().removeLineFromGroup(connection_id) | item2.parentItem().removeLineFromGroup(connection_id) | ||||
line.deleteFromScene() | |||||
if (options.eyecandy): | |||||
CanvasItemFX(line, False, True) | |||||
else: | |||||
line.deleteFromScene() | |||||
QTimer.singleShot(0, canvas.scene, SLOT("update()")) | QTimer.singleShot(0, canvas.scene, SLOT("update()")) | ||||
@@ -916,6 +968,16 @@ def CanvasGetConnectedPort(connection_id, port_id): | |||||
qCritical("PatchCanvas::CanvasGetConnectedPort(%i, %i) - unable to find connection" % (connection_id, port_id)) | qCritical("PatchCanvas::CanvasGetConnectedPort(%i, %i) - unable to find connection" % (connection_id, port_id)) | ||||
return 0 | return 0 | ||||
def CanvasRemoveAnimation(f_animation): | |||||
if (canvas.debug): | |||||
qDebug("PatchCanvas::CanvasRemoveAnimation(%s)" % (f_animation)) | |||||
for animation in canvas.animation_list: | |||||
if (animation.animation == f_animation): | |||||
del animation.animation | |||||
canvas.animation_list.remove(animation) | |||||
break | |||||
def CanvasPostponedGroups(): | def CanvasPostponedGroups(): | ||||
if (canvas.debug): | if (canvas.debug): | ||||
qDebug("PatchCanvas::CanvasPostponedGroups()") | qDebug("PatchCanvas::CanvasPostponedGroups()") | ||||
@@ -926,6 +988,52 @@ def CanvasCallback(action, value1, value2, value_str): | |||||
canvas.callback(action, value1, value2, value_str); | canvas.callback(action, value1, value2, value_str); | ||||
def CanvasItemFX(item, show, destroy=False): | |||||
if (canvas.debug): | |||||
qDebug("PatchCanvas::CanvasItemFX(%s, %s, %s)" % (item, bool2str(show), bool2str(destroy))) | |||||
# Check if item already has an animationItemFX | |||||
for animation in canvas.animation_list: | |||||
if (animation.item == item): | |||||
animation.animation.stop() | |||||
del animation.animation | |||||
canvas.animation_list.remove(animation) | |||||
break | |||||
animation = CanvasFadeAnimation(item, show) | |||||
animation.setDuration(750 if (show) else 500) | |||||
animation_dict = animation_dict_t() | |||||
animation_dict.animation = animation | |||||
animation_dict.item = item | |||||
canvas.animation_list.append(animation_dict) | |||||
if (show): | |||||
QObject.connect(animation, SIGNAL("finished()"), canvas.qobject, SLOT("AnimationIdle()")) | |||||
else: | |||||
if (destroy): | |||||
QObject.connect(animation, SIGNAL("finished()"), canvas.qobject, SLOT("AnimationDestroy()")) | |||||
else: | |||||
QObject.connect(animation, SIGNAL("finished()"), canvas.qobject, SLOT("AnimationHide()")) | |||||
animation.start() | |||||
def CanvasRemoveItemFX(item): | |||||
if (canvas.debug): | |||||
qDebug("PatchCanvas::CanvasRemoveItemFX(%s)" % (item)) | |||||
if (item.type() == CanvasBoxType): | |||||
item.removeIconFromScene() | |||||
canvas.scene.removeItem(item) | |||||
del item | |||||
elif (item.type() == CanvasBoxType): | |||||
canvas.scene.removeItem(item) | |||||
del item | |||||
elif (item.type() in (CanvasLineType,CanvasBezierLineType)): | |||||
item.deleteFromScene() | |||||
# ------------------------------------------------------------------------------ | # ------------------------------------------------------------------------------ | ||||
# patchscene.cpp | # patchscene.cpp | ||||
@@ -1130,6 +1238,9 @@ class CanvasFadeAnimation(QAbstractAnimation): | |||||
self.m_duration = 0 | self.m_duration = 0 | ||||
self.m_item = item | self.m_item = item | ||||
def item(self): | |||||
return self.m_item | |||||
def setDuration(self, time): | def setDuration(self, time): | ||||
if (self.m_show == False and self.m_item.opacity() == 0): | if (self.m_show == False and self.m_item.opacity() == 0): | ||||
self._duration = 0 | self._duration = 0 | ||||
@@ -1861,6 +1972,8 @@ class CanvasBox(QGraphicsItem): | |||||
def addPortFromGroup(self, port_id, port_mode, port_type, port_name): | def addPortFromGroup(self, port_id, port_mode, port_type, port_name): | ||||
if (len(self.m_port_list_ids) == 0): | if (len(self.m_port_list_ids) == 0): | ||||
if (options.auto_hide_groups): | if (options.auto_hide_groups): | ||||
if (options.eyecandy): | |||||
CanvasItemFX(self, True) | |||||
self.setVisible(True) | self.setVisible(True) | ||||
new_widget = CanvasPort(port_id, port_name, port_mode, port_type, self) | new_widget = CanvasPort(port_id, port_name, port_mode, port_type, self) | ||||
@@ -1888,7 +2001,10 @@ class CanvasBox(QGraphicsItem): | |||||
self.updatePositions() | self.updatePositions() | ||||
elif (self.isVisible()): | elif (self.isVisible()): | ||||
if (options.auto_hide_groups): | if (options.auto_hide_groups): | ||||
self.setVisible(False) | |||||
if (options.eyecandy): | |||||
CanvasItemFX(self, False) | |||||
else: | |||||
self.setVisible(False) | |||||
def addLineFromGroup(self, line, connection_id): | def addLineFromGroup(self, line, connection_id): | ||||
new_cbline = cb_line_t() | new_cbline = cb_line_t() | ||||