lib/glimmer/swt/custom/shape.rb in glimmer-dsl-swt-4.20.13.1 vs lib/glimmer/swt/custom/shape.rb in glimmer-dsl-swt-4.20.13.2
- old
+ new
@@ -60,11 +60,11 @@
# Represents a shape (graphics) to be drawn on a control/widget/canvas/display
# That is because Shape is drawn on a parent as graphics and doesn't have an SWT widget for itself
class Shape
include Properties
- DropEvent = Struct.new(:x, :y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y, :dragging_x, :dragging_y, :drop_shapes, keyword_init: true)
+ DropEvent = Struct.new(:doit, :x, :y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y, :dragging_x, :dragging_y, :drop_shapes, keyword_init: true)
class << self
attr_accessor :dragging, :dragging_x, :dragging_y, :dragged_shape, :dragged_shape_original_x, :dragged_shape_original_y
alias dragging? dragging
@@ -592,10 +592,11 @@
if observation_request == 'on_drop'
Shape.drop_shapes << self
handle_observation_request('on_mouse_up') do |event|
if Shape.dragged_shape
drop_event = DropEvent.new(
+ doit: true,
dragged_shape: Shape.dragged_shape,
dragged_shape_original_x: Shape.dragged_shape_original_x,
dragged_shape_original_y: Shape.dragged_shape_original_y,
dragging_x: Shape.dragging_x,
dragging_y: Shape.dragging_y,
@@ -607,10 +608,14 @@
shape_block.call(drop_event)
rescue => e
Glimmer::Config.logger.error e.full_message
ensure
Shape.dragging = false
+ if !drop_event.doit && Shape.dragged_shape
+ Shape.dragged_shape.x = Shape.dragged_shape_original_x
+ Shape.dragged_shape.y = Shape.dragged_shape_original_y
+ end
Shape.dragged_shape = nil
end
end
end
else
@@ -774,9 +779,10 @@
shapes.dup.each {|shape| shape.dispose(dispose_images: dispose_images, dispose_patterns: dispose_patterns, redraw: true) }
else
shapes.dup.each {|shape| shape.dispose(dispose_images: dispose_images, dispose_patterns: dispose_patterns, redraw: false) }
end
end
+ alias dispose_shapes clear_shapes
# Indicate if this is a container shape (meaning a shape bag that is just there to contain nested shapes, but doesn't render anything of its own)
def container?
@name == 'shape'
end