Skip to content

Commit

Permalink
Connections highlight on hower
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSekavcnik committed Dec 14, 2023
1 parent f9eff2e commit 000e762
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
Binary file modified quasi/gui/assets/beam_splitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions quasi/gui/assets/simple_trigger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quasi/gui/assets/wigner_control.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions quasi/gui/assets/wigner_control.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions quasi/gui/board/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@ def remove(self):
self.canvas.shapes.remove(self.connection)
self.canvas.update()
del self


def hover(self):
self.connection.paint = ft.Paint(
stroke_width=3,
style=ft.PaintingStyle.STROKE,
color="red"
)
self.canvas.update()

def hover_end(self):
self.connection.paint = ft.Paint(
stroke_width=3,
style=ft.PaintingStyle.STROKE,
color="black"
)
self.canvas.update()

13 changes: 10 additions & 3 deletions quasi/gui/board/ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def __init__(self,
self.right_radius = 0
self.left_radius = 5
self.port_comp = ft.GestureDetector(
on_enter=self.connection_hover_enter,
on_exit=self.connection_hover_exit,
on_secondary_tap=self.handle_on_right_click,
on_tap=self.handle_on_left_click,
mouse_cursor=ft.MouseCursor.CLICK,
Expand All @@ -52,6 +54,14 @@ def __init__(self,
def build(self) -> ft.Container:
return self.port_comp

def connection_hover_enter(self, e):
if self.connection is not None:
self.connection.hover()

def connection_hover_exit(self, e):
if self.connection is not None:
self.connection.redraw()

def get_location_on_board(self) -> Tuple[float, float]:
"""
Get center coordinates of the
Expand Down Expand Up @@ -94,7 +104,6 @@ def activate(self):
"""
Modifies the port when activated
"""
print("Activate")
self.port_comp.content.bgcolor = Ports.active_color
self.port_comp.content.update()

Expand Down Expand Up @@ -244,7 +253,6 @@ def handle_disconnect(self, port: Port):
Handles disconnect, when port is clicked
with right click
"""
print("DISCONNECT")
if port.connection is not None:
port.connection.remove()

Expand All @@ -259,7 +267,6 @@ def handle_connect(self, port: Port):
return
if self.first_click is None:
self.first_click = port
print("GETTING LOCATION ON BOARD")
self.first_location = port.get_location_on_board()
self.first_click.activate()
else:
Expand Down

0 comments on commit 000e762

Please sign in to comment.