Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multitouch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
multitouch
Commits
b9c5b6e3
Commit
b9c5b6e3
authored
Jun 09, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First attempt to make cairo rectangle draggable.
parent
878291b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
tests/cairotest.py
tests/cairotest.py
+27
-15
No files found.
tests/cairotest.py
View file @
b9c5b6e3
...
...
@@ -19,6 +19,14 @@ class Rectangle(mt.RectangularWidget):
self
.
scale
=
1
self
.
color
=
color
self
.
on_drag
(
self
.
move
)
def
move
(
self
,
g
):
print
'drag rectangle'
,
g
.
get_translation
()
self
.
translate
(
*
g
.
get_translation
())
print
self
refresh
()
def
scale
(
self
,
angle
):
self
.
scale
*=
scale
...
...
@@ -27,7 +35,7 @@ class Rectangle(mt.RectangularWidget):
def
get_transformation_matrix
(
self
):
t
=
cairo
.
Matrix
()
t
.
translate
(
*
self
.
get_position
()
)
t
.
translate
(
*
self
)
t
.
rotate
(
self
.
angle
)
t
.
scale
(
self
.
scale
,
self
.
scale
)
return
t
...
...
@@ -48,8 +56,6 @@ def create_context_window(w, h, callback):
def
create_context
(
area
,
event
):
"""Add Cairo context to GTK window and draw initial state."""
global
cr
#if cr:
# return
cr
=
area
.
window
.
cairo_create
()
draw
()
...
...
@@ -78,24 +84,26 @@ def create_context_window(w, h, callback):
root
=
mt
.
RectangularWidget
(
0
,
0
,
w
,
h
)
# GTK window
win
=
gtk
.
Window
()
win
.
set_title
(
'Cairo test'
)
win
.
connect
(
'destroy'
,
quit
)
win
.
connect
(
'key-press-event'
,
handle_key
)
win
.
connect
(
'configure-event'
,
move_window
)
win
.
connect
(
'show'
,
callback
)
global
window
window
=
gtk
.
Window
()
window
.
set_title
(
'Cairo test'
)
window
.
connect
(
'destroy'
,
quit
)
window
.
connect
(
'key-press-event'
,
handle_key
)
window
.
connect
(
'configure-event'
,
move_window
)
window
.
connect
(
'show'
,
callback
)
# Drawing area, needed by cairo context for drawing
area
=
gtk
.
DrawingArea
()
area
.
set_size_request
(
w
,
h
)
area
.
connect
(
'expose-event'
,
create_context
)
win
.
add
(
area
)
win
dow
.
add
(
area
)
area
.
show
()
win
.
show
()
win
dow
.
show
()
def
draw
():
def
draw
(
*
args
):
print
'draw'
# Background
cr
.
rectangle
(
0
,
0
,
*
root
.
get_size
())
cr
.
set_source_rgb
(
0
,
1
,
0
)
...
...
@@ -103,13 +111,17 @@ def draw():
# Drawable objects (use save and restore to allow transformations)
for
obj
in
draw_objects
:
#
cr.save()
cr
.
save
()
obj
.
draw
(
cr
)
#cr.restore()
cr
.
restore
()
def
refresh
():
window
.
queue_draw
()
# Initialization
cr
=
root
=
None
window
=
cr
=
root
=
None
draw_objects
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment