Class: Clogs::Oval

Inherits:
ArtDrawable show all
Defined in:
lib/clogs/drawables/shapes.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



119
120
121
122
123
124
125
126
127
# File 'lib/clogs/drawables/shapes.rb', line 119

def draw(painter, x, y)
  # Shoes' `center: true` means left/top name the centre, not the corner.
  if style(:center)
    x -= @width / 2.0
    y -= @height / 2.0
  end
  painter.fill_oval(x, y, @width, @height, fill_paint) if fill_paint
  painter.stroke_oval(x, y, @width, @height, stroke_paint, thickness: strokewidth) if stroke_paint
end

#measure(available_width) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/clogs/drawables/shapes.rb', line 109

def measure(available_width)
  radius = style(:radius)
  if radius && !style(:width)
    @width = @height = radius.to_i * 2
  else
    @width = Style.dimension(style(:width), available_width).to_i
    @height = Style.dimension(style(:height), available_width).to_i
  end
end