Class: Motion::Xray::FrameEditor
- Inherits:
-
PropertyEditor
- Object
- Editor
- PropertyEditor
- Motion::Xray::FrameEditor
- Defined in:
- lib/motion-xray/z_editors/xray_frame_editor.rb
Instance Attribute Summary
Attributes inherited from Editor
Instance Method Summary collapse
- #change_origin(delta) ⇒ Object
- #change_size(delta) ⇒ Object
- #did_change? ⇒ Boolean
- #edit_view(container_width) ⇒ Object
- #update_frame ⇒ Object
Methods inherited from PropertyEditor
#get_value, #initialize, #set_value
Methods inherited from Editor
#get_edit_view, #initialize, with_target
Constructor Details
This class inherits a constructor from Motion::Xray::PropertyEditor
Instance Method Details
#change_origin(delta) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/motion-xray/z_editors/xray_frame_editor.rb', line 62 def change_origin(delta) if @locked_button.lock_state == XrayLockButton::LockedState return end if @locked_button.lock_state == XrayLockButton::LockedHorizontalState delta.y = 0 end if @locked_button.lock_state == XrayLockButton::LockedVerticalState delta.x = 0 end frame = get_value frame.origin.x += delta.x frame.origin.y += delta.y set_value(frame) update_frame end |
#change_size(delta) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/motion-xray/z_editors/xray_frame_editor.rb', line 82 def change_size(delta) if @locked_button.lock_state == XrayLockButton::LockedState return end if @locked_button.lock_state == XrayLockButton::LockedHorizontalState delta.y = 0 end if @locked_button.lock_state == XrayLockButton::LockedVerticalState delta.x = 0 end frame = get_value frame.size.width += delta.x frame.size.height += delta.y set_value(frame) update_frame end |
#did_change? ⇒ Boolean
102 103 104 |
# File 'lib/motion-xray/z_editors/xray_frame_editor.rb', line 102 def did_change? ! CGRectEqualToRect(@original, @target.send(@property)) end |
#edit_view(container_width) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/motion-xray/z_editors/xray_frame_editor.rb', line 5 def edit_view(container_width) return UIView.alloc.initWithFrame([[0, 0], [container_width, 80]]).tap do |view| frame_view = UIView.alloc.initWithFrame([[4, 4], [92, 72]]) frame_view.clipsToBounds = true frame_view.backgroundColor = :light_gray.uicolor frame_view.layer.borderWidth = 1 frame_view.layer.borderColor = :gray.uicolor.cgcolor frame_view.layer.cornerRadius = 5 view << frame_view labels_view = UIView.alloc.initWithFrame([[3, 0], [24, frame_view.bounds.height]]) label = UILabel.new label.frame = [[4, 0], [18, 72]] label.text = "X:\nY:\nW:\nH:" label.textAlignment = :right.nstextalignment label.font = :small.uifont label.backgroundColor = :clear.uicolor label.numberOfLines = 4 labels_view << label frame_view << labels_view values_view = UIView.alloc.initWithFrame([[labels_view.frame.max_x, 0], [65, frame_view.bounds.height]]) values_view.backgroundColor = :white.uicolor values_view.layer.borderWidth = 1 values_view.layer.borderColor = :gray.uicolor @frame_label = UILabel.new @frame_label.frame = [[8, 0], [52, 72]] @frame_label.font = :small.uifont @frame_label.backgroundColor = :clear.uicolor @frame_label.numberOfLines = 0 values_view << @frame_label update_frame frame_view << values_view origin_dpad = XrayDpad.alloc.initWithFrame([[100, 4], [72, 72]]) origin_dpad.add_listener(self, :change_origin) view << origin_dpad size_dpad = XrayDpad.alloc.initWithFrame([[176, 4], [72, 72]]) size_dpad.add_listener(self, :change_size) view << size_dpad @locked_button = XrayLockButton.alloc.init @locked_button.frame = @locked_button.frame.x(252).y(27) view << @locked_button end end |
#update_frame ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/motion-xray/z_editors/xray_frame_editor.rb', line 54 def update_frame frame = get_value @frame_label.text = "#{frame.origin.x}\n" + "#{frame.origin.y}\n" + "#{frame.size.width}\n" + "#{frame.size.height}" end |