Class: Vedeu::Cursors::Reposition Private
- Inherits:
-
Object
- Object
- Vedeu::Cursors::Reposition
- Defined in:
- lib/vedeu/cursors/reposition.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Arbitrarily move the cursor to a given position.
Instance Attribute Summary collapse
- #name ⇒ String|Symbol readonly protected private
- #x ⇒ Fixnum readonly protected private
- #y ⇒ Fixnum readonly protected private
Instance Method Summary collapse
- #absolute? ⇒ Boolean private private
-
#coordinate(offset, type) ⇒ Vedeu::Geometry::Coordinate
private
private
Determine correct x and y related coordinates.
- #cursor ⇒ Vedeu::Cursors::Cursor private private
-
#defaults ⇒ Hash<Symbol => Fixnum|Symbol|String]
private
private
Hash<Symbol => Fixnum|Symbol|String].
- #geometry ⇒ Vedeu::Geometry::Geometry private private
-
#initialize(attributes = {}) ⇒ Vedeu::Cursors::Reposition
constructor
private
Returns a new instance of Vedeu::Cursors::Reposition.
- #inside_geometry? ⇒ Boolean private private
- #mode ⇒ Symbol private private
-
#modes ⇒ Array<Symbol>
private
private
Positioning is handled either with absolute or relative coordinates, the coordinates are checked against the geometry of the interface/view and altered to reside within the boundary defined.
- #new_attributes ⇒ Hash<Symbol => Fixnum> private private
- #relative? ⇒ Boolean private private
- #reposition ⇒ Vedeu::Cursors::Cursor private
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Cursors::Reposition
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Cursors::Reposition.
22 23 24 25 26 |
# File 'lib/vedeu/cursors/reposition.rb', line 22 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#name ⇒ String|Symbol (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/vedeu/cursors/reposition.rb', line 39 def name @name end |
#x ⇒ Fixnum (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/vedeu/cursors/reposition.rb', line 43 def x @x end |
#y ⇒ Fixnum (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/vedeu/cursors/reposition.rb', line 47 def y @y end |
Instance Method Details
#absolute? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/vedeu/cursors/reposition.rb', line 52 def absolute? mode == :absolute end |
#coordinate(offset, type) ⇒ Vedeu::Geometry::Coordinate (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine correct x and y related coordinates.
61 62 63 |
# File 'lib/vedeu/cursors/reposition.rb', line 61 def coordinate(offset, type) Vedeu::Geometry::Coordinate.new(name: name, offset: offset, type: type) end |
#cursor ⇒ Vedeu::Cursors::Cursor (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 |
# File 'lib/vedeu/cursors/reposition.rb', line 66 def cursor Vedeu.cursors.by_name(name) end |
#defaults ⇒ Hash<Symbol => Fixnum|Symbol|String] (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Hash<Symbol => Fixnum|Symbol|String].
71 72 73 74 75 76 77 78 |
# File 'lib/vedeu/cursors/reposition.rb', line 71 def defaults { mode: :relative, name: Vedeu.focus, x: 0, y: 0, } end |
#geometry ⇒ Vedeu::Geometry::Geometry (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 |
# File 'lib/vedeu/cursors/reposition.rb', line 81 def geometry Vedeu.geometries.by_name(name) end |
#inside_geometry? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 89 90 91 |
# File 'lib/vedeu/cursors/reposition.rb', line 86 def inside_geometry? x >= geometry.x && x <= geometry.xn && y >= geometry.y && y <= geometry.yn end |
#mode ⇒ Symbol (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
94 95 96 97 98 99 100 101 102 |
# File 'lib/vedeu/cursors/reposition.rb', line 94 def mode @mode = if modes.include?(@mode) @mode else defaults[:mode] end end |
#modes ⇒ Array<Symbol> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Positioning is handled either with absolute or relative coordinates, the coordinates are checked against the geometry of the interface/view and altered to reside within the boundary defined.
110 111 112 |
# File 'lib/vedeu/cursors/reposition.rb', line 110 def modes [:relative, :absolute] end |
#new_attributes ⇒ Hash<Symbol => Fixnum> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/vedeu/cursors/reposition.rb', line 115 def new_attributes if absolute? && inside_geometry? cursor.attributes.merge!(x: coordinate((x - geometry.x), :x).x, y: coordinate((y - geometry.y), :y).y, ox: 0, oy: 0) elsif relative? cursor.attributes.merge!(x: coordinate(x, :x).x, y: coordinate(y, :y).y, ox: x, oy: y) else cursor.attributes end end |
#relative? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 |
# File 'lib/vedeu/cursors/reposition.rb', line 135 def relative? mode == :relative end |
#reposition ⇒ Vedeu::Cursors::Cursor
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 |
# File 'lib/vedeu/cursors/reposition.rb', line 29 def reposition Vedeu::Cursors::Cursor.store(new_attributes) do Vedeu.trigger(:_refresh_cursor_, name) end end |