Skip to content

Commit

Permalink
Merge pull request #279 from 4ms/multiple-open-patches
Browse files Browse the repository at this point in the history
Manage multiple open patches, displaying in the Patch Selector page under "Recent".
Use red dots to indicate if a patch has unsaved changed.
Minor GUI cleanups (fonts)
  • Loading branch information
danngreen authored Jun 18, 2024
2 parents f193fcc + 249b166 commit af6bfed
Show file tree
Hide file tree
Showing 55 changed files with 17,757 additions and 5,196 deletions.
2 changes: 1 addition & 1 deletion firmware/src/console/pr_dbg.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inline constexpr bool PRINT_WARN = true;
inline constexpr bool PRINT_INFO = true;

// Debug: temporary messges used for debugging
inline constexpr bool PRINT_DEBUG = true;
inline constexpr bool PRINT_DEBUG = false;

// Trace: detailed log of execution
inline constexpr bool PRINT_TRACE = false;
Expand Down
2 changes: 2 additions & 0 deletions firmware/src/core_a7/a7_shared_memory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class PatchPlayer;
class PatchPlayLoader;
class FileStorageProxy;
class SyncParams;
class OpenPatchManager;

struct A7SharedMemoryS {
struct Ptrs {
PatchPlayer *patch_player{};
PatchPlayLoader *patch_playloader{};
FileStorageProxy *patch_storage{};
OpenPatchManager *open_patch_manager{};
SyncParams *sync_params{};
PatchModQueue *patch_mod_queue{};
RamDrive *ramdrive{};
Expand Down
3 changes: 2 additions & 1 deletion firmware/src/core_a7/aux_core_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern "C" void aux_core_main() {
auto patch_player = A7SharedMemoryS::ptrs.patch_player;
auto patch_playloader = A7SharedMemoryS::ptrs.patch_playloader;
auto file_storage_proxy = A7SharedMemoryS::ptrs.patch_storage;
auto open_patch_manager = A7SharedMemoryS::ptrs.open_patch_manager;
auto sync_params = A7SharedMemoryS::ptrs.sync_params;
auto patch_mod_queue = A7SharedMemoryS::ptrs.patch_mod_queue;
auto ramdisk_storage = A7SharedMemoryS::ptrs.ramdrive;
Expand All @@ -46,7 +47,7 @@ extern "C" void aux_core_main() {
AssetFS asset_fs{AssetVolFlashOffset};

PluginManager plugin_manager{*file_storage_proxy, ramdisk};
Ui ui{*patch_playloader, *file_storage_proxy, *sync_params, *patch_mod_queue, plugin_manager};
Ui ui{*patch_playloader, *file_storage_proxy, *open_patch_manager, *sync_params, *patch_mod_queue, plugin_manager};
ui.update();

InternalPluginManager internal_plugin_manager{ramdisk, asset_fs};
Expand Down
4 changes: 3 additions & 1 deletion firmware/src/core_a7/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void main() {
PatchPlayer patch_player;
FileStorageComm patch_comm{StaticBuffers::icc_shared_message};
FileStorageProxy file_storage_proxy{StaticBuffers::raw_patch_data, patch_comm, StaticBuffers::patch_dir_list};
PatchPlayLoader patch_playloader{file_storage_proxy, patch_player};
OpenPatchManager open_patches_manager;
PatchPlayLoader patch_playloader{file_storage_proxy, open_patches_manager, patch_player};

SyncParams sync_params;
PatchModQueue patch_mod_queue;
Expand All @@ -64,6 +65,7 @@ void main() {
&patch_player,
&patch_playloader,
&file_storage_proxy,
&open_patches_manager,
&sync_params,
&patch_mod_queue,
&StaticBuffers::virtdrive,
Expand Down
44 changes: 15 additions & 29 deletions firmware/src/gui/pages/add_map_popup.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ namespace MetaModule
struct AddMapPopUp {

AddMapPopUp(PatchModQueue &patch_mod_queue)
: patch_mod_queue{patch_mod_queue} {
lv_obj_add_event_cb(ui_OkAdd, button_cb, LV_EVENT_CLICKED, this);
: patch_mod_queue{patch_mod_queue}
, popup_group(lv_group_create()) {

lv_group_add_obj(popup_group, ui_CancelAdd);
lv_group_add_obj(popup_group, ui_OkAdd);
lv_obj_add_event_cb(ui_CancelAdd, button_cb, LV_EVENT_CLICKED, this);
lv_obj_add_event_cb(ui_OkAdd, button_cb, LV_EVENT_CLICKED, this);
}
//

void prepare_focus(lv_group_t *group, lv_obj_t *base) {
base_group = group;
Expand All @@ -28,26 +31,13 @@ struct AddMapPopUp {
void show(uint32_t knobset_id, uint16_t param_id, uint16_t module_id) {
selected_knob = std::nullopt;

popup_group = lv_group_create();
lv_group_remove_all_objs(popup_group);
lv_group_set_editing(popup_group, false);
lv_group_add_obj(popup_group, ui_CancelAdd);
lv_group_add_obj(popup_group, ui_OkAdd);
lv_group_focus_obj(ui_CancelAdd);

lv_show(ui_AddMapPopUp);
lv_obj_scroll_to_y(ui_AddMapPopUp, 0, LV_ANIM_OFF);

auto indev = lv_indev_get_next(nullptr);
if (!indev)
return;

lv_indev_set_group(indev, popup_group);

if (knobset_id == PatchData::MIDIKnobSet) {
lv_label_set_text(ui_AddModuleName, "Add a map: Send MIDI CC");
lv_label_set_text(ui_AddMappingTitle, "Add a map: Send MIDI CC");
} else
lv_label_set_text(ui_AddModuleName, "Add a map: Wiggle a knob");
lv_label_set_text(ui_AddMappingTitle, "Add a map: Wiggle a knob");

lv_label_set_text(ui_MapDetected, "");

Expand All @@ -56,6 +46,11 @@ struct AddMapPopUp {

set_id = knobset_id;
visible = true;

lv_group_activate(popup_group);
lv_group_focus_obj(ui_CancelAdd);
lv_group_set_editing(popup_group, false);
lv_group_set_wrap(popup_group, true);
}

void hide() {
Expand All @@ -65,17 +60,8 @@ struct AddMapPopUp {

lv_hide(ui_AddMapPopUp);

auto indev = lv_indev_get_next(nullptr);
if (!indev)
return;

if (base_group)
lv_indev_set_group(indev, base_group);

if (popup_group) {
lv_group_del(popup_group);
popup_group = nullptr;
}
lv_group_activate(base_group);
lv_group_set_editing(base_group, false);
}

void update(ParamsMidiState &params) {
Expand Down
10 changes: 9 additions & 1 deletion firmware/src/gui/pages/base.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#include "gui/notify/queue.hh"
#include "gui/pages/page_args.hh"
#include "gui/pages/page_list.hh"
#include "gui/pages/view_settings.hh"
#include "lvgl.h"
#include "params/metaparams.hh"
#include "params/params_state.hh"
#include "patch_file/file_storage_proxy.hh"
#include "patch_file/open_patch_manager.hh"
#include "patch_play/patch_mod_queue.hh"
#include "patch_play/patch_playloader.hh"

Expand All @@ -34,25 +36,29 @@ struct GuiState {

struct PatchContext {
FileStorageProxy &patch_storage;
OpenPatchManager &open_patch_manager;
PatchPlayLoader &patch_playloader;
ParamsMidiState &params;
MetaParams &metaparams;
NotificationQueue &notify_queue;
PatchModQueue &patch_mod_queue;
PageList &page_list;
GuiState &gui_state;
ViewSettings &settings;
PluginManager &plugin_manager;
};

struct PageBase {
FileStorageProxy &patch_storage;
OpenPatchManager &patches;
PatchPlayLoader &patch_playloader;
ParamsMidiState &params;
MetaParams &metaparams;
NotificationQueue &notify_queue;
PatchModQueue &patch_mod_queue;
PageList &page_list;
GuiState &gui_state;
ViewSettings &settings;

PageArguments args;

Expand All @@ -71,13 +77,15 @@ struct PageBase {

PageBase(PatchContext info, PageId id)
: patch_storage{info.patch_storage}
, patches{info.open_patch_manager}
, patch_playloader{info.patch_playloader}
, params{info.params}
, metaparams{info.metaparams}
, notify_queue{info.notify_queue}
, patch_mod_queue{info.patch_mod_queue}
, page_list{info.page_list}
, gui_state{info.gui_state}
, settings{info.settings}
, id{id} {
page_list.register_page(this, id);
}
Expand Down Expand Up @@ -129,7 +137,7 @@ struct PageBase {

bool patch_is_playing(std::optional<PatchLocHash> patch_loc_hash) {
if (patch_loc_hash.has_value()) {
return (patch_loc_hash.value() == patch_storage.get_playing_patch_loc_hash());
return (patch_loc_hash.value() == patches.get_playing_patch_loc_hash());
} else {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions firmware/src/gui/pages/jackmaps.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct JackMapViewPage : PageBase {
JackMapViewPage(PatchContext info)
: PageBase{info, PageId::JackMapView}
, base{ui_JackMapViewPage}
, patch{patch_storage.get_view_patch()} {
, patch{patches.get_view_patch()} {
init_bg(base);
lv_group_set_editing(group, false);

Expand All @@ -36,7 +36,7 @@ struct JackMapViewPage : PageBase {
}

void prepare_focus() override {
patch = patch_storage.get_view_patch();
patch = patches.get_view_patch();

// Clear old text
for (unsigned i = 0; i < PanelDef::NumUserFacingInJacks; i++) {
Expand Down
18 changes: 9 additions & 9 deletions firmware/src/gui/pages/knobmap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ struct KnobMapPage : PageBase {
KnobMapPage(PatchContext info)
: PageBase{info, PageId::KnobMap}
, base{ui_EditMappingPage}
, patch{patch_storage.get_view_patch()}
, add_map_popup{patch_mod_queue} {
, patch{patches.get_view_patch()} // , add_map_popup{patch_mod_queue}
{

init_bg(base);
lv_group_set_editing(group, false);
Expand Down Expand Up @@ -62,7 +62,7 @@ struct KnobMapPage : PageBase {
lv_obj_set_parent(ui_Keyboard, ui_EditMappingPage);
lv_obj_set_y(ui_Keyboard, 1);

patch = patch_storage.get_view_patch();
patch = patches.get_view_patch();

view_set_idx = args.view_knobset_id.value_or(view_set_idx);
if (view_set_idx != PatchData::MIDIKnobSet && view_set_idx >= patch->knob_sets.size()) {
Expand Down Expand Up @@ -130,8 +130,8 @@ struct KnobMapPage : PageBase {

lv_group_set_editing(group, false);

add_map_popup.prepare_focus(group, ui_EditMappingPage);
add_map_popup.hide();
// add_map_popup.prepare_focus(group, ui_EditMappingPage);
// add_map_popup.hide();
}

void update() override {
Expand All @@ -152,7 +152,7 @@ struct KnobMapPage : PageBase {
set_knob_arc<min_arc, max_arc>(map, ui_EditMappingArc, s_val);
}

add_map_popup.update(params);
// add_map_popup.update(params);
}

void update_active_status() {
Expand Down Expand Up @@ -197,7 +197,7 @@ struct KnobMapPage : PageBase {
page->patch_mod_queue.put(
EditMappingMinMax{.map = page->map, .set_id = page->view_set_idx, .cur_val = val / 100.f});
page->patch->add_update_mapped_knob(page->view_set_idx, page->map);
page->patch_storage.mark_view_patch_modified();
page->patches.mark_view_patch_modified();
}

static void edit_text_cb(lv_event_t *event) {
Expand Down Expand Up @@ -282,7 +282,7 @@ struct KnobMapPage : PageBase {
return;

page->patch_mod_queue.put(RemoveMapping{.map = page->map, .set_id = page->view_set_idx});
page->patch_storage.mark_view_patch_modified();
page->patches.mark_view_patch_modified();

if (!page->patch->remove_mapping(page->view_set_idx, page->map))
pr_err("Could not delete mapping\n");
Expand All @@ -309,7 +309,7 @@ private:

ConfirmPopup del_popup;

AddMapPopUp add_map_popup;
// AddMapPopUp add_map_popup;

bool kb_visible = false;

Expand Down
4 changes: 2 additions & 2 deletions firmware/src/gui/pages/knobset_view.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct KnobSetViewPage : PageBase {
KnobSetViewPage(PatchContext info)
: PageBase{info, PageId::KnobSetView}
, base{ui_KnobSetViewPage}
, patch{patch_storage.get_view_patch()} {
, patch{patches.get_view_patch()} {
init_bg(base);
lv_group_set_editing(group, false);
// lv_obj_add_event_cb(ui_PreviousKnobSet, prev_knobset_cb, LV_EVENT_CLICKED, this);
Expand Down Expand Up @@ -61,7 +61,7 @@ struct KnobSetViewPage : PageBase {
update_active_status();
display_active_status();

patch = patch_storage.get_view_patch();
patch = patches.get_view_patch();

if (patch->knob_sets.size() > 2) {
// lv_show(ui_PreviousKnobSet);
Expand Down
18 changes: 9 additions & 9 deletions firmware/src/gui/pages/main_menu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct MainMenuPage : PageBase {
}

void prepare_focus() final {
auto patch = patch_storage.get_playing_patch();
auto patch = patches.get_playing_patch();
if (!patch || patch->patch_name.length() == 0) {
lv_hide(ui_MainMenuNowPlayingPanel);
} else {
Expand All @@ -44,7 +44,7 @@ struct MainMenuPage : PageBase {
lv_label_set_text(ui_MainMenuNowPlayingName, patch->patch_name.c_str());
}

auto viewpatch = patch_storage.get_view_patch();
auto viewpatch = patches.get_view_patch();
if (viewpatch == patch || !viewpatch || viewpatch->patch_name.length() == 0) {
lv_hide(ui_MainMenuLastViewedPanel);
} else {
Expand All @@ -58,8 +58,8 @@ struct MainMenuPage : PageBase {

void update() final {
if (metaparams.back_button.is_just_released()) {
if (patch_storage.get_view_patch())
load_page(PageId::PatchView, {.patch_loc_hash = patch_storage.get_view_patch_loc_hash()});
if (patches.get_view_patch())
load_page(PageId::PatchView, {.patch_loc_hash = patches.get_view_patch_loc_hash()});
}

if (last_audio_load != metaparams.audio_load) {
Expand All @@ -78,15 +78,15 @@ private:
auto page = static_cast<MainMenuPage *>(event->user_data);
if (!page)
return;
page->load_page(PageId::PatchView, {.patch_loc_hash = page->patch_storage.get_view_patch_loc_hash()});
page->load_page(PageId::PatchView, {.patch_loc_hash = page->patches.get_view_patch_loc_hash()});
}

static void now_playing_cb(lv_event_t *event) {
auto page = static_cast<MainMenuPage *>(event->user_data);
if (!page)
return;
page->patch_storage.view_playing_patch();
page->load_page(PageId::PatchView, {.patch_loc_hash = page->patch_storage.get_playing_patch_loc_hash()});
page->patches.view_playing_patch();
page->load_page(PageId::PatchView, {.patch_loc_hash = page->patches.get_playing_patch_loc_hash()});
}

static void patchsel_cb(lv_event_t *event) {
Expand All @@ -100,9 +100,9 @@ private:
auto page = static_cast<MainMenuPage *>(event->user_data);
if (!page)
return;
page->patch_storage.new_patch();
page->patches.new_patch();
page->patch_playloader.request_load_view_patch();
page->load_page(PageId::PatchView, {.patch_loc_hash = page->patch_storage.get_view_patch_loc_hash()});
page->load_page(PageId::PatchView, {.patch_loc_hash = page->patches.get_view_patch_loc_hash()});
}

static void settings_cb(lv_event_t *event) {
Expand Down
Loading

0 comments on commit af6bfed

Please sign in to comment.