Skip to content

Commit

Permalink
Add dynamic render area and key sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
ad3154 committed Dec 10, 2023
1 parent 246d58b commit 55a546a
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 25 deletions.
2 changes: 1 addition & 1 deletion include/AlarmMaskComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AlarmMaskComponent : public isobus::AlarmMask
, public Component
{
public:
AlarmMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::AlarmMask sourceObject);
AlarmMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::AlarmMask sourceObject, int dataMaskSize);

void on_content_changed(bool initial = false);

Expand Down
2 changes: 1 addition & 1 deletion include/DataMaskComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DataMaskComponent : public isobus::DataMask
, public Component
{
public:
DataMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::DataMask sourceObject);
DataMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::DataMask sourceObject, int dataMaskSize);

void on_content_changed(bool initial = false);

Expand Down
9 changes: 9 additions & 0 deletions include/JuceManagedWorkingSetCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class JuceManagedWorkingSetCache
public:
static std::shared_ptr<Component> create_component(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::shared_ptr<isobus::VTObject> sourceObject);

static void set_data_alarm_mask_size(int size);

static void set_soft_key_width(int size);

static void set_soft_key_height(int size);

private:
class ComponentCacheClass
{
Expand All @@ -28,6 +34,9 @@ class JuceManagedWorkingSetCache
//std::map<std::uint16_t, std::shared_ptr<Component>> componentLookup;
};
static std::vector<ComponentCacheClass> workingSetComponentCache;
static int dataAndAlarmMaskSize;
static int keyWidth;
static int keyHeight;
};

#endif // JUCE_MANAGED_WORKING_SET_HPP
2 changes: 1 addition & 1 deletion include/KeyComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class KeyComponent : public isobus::Key
, public Component
{
public:
KeyComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Key sourceObject);
KeyComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Key sourceObject, int keyWidth, int keyHeight);

void paint(Graphics &g) override;

Expand Down
7 changes: 6 additions & 1 deletion include/ServerMainComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class ServerMainComponent : public juce::Component
NoCommand = 0, /// 0 Is an invalid command ID
About,
ConfigureLanguageCommand,
ConfigureReportedVersion
ConfigureReportedVersion,
ConfigureReportedHardware
};

class LanguageCommandConfigClosed
Expand Down Expand Up @@ -132,6 +133,10 @@ class ServerMainComponent : public juce::Component
AudioDeviceManager mAudioDeviceManager;
std::unique_ptr<AlertWindow> popupMenu;
std::uint8_t numberOfPoolsToRender = 0;
std::uint8_t numberPhysicalSoftKeys = 6;
std::uint8_t numberVirtualSoftKeys = 64;
std::uint8_t softKeyDesignatorWidth = 60;
std::uint8_t softKeyDesignatorHeight = 60;
VTVersion versionToReport = VTVersion::Version5;
bool needToRepaint = false;

Expand Down
4 changes: 2 additions & 2 deletions src/AlarmMaskComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "AlarmMaskComponent.hpp"
#include "JuceManagedWorkingSetCache.hpp"

AlarmMaskComponent::AlarmMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::AlarmMask sourceObject) :
AlarmMaskComponent::AlarmMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::AlarmMask sourceObject, int dataMaskSize) :
isobus::AlarmMask(sourceObject),
parentWorkingSet(workingSet)
{
setOpaque(true);
setBounds(0, 0, 480, 480);
setBounds(0, 0, dataMaskSize, dataMaskSize);
on_content_changed(true);
}

Expand Down
4 changes: 2 additions & 2 deletions src/DataMaskComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "DataMaskComponent.hpp"
#include "JuceManagedWorkingSetCache.hpp"

DataMaskComponent::DataMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::DataMask sourceObject) :
DataMaskComponent::DataMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::DataMask sourceObject, int dataMaskSize) :
isobus::DataMask(sourceObject),
parentWorkingSet(workingSet)
{
setOpaque(true);
setBounds(0, 0, 480, 480);
setBounds(0, 0, dataMaskSize, dataMaskSize);
on_content_changed(true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/DataMaskRenderAreaComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void DataMaskRenderAreaComponent::paint(Graphics &g)

if (nullptr != parentWorkingSet)
{
g.drawRect(0, 0, 480, 480, 1);
g.drawRect(0, 0, getWidth(), getHeight(), 1);
}
else
{
Expand Down
24 changes: 21 additions & 3 deletions src/JuceManagedWorkingSetCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include "WorkingSetComponent.hpp"

std::vector<JuceManagedWorkingSetCache::ComponentCacheClass> JuceManagedWorkingSetCache::workingSetComponentCache;
int JuceManagedWorkingSetCache::dataAndAlarmMaskSize = 480;
int JuceManagedWorkingSetCache::keyWidth = 60;
int JuceManagedWorkingSetCache::keyHeight = 60;

std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::shared_ptr<isobus::VTObject> sourceObject)
{
Expand All @@ -64,13 +67,13 @@ std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::sha
{
case isobus::VirtualTerminalObjectType::AlarmMask:
{
retVal = std::make_shared<AlarmMaskComponent>(workingSet, *std::static_pointer_cast<isobus::AlarmMask>(sourceObject));
retVal = std::make_shared<AlarmMaskComponent>(workingSet, *std::static_pointer_cast<isobus::AlarmMask>(sourceObject), dataAndAlarmMaskSize);
}
break;

case isobus::VirtualTerminalObjectType::DataMask:
{
retVal = std::make_shared<DataMaskComponent>(workingSet, *std::static_pointer_cast<isobus::DataMask>(sourceObject));
retVal = std::make_shared<DataMaskComponent>(workingSet, *std::static_pointer_cast<isobus::DataMask>(sourceObject), dataAndAlarmMaskSize);
}
break;

Expand All @@ -93,7 +96,7 @@ std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::sha

case isobus::VirtualTerminalObjectType::Key:
{
retVal = std::make_shared<KeyComponent>(workingSet, *std::static_pointer_cast<isobus::Key>(sourceObject));
retVal = std::make_shared<KeyComponent>(workingSet, *std::static_pointer_cast<isobus::Key>(sourceObject), keyWidth, keyHeight);
}
break;

Expand Down Expand Up @@ -218,3 +221,18 @@ std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::sha
}
return retVal;
}

void JuceManagedWorkingSetCache::set_data_alarm_mask_size(int size)
{
dataAndAlarmMaskSize = size;
}

void JuceManagedWorkingSetCache::set_soft_key_width(int size)
{
keyWidth = size;
}

void JuceManagedWorkingSetCache::set_soft_key_height(int size)
{
keyHeight = size;
}
4 changes: 2 additions & 2 deletions src/KeyComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

#include "JuceManagedWorkingSetCache.hpp"

KeyComponent::KeyComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Key sourceObject) :
KeyComponent::KeyComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::Key sourceObject, int keyWidth, int keyHeight) :
isobus::Key(sourceObject),
parentWorkingSet(workingSet)
{
setSize(60, 60);
setSize(keyWidth, keyHeight);
setOpaque(true);

for (std::uint16_t i = 0; i < this->get_number_children(); i++)
Expand Down
Loading

0 comments on commit 55a546a

Please sign in to comment.