Marking lots of stuff as :nodoc:
parent
98c4152a21
commit
7f309869f2
|
|
@ -9,6 +9,8 @@ require 'squib/card'
|
||||||
|
|
||||||
module Squib
|
module Squib
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def logger
|
def logger
|
||||||
@logger ||= Logger.new(STDOUT)
|
@logger ||= Logger.new(STDOUT)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,20 @@ require 'cairo'
|
||||||
require 'squib/input_helpers'
|
require 'squib/input_helpers'
|
||||||
|
|
||||||
module Squib
|
module Squib
|
||||||
|
# Back end graphics. Private.
|
||||||
class Card
|
class Card
|
||||||
include Squib::InputHelpers
|
include Squib::InputHelpers
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
attr_reader :width, :height
|
attr_reader :width, :height
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
attr_accessor :cairo_surface, :cairo_context
|
attr_accessor :cairo_surface, :cairo_context
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def initialize(deck, width, height)
|
def initialize(deck, width, height)
|
||||||
@deck=deck; @width=width; @height=height
|
@deck=deck; @width=width; @height=height
|
||||||
@cairo_surface = Cairo::ImageSurface.new(width,height)
|
@cairo_surface = Cairo::ImageSurface.new(width,height)
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,17 @@ module Squib
|
||||||
class Deck
|
class Deck
|
||||||
include Enumerable
|
include Enumerable
|
||||||
include Squib::InputHelpers
|
include Squib::InputHelpers
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
attr_reader :width, :height
|
attr_reader :width, :height
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
attr_reader :cards
|
attr_reader :cards
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
attr_reader :text_hint
|
attr_reader :text_hint
|
||||||
|
|
||||||
# Squib's constructor that sets the immutable properties.
|
# Squib's constructor that sets the immutable properties.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
module Squib
|
module Squib
|
||||||
class Card
|
class Card
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def background(color)
|
def background(color)
|
||||||
cc = cairo_context
|
cc = cairo_context
|
||||||
cc.set_source_color(color)
|
cc.set_source_color(color)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
module Squib
|
module Squib
|
||||||
class Card
|
class Card
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def png(file, x, y, alpha)
|
def png(file, x, y, alpha)
|
||||||
cc = cairo_context
|
cc = cairo_context
|
||||||
png = Cairo::ImageSurface.from_png(file)
|
png = Cairo::ImageSurface.from_png(file)
|
||||||
|
|
@ -8,6 +10,8 @@ module Squib
|
||||||
cc.paint(alpha)
|
cc.paint(alpha)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def svg(file, id, x, y, width, height)
|
def svg(file, id, x, y, width, height)
|
||||||
svg = RSVG::Handle.new_from_file(file)
|
svg = RSVG::Handle.new_from_file(file)
|
||||||
width = svg.width if width == :native
|
width = svg.width if width == :native
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ module Squib
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
def trim(surface, trim, width, height)
|
def trim(surface, trim, width, height)
|
||||||
if trim > 0
|
if trim > 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
module Squib
|
module Squib
|
||||||
class Card
|
class Card
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def save_png(i, dir, prefix)
|
def save_png(i, dir, prefix)
|
||||||
cairo_context.target.write_to_png("#{dir}/#{prefix}#{i}.png")
|
cairo_context.target.write_to_png("#{dir}/#{prefix}#{i}.png")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
module Squib
|
module Squib
|
||||||
class Card
|
class Card
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def rect(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width)
|
def rect(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width)
|
||||||
cc = cairo_context
|
cc = cairo_context
|
||||||
cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
|
cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ require 'pango'
|
||||||
module Squib
|
module Squib
|
||||||
class Card
|
class Card
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def draw_text_hint(x,y,layout, color)
|
def draw_text_hint(x,y,layout, color)
|
||||||
return if color.nil? && @deck.text_hint.nil?
|
return if color.nil? && @deck.text_hint.nil?
|
||||||
color ||= @deck.text_hint
|
color ||= @deck.text_hint
|
||||||
|
|
@ -14,6 +16,8 @@ module Squib
|
||||||
rect(x,y,w,h,0,0,'#0000',color, 2.0)
|
rect(x,y,w,h,0,0,'#0000',color, 2.0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def ellipsize(layout, options)
|
def ellipsize(layout, options)
|
||||||
unless options[:ellipsize].nil?
|
unless options[:ellipsize].nil?
|
||||||
h = { :none => Pango::Layout::ELLIPSIZE_NONE,
|
h = { :none => Pango::Layout::ELLIPSIZE_NONE,
|
||||||
|
|
@ -28,6 +32,8 @@ module Squib
|
||||||
layout
|
layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def wrap(layout, options)
|
def wrap(layout, options)
|
||||||
unless options[:wrap].nil?
|
unless options[:wrap].nil?
|
||||||
h = { :word => Pango::Layout::WRAP_WORD,
|
h = { :word => Pango::Layout::WRAP_WORD,
|
||||||
|
|
@ -42,6 +48,8 @@ module Squib
|
||||||
layout
|
layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def align(layout, options)
|
def align(layout, options)
|
||||||
unless options[:align].nil?
|
unless options[:align].nil?
|
||||||
h = { :left => Pango::ALIGN_LEFT,
|
h = { :left => Pango::ALIGN_LEFT,
|
||||||
|
|
@ -53,6 +61,8 @@ module Squib
|
||||||
layout
|
layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def valign(cc, layout, extents, x, y, valign)
|
def valign(cc, layout, extents, x, y, valign)
|
||||||
if layout.height > 0
|
if layout.height > 0
|
||||||
case valign
|
case valign
|
||||||
|
|
@ -64,12 +74,16 @@ module Squib
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def setwh(layout, options)
|
def setwh(layout, options)
|
||||||
layout.width = options[:width] * Pango::SCALE unless options[:width].nil? || options[:width] == :native
|
layout.width = options[:width] * Pango::SCALE unless options[:width].nil? || options[:width] == :native
|
||||||
layout.height = options[:height] * Pango::SCALE unless options[:height].nil? || options[:height] == :native
|
layout.height = options[:height] * Pango::SCALE unless options[:height].nil? || options[:height] == :native
|
||||||
layout
|
layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
def text(str, font, x, y, color, options)
|
def text(str, font, x, y, color, options)
|
||||||
cc = cairo_context
|
cc = cairo_context
|
||||||
cc.set_source_color(color)
|
cc.set_source_color(color)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
require 'squib/constants'
|
require 'squib/constants'
|
||||||
|
|
||||||
module Squib
|
module Squib
|
||||||
|
# :nodoc:
|
||||||
|
# @api private
|
||||||
module InputHelpers
|
module InputHelpers
|
||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue