mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-15 03:47:42 +00:00
Remove expensive path.string() calls, UI changes
This commit is contained in:
@@ -238,7 +238,7 @@ bool MenuView::set_highlighted(int32_t new_value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t MenuView::highlighted_index() {
|
||||
uint32_t MenuView::highlighted_index() const {
|
||||
return highlighted_item;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ public:
|
||||
MenuItemView* item_view(size_t index) const;
|
||||
|
||||
bool set_highlighted(int32_t new_value);
|
||||
uint32_t highlighted_index();
|
||||
uint32_t highlighted_index() const;
|
||||
|
||||
void set_parent_rect(const Rect new_parent_rect) override;
|
||||
void on_focus() override;
|
||||
|
@@ -29,9 +29,25 @@ using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
void text_prompt(NavigationView& nav, std::string& str, const size_t max_length, const std::function<void(std::string&)> on_done) {
|
||||
void text_prompt(
|
||||
NavigationView& nav,
|
||||
std::string& str,
|
||||
const size_t max_length,
|
||||
const std::function<void(std::string&)> on_done
|
||||
) {
|
||||
text_prompt(nav, str, str.length(), max_length, on_done);
|
||||
}
|
||||
|
||||
void text_prompt(
|
||||
NavigationView& nav,
|
||||
std::string& str,
|
||||
uint32_t cursor_pos,
|
||||
const size_t max_length,
|
||||
const std::function<void(std::string&)> on_done
|
||||
) {
|
||||
//if (persistent_memory::ui_config_textentry() == 0) {
|
||||
auto te_view = nav.push<AlphanumView>(str, max_length);
|
||||
te_view->set_cursor(cursor_pos);
|
||||
te_view->on_changed = [on_done](std::string& value) {
|
||||
if (on_done)
|
||||
on_done(value);
|
||||
@@ -211,6 +227,10 @@ void TextEntryView::char_add(const char c) {
|
||||
text_input.char_add(c);
|
||||
}
|
||||
|
||||
void TextEntryView::set_cursor(uint32_t pos) {
|
||||
text_input.set_cursor(pos);
|
||||
}
|
||||
|
||||
void TextEntryView::focus() {
|
||||
text_input.focus();
|
||||
}
|
||||
|
@@ -82,6 +82,8 @@ public:
|
||||
|
||||
void focus() override;
|
||||
std::string title() const override { return "Text entry"; };
|
||||
|
||||
void set_cursor(uint32_t pos);
|
||||
|
||||
protected:
|
||||
TextEntryView(NavigationView& nav, std::string& str, size_t max_length);
|
||||
@@ -101,7 +103,18 @@ protected:
|
||||
};
|
||||
};
|
||||
|
||||
void text_prompt(NavigationView& nav, std::string& str, size_t max_length, const std::function<void(std::string&)> on_done = nullptr);
|
||||
void text_prompt(
|
||||
NavigationView& nav,
|
||||
std::string& str,
|
||||
size_t max_length,
|
||||
const std::function<void(std::string&)> on_done = nullptr);
|
||||
|
||||
void text_prompt(
|
||||
NavigationView& nav,
|
||||
std::string& str,
|
||||
uint32_t cursor_pos,
|
||||
size_t max_length,
|
||||
const std::function<void(std::string&)> on_done = nullptr);
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
|
Reference in New Issue
Block a user