Sha256: 00af608ff5d00c0288fceedbc8208be998dbd56a805b26d7ce0f88447232bae7

Contents?: true

Size: 1.34 KB

Versions: 10

Compression:

Stored size: 1.34 KB

Contents

require_relative 'helpers/example_window'


Fidgit::Element.schema.merge_elements!(Element: { font_height: 15 })

class ExampleState < Fidgit::GuiState
  def initialize
    super

    container.background_color = Gosu::Color.rgb(50, 50, 50)
    vertical align: :center do
      full_base_directory = ''
      restricted_base_directory = File.expand_path(File.join(__FILE__, '..', '..'))
      directory = File.join(restricted_base_directory, 'media', 'images')

      my_label = label "No files are actually loaded or saved by this example"
      button("Load...(limited path access)") do
        file_dialog(:open, base_directory: restricted_base_directory, directory: directory, pattern: "*.png") do |result, file|
          case result
            when :open
              my_label.text = "Loaded #{file}"
            when :cancel
              my_label.text = "Loading cancelled"
          end
        end
      end

      button("Save...(unrestricted path access)") do
        file_dialog(:save, base_directory: full_base_directory, directory: directory, pattern: "*.png") do |result, file|
          case result
            when :save
              my_label.text = "Saved #{file}"
            when :cancel
              my_label.text = "Save cancelled"
          end
        end
      end
    end
  end
end

ExampleWindow.new.show

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fidgit-0.2.4 examples/file_dialog_example.rb
fidgit-0.2.3 examples/file_dialog_example.rb
fidgit-0.2.2 examples/file_dialog_example.rb
fidgit-0.2.1 examples/file_dialog_example.rb
fidgit-0.2.0 examples/file_dialog_example.rb
fidgit-0.1.10 examples/file_dialog_example.rb
fidgit-0.1.9 examples/file_dialog_example.rb
fidgit-0.1.8 examples/file_dialog_example.rb
fidgit-0.1.7 examples/file_dialog_example.rb
fidgit-0.1.6 examples/file_dialog_example.rb