Class: Reflex::View

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
HasFrame, HasTags, Xot::Hookable, Xot::Setter
Defined in:
lib/reflex/view.rb

Direct Known Subclasses

Button, ListView, TextView

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasTags

#clear_tags, #tag, #tag=, #tags, #untag

Methods included from HasFrame

#inset_by, #move_by, #move_to, #resize_by, #resize_to

Constructor Details

#initialize(options = nil, &block) ⇒ View

Returns a new instance of View.



56
57
58
59
60
# File 'lib/reflex/view.rb', line 56

def initialize(options = nil, &block)
  super()
  set options if options
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
end

Class Method Details

.has_modelObject



199
200
201
# File 'lib/reflex/view.rb', line 199

def self.has_model()
  include ModelView
end

Instance Method Details

#add_child(child, index: nil) ⇒ Object Also known as: add



76
77
78
# File 'lib/reflex/view.rb', line 76

def add_child(child, index: nil)
  add_child! child, index
end

#add_shape(shape, index: nil) ⇒ Object



117
118
119
# File 'lib/reflex/view.rb', line 117

def add_shape(shape, index: nil)
  add_shape! shape, index
end

#capturing?(*args) ⇒ Boolean

Returns:

  • (Boolean)


154
155
156
157
158
159
160
161
162
163
# File 'lib/reflex/view.rb', line 154

def capturing?(*args)
  args, cap = args.flatten, capture
  if args.empty?
    not cap.empty?
  elsif args.include?(:all)
    cap == [:key, :pointer, :midi]
  else
    args.all? {|type| cap.include? type}
  end
end

#chase(*args, **options, &block) ⇒ Object



141
142
143
# File 'lib/reflex/view.rb', line 141

def chase(*args, **options, &block)
  pin.chase(*args, **options, &block)
end

#childrenObject



93
94
95
# File 'lib/reflex/view.rb', line 93

def children()
  each_child.to_a
end

#constraintsObject



150
151
152
# File 'lib/reflex/view.rb', line 150

def constraints()
  each_constraint.to_a
end

#delay(seconds = 0, &block) ⇒ Object



72
73
74
# File 'lib/reflex/view.rb', line 72

def delay(seconds = 0, &block)
  timeout seconds, &block
end

#each_child(&block) ⇒ Object



88
89
90
91
# File 'lib/reflex/view.rb', line 88

def each_child(&block)
  return enum_for :each_child unless block
  each_child!(&block)
end

#each_constraint(&block) ⇒ Object



145
146
147
148
# File 'lib/reflex/view.rb', line 145

def each_constraint(&block)
  return enum_for :each_constraint unless block
  each_constraint!(&block)
end

#each_shape(&block) ⇒ Object



112
113
114
115
# File 'lib/reflex/view.rb', line 112

def each_shape(&block)
  return enum_for :each_shape unless block
  each_shape!(&block)
end

#each_style(&block) ⇒ Object



97
98
99
100
# File 'lib/reflex/view.rb', line 97

def each_style(&block)
  return enum_for :each_style unless block
  each_style!(&block)
end

#find_child(*args) ⇒ Object Also known as: find



84
85
86
# File 'lib/reflex/view.rb', line 84

def find_child(*args)
  find_children(*args).first
end

#interval(seconds = 0, &block) ⇒ Object



68
69
70
# File 'lib/reflex/view.rb', line 68

def interval(seconds = 0, &block)
  timeout seconds, count: -1, &block
end


133
134
135
# File 'lib/reflex/view.rb', line 133

def link(*args, **options, &block)
  pin.link(*args, **options, &block)
end

#on_contact(e) ⇒ Object



165
166
# File 'lib/reflex/view.rb', line 165

def on_contact(e)
end

#on_contact_begin(e) ⇒ Object



168
169
# File 'lib/reflex/view.rb', line 168

def on_contact_begin(e)
end

#on_contact_end(e) ⇒ Object



171
172
# File 'lib/reflex/view.rb', line 171

def on_contact_end(e)
end

#pin(*args) ⇒ Object



125
126
127
# File 'lib/reflex/view.rb', line 125

def pin(*args)
  Pin.new self, *args
end

#remove_selfObject



80
81
82
# File 'lib/reflex/view.rb', line 80

def remove_self()
  parent.remove self if parent
end

#shapesObject



121
122
123
# File 'lib/reflex/view.rb', line 121

def shapes()
  each_shape.to_a
end

#snap(*args, **options, &block) ⇒ Object



129
130
131
# File 'lib/reflex/view.rb', line 129

def snap(*args, **options, &block)
  pin.snap(*args, **options, &block)
end

#style(*args, &block) ⇒ Object



106
107
108
109
110
# File 'lib/reflex/view.rb', line 106

def style(*args, &block)
  s = get_style args.empty? ? nil : Selector.selector(*args)
  Xot::BlockUtil.instance_eval_or_block_call s, &block if block
  s
end

#stylesObject



102
103
104
# File 'lib/reflex/view.rb', line 102

def styles()
  each_style.to_a
end

#timeout(seconds = 0, count: 1, &block) ⇒ Object



62
63
64
65
66
# File 'lib/reflex/view.rb', line 62

def timeout(seconds = 0, count: 1, &block)
  timer = start_timer! seconds, count
  timer.block = block if block
  timer
end

#wheel(*args, **options, &block) ⇒ Object



137
138
139
# File 'lib/reflex/view.rb', line 137

def wheel(*args, **options, &block)
  pin.wheel(*args, **options, &block)
end