32
32
#include " gui/drawing.h"
33
33
#include " gui/elems/basics/boxtypes.h"
34
34
#include " gui/elems/basics/dial.h"
35
+ #include " gui/elems/basics/menu.h"
35
36
#include " gui/elems/basics/resizerBar.h"
36
37
#include " gui/elems/basics/textButton.h"
37
38
#include " gui/elems/mainWindow/keyboard/channelButton.h"
@@ -51,6 +52,18 @@ extern giada::v::Ui* g_ui;
51
52
52
53
namespace giada ::v
53
54
{
55
+ namespace
56
+ {
57
+ enum class Menu
58
+ {
59
+ ADD_TRACK = 0
60
+ };
61
+ } // namespace
62
+
63
+ /* -------------------------------------------------------------------------- */
64
+ /* -------------------------------------------------------------------------- */
65
+ /* -------------------------------------------------------------------------- */
66
+
54
67
geKeyboard::ChannelDragger::ChannelDragger (geKeyboard& k)
55
68
: m_keyboard(k)
56
69
, m_channelId(-1 )
@@ -187,6 +200,27 @@ size_t geKeyboard::countTracks() const
187
200
188
201
/* -------------------------------------------------------------------------- */
189
202
203
+ void geKeyboard::showMenu () const
204
+ {
205
+ geMenu menu;
206
+
207
+ menu.addItem ((ID)Menu::ADD_TRACK, g_ui->getI18Text (LangMap::MAIN_TRACK_BUTTON_ADD_TRACK));
208
+
209
+ menu.onSelect = [this ](ID menuId)
210
+ {
211
+ switch (static_cast <Menu>(menuId))
212
+ {
213
+ case Menu::ADD_TRACK:
214
+ addTrack ();
215
+ break ;
216
+ }
217
+ };
218
+
219
+ menu.popup ();
220
+ }
221
+
222
+ /* -------------------------------------------------------------------------- */
223
+
190
224
void geKeyboard::init ()
191
225
{
192
226
deleteAllTracks ();
@@ -260,7 +294,7 @@ int geKeyboard::handle(int e)
260
294
}
261
295
if (Fl::event_button3 ())
262
296
{
263
- openTrackMenu ();
297
+ openMenu ();
264
298
return 1 ;
265
299
}
266
300
@@ -355,7 +389,7 @@ geompp::Rect<int> geKeyboard::getTrackBackround(const geTrack& c) const
355
389
356
390
/* -------------------------------------------------------------------------- */
357
391
358
- void geKeyboard::addTrack ()
392
+ void geKeyboard::addTrack () const
359
393
{
360
394
c::channel::addTrack ();
361
395
}
@@ -455,11 +489,15 @@ std::vector<std::string> geKeyboard::getDroppedFilePaths() const
455
489
456
490
/* -------------------------------------------------------------------------- */
457
491
458
- void geKeyboard::openTrackMenu () const
492
+ void geKeyboard::openMenu () const
459
493
{
460
494
const geTrack* track = getTrackAtCursor (Fl::event_x ());
461
- if (track == nullptr || track->getChannelAtCursor (Fl::event_y ()) != nullptr )
495
+ if (track == nullptr ) // No track hovered: show Keyboard menu
496
+ {
497
+ showMenu ();
462
498
return ;
463
- track->showMenu ();
499
+ }
500
+ if (track->getChannelAtCursor (Fl::event_y ()) == nullptr ) // No channel hovered: show track menu
501
+ track->showMenu ();
464
502
}
465
503
} // namespace giada::v
0 commit comments