Sha256: ef3ae3fa30ed8ff1d83a9dbce3b541aea448f4699fcccc3461e5c1a11ae7a00e

Contents?: true

Size: 966 Bytes

Versions: 21

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true
# Here's a little library for quickly hooking up in sketch sliders.
# Copyright (c) 2016 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

21 entries across 21 versions & 2 rubygems

Version Path
propane-2.0.6-java library/slider/slider.rb