Class: Fidgit::FileDialog

Inherits:
DialogState show all
Defined in:
lib/fidgit/states/file_dialog.rb

Overview

A simple dialog that manages a message with a set of buttons beneath it.

Constant Summary

Constants inherited from DialogState

DialogState::DEFAULT_BACKGROUND_COLOR, DialogState::DEFAULT_BORDER_COLOR, DialogState::DEFAULT_SHADOW_COLOR, DialogState::DEFAULT_SHADOW_OFFSET

Constants inherited from GuiState

GuiState::PIXEL_IMAGE

Instance Attribute Summary

Attributes inherited from GuiState

#container, #focus

Instance Method Summary collapse

Methods inherited from DialogState

#draw, #hide, #show

Methods inherited from GuiState

#clear, clear, #cursor, #distance, #draw, #draw_frame, #draw_rect, #file_dialog, #finalize, #flush, #hide, #hide_menu, #menu, #message, #setup, #show, #show_menu, #t, #tool_tip_delay, #unset_mouse_over, #update, #write_tree

Constructor Details

#initialize(type, options = {}, &block) ⇒ FileDialog

Returns a new instance of FileDialog.


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fidgit/states/file_dialog.rb', line 4

def initialize(type, options = {}, &block)
  options = {
    show: true,
    background_color: DEFAULT_BACKGROUND_COLOR,
    border_color: DEFAULT_BORDER_COLOR,
  }.merge! options

  super(options)

  vertical align: :center, padding: 0 do |packer|
    FileBrowser.new(type, { parent: packer }.merge!(options)) do |sender, result, file_name|
      hide
      block.call result, file_name if block
    end
  end

  show if options[:show]
end