Sha256: 59c899b696212e8470fa16cc47eaa9eb4e56bf153f9acc8671885f0687a8e0a2

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

def method_missing(method, *args, **kwargs, &block)
  if Scarpe::SIZES.keys.include?(method)
    kwargs[:size] = Scarpe::SIZES[method]
    Scarpe.para(*args, **kwargs, &block)
  else
    case method.to_s
    when "alert"
      Scarpe.alert(*args, **kwargs, &block)
    when "button"
      Scarpe.button(*args, **kwargs, &block)
    when "stack"
      Scarpe.stack(*args, **kwargs, &block)
    when "flow"
      Scarpe.flow(*args, **kwargs, &block)
    else
      super
    end
  end
end

def respond_to_missing?(method_name, include_private = false)
  [
    "alert",
    "button",
    "stack",
  ].include?(method_name.to_s) || super
end

def para(*args, **kwargs)
  Scarpe.para(*args, **kwargs)
end

class Scarpe
  class << self
    def app(title: "Scarpe app", height: 400, width: 400)
      setup(title, height, width)
      yield
      closing_stuff
    end

    def setup(title, height, width)
      UI.init

      $main_window = UI.new_window(title, height, width, 1)
      $vbox = UI.new_vertical_box
      UI.window_set_child($main_window, $vbox)
    end

    def closing_stuff
      UI.window_on_closing($main_window) do
        puts "Bye Bye"
        UI.control_destroy($main_window)
        UI.quit
        0
      end

      UI.control_show($main_window)

      # Add main box to main window, close everything out
      UI.main
      UI.quit
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
scarpe-0.4.0 spikes/libui/core.rb
scarpe-0.3.0 spikes/libui/core.rb
scarpe-0.2.2 spikes/libui/core.rb
lacci-0.2.1 lib/scarpe/libui/core.rb
scarpe-0.2.1 lib/scarpe/libui/core.rb
scarpe-0.2.0 lib/scarpe/libui/core.rb