Module: Shoes::DSL::Style

Included in:
Shoes::DSL
Defined in:
shoes-core/lib/shoes/dsl/style.rb

Overview

DSL methods for styling elements in Shoes applications

See Also:

Constant Summary collapse

PATTERN_APP_STYLES =

Each value is a top-level Shoes DSL method overriding the default styling of following elements.

[:fill, :stroke].freeze
OTHER_APP_STYLES =

Each value is a top-level Shoes DSL method overriding the default styling of following elements.

[:cap, :rotate, :strokewidth, :transform].freeze

Instance Method Summary collapse

Instance Method Details

#nofillShoes::App

Clear any default fill settings following this call.

Returns:


79
80
81
82
83
# File 'shoes-core/lib/shoes/dsl/style.rb', line 79

def nofill
  @__app__.remove_styles << :fill
  @__app__.style[:fill] = nil
  @__app__.app
end

#nostrokeShoes::App

Clear any default stroke settings following this call.

Returns:


70
71
72
73
74
# File 'shoes-core/lib/shoes/dsl/style.rb', line 70

def nostroke
  @__app__.remove_styles << :stroke
  @__app__.style[:stroke] = nil
  @__app__.app
end

#style(klass, styles) ⇒ Object #style(styles) ⇒ Object #styleHash

Apply default styling at the app or element class level.

Overloads:

  • #style(klass, styles) ⇒ Object

    Set default style for elements of a particular class

    Examples:

    style Para, :text_size => 42, :stroke => green

    Parameters:

    • klass (Class)

      a Shoes element class

    • styles (Hash)

      default styles for elements of klass

  • #style(styles) ⇒ Object

    Set default style for all elements

    Examples:

    style :stroke => alicewhite, :fill => black

    Parameters:

    • styles (Hash)

      default style for all elements

  • #styleHash

    Set styles for application element

    Returns:

    • (Hash)

      the default style for all elements


27
28
29
30
31
32
33
34
# File 'shoes-core/lib/shoes/dsl/style.rb', line 27

def style(klass_or_styles = nil, styles = {})
  if klass_or_styles.kind_of? Class
    klass = klass_or_styles
    @__app__.element_styles[klass] = styles
  else
    @__app__.style(klass_or_styles)
  end
end

#translate(left, top) ⇒ Shoes::App

Shift position of all elements following this call.

Parameters:

  • left (Fixnum)

    amount to shift element horizontally

  • top (Fixnum)

    amount to shift element vertically

Returns:


62
63
64
65
# File 'shoes-core/lib/shoes/dsl/style.rb', line 62

def translate(left, top)
  @__app__.style[:translate] = [left, top]
  @__app__.app
end