Class: Clogs::Rect

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



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/clogs/drawables/shapes.rb', line 94

def draw(painter, x, y)
  curve = style(:curve).to_i
  if curve.positive?
    painter.draw(fill: fill_paint, stroke: stroke_paint, thickness: strokewidth) do |p|
      Clogs.rounded_rect(p, x, y, @width, @height, curve)
    end
  else
    painter.fill_rect(x, y, @width, @height, fill_paint) if fill_paint
    painter.stroke_rect(x, y, @width, @height, stroke_paint, thickness: strokewidth) if stroke_paint
  end
end

#measure(available_width) ⇒ Object



89
90
91
92
# File 'lib/clogs/drawables/shapes.rb', line 89

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