2 Copyright 2009 by Hans Baier
10 public class KnobWithDisplay
: EventBox
{
13 private ValueDisplay display
;
15 public string unit
{ get; set; }
17 // This function is called whenever the knob value changes
18 public delegate
void DisplayFunc (Knob knob
, ValueDisplay display
, KnobWithDisplay knob_with_display
);
20 private DisplayFunc? display_func
= null;
21 public void set_display_func (DisplayFunc func
) {
25 // delegating properties
26 [Description(nick
="show matrix", blurb
="Whether a pixel matrix should be drawn in the display background (much faster if false)")]
27 public bool show_matrix
{ get { return display
.show_matrix
; } set { display
.show_matrix
= value
; } }
28 public Adjustment adjustment
{ get { return knob
.get_adjustment (); } set { knob
.set_adjustment (value
); } }
29 [Description(nick
="knob mode", blurb
="determines, how the knob will work / look like")]
30 public KnobMode knob_mode
{ get { return knob
.knob_mode
; } set { knob
.knob_mode
= value
; } }
31 [Description(nick
="decimal places", blurb
="The value will be rounded to the given number of decimal places")]
32 public uint decimal_places
{ get { return knob
.decimal_places
; } set { knob
.decimal_places
= value
; } }
35 vbox
= new
VBox (false, 0);
38 display
= new
ValueDisplay ();
40 knob
.user_data
= display
;
42 var adj
= knob
.get_adjustment ();
43 knob
.value_changed
+= (knob
) => {
44 ValueDisplay disp
= knob
.user_data as ValueDisplay
;
47 if (display_func
!= null) {
48 display_func (knob
, display
, this
);
50 text
= "%.*f".printf (knob
.decimal_places
, knob
.get_value ()) + " " + unit
;
57 GLib
.Timeout
.add (512, ()=> {
58 knob
.value_changed ();
63 } // namespace Prolooks