2017-01-30 08:10:30 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui_script.hpp"
|
|
|
|
|
|
|
|
#include "portapack.hpp"
|
|
|
|
#include "event_m0.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
using namespace portapack;
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
void ScriptView::on_frequency_select() {
|
2023-05-18 16:16:05 -04:00
|
|
|
// button_edit_freq.focus();
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptView::on_edit_freq(rf::Frequency f) {
|
2023-05-18 16:16:05 -04:00
|
|
|
(void)f;
|
|
|
|
// frequencies[menu_view.highlighted()].value = f;
|
|
|
|
setup_list();
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptView::on_edit_desc(NavigationView& nav) {
|
2023-05-18 16:16:05 -04:00
|
|
|
(void)nav;
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptView::on_delete() {
|
2023-05-18 16:16:05 -04:00
|
|
|
// frequencies.erase(frequencies.begin() + menu_view.highlighted());
|
|
|
|
setup_list();
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptView::setup_list() {
|
2023-05-18 16:16:05 -04:00
|
|
|
// size_t n;
|
|
|
|
|
|
|
|
menu_view.clear();
|
|
|
|
|
|
|
|
/*for (n = 0; n < frequencies.size(); n++) {
|
|
|
|
menu_view.add_item({ freqman_item_string(frequencies[n]), ui::Color::white(), nullptr, [this](){ on_frequency_select(); } });
|
|
|
|
}*/
|
|
|
|
|
|
|
|
menu_view.set_parent_rect({0, 0, 240, 168});
|
|
|
|
menu_view.set_highlighted(menu_view.highlighted()); // Refresh
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScriptView::focus() {
|
2023-05-18 16:16:05 -04:00
|
|
|
menu_view.focus();
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ScriptView::ScriptView(
|
2023-05-18 16:16:05 -04:00
|
|
|
NavigationView& nav) {
|
|
|
|
add_children({&menu_view,
|
|
|
|
&text_edit,
|
|
|
|
&button_edit_freq,
|
|
|
|
&button_edit_desc,
|
|
|
|
&button_del,
|
|
|
|
&button_exit});
|
|
|
|
|
|
|
|
setup_list();
|
2017-01-30 08:10:30 -05:00
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
button_edit_freq.on_select = [this, &nav](Button&) {
|
|
|
|
/*auto new_view = nav.push<FrequencyKeypadView>(frequencies[menu_view.highlighted()].value);
|
|
|
|
new_view->on_changed = [this](rf::Frequency f) {
|
|
|
|
on_edit_freq(f);
|
|
|
|
};*/
|
|
|
|
};
|
|
|
|
|
|
|
|
button_edit_desc.on_select = [this, &nav](Button&) {
|
|
|
|
on_edit_desc(nav);
|
|
|
|
};
|
|
|
|
|
|
|
|
button_del.on_select = [this, &nav](Button&) {
|
|
|
|
nav.push<ModalMessageView>("Confirm", "Are you sure?", YESNO,
|
|
|
|
[this](bool choice) {
|
|
|
|
if (choice) {
|
|
|
|
on_delete();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
button_exit.on_select = [this, &nav](Button&) {
|
|
|
|
nav.pop();
|
|
|
|
};
|
2017-01-30 08:10:30 -05:00
|
|
|
}
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
} // namespace ui
|