class Glimmer::Gtk::Shape::Path

Represents Gtk paths consisting of operations: move_to, line_to, curve_to, rel_move_to, rel_line_to, rel_curve_to, and close_path

Attributes

drawing_operations[R]

Public Class Methods

new(keyword, parent, args, &block) click to toggle source
Calls superclass method Glimmer::Gtk::Shape::new
# File lib/glimmer/gtk/shape/path.rb, line 67
def initialize(keyword, parent, args, &block)
  super
  @drawing_operations = []
end

Public Instance Methods

arc(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 102
def arc(*args)
  @drawing_operations << [:arc, args]
end
arc_negative(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 106
def arc_negative(*args)
  @drawing_operations << [:arc_negative, args]
end
child_paths() click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 76
def child_paths
  @child_paths ||= []
end
close_path() click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 158
def close_path
  @drawing_operations << [:close_path]
end
curve_to(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 142
def curve_to(*args)
  @drawing_operations << [:curve_to, args]
end
draw_shape(drawing_area_widget, cairo_context) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 80
def draw_shape(drawing_area_widget, cairo_context)
  previous_matrix = cairo_context.matrix
  apply_transforms(cairo_context, target: :shape)
  cairo_context.new_path
  @drawing_operations.each do |drawing_operation_details|
    cairo_context.send(drawing_operation_details[0], *drawing_operation_details[1])
  end
  child_paths.each do |child|
    cairo_context.new_sub_path
    child.drawing_operations.each do |drawing_operation_details|
      cairo_context.send(drawing_operation_details[0], *drawing_operation_details[1])
    end
  end
  cairo_context.set_matrix(previous_matrix)
end
glyph_path(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 126
def glyph_path(*args)
  @drawing_operations << [:text_path, args]
end
line_to(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 138
def line_to(*args)
  @drawing_operations << [:line_to, args]
end
move_to(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 134
def move_to(*args)
  @drawing_operations << [:move_to, args]
end
new_sub_path(*args) click to toggle source

TODO look into a way to generalize the declaration of the methods below (or perform code reuse)

# File lib/glimmer/gtk/shape/path.rb, line 98
def new_sub_path(*args)
  @drawing_operations << [:new_sub_path, args]
end
post_initialize_child(child) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 72
def post_initialize_child(child)
  child_paths << child if child.is_a?(Path)
end
rectangle(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 110
def rectangle(*args)
  @drawing_operations << [:rectangle, args]
end
rel_curve_to(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 154
def rel_curve_to(*args)
  @drawing_operations << [:rel_curve_to, args]
end
rel_line_to(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 150
def rel_line_to(*args)
  @drawing_operations << [:rel_line_to, args]
end
rel_move_to(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 146
def rel_move_to(*args)
  @drawing_operations << [:rel_move_to, args]
end
rounded_rectangle(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 114
def rounded_rectangle(*args)
  @drawing_operations << [:rounded_rectangle, args]
end
show_glyphs(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 130
def show_glyphs(*args)
  @drawing_operations << [:show_text, args]
end
show_text(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 122
def show_text(*args)
  @drawing_operations << [:show_text, args]
end
text_path(*args) click to toggle source
# File lib/glimmer/gtk/shape/path.rb, line 118
def text_path(*args)
  @drawing_operations << [:text_path, args]
end