Class: Motion::Xray::UIPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/motion-xray/plugins/ui_plugin.rb

Instance Attribute Summary

Attributes inherited from Plugin

#name, #target, #view

Instance Method Summary collapse

Methods inherited from Plugin

#get_plugin_view, #hide, name, #show, #xray_name

Constructor Details

#initializeUIPlugin


6
7
8
# File 'lib/motion-xray/plugins/ui_plugin.rb', line 6

def initialize
  @editor_instances = []
end

Instance Method Details

#edit(target) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/motion-xray/plugins/ui_plugin.rb', line 16

def edit(target)
  super
  @editors.subviews.each &:removeFromSuperview
  @editor_instances = []

  properties = @target.xray
  sections = properties.keys
  properties.each do |section, editors|
    section_view = XraySectionHeader.alloc.initWithFrame([[0, 0], [Xray.ui.full_screen_width, 20]])
    section_view.text = section
    @editors << section_view
    editors.each do |property, editor_class|
      next unless editor_class

      editor_instance = editor_class.with_target(@target, property:property)
      @editor_instances << editor_instance
      section_view.tracking_view << editor_instance.get_edit_view(@editors.bounds.size.width)
    end
    @editors << section_view.tracking_view
  end
  @editors.layoutIfNeeded
end

#plugin_view(canvas) ⇒ Object


10
11
12
13
14
# File 'lib/motion-xray/plugins/ui_plugin.rb', line 10

def plugin_view(canvas)
  @editors = XrayTypewriterView.alloc.initWithFrame(canvas.bounds)
  @editors.scroll_view = canvas
  @editors
end