| 1 |
/* |
| 2 |
============================================================================== |
| 3 |
|
| 4 |
ControlComponent.h |
| 5 |
Created: 6 Jun 2018 11:18:56pm |
| 6 |
Author: adamson |
| 7 |
|
| 8 |
============================================================================== |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include "../JuceLibraryCode/JuceHeader.h" |
| 14 |
|
| 15 |
//============================================================================== |
| 16 |
/* |
| 17 |
*/ |
| 18 |
#ifdef USE_BURGER_MENU |
| 19 |
// This class is adapted from the JUCE "MenusDemo" |
| 20 |
class BurgerMenuHeader : public Component |
| 21 |
{ |
| 22 |
public: |
| 23 |
BurgerMenuHeader(SidePanel& sp); |
| 24 |
~BurgerMenuHeader(); |
| 25 |
|
| 26 |
private: |
| 27 |
void paint (Graphics& g) override; |
| 28 |
|
| 29 |
void resized() override; |
| 30 |
|
| 31 |
void showOrHide() |
| 32 |
{sidePanel.showOrHide(!sidePanel.isPanelShowing());} |
| 33 |
|
| 34 |
SidePanel& sidePanel; |
| 35 |
Label titleLabel; |
| 36 |
ShapeButton burgerButton; |
| 37 |
|
| 38 |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BurgerMenuHeader) |
| 39 |
}; // end class BurgerMenuHeader |
| 40 |
#endif // USE_BURGER_MENU |
| 41 |
|
| 42 |
class ControlComponent : public Component, |
| 43 |
public Button::Listener, |
| 44 |
public ComboBox::Listener, |
| 45 |
public TextEditor::Listener, |
| 46 |
public AsyncUpdater |
| 47 |
{ |
| 48 |
public: |
| 49 |
ControlComponent(class MgenderApp& theApp); |
| 50 |
~ControlComponent(); |
| 51 |
|
| 52 |
void paint (Graphics&) override; |
| 53 |
void resized() override; |
| 54 |
void buttonClicked(Button* buttonThatWasClicked) override; |
| 55 |
|
| 56 |
void comboBoxChanged(ComboBox* comboBoxThatHasChanged) override; |
| 57 |
|
| 58 |
void textEditorTextChanged(TextEditor &) override {} |
| 59 |
void textEditorReturnKeyPressed(TextEditor &editor) override; |
| 60 |
void textEditorEscapeKeyPressed(TextEditor &editor) override |
| 61 |
{textEditorReturnKeyPressed(editor);} |
| 62 |
void textEditorFocusLost(TextEditor &editor) override |
| 63 |
{textEditorReturnKeyPressed(editor);} |
| 64 |
|
| 65 |
void handleAsyncUpdate() override; |
| 66 |
|
| 67 |
void SetInterfaceText(const String& ifaceName) |
| 68 |
{iface_text.setText(ifaceName);} |
| 69 |
|
| 70 |
void SetReportContent(const String& theContent); // to be called by mgen thread only |
| 71 |
void SetReportContentDirect(const String& theContent) |
| 72 |
{report_text.setText(theContent);} |
| 73 |
void UpdateProbeAddress(); |
| 74 |
bool StartProbing(); |
| 75 |
void OnUpdateProbeAddress(); |
| 76 |
|
| 77 |
// Binary resources: |
| 78 |
static const char* mgenLogo_png; |
| 79 |
static const int mgenLogo_pngSize; |
| 80 |
|
| 81 |
private: |
| 82 |
class MgenderApp& mgender; |
| 83 |
MenuBarComponent menu_bar; |
| 84 |
#ifdef USE_BURGER_MENU |
| 85 |
// Alternative "burger" menu for mobile devices |
| 86 |
// (copied from JUCE MenuDemo" |
| 87 |
BurgerMenuComponent burger_menu; |
| 88 |
SidePanel menu_panel {"Menu", 300, false}; |
| 89 |
BurgerMenuHeader menu_header{menu_panel}; |
| 90 |
#endif // USE_BURGER_MENU |
| 91 |
ImageButton logo_butn; |
| 92 |
GroupComponent dest_group; |
| 93 |
TextEditor addr_text; |
| 94 |
Label addr_label; |
| 95 |
Label port_label; |
| 96 |
TextEditor port_text; |
| 97 |
Label iface_label; |
| 98 |
TextEditor iface_text; |
| 99 |
Label pattern_label; |
| 100 |
ComboBox pattern_box; |
| 101 |
Label rate_label; |
| 102 |
Label size_label; |
| 103 |
TextEditor rate_text; |
| 104 |
Label rate_units; |
| 105 |
TextEditor size_text; |
| 106 |
Label size_units; |
| 107 |
GroupComponent report_group; |
| 108 |
TextEditor report_text; |
| 109 |
TextButton start_butn; |
| 110 |
TextButton stop_butn; |
| 111 |
ToggleButton auto_toggle; |
| 112 |
|
| 113 |
FlexBox main_box; |
| 114 |
FlexBox logo_box; |
| 115 |
FlexBox flow_box; |
| 116 |
FlexBox report_box; |
| 117 |
FlexBox control_box; |
| 118 |
|
| 119 |
String report_content; |
| 120 |
bool report_content_pending; |
| 121 |
bool probe_addr_update_pending; |
| 122 |
CriticalSection update_lock; |
| 123 |
|
| 124 |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ControlComponent) |
| 125 |
|
| 126 |
}; // end class ControlComponent |