Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
d6c8da8e
Commit
d6c8da8e
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Enable horizontal flipping of operations
parent
a32dbe1c
No related branches found
No related tags found
1 merge request
!105
Enable horizontal flipping of operations
Pipeline
#88077
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/GUI/drag_button.py
+25
-1
25 additions, 1 deletion
b_asic/GUI/drag_button.py
with
25 additions
and
1 deletion
b_asic/GUI/drag_button.py
+
25
−
1
View file @
d6c8da8e
...
...
@@ -12,7 +12,8 @@ from qtpy.QtWidgets import QAction, QMenu, QPushButton
from
b_asic.GUI.properties_window
import
PropertiesWindow
from
b_asic.GUI.utils
import
decorate_class
,
handle_error
from
b_asic.GUI._preferences
import
GRID
,
MINBUTTONSIZE
from
b_asic.GUI._preferences
import
GRID
,
MINBUTTONSIZE
,
PORTWIDTH
from
b_asic.port
import
InputPort
@decorate_class
(
handle_error
)
...
...
@@ -47,6 +48,7 @@ class DragButton(QPushButton):
self
.
_m_drag
=
False
self
.
_mouse_press_pos
=
None
self
.
_mouse_move_pos
=
None
self
.
_flipped
=
False
super
().
__init__
(
parent
)
def
contextMenuEvent
(
self
,
event
):
...
...
@@ -58,6 +60,10 @@ class DragButton(QPushButton):
delete
=
QAction
(
"
Delete
"
)
menu
.
addAction
(
delete
)
delete
.
triggered
.
connect
(
self
.
remove
)
flip
=
QAction
(
"
Flip horizontal
"
)
menu
.
addAction
(
flip
)
flip
.
triggered
.
connect
(
self
.
_flip
)
menu
.
exec_
(
self
.
cursor
().
pos
())
def
show_properties_window
(
self
,
event
):
...
...
@@ -116,6 +122,20 @@ class DragButton(QPushButton):
self
.
_window
.
graphic_view
.
update
()
super
().
mouseReleaseEvent
(
event
)
def
_flip
(
self
,
event
):
self
.
_flipped
=
not
self
.
_flipped
for
pb
in
self
.
ports
:
if
isinstance
(
pb
.
port
,
InputPort
):
newx
=
MINBUTTONSIZE
-
PORTWIDTH
if
self
.
_flipped
else
0
else
:
newx
=
0
if
self
.
_flipped
else
MINBUTTONSIZE
-
PORTWIDTH
text
=
"
<
"
if
self
.
_flipped
else
"
>
"
pb
.
move
(
newx
,
pb
.
pos
().
y
())
pb
.
setText
(
text
)
self
.
_window
.
scene
.
update
()
self
.
_window
.
graphic_view
.
update
()
def
_toggle_button
(
self
,
pressed
=
False
):
self
.
pressed
=
not
pressed
self
.
setStyleSheet
(
...
...
@@ -133,6 +153,10 @@ class DragButton(QPushButton):
self
.
setIcon
(
QIcon
(
path_to_image
))
self
.
setIconSize
(
QSize
(
MINBUTTONSIZE
,
MINBUTTONSIZE
))
def
is_flipped
(
self
):
"""
Return True if the button is flipped (inputs to the right).
"""
return
self
.
_is_flipped
def
select_button
(
self
,
modifiers
=
None
):
if
modifiers
!=
Qt
.
KeyboardModifier
.
ControlModifier
:
for
button
in
self
.
_window
.
pressed_operations
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment