Browse Source

Move favorite menu item from ModelBox menu to Model menu.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
8df21af258
3 changed files with 27 additions and 22 deletions
  1. +2
    -0
      include/plugin/Model.hpp
  2. +2
    -22
      src/app/Browser.cpp
  3. +23
    -0
      src/plugin/Model.cpp

+ 2
- 0
include/plugin/Model.hpp View File

@@ -73,6 +73,8 @@ struct Model {
/** Returns the module or plugin manual URL, whichever exists. */
std::string getManualUrl();
void appendContextMenu(ui::Menu* menu);
bool isFavorite();
void setFavorite(bool favorite);
};




+ 2
- 22
src/app/Browser.cpp View File

@@ -239,8 +239,9 @@ struct ModelBox : widget::OpaqueWidget {
mw->dragEnabled() = false;
}

// Toggle favorite
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) {
setFavorite(!isFavorite());
model->setFavorite(!model->isFavorite());
e.consume(this);
}

@@ -305,27 +306,6 @@ struct ModelBox : widget::OpaqueWidget {
menu->addChild(createMenuLabel(model->name));
menu->addChild(createMenuLabel(model->plugin->brand));
model->appendContextMenu(menu);

menu->addChild(new ui::MenuSeparator);

menu->addChild(createBoolMenuItem("Favorite",
[=]() {
return isFavorite();
},
[=](bool favorite) {
setFavorite(favorite);
}
));
}

bool isFavorite() {
const settings::ModuleInfo* mi = settings::getModuleInfo(model->plugin->slug, model->slug);
return mi && mi->favorite;
}

void setFavorite(bool favorite) {
settings::ModuleInfo& mi = settings::moduleInfos[model->plugin->slug][model->slug];
mi.favorite = favorite;
}
};



+ 23
- 0
src/plugin/Model.cpp View File

@@ -4,6 +4,7 @@
#include <plugin.hpp>
#include <asset.hpp>
#include <system.hpp>
#include <settings.hpp>
#include <string.hpp>
#include <tag.hpp>
#include <ui/Menu.hpp>
@@ -178,6 +179,28 @@ void Model::appendContextMenu(ui::Menu* menu) {
system::openDirectory(plugin->path);
}));
}

// Favorite
menu->addChild(createBoolMenuItem("Favorite",
[=]() {
return isFavorite();
},
[=](bool favorite) {
setFavorite(favorite);
}
));
}


bool Model::isFavorite() {
const settings::ModuleInfo* mi = settings::getModuleInfo(plugin->slug, slug);
return mi && mi->favorite;
}


void Model::setFavorite(bool favorite) {
settings::ModuleInfo& mi = settings::moduleInfos[plugin->slug][slug];
mi.favorite = favorite;
}




Loading…
Cancel
Save