Class: MittensUi::Separator
Overview
A visual divider used to separate sections of a UI. Wraps Gtk::Separator. Vertical separators are automatically wrapped in a horizontal Gtk::Box with a minimum height so they render correctly in any layout context.
Instance Attribute Summary
Attributes inherited from Core
Instance Method Summary collapse
-
#initialize(orientation = :horizontal, options = {}) ⇒ Separator
constructor
Creates a new Separator widget.
Methods inherited from Core
#hidden?, #hide, #keyboard_shortcut, #remove, #remove_keyboard_shortcut, #render, #shortcuts, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(orientation = :horizontal, options = {}) ⇒ Separator
Creates a new Separator widget.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mittens_ui/separator.rb', line 34 def initialize(orientation = :horizontal, = {}) unless %i[horizontal vertical].include?(orientation) raise ArgumentError, 'orientation must be :horizontal or :vertical' end gtk_orientation = orientation == :horizontal ? Gtk::Orientation::HORIZONTAL : Gtk::Orientation::VERTICAL @separator = Gtk::Separator.new(gtk_orientation) = if orientation == :vertical height = [:height] || 100 container = Gtk::Box.new(Gtk::Orientation::HORIZONTAL, 0) container.set_size_request(10, height) @separator.set_size_request(2, height) @separator. = false @separator. = true container.append(@separator) container else @separator. = true @separator end super(, ) end |