Permalink
Browse files

Made sliders accept being disabled.

  • Loading branch information...
1 parent 701e7bf commit d81facc5a53727461c6a6bf2a88af2fa09905e59 @Spooner Spooner committed Feb 26, 2012
Showing with 11 additions and 3 deletions.
  1. +6 −2 examples/slider_example.rb
  2. +5 −1 lib/fidgit/elements/slider.rb
@@ -7,7 +7,7 @@ def initialize
vertical do
horizontal do
# Discrete values (0..100)
- slider = slider(width: 100, range: 0..5, value: 3) do |sender, value|
+ slider = slider(width: 100, range: 0..5, value: 3, tip: "Discrete value is") do |sender, value|
@discrete_label.text = "Discrete slider is at #{value}"
end
@@ -17,12 +17,16 @@ def initialize
horizontal do
# Continuous values (0.0..1.0)
- slider = slider(width: 100, range: 0.0..100.0, value: 77.2) do |sender, value|
+ slider = slider(width: 100, range: 0.0..100.0, value: 77.2, tip: "Continuous value is") do |sender, value|
@continuous_label.text = "Continuous slider is at #{"%.03f" % value}%"
end
@continuous_label = label "Continuous slider is at #{"%.03f" % slider.value}%"
end
+
+ horizontal do
+ slider(width: 100, range: 0.0..100.0, value: 77.2, tip: "Disabled slider value is", enabled: false)
+ end
end
end
end
@@ -27,7 +27,11 @@ def initialize(options = {}, &block)
end
subscribe :update_drag do |sender, x, y|
- parent.handle_dragged_to x - @drag_start_pos[0], y - @drag_start_pos[1]
+ if parent.enabled?
+ parent.handle_dragged_to x - @drag_start_pos[0], y - @drag_start_pos[1]
+ else
+ publish :end_drag
+ end
end
subscribe :end_drag do

0 comments on commit d81facc

Please sign in to comment.