void Module::update_tooltip ( void ) { char *s; asprintf( &s, "Left click to edit parameters; Ctrl + left click to select; right click or MENU key for menu. (info: latency: %lu)", (unsigned long) get_module_latency() ); copy_tooltip(s); free(s); }
int tabbar::handle(const int e) { bool ontab = false; u32 which = 0; bool leftcloser = false; // Over a tab? if (mousein) { u32 max; const u32 tabw = calctabw(&max, w()); if (mousex < x() + max * tabw && mousex >= (u32) x()) { ontab = true; u32 tmp = mousex - x(); const u32 whichmod = tmp % tabw; if (whichmod < tabw / 2) leftcloser = true; tmp /= tabw; which = tmp; } } switch (e) { case FL_ENTER: mousein = true; return 1; case FL_LEAVE: mousein = false; redraw(); return 1; case FL_DRAG: if (!dragging && ontab && Fl::event_state(FL_BUTTON1)) { srctab = which; if (abs(Fl::event_x() - (int) dragstartx) >= 10) dragging = true; } // Fallthrough case FL_MOVE: mousex = Fl::event_x(); redraw(); if (ontab) { if (!tooltip() || strcmp(tooltip(), g->tabs[which].title())) { copy_tooltip(g->tabs[which].title()); Fl_Tooltip::enter(0); Fl_Tooltip::enter(this); } } else { if (!tooltip() || strcmp(tooltip(), "")) { tooltip(""); Fl_Tooltip::enter(0); Fl_Tooltip::enter(this); } } return 1; case FL_PUSH: // Double click on empty? if (Fl::event_clicks() && Fl::event_button() == FL_LEFT_MOUSE && !ontab) { newtab(); return 1; } dragstartx = Fl::event_x(); return 1; case FL_RELEASE: // Tiny differences are mouse jerks, ignore under 10 pixels if (abs(Fl::event_x() - (int) dragstartx) < 10) dragging = false; if (dragging) { const tab tmp = g->tabs[srctab]; if (ontab) { u32 newpos = which; // No drag? if ((srctab == newpos - 1 && leftcloser) || (srctab == newpos + 1 && !leftcloser) || srctab == which) goto dragdone; if (!leftcloser && newpos < srctab) newpos++; else if (leftcloser && newpos > srctab) newpos--; g->tabs.erase(g->tabs.begin() + srctab); if (newpos < g->tabs.size()) g->tabs.insert(g->tabs.begin() + newpos, tmp); else g->tabs.push_back(tmp); if (g->curtab == srctab) g->curtab = newpos; else if (g->curtab > srctab && g->curtab <= newpos) g->curtab--; else if (g->curtab < srctab && g->curtab >= newpos) g->curtab++; if (g->curtab >= g->tabs.size()) g->curtab = g->tabs.size() - 1; } else { g->tabs.erase(g->tabs.begin() + srctab); g->tabs.push_back(tmp); if (g->curtab > srctab) g->curtab--; else if (g->curtab == srctab) g->curtab = g->tabs.size() - 1; } } else if (ontab) { if (Fl::event_button() == FL_LEFT_MOUSE) { activatetab(which); } else if (Fl::event_button() == FL_MIDDLE_MOUSE) { activatetab(which); closetab(); } } dragdone: dragging = false; return 1; } return Fl_Widget::handle(e); }