Class: Iup::Dial
- Includes:
- ButtonCallback
- Defined in:
- lib/wrapped/dial.rb
Overview
Creates a dial for setting an angular variable.
Example
The following creates a horizontal dial which updates a label whenever its value changes.
Iup::Dial.new do |d|
d.valuechanged_cb = ->{
label.title = "dial value: #{'%0.2f' % d.value}"
Iup::DEFAULT
}
end
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#button_press_cb=(callback) ⇒ Object
--.
-
#button_release_cb=(callback) ⇒ Object
--.
-
#initialize(orientation = 'horizontal') {|_self| ... } ⇒ Dial
constructor
Creates a new instance.
-
#mousemove_cb=(callback) ⇒ Object
--.
-
#orientation ⇒ Object
:attr: orientation Value one of 'horizontal' / 'vertical' / 'circular'.
-
#unit ⇒ Object
:attr: unit 'radians' / 'degrees' - used in the callbacks.
-
#value ⇒ Object
--.
-
#value=(val) ⇒ Object
:nodoc:.
-
#valuechanged_cb=(callback) ⇒ Object
--.
Methods included from ButtonCallback
Methods inherited from Canvas
#action=, #activate, #arc, #background, #background=, #backopacity, #backopacity=, #begin_block, #border, #box, #canfocus, #chord, #clear, #cursor, #deactivate, #drawsize, #end_block, #expand, #fillmode, #fillmode=, #focus_cb=, #font, #foreground, #foreground=, #hatch, #hatch=, #init, #interiorstyle, #interiorstyle=, #keypress_cb=, #kill, #line, #linecap, #linecap=, #linejoin, #linejoin=, #linestyle, #linestyle=, #linewidth, #linewidth=, #mark, #marksize, #marksize=, #marktype, #marktype=, #motion_cb=, #nativefont=, #padding, #pathset, #pixel, #position, #rastersize, #rectangle, #redraw, #resize_cb=, #screenposition, #sector, #stipple, #text, #textalignment, #textalignment=, #textorientation, #textorientation=, #tip, #vectortext, #vectortext_charsize, #vectortext_charsize=, #vectortext_direction, #vectortext_fontsize, #vectortext_loadfont, #vectortext_size, #vertex, #viewport, #wheel_cb=, #window, #writemode, #writemode=
Methods included from ScrollBarAttributes
#dx, #dx=, #dy, #dy=, #linex, #linex=, #liney, #liney=, #posx, #posx=, #posy, #posy=, #scroll_cb=, #scrollbar, #xautohide, #xmax, #xmax=, #xmin, #xmin=, #yautohide, #ymax, #ymax=, #ymin, #ymin=
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_reader, #define_id_writer, #define_property_attribute, #define_property_reader, #define_property_writer, #define_reader, #define_writer
Methods included from DragDropAttributes
#dragbegin_cb=, #dragdata_cb=, #dragdatasize_cb=, #dragend_cb=, #dragsource, #dragsourcemove, #dragtypes, #dropdata_cb=, #dropmotion_cb=, #droptarget, #droptypes
Methods inherited from Widget
#active, #assign_handle, #bgcolor, #destroy, #enterwindow_cb=, #fgcolor, #font, #getfocus_cb=, #help_cb=, #k_any=, #killfocus_cb=, #leavewindow_cb=, #map_cb=, #maxsize, #minsize, #open_controls, #size, #unmap_cb=, #visible, #wid, #zorder
Methods included from CallbackSetter
Constructor Details
#initialize(orientation = 'horizontal') {|_self| ... } ⇒ Dial
Creates a new instance. If a block is given, the new instance is yielded to it.
orientation- 'horizontal' / 'vertical' / 'circular'
22 23 24 25 26 27 28 |
# File 'lib/wrapped/dial.rb', line 22 def initialize(orientation = 'horizontal') open_controls @handle = ControlsLib.IupDial(orientation) # run any provided block on instance, to set up further attributes yield self if block_given? end |
Instance Method Details
#button_press_cb=(callback) ⇒ Object
--
69 70 71 72 73 74 75 76 77 |
# File 'lib/wrapped/dial.rb', line 69 def callback unless callback.arity == 1 raise ArgumentError, 'button_press_cb callback must take 1 argument: (angle)' end cb = Proc.new do |ih, angle| callback.call angle end define_callback cb, 'BUTTON_PRESS_CB', :d_i end |
#button_release_cb=(callback) ⇒ Object
--
86 87 88 89 90 91 92 93 94 |
# File 'lib/wrapped/dial.rb', line 86 def callback unless callback.arity == 1 raise ArgumentError, 'button_release_cb callback must take 1 argument: (angle)' end cb = Proc.new do |ih, angle| callback.call angle end define_callback cb, 'BUTTON_RELEASE_CB', :d_i end |
#mousemove_cb=(callback) ⇒ Object
--
103 104 105 106 107 108 109 110 111 |
# File 'lib/wrapped/dial.rb', line 103 def mousemove_cb= callback unless callback.arity == 1 raise ArgumentError, 'mousemove_cb callback must take 1 argument: (angle)' end cb = Proc.new do |ih, angle| callback.call angle end define_callback cb, 'MOUSEMOVE_CB', :d_i end |
#orientation ⇒ Object
:attr: orientation Value one of 'horizontal' / 'vertical' / 'circular'. Horizontal or vertical orientations show a dial to be scrolled across; a circular orientation shows a round dial to be rotated.
37 |
# File 'lib/wrapped/dial.rb', line 37 define_attribute :orientation |
#unit ⇒ Object
:attr: unit 'radians' / 'degrees' - used in the callbacks.
42 |
# File 'lib/wrapped/dial.rb', line 42 define_attribute :unit |
#value ⇒ Object
--
50 51 52 |
# File 'lib/wrapped/dial.rb', line 50 def value IupLib.IupGetAttribute(@handle, 'VALUE').first.to_f end |
#value=(val) ⇒ Object
:nodoc:
54 55 56 |
# File 'lib/wrapped/dial.rb', line 54 def value= val # :nodoc: IupLib.IupSetAttribute(@handle, 'VALUE', val.to_s) end |
#valuechanged_cb=(callback) ⇒ Object
--
119 120 121 122 123 124 125 126 127 |
# File 'lib/wrapped/dial.rb', line 119 def valuechanged_cb= callback unless callback.arity.zero? raise ArgumentError, 'valuechanged_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'VALUECHANGED_CB', :plain end |