Sha256: b4237e080bb24f88e889ea4895613d8152016c24ac8c2bb456916b1af082892d

Contents?: true

Size: 983 Bytes

Versions: 7

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true
# Here's a little library for quickly hooking up in sketch sliders.
# Copyright (c) 2016-18 Martin Prout.

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

# Slider module
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

7 entries across 7 versions & 1 rubygems

Version Path
propane-3.1.0.pre-java library/slider/slider.rb
propane-2.9.3-java library/slider/slider.rb
propane-3.0.1.pre-java library/slider/slider.rb
propane-2.9.2-java library/slider/slider.rb
propane-3.0.0.pre-java library/slider/slider.rb
propane-2.9.1-java library/slider/slider.rb
propane-2.9.0-java library/slider/slider.rb