Sha256: 1723870a911cc75664091b8ecb51f6278bea964a84ada7c6cf5b8df777f95599

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 Bytes

Contents

module Nuklear
  module UI
    class Property < Base
      attr_accessor :current, :min, :max, :step, :inc_per_pixel, :text

      def initialize(enabled: true, text: '', min: 1, max: 100, current: 1, step: 1, inc_per_pixel: 1)
        super enabled: enabled
        @text = text
        @min = min
        @max = max
        @current = current
        @step = step
        @inc_per_pixel = inc_per_pixel
        on(:changed) { yield @current } if block_given?
      end

      def to_command
        [:ui_property, text, min, current, max, step, inc_per_pixel]
      end

      def result(x, context)
        @current = x
        trigger :changed
        @last_event = nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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