Sha256: 2bfa649bb0496dcfb704fe3fe4e3d30bf1ab17e1acf8ce060cd517228a6d26ea
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
class Shoes module Swt class ShoesLayout < ::Swt::Widgets::Layout attr_accessor :gui_app def layout(*_dontcare) height, scroll_height, is_scrolling = gather_height_info(@gui_app.dsl) set_heights(@gui_app.dsl, @gui_app.real, height, scroll_height) if is_scrolling show_scrollbar(vertical_scrollbar, height, scroll_height) else hide_scrollbar(vertical_scrollbar, @gui_app.real) end end private def gather_height_info(dsl_app) height = dsl_app.height scroll_height = dsl_app.top_slot.contents_alignment [height, scroll_height, scroll_height > height] end def set_heights(dsl_app, real_app, height, scroll_height) maximum_height = [height, scroll_height].max set_real_size(dsl_app, real_app, maximum_height) set_top_slot_size(dsl_app, maximum_height) end def set_real_size(dsl_app, real_app, maximum_height) size = real_app.compute_trim 0, 0, dsl_app.width, maximum_height real_app.set_size(size.width, size.height) end def set_top_slot_size(dsl_app, maximum_height) dsl_app.top_slot.width = dsl_app.width dsl_app.top_slot.height = maximum_height end def show_scrollbar(scrollbar, height, scroll_height) scrollbar.visible = true scrollbar.thumb = height * height / scroll_height scrollbar.maximum = scroll_height - height + scrollbar.thumb scrollbar.increment = 10 end def hide_scrollbar(scrollbar, real_app) scrollbar.visible = false location = real_app.location location.y = 0 real_app.location = location end def vertical_scrollbar @gui_app.shell.vertical_bar end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shoes-swt-4.0.0.pre6 | lib/shoes/swt/shoes_layout.rb |
shoes-swt-4.0.0.pre5 | lib/shoes/swt/shoes_layout.rb |
shoes-swt-4.0.0.pre4 | lib/shoes/swt/shoes_layout.rb |