mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-14 12:08:40 +00:00
Added new "App Setting" app (#1759)
* New "App Settings" app for quicker settings access
This commit is contained in:
parent
1676702a09
commit
58b488b840
@ -27,6 +27,7 @@
|
|||||||
#include "ui_navigation.hpp"
|
#include "ui_navigation.hpp"
|
||||||
#include "ui_receiver.hpp"
|
#include "ui_receiver.hpp"
|
||||||
#include "ui_touch_calibration.hpp"
|
#include "ui_touch_calibration.hpp"
|
||||||
|
#include "ui_text_editor.hpp"
|
||||||
|
|
||||||
#include "portapack_persistent_memory.hpp"
|
#include "portapack_persistent_memory.hpp"
|
||||||
#include "lpc43xx_cpp.hpp"
|
#include "lpc43xx_cpp.hpp"
|
||||||
@ -628,6 +629,34 @@ void SetEncoderDialView::focus() {
|
|||||||
button_save.focus();
|
button_save.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* AppSettingsView ************************************/
|
||||||
|
|
||||||
|
AppSettingsView::AppSettingsView(
|
||||||
|
NavigationView& nav)
|
||||||
|
: nav_{nav} {
|
||||||
|
add_children({&labels,
|
||||||
|
&menu_view});
|
||||||
|
|
||||||
|
menu_view.set_parent_rect({0, 3 * 8, 240, 33 * 8});
|
||||||
|
|
||||||
|
ensure_directory(SETTINGS_DIR);
|
||||||
|
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator(SETTINGS_DIR, u"*.ini")) {
|
||||||
|
auto path = (std::filesystem::path)SETTINGS_DIR / entry.path();
|
||||||
|
|
||||||
|
menu_view.add_item({path.filename().string().substr(0, 26),
|
||||||
|
ui::Color::dark_cyan(),
|
||||||
|
&bitmap_icon_file_text,
|
||||||
|
[this, path](KeyEvent) {
|
||||||
|
nav_.push<TextEditorView>(path);
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppSettingsView::focus() {
|
||||||
|
menu_view.focus();
|
||||||
|
}
|
||||||
|
|
||||||
/* SettingsMenuView **************************************/
|
/* SettingsMenuView **************************************/
|
||||||
|
|
||||||
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
||||||
@ -635,6 +664,7 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
|||||||
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}});
|
||||||
}
|
}
|
||||||
add_items({
|
add_items({
|
||||||
|
{"App Settings", ui::Color::dark_cyan(), &bitmap_icon_notepad, [&nav]() { nav.push<AppSettingsView>(); }},
|
||||||
{"Audio", ui::Color::dark_cyan(), &bitmap_icon_speaker, [&nav]() { nav.push<SetAudioView>(); }},
|
{"Audio", ui::Color::dark_cyan(), &bitmap_icon_speaker, [&nav]() { nav.push<SetAudioView>(); }},
|
||||||
{"Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav]() { nav.push<TouchCalibrationView>(); }},
|
{"Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav]() { nav.push<TouchCalibrationView>(); }},
|
||||||
{"Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push<SetConverterSettingsView>(); }},
|
{"Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push<SetConverterSettingsView>(); }},
|
||||||
|
@ -564,6 +564,23 @@ class SetPersistentMemoryView : public View {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AppSettingsView : public View {
|
||||||
|
public:
|
||||||
|
AppSettingsView(NavigationView& nav);
|
||||||
|
std::string title() const override { return "App Settings"; };
|
||||||
|
void focus() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
NavigationView& nav_;
|
||||||
|
|
||||||
|
Labels labels{
|
||||||
|
{{0, 4}, "Select file to edit:", Color::white()}};
|
||||||
|
|
||||||
|
MenuView menu_view{
|
||||||
|
{0, 2 * 8, 240, 26 * 8},
|
||||||
|
true};
|
||||||
|
};
|
||||||
|
|
||||||
class SettingsMenuView : public BtnGridView {
|
class SettingsMenuView : public BtnGridView {
|
||||||
public:
|
public:
|
||||||
SettingsMenuView(NavigationView& nav);
|
SettingsMenuView(NavigationView& nav);
|
||||||
|
Loading…
Reference in New Issue
Block a user