Remove Item.request_update()

Updates should be requested on the Canvas now.
This commit is contained in:
Arjan Molenaar 2020-10-23 18:11:45 +02:00
parent b281b1fcdd
commit 9a0f23360d
8 changed files with 12 additions and 15 deletions

View File

@ -193,7 +193,7 @@ class ItemHandleInMotion:
# do not request matrix update as matrix recalculation will be
# performed due to item normalization if required
item.request_update(matrix=False)
view.canvas.request_update(item, matrix=False)
return sink

View File

@ -253,6 +253,7 @@ class GuidedItemHandleInMotion(GuideMixin, ItemHandleInMotion):
if not sink:
item = self.item
view = self.view
canvas = view.canvas
x, y = pos
v2i = view.get_matrix_v2i(item)
@ -277,7 +278,7 @@ class GuidedItemHandleInMotion(GuideMixin, ItemHandleInMotion):
self.queue_draw_guides()
item.request_update()
canvas.request_update(item)
def stop_move(self):
self.queue_draw_guides()

View File

@ -89,10 +89,6 @@ class Item:
def matrix_i2c(self) -> Matrix:
return self._matrix_i2c
def request_update(self, update=True, matrix=True):
if self._canvas:
self._canvas.request_update(self, update=update, matrix=matrix)
def pre_update(self, context):
"""Perform any changes before item update here, for example:
@ -419,7 +415,7 @@ class Line(Item):
p1.x.notify()
p1.y.notify()
self._set_orthogonal_constraints(cons)
self.request_update()
self.canvas.request_update(self)
@observed
def _set_orthogonal_constraints(self, orthogonal_constraints):

View File

@ -230,7 +230,7 @@ class SegmentHandleSelection(ItemHandleSelection):
Segment(item, self.view).merge_segment(segment)
if handle:
item.request_update()
self.view.canvas.request_update(item)
@PaintFocused.register(Line)

View File

@ -390,7 +390,7 @@ class HandleTool(Tool):
self.ungrab_handle()
if grabbed_handle and grabbed_item:
grabbed_item.request_update()
self.view.canvas.request_update(grabbed_item)
return True
def on_motion_notify(self, event):

View File

@ -29,14 +29,14 @@ class SimpleCanvas:
self.box1.matrix.translate(100, 50)
self.box1.width = 40
self.box1.height = 40
self.box1.request_update()
self.canvas.request_update(self.box1)
self.box2 = Box()
self.canvas.add(self.box2)
self.box2.matrix.translate(100, 150)
self.box2.width = 50
self.box2.height = 50
self.box2.request_update()
self.canvas.request_update(self.box2)
self.line = Line()
self.head = self.line.handles()[0]

View File

@ -52,7 +52,7 @@ def test_resize_se(cb):
for _ in range(count):
h_se.pos.x += 100 # h.se.{x,y} = 10, now
h_se.pos.y += 100
cb.box.request_update()
cb.canvas.request_update(cb.box)
cb.canvas.update()
assert 110 * count == h_se.pos.x # h_se changed above, should remain the same
@ -76,7 +76,7 @@ def test_minimal_se(cb):
h_se.pos.y -= 20
assert h_se.pos.x == h_se.pos.y == -10
cb.box.request_update()
cb.canvas.request_update(cb.box)
cb.canvas.update()
assert 10 == h_se.pos.x # h_se changed above, should be 10

View File

@ -99,7 +99,7 @@ def test_guide_item_in_motion(win):
assert 0 == win.e1.matrix[5]
win.e2.matrix.translate(40, 40)
win.e2.request_update()
win.canvas.request_update(win.e2)
assert 40 == win.e2.matrix[4]
assert 40 == win.e2.matrix[5]
@ -134,7 +134,7 @@ def test_guide_item_in_motion_2(win):
assert 0 == win.e1.matrix[5]
win.e2.matrix.translate(40, 40)
win.e2.request_update()
win.canvas.request_update(win.e2)
assert 40 == win.e2.matrix[4]
assert 40 == win.e2.matrix[5]