Class: Clogs::Arrow

Inherits:
ArtDrawable show all
Defined in:
lib/clogs/drawables/misc.rb

Instance Attribute Summary

Attributes inherited from Drawable

#abs_x, #abs_y, #children, #height, #parent, #shoes_linkable_id, #styles, #width, #x, #y

Instance Method Summary collapse

Methods inherited from ArtDrawable

#context_style, #draw_context, #fill_paint, #left, #opaque, #paint, #parent_content_width, #positioned?, #rotation, #stroke_paint, #strokewidth, #top

Methods inherited from Drawable

#add_child, #app, #clickable?, #contains?, #destroy_self, #each_peer, #focus_gained, #focus_lost, #focusable?, for_shoes_class, #hidden?, #initialize, #margin, #needs_layout!, #notify, #on_click, #on_key, #on_mouse_move, #on_release, #paint, #positioned?, #properties_changed, #redraw!, #remove_child, #requested_height, #requested_width, #set_parent, #style

Constructor Details

This class inherits a constructor from Clogs::Drawable

Instance Method Details

#draw(painter, x, y) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/clogs/drawables/misc.rb', line 110

def draw(painter, x, y)
  w = @width
  h = @height
  painter.draw(fill: fill_paint, stroke: stroke_paint, thickness: strokewidth) do |p|
    p.move_to(x, y + h * 0.35)
      .line_to(x + w * 0.6, y + h * 0.35)
      .line_to(x + w * 0.6, y)
      .line_to(x + w, y + h * 0.5)
      .line_to(x + w * 0.6, y + h)
      .line_to(x + w * 0.6, y + h * 0.65)
      .line_to(x, y + h * 0.65)
      .close
  end
end

#measure(available_width) ⇒ Object



105
106
107
108
# File 'lib/clogs/drawables/misc.rb', line 105

def measure(available_width)
  @width = Style.dimension(style(:width), available_width).to_i
  @height = (@width / 2.0).round
end