Sha256: 4bd326470a53be1b4b0a63af41073f669eda728483d3cd1484d506c6e977850a

Contents?: true

Size: 969 Bytes

Versions: 10

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true
# Here's a little library for quickly hooking up in sketch sliders.
# Copyright (c) 2016-17 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
    if options[:vertical]
      slider = CustomVerticalSlider.new(
        app,
        x,
        y,
        options[:length],
        options[:range].first,
        options[:range].last,
        name
    )
    else
      slider = 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

10 entries across 10 versions & 2 rubygems

Version Path
propane-2.6.4-java library/slider/slider.rb
jruby_art-1.4.6 library/slider/slider.rb
jruby_art-1.4.5 library/slider/slider.rb
propane-2.6.3-java library/slider/slider.rb
jruby_art-1.4.4 library/slider/slider.rb
jruby_art-1.4.3 library/slider/slider.rb
propane-2.6.2-java library/slider/slider.rb
jruby_art-1.4.2 library/slider/slider.rb
jruby_art-1.4.1 library/slider/slider.rb
propane-2.6.1-java library/slider/slider.rb