Sha256: 9e8c737182cc6f98241717059bb1f003f727e2fb714e1b4b21e2e0f6e0740f7e

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

require 'nuklear/ui/window'

module Nuklear
  module UI
    class Popup < Nuklear::UI::Window
      attr_accessor :type

      def initialize(title, type: :static, enabled: false, **options)
        super title, enabled: enabled, **options
        self.type = type
        on(:visible) { self.enabled = true }
        on(:hidden) { self.enabled = false }
      end

      def to_command
        [:ui_popup,
          type == :dynamic ? NK_POPUP_DYNAMIC : NK_POPUP_STATIC,
          title,
          flags,
          left,
          top,
          width,
          height
        ]
      end

      def visible?
        @enabled
      end

      def result(visibility, context)
        trigger(visibility)
        run_commands(context) if visible?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nuklear-0.1.3 lib/nuklear/ui/popup.rb
nuklear-0.1.2 lib/nuklear/ui/popup.rb
nuklear-0.1.1 lib/nuklear/ui/popup.rb
nuklear-0.1.0 lib/nuklear/ui/popup.rb