Class: MittensUi::HBox
- Includes:
- Helpers
- Defined in:
- lib/mittens_ui/hbox.rb
Overview
A horizontal layout container that places widgets side by side in a row. Wraps Gtk::Box with :horizontal orientation. Supports nesting — HBox instances can be placed inside other HBox instances.
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#attach_widget(gtk_widget) ⇒ void
Attaches a raw GTK widget to the horizontal box.
-
#initialize(widgets_or_options = [], options = {}) { ... } ⇒ HBox
constructor
Creates a new HBox container.
-
#remove ⇒ void
Removes the HBox from the application layout.
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Methods inherited from Core
#hidden?, #hide, #keyboard_shortcut, #remove_keyboard_shortcut, #render, #shortcuts, #show
Constructor Details
#initialize(widgets_or_options = [], options = {}) { ... } ⇒ HBox
Creates a new HBox container.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mittens_ui/hbox.rb', line 47 def initialize( = [], = {}, &block) if .is_a?(Hash) = = [] else = end box_spacing = [:spacing] || 6 @box = Gtk::Box.new(:horizontal, box_spacing) set_margin_from_opts_for(@box, ) if block_given? MittensUi::Application.push_container(self) instance_eval(&block) MittensUi::Application.pop_container else .each do |w| w.remove if w.respond_to?(:remove) attach(w.) end end super(@box, ) end |
Instance Method Details
#attach_widget(gtk_widget) ⇒ void
This method returns an undefined value.
Attaches a raw GTK widget to the horizontal box. Called automatically by Core#render when widgets are created inside an HBox block.
79 80 81 |
# File 'lib/mittens_ui/hbox.rb', line 79 def () attach() end |
#remove ⇒ void
This method returns an undefined value.
Removes the HBox from the application layout.
86 87 88 89 90 |
# File 'lib/mittens_ui/hbox.rb', line 86 def remove return if @box.nil? MittensUi::Application.layout.remove(@box) end |