Sha256: 703e722158e93e1dee4eef6d160a274236f7e71fa8c6d16b0146a7c1943d099b

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

# Here's a little library for quickly hooking up in sketch sliders.
# Copyright (c) 2015-20 Martin Prout.

java_import 'monkstone.slider.CustomHorizontalSlider'
java_import 'monkstone.slider.CustomVerticalSlider'

module Slider
  def self.slider(app:, x:, y:, name:, **opts)
    options = default.merge opts
    slider = if options[:vertical]
               CustomVerticalSlider.new(
                 app,
                 x,
                 y,
                 options[:length],
                 options[:range].first,
                 options[:range].last,
                 name
               )
             else
               CustomHorizontalSlider.new(
                 app,
                 x,
                 y,
                 options[:length],
                 options[:range].first,
                 options[:range].last,
                 name
               )
             end
    unless opts.empty?
      slider.bar_width(opts.fetch(:bar_width, 10))
      slider.set_value(opts.fetch(:initial_value, 0))
    end
    slider
  end

  def self.default
    { length: 100, range: (0..100) }
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jruby_art-2.6.1 library/slider/slider.rb
jruby_art-2.6.0 library/slider/slider.rb
jruby_art-2.5.1 library/slider/slider.rb
jruby_art-2.5.0 library/slider/slider.rb
jruby_art-2.4.3 library/slider/slider.rb
jruby_art-2.4.2 library/slider/slider.rb
jruby_art-2.4.1 library/slider/slider.rb
jruby_art-2.4.0 library/slider/slider.rb
jruby_art-2.3.0 library/slider/slider.rb