Class: Shoes::Arrow

Inherits:
Common::ArtElement show all
Defined in:
shoes-core/lib/shoes/arrow.rb

Constant Summary collapse

STYLES =
{ fill: Shoes::COLORS[:black] }.freeze
REDRAW_OFFSET_FACTOR =

Redrawing needs a bit of extra room. We offset by this factor, then extend our size by twice that to evenly surround the whole thing.

2
REDRAW_SIZING_FACTOR =
REDRAW_OFFSET_FACTOR * 2

Constants included from Common::Style

Common::Style::DEFAULT_STYLES, Common::Style::STYLE_GROUPS

Instance Attribute Summary

Attributes included from Common::Clickable

#pass_coordinates

Attributes inherited from Common::UIElement

#app, #dimensions, #gui, #parent

Instance Method Summary collapse

Methods inherited from Common::ArtElement

#painted?

Methods included from Common::Translate

#clear_translate, #translate_left, #translate_top

Methods included from Common::Stroke

#update_stroke

Methods included from Common::Rotate

#needs_rotate?

Methods included from Common::Fill

#update_fill

Methods included from Common::Clickable

#click, #pass_coordinates?, #register_click, #release

Methods inherited from Common::UIElement

#add_to_parent, #after_initialize, #before_initialize, #create_backend, #handle_block, #initialize, #needs_rotate?, #painted?, #update_fill, #update_stroke

Methods included from Common::Style

#applicable_app_styles, #create_style_hash, included, #style, #style_init

Methods included from Common::SafelyEvaluate

#safely_evaluate

Methods included from Common::Remove

#remove

Methods included from Common::Positioning

#_position, #displace, #move

Methods included from Common::Visibility

#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?

Methods included from Common::Inspect

#inspect, #to_s

Methods included from Common::Attachable

#attached_to

Constructor Details

This class inherits a constructor from Shoes::Common::UIElement

Instance Method Details

#create_dimensions(left, top, width) ⇒ Object



8
9
10
11
12
13
14
# File 'shoes-core/lib/shoes/arrow.rb', line 8

def create_dimensions(left, top, width)
  left   ||= @style[:left] || 0
  top    ||= @style[:top] || 0
  width  ||= @style[:width] || 0

  @dimensions = AbsoluteDimensions.new left, top, width, width, @style
end

#gradient_heightObject



53
54
55
# File 'shoes-core/lib/shoes/arrow.rb', line 53

def gradient_height
  redraw_height
end

#gradient_leftObject



45
46
47
# File 'shoes-core/lib/shoes/arrow.rb', line 45

def gradient_left
  redraw_left
end

#gradient_topObject



49
50
51
# File 'shoes-core/lib/shoes/arrow.rb', line 49

def gradient_top
  redraw_top
end

#redraw_heightObject



41
42
43
# File 'shoes-core/lib/shoes/arrow.rb', line 41

def redraw_height
  width + strokewidth.ceil * REDRAW_SIZING_FACTOR
end

#redraw_leftObject

Our locations are nonstandard, so let redrawing and gradient know



27
28
29
30
# File 'shoes-core/lib/shoes/arrow.rb', line 27

def redraw_left
  return 0 unless element_left
  element_left - width * 0.5 - strokewidth.ceil * REDRAW_OFFSET_FACTOR
end

#redraw_topObject



32
33
34
35
# File 'shoes-core/lib/shoes/arrow.rb', line 32

def redraw_top
  return 0 unless element_top
  element_top - width * 0.4 - strokewidth.ceil * REDRAW_OFFSET_FACTOR
end

#redraw_widthObject



37
38
39
# File 'shoes-core/lib/shoes/arrow.rb', line 37

def redraw_width
  width + strokewidth.ceil * REDRAW_SIZING_FACTOR
end

#width=(*_) ⇒ Object



16
17
18
19
# File 'shoes-core/lib/shoes/arrow.rb', line 16

def width=(*_)
  super
  gui.update_position
end