2016-07-25 10:21:27 -04: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.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
|
|
|
#include "ui_painter.hpp"
|
|
|
|
#include "ui_menu.hpp"
|
|
|
|
#include "ui_navigation.hpp"
|
2016-12-25 19:31:38 -05:00
|
|
|
#include "ui_receiver.hpp"
|
|
|
|
#include "ui_textentry.hpp"
|
|
|
|
#include "freqman.hpp"
|
2016-07-25 10:21:27 -04:00
|
|
|
|
|
|
|
namespace ui {
|
2017-06-22 04:08:37 -04:00
|
|
|
|
|
|
|
class FreqManBaseView : public View {
|
|
|
|
public:
|
|
|
|
FreqManBaseView(
|
2017-09-02 03:28:29 -04:00
|
|
|
NavigationView& nav
|
2017-06-22 04:08:37 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
using option_t = std::pair<std::string, int32_t>;
|
|
|
|
using options_t = std::vector<option_t>;
|
|
|
|
|
|
|
|
NavigationView& nav_;
|
|
|
|
freqman_error error_ { NO_ERROR };
|
|
|
|
options_t categories { };
|
|
|
|
std::function<void(int32_t category_id)> on_change_category { nullptr };
|
|
|
|
std::function<void(void)> on_select_frequency { nullptr };
|
2017-06-22 19:13:13 -04:00
|
|
|
std::function<void(bool)> on_refresh_widgets { nullptr };
|
2017-06-22 04:08:37 -04:00
|
|
|
std::vector<std::string> file_list { };
|
|
|
|
int32_t current_category_id { 0 };
|
|
|
|
|
2017-10-04 22:42:46 -04:00
|
|
|
void populate_categories();
|
2017-06-22 04:08:37 -04:00
|
|
|
void change_category(int32_t category_id);
|
|
|
|
void refresh_list();
|
|
|
|
|
|
|
|
freqman_db database { };
|
|
|
|
|
|
|
|
Labels label_category {
|
|
|
|
{ { 0, 4 }, "Category:", Color::light_grey() }
|
|
|
|
};
|
|
|
|
|
|
|
|
OptionsField options_category {
|
|
|
|
{ 9 * 8, 4 },
|
2020-04-12 09:26:20 -04:00
|
|
|
12,
|
2017-06-22 04:08:37 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
MenuView menu_view {
|
|
|
|
{ 0, 3 * 8, 240, 23 * 8 },
|
|
|
|
true
|
|
|
|
};
|
|
|
|
Text text_empty {
|
|
|
|
{ 7 * 8, 12 * 8, 16 * 8, 16 },
|
|
|
|
"Empty category !",
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_exit {
|
|
|
|
{ 20 * 8, 34 * 8, 10 * 8, 4 * 8 },
|
|
|
|
"Exit"
|
|
|
|
};
|
|
|
|
};
|
2016-07-25 10:21:27 -04:00
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
class FrequencySaveView : public FreqManBaseView {
|
2016-12-06 07:31:38 -05:00
|
|
|
public:
|
|
|
|
FrequencySaveView(NavigationView& nav, const rf::Frequency value);
|
|
|
|
|
2018-06-10 05:15:43 -04:00
|
|
|
std::string title() const override { return "Save frequency"; };
|
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
private:
|
2017-06-10 21:53:06 -04:00
|
|
|
std::string desc_buffer { };
|
2017-01-29 20:09:00 -05:00
|
|
|
rf::Frequency value_ { };
|
2016-12-25 19:31:38 -05:00
|
|
|
|
2017-06-10 21:53:06 -04:00
|
|
|
void on_save_name();
|
2017-02-03 11:22:12 -05:00
|
|
|
void on_save_timestamp();
|
2017-10-04 22:42:46 -04:00
|
|
|
void save_current_file();
|
2016-12-25 19:31:38 -05:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
BigFrequency big_display {
|
|
|
|
{ 4, 2 * 16, 28 * 8, 32 },
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2017-09-20 02:50:59 -04:00
|
|
|
Labels labels {
|
|
|
|
{ { 2 * 8, 14 * 8 }, "Save as:", Color::white() }
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
2017-09-20 02:50:59 -04:00
|
|
|
|
2016-12-09 12:21:47 -05:00
|
|
|
Button button_save_name {
|
2017-09-20 02:50:59 -04:00
|
|
|
{ 2 * 8, 17 * 8, 14 * 8, 48 },
|
2016-12-25 19:31:38 -05:00
|
|
|
"Name (set)"
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
Button button_save_timestamp {
|
2017-09-20 02:50:59 -04:00
|
|
|
{ 2 * 8, 25 * 8, 14 * 8, 48 },
|
2016-12-25 19:31:38 -05:00
|
|
|
"Timestamp:"
|
|
|
|
};
|
2017-09-20 02:50:59 -04:00
|
|
|
LiveDateTime live_timestamp {
|
|
|
|
{ 17 * 8, 27 * 8, 11 * 8, 16 }
|
2016-12-09 12:21:47 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
class FrequencyLoadView : public FreqManBaseView {
|
2016-12-09 12:21:47 -05:00
|
|
|
public:
|
2017-12-08 13:58:46 -05:00
|
|
|
std::function<void(rf::Frequency)> on_frequency_loaded { };
|
|
|
|
std::function<void(rf::Frequency, rf::Frequency)> on_range_loaded { };
|
2016-12-25 19:31:38 -05:00
|
|
|
|
|
|
|
FrequencyLoadView(NavigationView& nav);
|
2016-12-09 12:21:47 -05:00
|
|
|
|
2018-06-10 05:15:43 -04:00
|
|
|
std::string title() const override { return "Load frequency"; };
|
|
|
|
|
2016-12-06 07:31:38 -05:00
|
|
|
private:
|
2017-06-22 19:13:13 -04:00
|
|
|
void refresh_widgets(const bool v);
|
2016-12-06 07:31:38 -05:00
|
|
|
};
|
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
class FrequencyManagerView : public FreqManBaseView {
|
2016-07-25 10:21:27 -04:00
|
|
|
public:
|
2017-06-22 04:08:37 -04:00
|
|
|
FrequencyManagerView(NavigationView& nav);
|
|
|
|
~FrequencyManagerView();
|
2016-07-25 10:21:27 -04:00
|
|
|
|
2018-06-10 05:15:43 -04:00
|
|
|
std::string title() const override { return "Freq. manager"; };
|
|
|
|
|
2016-07-25 10:21:27 -04:00
|
|
|
private:
|
2017-06-10 21:53:06 -04:00
|
|
|
std::string desc_buffer { };
|
2016-12-25 19:31:38 -05:00
|
|
|
|
2017-06-22 19:13:13 -04:00
|
|
|
void refresh_widgets(const bool v);
|
2016-12-25 19:31:38 -05:00
|
|
|
void on_edit_freq(rf::Frequency f);
|
|
|
|
void on_edit_desc(NavigationView& nav);
|
2017-06-22 04:08:37 -04:00
|
|
|
void on_new_category(NavigationView& nav);
|
2016-12-25 19:31:38 -05:00
|
|
|
void on_delete();
|
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
Labels labels {
|
|
|
|
{ { 4 * 8 + 4, 26 * 8 }, "Edit:", Color::light_grey() }
|
2017-02-03 10:10:27 -05:00
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
Button button_new_category {
|
2018-01-09 16:12:19 -05:00
|
|
|
{ 23 * 8, 2, 7 * 8, 20 },
|
|
|
|
"New"
|
2017-01-30 08:10:30 -05:00
|
|
|
};
|
2017-02-13 00:35:13 -05:00
|
|
|
|
2016-12-25 19:31:38 -05:00
|
|
|
Button button_edit_freq {
|
2017-06-22 04:08:37 -04:00
|
|
|
{ 0 * 8, 29 * 8, 14 * 8, 32 },
|
2017-01-30 08:10:30 -05:00
|
|
|
"Frequency"
|
2016-12-25 19:31:38 -05:00
|
|
|
};
|
|
|
|
Button button_edit_desc {
|
2017-06-22 04:08:37 -04:00
|
|
|
{ 0 * 8, 34 * 8, 14 * 8, 32 },
|
2017-01-30 08:10:30 -05:00
|
|
|
"Description"
|
2016-12-25 19:31:38 -05:00
|
|
|
};
|
2017-02-03 10:10:27 -05:00
|
|
|
|
2017-06-22 04:08:37 -04:00
|
|
|
Button button_delete {
|
|
|
|
{ 18 * 8, 27 * 8, 12 * 8, 32 },
|
2017-01-30 08:10:30 -05:00
|
|
|
"Delete"
|
2016-12-25 19:31:38 -05:00
|
|
|
};
|
2016-07-25 10:21:27 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|