Module: Shoes
- Defined in:
- lacci/lib/shoes.rb,
lacci/lib/shoes.rb,
lacci/lib/shoes/app.rb,
lacci/lib/shoes/log.rb,
lacci/lib/shoes/border.rb,
lacci/lib/shoes/colors.rb,
lacci/lib/shoes/widget.rb,
lacci/lib/shoes/spacing.rb,
lacci/lib/shoes/download.rb,
lacci/lib/shoes/constants.rb,
lacci/lib/shoes/background.rb,
lacci/lib/shoes/widgets/arc.rb,
lacci/lib/shoes/widgets/flow.rb,
lacci/lib/shoes/widgets/font.rb,
lacci/lib/shoes/widgets/line.rb,
lacci/lib/shoes/widgets/link.rb,
lacci/lib/shoes/widgets/para.rb,
lacci/lib/shoes/widgets/para.rb,
lacci/lib/shoes/widgets/span.rb,
lacci/lib/shoes/widgets/star.rb,
lacci/lib/shoes/widgets/alert.rb,
lacci/lib/shoes/widgets/check.rb,
lacci/lib/shoes/widgets/image.rb,
lacci/lib/shoes/widgets/radio.rb,
lacci/lib/shoes/widgets/shape.rb,
lacci/lib/shoes/widgets/stack.rb,
lacci/lib/shoes/widgets/video.rb,
lacci/lib/shoes/widgets/button.rb,
lacci/lib/shoes/display_service.rb,
lacci/lib/shoes/widgets/edit_box.rb,
lacci/lib/shoes/widgets/list_box.rb,
lacci/lib/shoes/widgets/edit_line.rb,
lacci/lib/shoes/widgets/text_widget.rb,
lacci/lib/shoes/widgets/document_root.rb
Overview
Shoes::TextWidget
Defined Under Namespace
Modules: Background, Border, Colors, Constants, Log, Spacing Classes: Alert, App, Arc, Button, Check, DisplayService, DocumentRoot, EditBox, EditLine, Error, Flow, Font, Image, InvalidAttributeValueError, Line, Link, Linkable, ListBox, LoggedWrapper, Para, Radio, Shape, Slot, Span, Stack, Star, SubscriptionItem, TextWidget, Video, Widget
Constant Summary collapse
- LOG_LEVELS =
[:debug, :info, :warn, :error, :fatal].freeze
Class Method Summary collapse
- .add_file_loader(loader) ⇒ Object
-
.app(title: "Shoes!", width: 480, height: 420, resizable: true, &app_code_body) ⇒ void
Creates a Shoes app with a new window.
- .default_file_loaders ⇒ Object
- .default_text_widget_with(element) ⇒ Object
- .file_loaders ⇒ Object
- .reset_file_loaders ⇒ Object
-
.run_app(relative_path) ⇒ void
Load a Shoes app from a file.
- .set_file_loaders(loaders) ⇒ Object
Class Method Details
.add_file_loader(loader) ⇒ Object
115 116 117 |
# File 'lacci/lib/shoes.rb', line 115 def add_file_loader(loader) file_loaders.prepend(loader) end |
.app(title: "Shoes!", width: 480, height: 420, resizable: true, &app_code_body) ⇒ void
This method returns an undefined value.
Creates a Shoes app with a new window. The block parameter is used to create widgets and set up handlers. Arguments are passed to Shoes::App.new internally.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lacci/lib/shoes.rb', line 66 def app( title: "Shoes!", width: 480, height: 420, resizable: true, &app_code_body ) app = Shoes::App.new(title:, width:, height:, resizable:, &app_code_body) app.init app.run nil end |
.default_file_loaders ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lacci/lib/shoes.rb', line 101 def default_file_loaders [ # By default we will always try to load any file, regardless of extension, as a Shoes Ruby file. proc do |path| load path true end, ] end |
.default_text_widget_with(element) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lacci/lib/shoes/widgets/text_widget.rb', line 18 def (element) class_name = element.capitalize = Class.new(Shoes::TextWidget) do # Can we just change content to text to match the Shoes API? display_property :content def initialize(content) @content = content super end def text self.content end def text=(new_text) self.content = new_text end end Shoes.const_set class_name, .class_eval do display_property :content end end |
.file_loaders ⇒ Object
111 112 113 |
# File 'lacci/lib/shoes.rb', line 111 def file_loaders @file_loaders ||= default_file_loaders end |
.reset_file_loaders ⇒ Object
119 120 121 |
# File 'lacci/lib/shoes.rb', line 119 def reset_file_loaders @file_loaders = default_file_loaders end |
.run_app(relative_path) ⇒ void
This method returns an undefined value.
Load a Shoes app from a file. By default, this will load old-style Shoes apps from a .rb file with all the appropriate libraries loaded. By setting one or more loaders, a Lacci-based display library can accept new file formats as well, not just raw Shoes .rb files.
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lacci/lib/shoes.rb', line 87 def run_app(relative_path) path = File. relative_path loaded = false file_loaders.each do |loader| if loader.call(path) loaded = true break end end raise "Could not find a file loader for #{path.inspect}!" unless loaded nil end |
.set_file_loaders(loaders) ⇒ Object
123 124 125 |
# File 'lacci/lib/shoes.rb', line 123 def set_file_loaders(loaders) @file_loaders = loaders end |