mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-14 01:15:38 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -46,327 +46,310 @@
|
|||
|
||||
using namespace sd_card;
|
||||
|
||||
namespace ui
|
||||
{
|
||||
namespace ui {
|
||||
|
||||
enum modal_t
|
||||
{
|
||||
INFO = 0,
|
||||
YESNO,
|
||||
YESCANCEL,
|
||||
ABORT
|
||||
};
|
||||
enum modal_t {
|
||||
INFO = 0,
|
||||
YESNO,
|
||||
YESCANCEL,
|
||||
ABORT
|
||||
};
|
||||
|
||||
class NavigationView : public View
|
||||
{
|
||||
public:
|
||||
std::function<void(const View &)> on_view_changed{};
|
||||
class NavigationView : public View {
|
||||
public:
|
||||
std::function<void(const View&)> on_view_changed{};
|
||||
|
||||
NavigationView() = default;
|
||||
NavigationView() = default;
|
||||
|
||||
NavigationView(const NavigationView &) = delete;
|
||||
NavigationView(NavigationView &&) = delete;
|
||||
NavigationView &operator=(const NavigationView &) = delete;
|
||||
NavigationView &operator=(NavigationView &&) = delete;
|
||||
NavigationView(const NavigationView&) = delete;
|
||||
NavigationView(NavigationView&&) = delete;
|
||||
NavigationView& operator=(const NavigationView&) = delete;
|
||||
NavigationView& operator=(NavigationView&&) = delete;
|
||||
|
||||
bool is_top() const;
|
||||
bool is_top() const;
|
||||
|
||||
template <class T, class... Args>
|
||||
T *push(Args &&...args)
|
||||
{
|
||||
return reinterpret_cast<T *>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
template <class T, class... Args>
|
||||
T* push(Args&&... args) {
|
||||
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
|
||||
// Pushes a new view under the current on the stack so the current view returns into this new one.
|
||||
template <class T, class... Args>
|
||||
void push_under_current(Args &&...args)
|
||||
{
|
||||
auto new_view = std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...));
|
||||
view_stack.insert(view_stack.end() - 1, std::move(new_view));
|
||||
}
|
||||
// Pushes a new view under the current on the stack so the current view returns into this new one.
|
||||
template <class T, class... Args>
|
||||
void push_under_current(Args&&... args) {
|
||||
auto new_view = std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...));
|
||||
view_stack.insert(view_stack.end() - 1, std::move(new_view));
|
||||
}
|
||||
|
||||
template <class T, class... Args>
|
||||
T *replace(Args &&...args)
|
||||
{
|
||||
pop();
|
||||
return reinterpret_cast<T *>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
template <class T, class... Args>
|
||||
T* replace(Args&&... args) {
|
||||
pop();
|
||||
return reinterpret_cast<T*>(push_view(std::unique_ptr<View>(new T(*this, std::forward<Args>(args)...))));
|
||||
}
|
||||
|
||||
void push(View *v);
|
||||
void replace(View *v);
|
||||
void push(View* v);
|
||||
void replace(View* v);
|
||||
|
||||
void pop();
|
||||
void pop_modal();
|
||||
void pop();
|
||||
void pop_modal();
|
||||
|
||||
void display_modal(const std::string &title, const std::string &message);
|
||||
void display_modal(const std::string &title, const std::string &message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
|
||||
void display_modal(const std::string& title, const std::string& message);
|
||||
void display_modal(const std::string& title, const std::string& message, const modal_t type, const std::function<void(bool)> on_choice = nullptr);
|
||||
|
||||
void focus() override;
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<View>> view_stack{};
|
||||
Widget *modal_view{nullptr};
|
||||
private:
|
||||
std::vector<std::unique_ptr<View>> view_stack{};
|
||||
Widget* modal_view{nullptr};
|
||||
|
||||
Widget *view() const;
|
||||
Widget* view() const;
|
||||
|
||||
void free_view();
|
||||
void update_view();
|
||||
View *push_view(std::unique_ptr<View> new_view);
|
||||
};
|
||||
void free_view();
|
||||
void update_view();
|
||||
View* push_view(std::unique_ptr<View> new_view);
|
||||
};
|
||||
|
||||
class SystemStatusView : public View
|
||||
{
|
||||
public:
|
||||
std::function<void(void)> on_back{};
|
||||
class SystemStatusView : public View {
|
||||
public:
|
||||
std::function<void(void)> on_back{};
|
||||
|
||||
SystemStatusView(NavigationView &nav);
|
||||
SystemStatusView(NavigationView& nav);
|
||||
|
||||
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_back_enabled(bool new_value);
|
||||
void set_title_image_enabled(bool new_value);
|
||||
void set_title(const std::string new_value);
|
||||
|
||||
private:
|
||||
static constexpr auto default_title = "";
|
||||
private:
|
||||
static constexpr auto default_title = "";
|
||||
|
||||
NavigationView &nav_;
|
||||
NavigationView& nav_;
|
||||
|
||||
Rectangle backdrop{
|
||||
{0 * 8, 0 * 16, 240, 16},
|
||||
Color::dark_grey()};
|
||||
Rectangle backdrop{
|
||||
{0 * 8, 0 * 16, 240, 16},
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_back{
|
||||
{0, 0 * 16, 12 * 8, 16}, // Back button also covers the title for easier touch.
|
||||
&bitmap_icon_previous,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_back{
|
||||
{0, 0 * 16, 12 * 8, 16}, // Back button also covers the title for easier touch.
|
||||
&bitmap_icon_previous,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
Text title{
|
||||
{20, 0, 14 * 8, 1 * 16},
|
||||
default_title,
|
||||
};
|
||||
Text title{
|
||||
{20, 0, 14 * 8, 1 * 16},
|
||||
default_title,
|
||||
};
|
||||
|
||||
ImageButton button_title{
|
||||
{2, 0, 80, 16},
|
||||
&bitmap_titlebar_image,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_title{
|
||||
{2, 0, 80, 16},
|
||||
&bitmap_titlebar_image,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_speaker{
|
||||
{15 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_speaker_mute,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_speaker{
|
||||
{15 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_speaker_mute,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_converter{
|
||||
{17 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_upconvert,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()
|
||||
};
|
||||
ImageButton button_converter{
|
||||
{17 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_upconvert,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_stealth{
|
||||
{19 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_stealth,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_stealth{
|
||||
{19 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_stealth,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
/*ImageButton button_textentry {
|
||||
{ 170, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_unistroke,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};*/
|
||||
/*ImageButton button_textentry {
|
||||
{ 170, 0, 2 * 8, 1 * 16 },
|
||||
&bitmap_icon_unistroke,
|
||||
Color::white(),
|
||||
Color::dark_grey()
|
||||
};*/
|
||||
|
||||
ImageButton button_camera{
|
||||
{21 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_camera,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_camera{
|
||||
{21 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_camera,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_sleep{
|
||||
{23 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_sleep,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_sleep{
|
||||
{23 * 8, 0, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_sleep,
|
||||
Color::white(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_bias_tee{
|
||||
{25 * 8, 0, 12, 1 * 16},
|
||||
&bitmap_icon_biast_off,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_bias_tee{
|
||||
{25 * 8, 0, 12, 1 * 16},
|
||||
&bitmap_icon_biast_off,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
ImageButton button_clock_status{
|
||||
{27 * 8, 0 * 16, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_clk_int,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
ImageButton button_clock_status{
|
||||
{27 * 8, 0 * 16, 2 * 8, 1 * 16},
|
||||
&bitmap_icon_clk_int,
|
||||
Color::light_grey(),
|
||||
Color::dark_grey()};
|
||||
|
||||
SDCardStatusView sd_card_status_view{
|
||||
{28 * 8, 0 * 16, 2 * 8, 1 * 16}};
|
||||
SDCardStatusView sd_card_status_view{
|
||||
{28 * 8, 0 * 16, 2 * 8, 1 * 16}};
|
||||
|
||||
void on_converter();
|
||||
void on_speaker();
|
||||
void on_stealth();
|
||||
void on_bias_tee();
|
||||
// void on_textentry();
|
||||
void on_camera();
|
||||
void on_title();
|
||||
void refresh();
|
||||
void on_clk();
|
||||
void on_converter();
|
||||
void on_speaker();
|
||||
void on_stealth();
|
||||
void on_bias_tee();
|
||||
// void on_textentry();
|
||||
void on_camera();
|
||||
void on_title();
|
||||
void refresh();
|
||||
void on_clk();
|
||||
|
||||
MessageHandlerRegistration message_handler_refresh{
|
||||
Message::ID::StatusRefresh,
|
||||
[this](const Message *const p)
|
||||
{
|
||||
(void)p;
|
||||
this->refresh();
|
||||
}};
|
||||
};
|
||||
MessageHandlerRegistration message_handler_refresh{
|
||||
Message::ID::StatusRefresh,
|
||||
[this](const Message* const p) {
|
||||
(void)p;
|
||||
this->refresh();
|
||||
}};
|
||||
};
|
||||
|
||||
class InformationView : public View
|
||||
{
|
||||
public:
|
||||
InformationView(NavigationView &nav);
|
||||
void refresh();
|
||||
class InformationView : public View {
|
||||
public:
|
||||
InformationView(NavigationView& nav);
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
// static constexpr auto version_string = "v1.4.4"; // This is commented out as we are now setting the version via ENV (VERSION_STRING=v1.0.0)
|
||||
NavigationView &nav_;
|
||||
private:
|
||||
// static constexpr auto version_string = "v1.4.4"; // This is commented out as we are now setting the version via ENV (VERSION_STRING=v1.0.0)
|
||||
NavigationView& nav_;
|
||||
|
||||
Rectangle backdrop{
|
||||
{0, 0 * 16, 240, 16},
|
||||
{33, 33, 33}};
|
||||
Rectangle backdrop{
|
||||
{0, 0 * 16, 240, 16},
|
||||
{33, 33, 33}};
|
||||
|
||||
Text version{
|
||||
{2, 0, 11 * 8, 16},
|
||||
VERSION_STRING};
|
||||
Text version{
|
||||
{2, 0, 11 * 8, 16},
|
||||
VERSION_STRING};
|
||||
|
||||
LiveDateTime ltime{
|
||||
{86, 0, 19 * 8, 16}};
|
||||
};
|
||||
LiveDateTime ltime{
|
||||
{86, 0, 19 * 8, 16}};
|
||||
};
|
||||
|
||||
class BMPView : public View
|
||||
{
|
||||
public:
|
||||
BMPView(NavigationView &nav);
|
||||
void paint(Painter &) override;
|
||||
void focus() override;
|
||||
class BMPView : public View {
|
||||
public:
|
||||
BMPView(NavigationView& nav);
|
||||
void paint(Painter&) override;
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
Text text_info{
|
||||
{4 * 8, 284, 20 * 8, 16},
|
||||
"Version " VERSION_STRING};
|
||||
private:
|
||||
Text text_info{
|
||||
{4 * 8, 284, 20 * 8, 16},
|
||||
"Version " VERSION_STRING};
|
||||
|
||||
Button button_done{
|
||||
{240, 0, 1, 1},
|
||||
""};
|
||||
};
|
||||
Button button_done{
|
||||
{240, 0, 1, 1},
|
||||
""};
|
||||
};
|
||||
|
||||
class ReceiversMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
ReceiversMenuView(NavigationView &nav);
|
||||
std::string title() const override { return "Receive"; };
|
||||
};
|
||||
class ReceiversMenuView : public BtnGridView {
|
||||
public:
|
||||
ReceiversMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Receive"; };
|
||||
};
|
||||
|
||||
class TransmittersMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
TransmittersMenuView(NavigationView &nav);
|
||||
std::string title() const override { return "Transmit"; };
|
||||
};
|
||||
class TransmittersMenuView : public BtnGridView {
|
||||
public:
|
||||
TransmittersMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Transmit"; };
|
||||
};
|
||||
|
||||
class UtilitiesMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
UtilitiesMenuView(NavigationView &nav);
|
||||
std::string title() const override { return "Utilities"; };
|
||||
};
|
||||
class UtilitiesMenuView : public BtnGridView {
|
||||
public:
|
||||
UtilitiesMenuView(NavigationView& nav);
|
||||
std::string title() const override { return "Utilities"; };
|
||||
};
|
||||
|
||||
class SystemMenuView : public BtnGridView
|
||||
{
|
||||
public:
|
||||
SystemMenuView(NavigationView &nav);
|
||||
class SystemMenuView : public BtnGridView {
|
||||
public:
|
||||
SystemMenuView(NavigationView& nav);
|
||||
|
||||
private:
|
||||
void hackrf_mode(NavigationView &nav);
|
||||
};
|
||||
private:
|
||||
void hackrf_mode(NavigationView& nav);
|
||||
};
|
||||
|
||||
class SystemView : public View
|
||||
{
|
||||
public:
|
||||
SystemView(
|
||||
Context &context,
|
||||
const Rect parent_rect);
|
||||
class SystemView : public View {
|
||||
public:
|
||||
SystemView(
|
||||
Context& context,
|
||||
const Rect parent_rect);
|
||||
|
||||
Context &context() const override;
|
||||
void toggle_overlay();
|
||||
void paint_overlay();
|
||||
Context& context() const override;
|
||||
void toggle_overlay();
|
||||
void paint_overlay();
|
||||
|
||||
private:
|
||||
bool overlay_active {false};
|
||||
private:
|
||||
bool overlay_active{false};
|
||||
|
||||
SystemStatusView status_view{navigation_view};
|
||||
InformationView info_view{navigation_view};
|
||||
DfuMenu overlay{navigation_view};
|
||||
NavigationView navigation_view{};
|
||||
Context &context_;
|
||||
};
|
||||
SystemStatusView status_view{navigation_view};
|
||||
InformationView info_view{navigation_view};
|
||||
DfuMenu overlay{navigation_view};
|
||||
NavigationView navigation_view{};
|
||||
Context& context_;
|
||||
};
|
||||
|
||||
/*class NotImplementedView : public View {
|
||||
/*class NotImplementedView : public View {
|
||||
public:
|
||||
NotImplementedView(NavigationView& nav);
|
||||
NotImplementedView(NavigationView& nav);
|
||||
|
||||
void focus() override;
|
||||
void focus() override;
|
||||
|
||||
private:
|
||||
Text text_title {
|
||||
{ 5 * 8, 7 * 16, 19 * 8, 16 },
|
||||
"Not Yet Implemented"
|
||||
};
|
||||
Text text_title {
|
||||
{ 5 * 8, 7 * 16, 19 * 8, 16 },
|
||||
"Not Yet Implemented"
|
||||
};
|
||||
|
||||
Button button_done {
|
||||
{ 10 * 8, 13 * 16, 10 * 8, 24 },
|
||||
"Bummer",
|
||||
};
|
||||
Button button_done {
|
||||
{ 10 * 8, 13 * 16, 10 * 8, 24 },
|
||||
"Bummer",
|
||||
};
|
||||
};*/
|
||||
|
||||
class ModalMessageView : public View
|
||||
{
|
||||
public:
|
||||
ModalMessageView(
|
||||
NavigationView &nav,
|
||||
const std::string &title,
|
||||
const std::string &message,
|
||||
const modal_t type,
|
||||
const std::function<void(bool)> on_choice);
|
||||
class ModalMessageView : public View {
|
||||
public:
|
||||
ModalMessageView(
|
||||
NavigationView& nav,
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
const modal_t type,
|
||||
const std::function<void(bool)> on_choice);
|
||||
|
||||
void paint(Painter &painter) override;
|
||||
void focus() override;
|
||||
void paint(Painter& painter) override;
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return title_; };
|
||||
std::string title() const override { return title_; };
|
||||
|
||||
private:
|
||||
const std::string title_;
|
||||
const std::string message_;
|
||||
const modal_t type_;
|
||||
const std::function<void(bool)> on_choice_;
|
||||
private:
|
||||
const std::string title_;
|
||||
const std::string message_;
|
||||
const modal_t type_;
|
||||
const std::function<void(bool)> on_choice_;
|
||||
|
||||
Button button_ok{
|
||||
{10 * 8, 14 * 16, 10 * 8, 48},
|
||||
"OK",
|
||||
};
|
||||
Button button_ok{
|
||||
{10 * 8, 14 * 16, 10 * 8, 48},
|
||||
"OK",
|
||||
};
|
||||
|
||||
Button button_yes{
|
||||
{5 * 8, 14 * 16, 8 * 8, 48},
|
||||
"YES",
|
||||
};
|
||||
Button button_yes{
|
||||
{5 * 8, 14 * 16, 8 * 8, 48},
|
||||
"YES",
|
||||
};
|
||||
|
||||
Button button_no{
|
||||
{17 * 8, 14 * 16, 8 * 8, 48},
|
||||
"NO",
|
||||
};
|
||||
};
|
||||
Button button_no{
|
||||
{17 * 8, 14 * 16, 8 * 8, 48},
|
||||
"NO",
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue