From 7a237562c3cf3957a074179d6918e2855cb68bcc Mon Sep 17 00:00:00 2001 From: nick87720z Date: Mon, 15 Oct 2018 00:27:07 +0500 Subject: [PATCH] Frontend fixes (#774) * connection lines: Fix line selection bug Connection line was unselected if selection changed from input port to output port for same connection, probably due to repaint order issue. New variant should be more stable, yet not requiring non-standard state variable. * rack: Reset to noop color if unknown skin set Some skins are initially designed to have hardcoded, color scheme. With previously selected dark color and new dark skin, it may become close to black. --- source/frontend/carla_host.py | 5 ++++- source/frontend/patchcanvas.py | 28 +++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index d0c1ffe02..6827f800a 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -608,7 +608,10 @@ class HostWindow(QMainWindow): return self.host.set_custom_data(pluginId, CUSTOM_DATA_TYPE_PROPERTY, "CarlaSkin", skin) - pitem.recreateWidget(newSkin = skin) + if skin not in ("default","rncbc","presets","mpresets"): + pitem.recreateWidget(newSkin = skin, newColor = (255,255,255)) + else: + pitem.recreateWidget(newSkin = skin) def switchPlugins(self, pluginIdA, pluginIdB): if pluginIdA == pluginIdB: diff --git a/source/frontend/patchcanvas.py b/source/frontend/patchcanvas.py index 05d2d9acf..593d7daaf 100644 --- a/source/frontend/patchcanvas.py +++ b/source/frontend/patchcanvas.py @@ -1619,9 +1619,9 @@ class CanvasLine(QGraphicsLineItem): return if options.eyecandy == EYECANDY_FULL: - if yesno: + if yesno and not self.m_lineSelected: self.setGraphicsEffect(CanvasPortGlow(self.item1.getPortType(), self.toGraphicsObject())) - else: + elif self.m_lineSelected and not yesno: self.setGraphicsEffect(None) self.m_lineSelected = yesno @@ -1720,9 +1720,9 @@ class CanvasBezierLine(QGraphicsPathItem): return if options.eyecandy == EYECANDY_FULL: - if yesno: + if yesno and not self.m_lineSelected: self.setGraphicsEffect(CanvasPortGlow(self.item1.getPortType(), self.toGraphicsObject())) - else: + elif self.m_lineSelected and not yesno: self.setGraphicsEffect(None) self.m_lineSelected = yesno @@ -1935,7 +1935,6 @@ class CanvasPort(QGraphicsItem): self.m_line_mov = None self.m_hover_item = None - self.m_last_selected_state = False self.m_mouse_down = False self.m_cursor_moving = False @@ -2150,6 +2149,17 @@ class CanvasPort(QGraphicsItem): elif act_selected == act_x_rename: canvas.callback(ACTION_PORT_RENAME, self.m_group_id, self.m_port_id, "") + def setPortSelected(self, yesno): + for connection in canvas.connection_list: + if ((connection.group_out_id == self.m_group_id and connection.port_out_id == self.m_port_id) or + (connection.group_in_id == self.m_group_id and connection.port_in_id == self.m_port_id)): + connection.widget.setLineSelected(yesno) + + def itemChange(self, change, value): + if change == QGraphicsItem.ItemSelectedHasChanged: + self.setPortSelected(value) + return QGraphicsItem.itemChange(self, change, value) + def triggerDisconnect(self, conn_list=None): if not conn_list: conn_list = CanvasGetPortConnectionList(self.m_group_id, self.m_port_id) @@ -2266,12 +2276,6 @@ class CanvasPort(QGraphicsItem): painter.setFont(self.m_port_font) painter.drawText(text_pos, self.m_port_name) - if self.isSelected() != self.m_last_selected_state: - for connection in canvas.connection_list: - if ((connection.group_out_id == self.m_group_id and connection.port_out_id == self.m_port_id) or - (connection.group_in_id == self.m_group_id and connection.port_in_id == self.m_port_id)): - connection.widget.setLineSelected(self.isSelected()) - if canvas.theme.idx == Theme.THEME_OOSTUDIO and canvas.theme.port_bg_pixmap: painter.setPen(Qt.NoPen) painter.setBrush(conn_pen.brush()) @@ -2283,8 +2287,6 @@ class CanvasPort(QGraphicsItem): painter.drawRect(connRect) - self.m_last_selected_state = self.isSelected() - painter.restore() # ------------------------------------------------------------------------------