Sha256: 35ac7f8634753093536d1ef3cf3bd25b955032fd9511a9736bd476eecfe7e258

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'glimmer/swt/widget_proxy'

module Glimmer
  module SWT
    class TabFolderProxy < WidgetProxy      
      attr_reader :tabs
      
      def initialize(parent, args)
        super(parent, args)
        @tabs = []
      end
      
      def add_child(child)
        unless @children.include?(child)
          @children << child
        end
        if @children.size == 1
          child.show
        end
      end
      
      def redraw
        super()
        @children.each do |child|
          add_child(child) # TODO think of impact of this on performance
        end
      end
      
      def hide_all_tab_content
        @children.each(&:hide)
      end
    
      def tabs_path
        path + " > ##{tabs_id}"
      end
      
      def tabs_id
        id + '-tabs'
      end
      
      def dom
        tab_folder_id = id
        tab_folder_id_style = css
        @dom ||= html {
          div(id: tab_folder_id, style: tab_folder_id_style, class: 'tab-folder') {
            div(id: tabs_id, class: 'tabs')
          }
        }.to_s
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glimmer-dsl-opal-0.1.0 lib/glimmer/swt/tab_folder_proxy.rb