 
     Display.display(2, 124, 1, refresh_lower ? 7 : 4);
   }
+
+  DUINO_WidgetContainer<2> * container_outer_;
+  DUINO_WidgetContainer<3> * container_top_;
+  DUINO_WidgetContainer<12> * container_notes_;
+  DUINO_DisplayWidget * widget_trigger_mode_;
+  DUINO_DisplayWidget * widget_key_;
+  DUINO_DisplayWidget * widget_scale_;
+  DUINO_DisplayWidget * widgets_notes_[12];
 
   bool trigger_mode;
   int8_t key;

  uint16_t scale;
  uint8_t output_note;
  int output_octave;
  bool main_selected;
  uint8_t top_selected;  // 0 - trigger mode, 1 - key, 2 - scale
  int8_t note_selected;
  uint8_t current_displayed_note;
};



void trig_isr();

void trigger_mode_scroll_callback(int delta);
void key_scroll_callback(int delta);
void scale_scroll_callback(int delta);
void notes_click_callback(uint8_t selected);

class DU_Quantizer_Function : public DUINO_Function {
 public:
  DU_Quantizer_Function() : DUINO_Function(0b00001100) { }

  virtual void setup()
  {
    // build widget hierarchy
    container_outer_ = new DUINO_WidgetContainer<2>(DUINO_Widget::DoubleClick);
    container_top_ = new DUINO_WidgetContainer<3>(DUINO_Widget::Click, 2);
    container_outer_->attach_child(container_top_, 0);
    widget_trigger_mode_ = new DUINO_DisplayWidget(76, 0, 9, 9, DUINO_Widget::Full);
    widget_trigger_mode_->attach_scroll_callback(trigger_mode_scroll_callback);
    container_top_->attach_child(widget_trigger_mode_, 0);
    widget_key_ = new DUINO_DisplayWidget(90, 0, 13, 9, DUINO_Widget::Full);
    widget_key_->attach_scroll_callback(key_scroll_callback);
    container_top_->attach_child(widget_key_, 1);
    widget_scale_ = new DUINO_DisplayWidget(108, 0, 19, 9, DUINO_Widget::Full);
    widget_scale_->attach_scroll_callback(scale_scroll_callback);
    container_top_->attach_child(widget_scale_, 2);
    container_notes_ = new DUINO_WidgetContainer<12>(DUINO_Widget::Scroll);
    container_outer_->attach_child(container_notes_, 1);
    widgets_notes_[0] = new DUINO_DisplayWidget(6, 54, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[1] = new DUINO_DisplayWidget(15, 29, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[2] = new DUINO_DisplayWidget(24, 54, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[3] = new DUINO_DisplayWidget(33, 29, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[4] = new DUINO_DisplayWidget(42, 54, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[5] = new DUINO_DisplayWidget(60, 54, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[6] = new DUINO_DisplayWidget(69, 29, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[7] = new DUINO_DisplayWidget(78, 54, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[8] = new DUINO_DisplayWidget(87, 29, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[9] = new DUINO_DisplayWidget(96, 54, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[10] = new DUINO_DisplayWidget(105, 29, 7, 7, DUINO_Widget::DottedBox);
    widgets_notes_[11] = new DUINO_DisplayWidget(114, 54, 7, 7, DUINO_Widget::DottedBox);
    for(uint8_t i = 0; i < 12; ++i)
    {
      container_notes_->attach_child(widgets_notes_[i], i);
    }
    container_notes_->attach_click_callback_array(notes_click_callback);

    trigger_mode = false;
    key = 0;
    scale_id = 0;
    scale = get_scale_by_id(scale_id);
    output_octave = 0;
    output_note = 0;
    current_displayed_note = 0;

    gt_attach_interrupt(GT3, trig_isr, FALLING);
