Merge pull request #1 from eried/master

Update merge
This commit is contained in:
klockee 2020-08-03 00:11:38 -04:00 committed by GitHub
commit a982ee029e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2114 additions and 2049 deletions

View File

@ -92,31 +92,37 @@ FileManBaseView::FileManBaseView(
) : nav_ (nav), ) : nav_ (nav),
extension_filter { filter } extension_filter { filter }
{ {
load_directory_contents(current_path);
if (!entry_list.size())
empty_root = true;
add_children({ add_children({
&labels, &labels,
&text_current, &text_current,
&button_exit &button_exit
}); });
menu_view.on_left = [&nav, this]() {
load_directory_contents(get_parent_dir());
refresh_list();
};
button_exit.on_select = [this, &nav](Button&) { button_exit.on_select = [this, &nav](Button&) {
nav.pop(); nav.pop();
}; };
};
if (!sdcIsCardInserted(&SDCD1)) {
empty_root=true;
text_current.set("NO SD CARD!");
} else {
load_directory_contents(current_path);
if (!entry_list.size())
{
empty_root = true;
text_current.set("EMPTY SD CARD!");
} else {
menu_view.on_left = [&nav, this]() {
load_directory_contents(get_parent_dir());
refresh_list();
};
}
}
}
void FileManBaseView::focus() { void FileManBaseView::focus() {
if (empty_root) { if (empty_root) {
button_exit.focus(); button_exit.focus();
nav_.display_modal("Error", "No files in root.", ABORT, nullptr);
} else { } else {
menu_view.focus(); menu_view.focus();
} }
@ -190,7 +196,6 @@ void FileManBaseView::refresh_list() {
nav_.pop(); nav_.pop();
}); });
} }
FileSaveView::FileSaveView( FileSaveView::FileSaveView(
NavigationView& nav NavigationView& nav
) : FileManBaseView(nav) ) : FileManBaseView(nav)
@ -271,57 +276,59 @@ FileManagerView::FileManagerView(
NavigationView& nav NavigationView& nav
) : FileManBaseView(nav, "") ) : FileManBaseView(nav, "")
{ {
on_refresh_widgets = [this](bool v) { if (!empty_root) {
refresh_widgets(v); on_refresh_widgets = [this](bool v) {
}; refresh_widgets(v);
};
add_children({
&menu_view,
&labels,
&text_date,
&button_rename,
&button_new_dir,
&button_delete
});
menu_view.on_highlight = [this]() {
text_date.set(to_string_FAT_timestamp(file_created_date(get_selected_path())));
};
refresh_list();
on_select_entry = [this]() {
if (entry_list[menu_view.highlighted_index()].is_directory) {
load_directory_contents(get_selected_path());
refresh_list();
} else
button_rename.focus();
};
button_new_dir.on_select = [this, &nav](Button&) {
name_buffer.clear();
text_prompt(nav, name_buffer, max_filename_length, [this](std::string& buffer) { add_children({
make_new_directory(current_path.string() + '/' + buffer); &menu_view,
load_directory_contents(current_path); &labels,
refresh_list(); &text_date,
&button_rename,
&button_new_dir,
&button_delete
}); });
};
menu_view.on_highlight = [this]() {
button_rename.on_select = [this, &nav](Button&) { text_date.set(to_string_FAT_timestamp(file_created_date(get_selected_path())));
name_buffer = entry_list[menu_view.highlighted_index()].entry_path.filename().string().substr(0, max_filename_length); };
on_rename(nav);
}; refresh_list();
button_delete.on_select = [this, &nav](Button&) { on_select_entry = [this]() {
// Use display_modal ? if (entry_list[menu_view.highlighted_index()].is_directory) {
nav.push<ModalMessageView>("Delete", "Delete " + entry_list[menu_view.highlighted_index()].entry_path.filename().string() + "\nAre you sure?", YESNO, load_directory_contents(get_selected_path());
[this](bool choice) { refresh_list();
if (choice) } else
on_delete(); button_rename.focus();
} };
);
}; button_new_dir.on_select = [this, &nav](Button&) {
name_buffer.clear();
text_prompt(nav, name_buffer, max_filename_length, [this](std::string& buffer) {
make_new_directory(current_path.string() + '/' + buffer);
load_directory_contents(current_path);
refresh_list();
});
};
button_rename.on_select = [this, &nav](Button&) {
name_buffer = entry_list[menu_view.highlighted_index()].entry_path.filename().string().substr(0, max_filename_length);
on_rename(nav);
};
button_delete.on_select = [this, &nav](Button&) {
// Use display_modal ?
nav.push<ModalMessageView>("Delete", "Delete " + entry_list[menu_view.highlighted_index()].entry_path.filename().string() + "\nAre you sure?", YESNO,
[this](bool choice) {
if (choice)
on_delete();
}
);
};
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -120,8 +120,8 @@ void FrequencyScale::paint(Painter& painter) {
if (_blink) { if (_blink) {
const Rect r_cursor { const Rect r_cursor {
120 + cursor_position, r.bottom() - filter_band_height, 118 + cursor_position, r.bottom() - filter_band_height,
2, filter_band_height 5, filter_band_height
}; };
painter.fill_rectangle( painter.fill_rectangle(
r_cursor, r_cursor,

View File

@ -106,6 +106,7 @@ SystemStatusView::SystemStatusView(
&backdrop, &backdrop,
&button_back, &button_back,
&title, &title,
&button_title,
&button_speaker, &button_speaker,
&button_stealth, &button_stealth,
//&button_textentry, //&button_textentry,
@ -138,6 +139,10 @@ SystemStatusView::SystemStatusView(
if (this->on_back) if (this->on_back)
this->on_back(); this->on_back();
}; };
button_title.on_select = [this](ImageButton&) {
this->on_title();
};
button_speaker.on_select = [this](ImageButton&) { button_speaker.on_select = [this](ImageButton&) {
this->on_speaker(); this->on_speaker();
@ -194,8 +199,23 @@ void SystemStatusView::refresh() {
} }
void SystemStatusView::set_back_enabled(bool new_value) { void SystemStatusView::set_back_enabled(bool new_value) {
button_back.set_foreground(new_value ? Color::white() : Color::dark_grey());
button_back.set_focusable(new_value); if(new_value){
add_child(&button_back);
}
else{
remove_child(&button_back);
}
}
void SystemStatusView::set_title_image_enabled(bool new_value) {
if(new_value){
add_child(&button_title);
}
else{
remove_child(&button_title);
}
} }
void SystemStatusView::set_title(const std::string new_value) { void SystemStatusView::set_title(const std::string new_value) {
@ -282,6 +302,10 @@ void SystemStatusView::on_camera() {
} }
} }
void SystemStatusView::on_title() {
nav_.push<AboutView>();
}
/* Navigation ************************************************************/ /* Navigation ************************************************************/
bool NavigationView::is_top() const { bool NavigationView::is_top() const {
@ -515,8 +539,11 @@ SystemView::SystemView(
}); });
navigation_view.on_view_changed = [this](const View& new_view) { navigation_view.on_view_changed = [this](const View& new_view) {
this->status_view.set_back_enabled(!this->navigation_view.is_top()); this->status_view.set_back_enabled(!this->navigation_view.is_top());
this->status_view.set_title_image_enabled(this->navigation_view.is_top());
this->status_view.set_dirty();
this->status_view.set_title(new_view.title()); this->status_view.set_title(new_view.title());
}; };
// portapack::persistent_memory::set_playdead_sequence(0x8D1); // portapack::persistent_memory::set_playdead_sequence(0x8D1);

View File

@ -106,10 +106,11 @@ public:
SystemStatusView(NavigationView& nav); SystemStatusView(NavigationView& nav);
void set_back_enabled(bool new_value); void set_back_enabled(bool new_value);
void set_title_image_enabled(bool new_value);
void set_title(const std::string new_value); void set_title(const std::string new_value);
private: private:
static constexpr auto default_title = "MAYHEM v1.1.1"; // TODO: Move the version somewhere static constexpr auto default_title = " v1.1.1"; // TODO: Move the version somewhere
NavigationView& nav_; NavigationView& nav_;
@ -130,6 +131,13 @@ private:
default_title, default_title,
}; };
ImageButton button_title {
{2, 0, 80, 16},
&bitmap_titlebar_image,
Color::white(),
Color::dark_grey()
};
ImageButton button_speaker { ImageButton button_speaker {
{ 17 * 8, 0, 2 * 8, 1 * 16 }, { 17 * 8, 0, 2 * 8, 1 * 16 },
&bitmap_icon_speaker_mute, &bitmap_icon_speaker_mute,
@ -188,6 +196,7 @@ private:
void on_bias_tee(); void on_bias_tee();
//void on_textentry(); //void on_textentry();
void on_camera(); void on_camera();
void on_title();
void refresh(); void refresh();
MessageHandlerRegistration message_handler_refresh { MessageHandlerRegistration message_handler_refresh {

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB