Revision: 498 http://trac.macosforge.org/projects/ruby/changeset/498 Author: rich@infoether.com Date: 2008-08-27 18:45:43 -0700 (Wed, 27 Aug 2008) Log Message: ----------- add layout view app and remove old one Added Paths: ----------- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Info.plist MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/MacOS/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/MacOS/LayoutView MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/PkgInfo MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/Layout View.icns MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/application.rb MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/menu.rb MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/rb_main.rb MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Rakefile MacRuby/trunk/sample-macruby/HotCocoa/layout_view/config/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/config/build.yml MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/application.rb MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/menu.rb MacRuby/trunk/sample-macruby/HotCocoa/layout_view/resources/ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/resources/HotCocoa.icns Removed Paths: ------------- MacRuby/trunk/sample-macruby/HotCocoa/layout_view.rb Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Info.plist =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Info.plist (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Info.plist 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleIconFile</key> + <string>Layout View.icns</string> + <key>CFBundleExecutable</key> + <string>LayoutView</string> + <key>CFBundleIdentifier</key> + <string>com.yourcompany.Layout View</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Layout View</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/MacOS/LayoutView =================================================================== (Binary files differ) Property changes on: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/MacOS/LayoutView ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/PkgInfo =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/PkgInfo (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/PkgInfo 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1 @@ +APPL???? \ No newline at end of file Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/Layout View.icns =================================================================== (Binary files differ) Property changes on: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/Layout View.icns ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/application.rb =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/application.rb (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/application.rb 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,166 @@ +require 'hotcocoa' + +class MyView < NSView + + include HotCocoa::Behaviors + + DefaultSize = [30, 30] + + def self.create + alloc.initWithFrame([0, 0, *DefaultSize]) + end + + def initWithFrame(frame) + super + self.layout = {} + self + end + + def reset_size + setFrameSize(DefaultSize) + end + + attr_accessor :number + + def drawRect(rect) + (color :red => 0.29, :green => 0.26, :blue => 0.55).set + NSFrameRect(rect) + (color :red => 0.51, :green => 0.45, :blue => 0.95).set + NSRectFill(NSInsetRect(rect, 1, 1)) + + @attributes ||= { NSFontAttributeName => NSFont.systemFontOfSize(10) } + str = @number.to_s + strsize = str.sizeWithAttributes @attributes + point = [ + (rect.size.width / 2.0) - (strsize.width / 2.0), + (rect.size.height / 2.0) - (strsize.height / 2.0) + ] + @number.to_s.drawAtPoint point, withAttributes:@attributes + end + +end + +def create_slider_layout(label, &block) + layout_view :mode => :horizontal, :frame => [0, 0, 0, 24], :layout => {:expand => :width} do |view| + view << label(:text => label, :layout => {:align => :center}) + s = slider :min => 0, :max => 50, :tic_marks => 20, :on_action => block, :layout => {:expand => :width, :align => :center} + s.setFrameSize([0, 24]) # TODO sizeToFit doesn't set the height for us + view << s + end +end + +include HotCocoa + +application :name => "Layout View" do |app| + + window :frame => [100, 100, 500, 500], :title => "Packing View Madness" do |win| + views = [] + + window :frame => [700, 100, 200, 500], :default_layout => {:start => false} do |pane| + + pane.view << create_slider_layout('Spacing') { |x| win.view.spacing = x.to_i } + + pane.view << create_slider_layout('Margin') { |x| win.view.margin = x.to_i } + + pane.view << button(:title => "Vertical", :type => :switch, :state => :on) do |b| + b.on_action do |b| + views.each { |v| v.reset_size } + win.view.mode = b.on? ? :vertical : :horizontal + end + end + + selected_view = nil + expand_b = nil + expand_h = nil + left_padding_s = right_padding_s = top_padding_s = bottom_padding_s = nil + other_p = nil + views_p = popup :items => ['No View'], :layout => {:expand => :width} + views_p.on_action do |p| + selected_view = views[p.items.selected_index] + options = selected_view.layout + expand_b.state = options.expand_width? + expand_h.state = options.expand_height? + left_padding_s.intValue = options.left_padding + right_padding_s.intValue = options.right_padding + top_padding_s.intValue = options.top_padding + bottom_padding_s.intValue = options.bottom_padding + other_p.items.selected = case options.align + when :left then 0 + when :center then 1 + when :right then 2 + end + end + + add_b = button :title => "Add view" + add_b.on_action do + view = MyView.create + views << view + view.number = views.size + win.view.addSubview view + views_p.items = views.map { |x| "View #{x.number}" } + selected_view = views[0] + end + pane.view << add_b + pane.view << views_p + expand_b = button :title => "Expand width", :type => :switch, :state => :off + expand_h = button :title => "Expand height", :type => :switch, :state => :off + expand_b.on_action do |b| + selected_view.reset_size + selected_view.layout.expand = if expand_b.on? + if expand_h.on? + [:width, :height] + else + :width + end + elsif expand_h.on? + :height + else + nil + end + end + expand_h.on_action do |b| + selected_view.reset_size + selected_view.layout.expand = if expand_b.on? + if expand_h.on? + [:width, :height] + else + :width + end + elsif expand_h.on? + :height + else + nil + end + end + pane.view << expand_b + pane.view << expand_h + + v = create_slider_layout('Left') { |x| selected_view.layout.left_padding = x.to_i } + left_padding_s = v.subviews[1] + pane.view << v + + v = create_slider_layout('Right') { |x| selected_view.layout.right_padding = x.to_i } + right_padding_s = v.subviews[1] + pane.view << v + + v = create_slider_layout('Top') { |x| selected_view.layout.top_padding = x.to_i } + top_padding_s = v.subviews[1] + pane.view << v + + v = create_slider_layout('Bottom') { |x| selected_view.layout.bottom_padding = x.to_i } + bottom_padding_s = v.subviews[1] + pane.view << v + + pane.view << layout_view(:mode => :horizontal, :frame => [0, 0, 0, 24], :layout => {:expand => :width}) do |view| + view << label(:text => 'Align', :layout => {:align => :center}) + view << popup(:items => ['Left/Bottom', 'Center', 'Right/Top'], :layout => {:expand => :width, :align => :center}) do |p| + p.on_action do |x| + selected_view.reset_size + selected_view.layout.align = [:left, :center, :right][p.items.selected_index-1] + end + other_p = p + end + end + end + end +end Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/menu.rb =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/menu.rb (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/lib/menu.rb 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,32 @@ +module HotCocoa + def application_menu + menu do |main| + main.submenu :apple do |apple| + apple.item :about, :title => "About #{NSApp.name}" + apple.separator + apple.item :preferences, :key => "," + apple.separator + apple.submenu :services + apple.separator + apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h" + apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt] + apple.item :show_all, :title => "Show All" + apple.separator + apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q" + end + main.submenu :file do |file| + file.item :new, :key => "n" + file.item :open, :key => "o" + end + main.submenu :window do |win| + win.item :minimize, :key => "m" + win.item :zoom + win.separator + win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o" + end + main.submenu :help do |help| + help.item :help, :title => "#{NSApp.name} Help" + end + end + end +end Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/rb_main.rb =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/rb_main.rb (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Layout View.app/Contents/Resources/rb_main.rb 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,4 @@ + + $:.unshift NSBundle.mainBundle.resourcePath.fileSystemRepresentation + load 'lib/application.rb' + Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Rakefile =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Rakefile (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/Rakefile 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,18 @@ +task :default => [:run] + +task :build do + require 'hotcocoa/application_builder' + ApplicationBuilder.build :file => "config/build.yml" +end + +task :run => [:build] do + require 'yaml' + app_name = YAML.load(File.read("config/build.yml"))[:name] + `open "#{app_name}.app"` +end + +task :clean do + require 'yaml' + app_name = YAML.load(File.read("config/build.yml"))[:name] + `rm -rf "#{app_name}.app"` +end Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/config/build.yml =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/config/build.yml (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/config/build.yml 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,6 @@ +name: Layout View +load: lib/application.rb +version: "1.0" +icon: resources/HotCocoa.icns +sources: + - lib/**/*.rb Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/application.rb =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/application.rb (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/application.rb 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,166 @@ +require 'hotcocoa' + +class MyView < NSView + + include HotCocoa::Behaviors + + DefaultSize = [30, 30] + + def self.create + alloc.initWithFrame([0, 0, *DefaultSize]) + end + + def initWithFrame(frame) + super + self.layout = {} + self + end + + def reset_size + setFrameSize(DefaultSize) + end + + attr_accessor :number + + def drawRect(rect) + (color :red => 0.29, :green => 0.26, :blue => 0.55).set + NSFrameRect(rect) + (color :red => 0.51, :green => 0.45, :blue => 0.95).set + NSRectFill(NSInsetRect(rect, 1, 1)) + + @attributes ||= { NSFontAttributeName => NSFont.systemFontOfSize(10) } + str = @number.to_s + strsize = str.sizeWithAttributes @attributes + point = [ + (rect.size.width / 2.0) - (strsize.width / 2.0), + (rect.size.height / 2.0) - (strsize.height / 2.0) + ] + @number.to_s.drawAtPoint point, withAttributes:@attributes + end + +end + +def create_slider_layout(label, &block) + layout_view :mode => :horizontal, :frame => [0, 0, 0, 24], :layout => {:expand => :width} do |view| + view << label(:text => label, :layout => {:align => :center}) + s = slider :min => 0, :max => 50, :tic_marks => 20, :on_action => block, :layout => {:expand => :width, :align => :center} + s.setFrameSize([0, 24]) # TODO sizeToFit doesn't set the height for us + view << s + end +end + +include HotCocoa + +application :name => "Layout View" do |app| + + window :frame => [100, 100, 500, 500], :title => "Packing View Madness" do |win| + views = [] + + window :frame => [700, 100, 200, 500], :default_layout => {:start => false} do |pane| + + pane.view << create_slider_layout('Spacing') { |x| win.view.spacing = x.to_i } + + pane.view << create_slider_layout('Margin') { |x| win.view.margin = x.to_i } + + pane.view << button(:title => "Vertical", :type => :switch, :state => :on) do |b| + b.on_action do |b| + views.each { |v| v.reset_size } + win.view.mode = b.on? ? :vertical : :horizontal + end + end + + selected_view = nil + expand_b = nil + expand_h = nil + left_padding_s = right_padding_s = top_padding_s = bottom_padding_s = nil + other_p = nil + views_p = popup :items => ['No View'], :layout => {:expand => :width} + views_p.on_action do |p| + selected_view = views[p.items.selected_index] + options = selected_view.layout + expand_b.state = options.expand_width? + expand_h.state = options.expand_height? + left_padding_s.intValue = options.left_padding + right_padding_s.intValue = options.right_padding + top_padding_s.intValue = options.top_padding + bottom_padding_s.intValue = options.bottom_padding + other_p.items.selected = case options.align + when :left then 0 + when :center then 1 + when :right then 2 + end + end + + add_b = button :title => "Add view" + add_b.on_action do + view = MyView.create + views << view + view.number = views.size + win.view.addSubview view + views_p.items = views.map { |x| "View #{x.number}" } + selected_view = views[0] + end + pane.view << add_b + pane.view << views_p + expand_b = button :title => "Expand width", :type => :switch, :state => :off + expand_h = button :title => "Expand height", :type => :switch, :state => :off + expand_b.on_action do |b| + selected_view.reset_size + selected_view.layout.expand = if expand_b.on? + if expand_h.on? + [:width, :height] + else + :width + end + elsif expand_h.on? + :height + else + nil + end + end + expand_h.on_action do |b| + selected_view.reset_size + selected_view.layout.expand = if expand_b.on? + if expand_h.on? + [:width, :height] + else + :width + end + elsif expand_h.on? + :height + else + nil + end + end + pane.view << expand_b + pane.view << expand_h + + v = create_slider_layout('Left') { |x| selected_view.layout.left_padding = x.to_i } + left_padding_s = v.subviews[1] + pane.view << v + + v = create_slider_layout('Right') { |x| selected_view.layout.right_padding = x.to_i } + right_padding_s = v.subviews[1] + pane.view << v + + v = create_slider_layout('Top') { |x| selected_view.layout.top_padding = x.to_i } + top_padding_s = v.subviews[1] + pane.view << v + + v = create_slider_layout('Bottom') { |x| selected_view.layout.bottom_padding = x.to_i } + bottom_padding_s = v.subviews[1] + pane.view << v + + pane.view << layout_view(:mode => :horizontal, :frame => [0, 0, 0, 24], :layout => {:expand => :width}) do |view| + view << label(:text => 'Align', :layout => {:align => :center}) + view << popup(:items => ['Left/Bottom', 'Center', 'Right/Top'], :layout => {:expand => :width, :align => :center}) do |p| + p.on_action do |x| + selected_view.reset_size + selected_view.layout.align = [:left, :center, :right][p.items.selected_index-1] + end + other_p = p + end + end + end + end +end Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/menu.rb =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/menu.rb (rev 0) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view/lib/menu.rb 2008-08-28 01:45:43 UTC (rev 498) @@ -0,0 +1,32 @@ +module HotCocoa + def application_menu + menu do |main| + main.submenu :apple do |apple| + apple.item :about, :title => "About #{NSApp.name}" + apple.separator + apple.item :preferences, :key => "," + apple.separator + apple.submenu :services + apple.separator + apple.item :hide, :title => "Hide #{NSApp.name}", :key => "h" + apple.item :hide_others, :title => "Hide Others", :key => "h", :modifiers => [:command, :alt] + apple.item :show_all, :title => "Show All" + apple.separator + apple.item :quit, :title => "Quit #{NSApp.name}", :key => "q" + end + main.submenu :file do |file| + file.item :new, :key => "n" + file.item :open, :key => "o" + end + main.submenu :window do |win| + win.item :minimize, :key => "m" + win.item :zoom + win.separator + win.item :bring_all_to_front, :title => "Bring All to Front", :key => "o" + end + main.submenu :help do |help| + help.item :help, :title => "#{NSApp.name} Help" + end + end + end +end Added: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/resources/HotCocoa.icns =================================================================== (Binary files differ) Property changes on: MacRuby/trunk/sample-macruby/HotCocoa/layout_view/resources/HotCocoa.icns ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: MacRuby/trunk/sample-macruby/HotCocoa/layout_view.rb =================================================================== --- MacRuby/trunk/sample-macruby/HotCocoa/layout_view.rb 2008-08-27 21:55:20 UTC (rev 497) +++ MacRuby/trunk/sample-macruby/HotCocoa/layout_view.rb 2008-08-28 01:45:43 UTC (rev 498) @@ -1,166 +0,0 @@ -require 'hotcocoa' - -class MyView < NSView - - include HotCocoa::Behaviors - - DefaultSize = [30, 30] - - def self.create - alloc.initWithFrame([0, 0, *DefaultSize]) - end - - def initWithFrame(frame) - super - self.layout = {} - self - end - - def reset_size - setFrameSize(DefaultSize) - end - - attr_accessor :number - - def drawRect(rect) - (color :red => 0.29, :green => 0.26, :blue => 0.55).set - NSFrameRect(rect) - (color :red => 0.51, :green => 0.45, :blue => 0.95).set - NSRectFill(NSInsetRect(rect, 1, 1)) - - @attributes ||= { NSFontAttributeName => NSFont.systemFontOfSize(10) } - str = @number.to_s - strsize = str.sizeWithAttributes @attributes - point = [ - (rect.size.width / 2.0) - (strsize.width / 2.0), - (rect.size.height / 2.0) - (strsize.height / 2.0) - ] - @number.to_s.drawAtPoint point, withAttributes:@attributes - end - -end - -def create_slider_layout(label, &block) - layout_view :mode => :horizontal, :frame => [0, 0, 0, 24], :layout => {:expand => :width} do |view| - view << label(:text => label, :layout => {:align => :center}) - s = slider :min => 0, :max => 50, :tic_marks => 20, :on_action => block, :layout => {:expand => :width, :align => :center} - s.setFrameSize([0, 24]) # TODO sizeToFit doesn't set the height for us - view << s - end -end - -include HotCocoa - -application :name => "Layout View" do |app| - - window :frame => [100, 100, 500, 500], :title => "Packing View Madness" do |win| - views = [] - - window :frame => [700, 100, 200, 500], :default_layout => {:start => false} do |pane| - - pane.view << create_slider_layout('Spacing') { |x| win.view.spacing = x.to_i } - - pane.view << create_slider_layout('Margin') { |x| win.view.margin = x.to_i } - - pane.view << button(:title => "Vertical", :type => :switch, :state => :on) do |b| - b.on_action do |b| - views.each { |v| v.reset_size } - win.view.mode = b.on? ? :vertical : :horizontal - end - end - - selected_view = nil - expand_b = nil - expand_h = nil - left_padding_s = right_padding_s = top_padding_s = bottom_padding_s = nil - other_p = nil - views_p = popup :items => ['No View'], :layout => {:expand => :width} - views_p.on_action do |p| - selected_view = views[p.items.selected_index] - options = selected_view.layout - expand_b.state = options.expand_width? - expand_h.state = options.expand_height? - left_padding_s.intValue = options.left_padding - right_padding_s.intValue = options.right_padding - top_padding_s.intValue = options.top_padding - bottom_padding_s.intValue = options.bottom_padding - other_p.items.selected = case options.align - when :left then 0 - when :center then 1 - when :right then 2 - end - end - - add_b = button :title => "Add view" - add_b.on_action do - view = MyView.create - views << view - view.number = views.size - win.view.addSubview view - views_p.items = views.map { |x| "View #{x.number}" } - selected_view = views[0] - end - pane.view << add_b - pane.view << views_p - expand_b = button :title => "Expand width", :type => :switch, :state => :off - expand_h = button :title => "Expand height", :type => :switch, :state => :off - expand_b.on_action do |b| - selected_view.reset_size - selected_view.layout.expand = if expand_b.on? - if expand_h.on? - [:width, :height] - else - :width - end - elsif expand_h.on? - :height - else - nil - end - end - expand_h.on_action do |b| - selected_view.reset_size - selected_view.layout.expand = if expand_b.on? - if expand_h.on? - [:width, :height] - else - :width - end - elsif expand_h.on? - :height - else - nil - end - end - pane.view << expand_b - pane.view << expand_h - - v = create_slider_layout('Left') { |x| selected_view.layout.left_padding = x.to_i } - left_padding_s = v.subviews[1] - pane.view << v - - v = create_slider_layout('Right') { |x| selected_view.layout.right_padding = x.to_i } - right_padding_s = v.subviews[1] - pane.view << v - - v = create_slider_layout('Top') { |x| selected_view.layout.top_padding = x.to_i } - top_padding_s = v.subviews[1] - pane.view << v - - v = create_slider_layout('Bottom') { |x| selected_view.layout.bottom_padding = x.to_i } - bottom_padding_s = v.subviews[1] - pane.view << v - - pane.view << layout_view(:mode => :horizontal, :frame => [0, 0, 0, 24], :layout => {:expand => :width}) do |view| - view << label(:text => 'Align', :layout => {:align => :center}) - view << popup(:items => ['Left/Bottom', 'Center', 'Right/Top'], :layout => {:expand => :width, :align => :center}) do |p| - p.on_action do |x| - selected_view.reset_size - selected_view.layout.align = [:left, :center, :right][p.items.selected_index-1] - end - other_p = p - end - end - end - end -end
participants (1)
-
source_changes@macosforge.org