The Green Shoes Manual 1.1.362
The Styles Master List
You want to mess with the look of things? Well, throughout Green Shoes, styles are used to change the way elements appear. In some cases, you can even style an entire class of elements. (Like giving all links without an underline.)
Styles are easy to spot. They usually show up when the element is created.
Shoes.app title: "A Styling Sample" do
para 'Green Shoes', align: 'center', size: 50
end
Here we've got a :title
style on the app. And on the paragraph inside the app, a center :align
style and 50 font :size
style.
The style hash can also be changed by using the style method, available on every element and slot.
Note: Green Shoes can change style hash on Shape element only so far.
Shoes.app title: "A Styling Sample" do
choose =
lambda{[red, blue, green, yellow].sample}
s = star 100, 50, 30, 200, 180, strokewidth: 5
button 'change colors' do
s.style stroke: choose.call, fill: choose.call
end
end
Most styles can also be set by calling them as methods. (I'd use the manual search to find the method.)
Note: Green Shoes doesn't support them as methods.
# Not yet available
Shoes.app title: "A Styling Sample" do
choose =
lambda{[red, blue, green, yellow].sample}
s = star 100, 50, 30, 200, 180, strokewidth: 5
button 'change colors' do
s.stroke = choose.call; s.fill = choose.call
end
end
Rather than making you plow through the whole manual to figure out what styles go where, this helpful page speeds through every style in Green Shoes and suggests where that style is used.
For: banner, caption, inscription, para, subtitle, tagline, title
The alignment of the text. It is either:
- "left" - Align the text to the left.
- "center" - Align the text in the center.
- "right" - Align the text to the right.
For: background, border, line, oval, rect, shape, star.
The angle at which to apply a gradient. Normally, gradient colors range from top to bottom. If the :angle
is set to 90, the gradient will rotate 90 degrees counter-clockwise and the gradient will go from left to right.
For: flow, stack.
Pins a slot relative to another slot or element. Also, one may write :attach => Window
to position the slot at the window's top, left corner. Taking this a bit further, the style :top => 10, :left => 10, :attach => Window
would place the slot at (10, 10) in the window's coordinates.
If a slot is attached to an element that moves, the slot will move with it. If the attachment is reset to nil
, the slot will flow in with the other objects that surround, as normal.
Note: Green Shoes doesn't support :attach
style.
For: video.
Should this video begin playing after it appears? If set to true
, the video will start without asking the user.
Note: Green Shoes doesn't support video.
For: shapes, image, textblocks.
Comes to the back of the other elements.
Shoes.app do
rect 100, 100, 100, 100, fill: green
rect 120, 120, 100, 100, fill: yellow
para 'hello', left: 150, top: 150, front: true
oval 150, 150, 100, 100, fill: red
oval 180, 180, 100, 100, fill: gray, back: true
end
For: all slots and elements.
Sets the pixel coordinate of an element's lower edge. The edge is placed relative to its container's lower edge. So, :bottom => 0
will align the element so that its bottom edge and the bottom edge of its slot touch.
Note: Green Shoes doesn't support :bottom
style.
For: arc, line, shape.
Sets the shape of the line endpoint, whether curved or square. See the cap method for more explanation.
For: arc, image, oval, rect, shape.
Indicates whether the :top
and :left
coordinates refer to the center of the shape or not. If set to true
, this is similar to setting the transform method to :center
.
Note: Green Shoes doesn't support :center
style.
For: edit_box, edit_line, list_box.
The change
event handler is stored in this style. See the change method for the edit_box, as an example.
For: check, radio.
Is this checkbox or radio button checked? If set to true
, the box is checked. Also see the checked= method.
For: list_box.
Sets the currently chosen item in the list. More information at choose.
For: arc, arrow, button, check, flow, image, line, link, oval, radio, rect, shape, stack, star.
The click
event handler is stored in this style. See the click method for a description.
For: background, border, rect.
The radius of curved corners on each of these rectangular elements. As an example, if this is set to 6, the corners of the rectangle are given a curve with a 6-pixel radius.
For: all slots and elements.
Moves a shape, text block or any other kind of object to the left or right. A positive number displaces to the right by the given number of pixels; a negative number displaces to the left. Displacing an object doesn't effect the actual layout of the page. Before using this style, be sure to read the displace docs, since its behavior can be a bit surprising.
Note: Green Shoes doesn't support :displace_left
style.
For: all slots and elements.
Moves a shape, text block or any other kind of object up or down. A positive number moves the object down by this number of pixels; a negative number moves it up. Displacing doesn't effect the actual layout of the page or the object's true coordinates. Read the displace docs, since its behavior can be a bit surprising.
Note: Green Shoes doesn't support :displace_top
style.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Styles the text with an emphasis (commonly italicized.)
This style recognizes three possible settings:
- "normal" - the font is upright.
- "oblique" - the font is slanted, but in a roman style.
- "italic" - the font is slanted in an italic style.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Styles the text with a given font family. The string should contain the family name or a comma-separated list of families.
For: background, banner, border, caption, inscription, para, line, oval, rect, shape, star, subtitle, tagline, title.
The color of the background pen. For shapes, this is the fill color, the paint inside the shape. For textblock, this color is painted in the background (as if marked with a highlighter pen.)
For: banner, caption, inscription, para, subtitle, tagline, title.
Styles the text with a font description. The string is pretty flexible, but can take the form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace separated list of words where each WORD describes one of style, variant, weight, stretch, or gravity, and SIZE is a decimal number (size in points) or optionally followed by the unit modifier "px" for absolute size. Any one of the options may be absent. If FAMILY-LIST is absent, then the default font family (Arial) will be used.
For: shapes, image, textblocks.
Comes to the front of the other elements.
For: radio.
Indicates what group a radio button belongs to. Without this setting, radio buttons are grouped together with other radio buttons in their immediate slot. "Grouping" radio buttons doesn't mean they'll be grouped next to each other on the screen. It means that only one radio button from the group can be selected at a time.
By giving this style a string, the radio button will be grouped with other radio buttons that have the same group name.
For: all slots and elements.
Sets the pixel height of this object. If the number is a decimal number, the height becomes a percentage of its parent's height (with 0.0 being 0% and 1.0 being 100%.)
For: all slots and elements.
Hides or shows this object. Any object with hidden: true
are not displayed on the screen. Neither are its children.
Shoes.app do
slot = stack hidden: true do
title 'hello'
flow do
image File.join DIR, '../samples/loogink.png'
end
para link('Go go!'){alert 'hi'}
end
timer(2){slot.show}
timer(5){slot.hide}
end
Note: Green Shoes supports :hidden
style for only slots, shapes, textblocks and images so far.
For: star.
The size of the inner radius (in pixels.) The inner radius describes the solid circle within the star where the points begin to separate.
For: list_box.
The list of selections in the list box. See the list_box method for an example.
For: banner, caption, inscription, para, subtitle, tagline, title.
Evenly spaces the text horizontally.
For: banner, caption, code, del, em, ins, inscription, link, para, span, strong, sub, sup, subtitle, tagline, title.
Adds to the natural spacing between letters, in pixels.
Note: Green Shoes doesn't support :kerning
style.
For: banner, caption, inscription, para, subtitle, tagline, title.
Sets the spacing between lines in a text block. Defaults to 4 pixels.
For: all slots and elements.
Sets the left coordinate of this object to a specific pixel. Setting left: 10
places the object's left edge ten pixels away from the left edge of the slot containing it. If this style is left unset (or set to nil
,) the object will flow in with the other objects surrounding it.
For: all slots and elements.
Margins space an element out from its surroundings. Each element has a left, top, right, and bottom margin. If the :margin
style is set to a single number, the spacing around the element uniformly matches that number. In other words, if margin: 8
is set, all the margins around the element are set to eight pixels in length.
This style can also be given an array of four numbers in the form [left, top, right, bottom]
.
For: all slots and elements.
Sets the bottom margin of the element to a specific pixel size.
For: all slots and elements.
Sets the left margin of the element to a specific pixel size.
For: all slots and elements.
Sets the right margin of the element to a specific pixel size.
For: all slots and elements.
Sets the top margin of the element to a specific pixel size.
For: star.
Sets the outer radius (half of the total width) of the star, in pixels.
For: star.
How many points does this star have? A style of points: 5
creates a five-pointed star.
For: oval.
Sets the radius (half of the diameter or total width) for each of these elements. Setting this is equivalent to setting both :width
and :height
to double this number.
For: all slots and elements.
Sets the pixel coordinate of an element's right edge. The edge is placed relative to its container's rightmost edge. So, :right => 0
will align the element so that its own right edge and the right edge of its slot touch. Whereas :right => 20
will position the right edge of the element off to the left of its slot's right edge by twenty pixels.
Note: Green Shoes doesn't support :right
style.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Lifts or plunges the font baseline for some text. For example, a sup has a :rise
of 10 pixels. Conversely, the sub element has a :rise
of -10 pixels.
For: flow, stack.
Establishes this slot as a scrolling slot. If :scroll => true
is set, the slot will show a scrollbar if any of its contents go past its height. The scrollbar will appear and disappear as needed. It will also appear inside the width of the slot, meaning the slot's width will never change, regardless of whether there is a scrollbar or not.
Note: Green Shoes has restrictions. :scroll
style is just a trial so far.
- common Slot instance methods, i.e. clear, hide, etc., don't work well
- doesn't manage any mouse events
- need to write
flush
explicitly
Shoes.app do
s = stack left: 100, top: 50, width: 300,
height: 100, scroll: true do
background gold
image File.join(DIR, '../samples/loogink.png')
10.times{para 'hello'}
flush
end
end
For: ask, edit_line.
Used for password fields, this setting keeps any characters typed in from becoming visible on the screen. Instead, a replacement character (such as an asterisk) is show for each letter typed.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Sets the pixel size for the font used inside this text block.
Font size may also be augmented, through use of the following strings:
- "xx-small" - 57% of present size.
- "x-small" - 64% of present size.
- "small" - 83% of present size.
- "medium" - no change in size.
- "large" - 120% of present size.
- "x-large" - 143% of present size.
- "xx-large" - 173% of present size.
For: button, check, edit_box, edit_line, list_box, radio.
The :state
style is for disabling or locking certain controls, if you don't want them to be edited.
Here are the possible style settings:
- nil - the control is active and editable.
- "readonly" - the control is active but cannot be edited.
- "disabled" - the control is not active (grayed out) and cannot be edited.
For: banner, caption, code, del, em, ins, inscription, link, para, span, strong, sub, sup, subtitle, tagline, title.
Sets the font stretching used for a text object.
Possible settings are:
- "condensed" - a smaller width of letters.
- "normal" - the standard width of letters.
- "expanded" - a larger width of letters.
Note: Green Shoes doesn't support :stretch
style.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
The color used to paint any lines stricken through this text.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Is this text stricken through? Two options here:
- "none" - no strikethrough
- "single" - a single-line strikethrough.
For: background, banner, border, caption, inscription, para, line, oval, rect, shape, star, subtitle, tagline, title.
The color of the foreground pen. In the case of shapes, this is the color the lines are drawn with. For textblock, the letters are printed in this color.
For: background, border, line, oval, rect, shape, star.
The thickness of the stroke, in pixels, of the line defining each of these shapes. For example, the number two would set the strokewidth to 2 pixels.
For: edit_box, edit_line.
Sets the message displayed on the contents of edit_box or edit_line.
For: all slots and elements.
Sets the top coordinate for an object, relative to the top slot (window). If an object is set with top: 40
, this means the object's top edge will be placed 40 pixels beneath the top edge of the top slot (window). If no :top
style is given, the object is automatically placed in the natural flow of the slot it contains.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
The color used to underline text.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Dictates the style of underline used in the text.
The choices for this setting are:
- "none" - no underline at all.
- "single" - a continuous underline.
- "double" - two continuous parallel underlines.
- "low" - a lower underline, beneath the font baseline. (This is generally recommended only for single characters, particularly when showing keyboard accelerators.)
- "error" - a wavy underline, usually found indicating a misspelling.
For: banner, caption, code, del, em, ins, inscription, link, para, span, strong, sub, sup, subtitle, tagline, title.
Vary the font for a group of text. Two choices:
- "normal" - standard font.
- "smallcaps" - font with the lower case characters replaced by smaller variants of the capital characters.
Note: Green Shoes doesn't support :variant
style.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
Set the boldness of the text. Commonly, this style is set to one of the following strings:
- "ultralight" - the ultralight weight (= 200)
- "light" - the light weight (= 300)
- "normal" - the default weight (= 400)
- "semibold" - a weight intermediate between normal and bold (= 600)
- "bold" - the bold weight (= 700)
- "ultrabold" - the ultrabold weight (= 800)
- "heavy" - the heavy weight (= 900)
However, you may also pass in the numerical weight directly.
For: all slots and elements.
Sets the pixel width for the element. If the number is a decimal, the width is converted to a percentage (with 0.0 being 0% and 1.0 being 100%.) A width of 100% means the object fills its parent slot.
For: banner, caption, inscription, para, span, subtitle, tagline, title.
How should the text wrap when it fills its width? Possible options are:
- "word" - Break lines at word breaks.
- "char" - Break lines between characters, thus breaking some words.
- "trim" - Cut the line off with an ellipsis if it goes too long.
Next: Classes List