Sha256: 8fb46b7eb8868219c350ff6c116dcb56f55bd14ef4e59dd27b01152e580cf8be

Contents?: true

Size: 574 Bytes

Versions: 4

Compression:

Stored size: 574 Bytes

Contents

module Nuklear
  module UI
    class Slider < Base
      attr_accessor :current, :min, :max, :step

      def initialize(enabled: true, min: 0.0, max: 1.0, current: 0.0, step: 0.001)
        super enabled: enabled
        @min = min
        @max = max
        @current = current
        @step = step
        on(:changed) { yield @current } if block_given?
      end

      def to_command
        [:ui_slider, current, min, max, step]
      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/slider.rb
nuklear-0.1.2 lib/nuklear/ui/slider.rb
nuklear-0.1.1 lib/nuklear/ui/slider.rb
nuklear-0.1.0 lib/nuklear/ui/slider.rb