From f358308919c1d902ba28dd5238c9cfc4e56c5b5f Mon Sep 17 00:00:00 2001
From: Sebastian Koslowski <koslowski@kit.edu>
Date: Tue, 16 Sep 2014 22:01:26 -0400
Subject: [PATCH 1/2] grc: fix lagging drag and drop
---
grc/gui/Block.py | 3 +--
grc/gui/Port.py | 24 +++++++++++++++---------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 0ae624f..1a32f6c 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -224,8 +224,7 @@ class Block(Element):
window.draw_drawable(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
#draw ports
for port in self.get_ports_gui():
- if not port.get_hide():
- port.draw(gc, window)
+ port.draw(gc, window)
def what_is_selected(self, coor, coor_m=None):
"""
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 188281a..364ca6a 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -45,7 +45,7 @@ class Port(Element):
"""
Element.__init__(self)
self.W = self.H = self.w = self.h = 0
- self._connector_coordinate = (0,0)
+ self._connector_coordinate = (0, 0)
self._connector_length = 0
self._hovering = True
self._force_label_unhidden = False
@@ -53,11 +53,15 @@ class Port(Element):
def create_shapes(self):
"""Create new areas and labels for the port."""
Element.create_shapes(self)
+ if self.get_hide():
+ return # this port is hidden, no need to create shapes
#get current rotation
rotation = self.get_rotation()
#get all sibling ports
- if self.is_source(): ports = self.get_parent().get_sources_gui()
- elif self.is_sink(): ports = self.get_parent().get_sinks_gui()
+ if self.is_source():
+ ports = self.get_parent().get_sources_gui()
+ elif self.is_sink():
+ ports = self.get_parent().get_sinks_gui()
#get the max width
self.W = max([port.W for port in ports] + [PORT_MIN_WIDTH])
W = self.W if not self._label_hidden() else PORT_LABEL_HIDDEN_WIDTH
@@ -70,7 +74,8 @@ class Port(Element):
return
length = len(filter(lambda p: not p.get_hide(), ports))
#reverse the order of ports for these rotations
- if rotation in (180, 270): index = length-index-1
+ if rotation in (180, 270):
+ index = length-index-1
offset = (self.get_parent().H - (length-1)*PORT_SEPARATION - self.H)/2
#create areas and connector coordinates
if (self.is_sink() and rotation == 0) or (self.is_source() and rotation == 180):
@@ -137,12 +142,13 @@ class Port(Element):
Element.draw(
self, gc, window, bg_color=self._bg_color,
border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or
- self.get_parent().is_dummy_block() and Colors.MISSING_BLOCK_BORDER_COLOR or Colors.BORDER_COLOR,
+ self.get_parent().is_dummy_block() and Colors.MISSING_BLOCK_BORDER_COLOR or
+ Colors.BORDER_COLOR,
)
- if self._label_hidden():
- return
- X,Y = self.get_coordinate()
- (x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels
+ if not self._areas_list or self._label_hidden():
+ return # this port is either hidden (no areas) or folded (no label)
+ X, Y = self.get_coordinate()
+ (x, y), (w, h) = self._areas_list[0] # use the first area's sizes to place the labels
if self.is_horizontal():
window.draw_drawable(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
elif self.is_vertical():
--
1.9.3
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCAAGBQJUGvgdAAoJEIcqoDnyZkMDxI0P/RkOuiQekULAX8V4M7z6gJ0l
XVP/nvw0n3DPrrmmOcYmmuubEKZ02G0uIujzRRr+fo/OWQ0+B2ZfIeWVadCYTn6Y
nBu1Chh4KBxa6+yJJ+vWfVo+c+9lelqBU1m5CLvqwhGk69WhImjY9ROmO4kcSCFD
Mhe6hj5DjQMCW4iWSKFPvwilBVT4RKqJI2u2t0NPs2INJhVOweE4NySMwl4sVIgj
dzX82T8CMbWx1RP9rpul4CpvYpm9kHV6MQFVOeuZM/83Zk1XKl86mU2nC/0fk75t
CV7KwCcOM3g7OVt63SPkOLKroEz+JQFmHqkVQC39Tqrv6DbNI4+MwbQlLNqpH1FE
8Rn3o9MjCh6Lwr2tT0z5HwGQ1I0hbn1kG6128jcZqd0nrHVgzcuhPm8UvUyTbjPC
L8ozAoDRIg7NTjIH6J50VuL67zK3hxmBAMEnUAOpyKGcUEjoYDK3JYM73dQ24YMF
lgPTdN36ys324F80vUAmTTHWpsAhYauq3QLeyzwclIBPgPgMSjKz6J65962+nWKh
T/SsDONQ8qnOWtpkMYZRvpKLGqal2d9zu0tY7Qx2GeFLu3I6s8NM4mNzu7HCHy0Z
OmXkanjbNaVhSIN1PPb5YXlLzQhZhFkhKs+3RCva2QAXuigi+MsJjvo0aJa1EKbA
tfBFb+Vm0LKePcvGJ7KF
=+osS
-----END PGP SIGNATURE-----
On 09/18/2014 10:53 AM, Marcus D. Leech wrote:
> What's the best way to apply this to master/HEAD ?
"git cherry-pick" or apply the attached patch file.
--
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)
Dipl.-Ing. Sebastian Koslowski
Research Associate
Kaiserstraße 12
Building 05.01
76131 Karlsruhe, Germany
Phone: +49 721 608-46275
Fax: +49 721 608-46071
Email: sebastian.koslowski@kit.edu
Web: http://www.cel.kit.edu/
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association
No comments:
Post a Comment