Skip to content

Commit

Permalink
Merge branch 'main' into dry_numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Jan 11, 2025
2 parents 6282844 + 9430daf commit 48a6ab5
Show file tree
Hide file tree
Showing 22 changed files with 197 additions and 110 deletions.
Binary file added doc/smallLogo_for_windowicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions include/AppImages.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ namespace AppImages
{
extern const char *logo2_png;
const int logo2_pngSize = 49015;

extern const char *logosmall_png;
const int logosmall_pngSize = 21145;
}
2 changes: 1 addition & 1 deletion include/InputNumberComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef INPUT_NUMBER_COMPONENT_HPP
#define INPUT_NUMBER_COMPONENT_HPP

#include "NumberComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "NumberComponent.hpp"

#include "JuceHeader.h"

Expand Down
2 changes: 1 addition & 1 deletion include/InputStringComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef INPUT_STRING_COMPONENT_HPP
#define INPUT_STRING_COMPONENT_HPP

#include "TextDrawingComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "TextDrawingComponent.hpp"

#include "JuceHeader.h"

Expand Down
11 changes: 4 additions & 7 deletions include/JuceManagedWorkingSetCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"

#include "JuceHeader.h"
#include "SoftKeyMaskComponent.hpp"

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);
static void set_softkey_mask_dimension_info(const SoftKeyMaskDimensions &info);

private:
class ComponentCacheClass
Expand All @@ -34,9 +31,9 @@ class JuceManagedWorkingSetCache
//std::map<std::uint16_t, std::shared_ptr<Component>> componentLookup;
};
static std::vector<ComponentCacheClass> workingSetComponentCache;

static SoftKeyMaskDimensions softKeyDimensionInfo;
static int dataAndAlarmMaskSize;
static int keyWidth;
static int keyHeight;
};

#endif // JUCE_MANAGED_WORKING_SET_HPP
2 changes: 1 addition & 1 deletion include/NumberComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef NUMBER_COMPONENT_HPP
#define NUMBER_COMPONENT_HPP

#include "TextDrawingComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "TextDrawingComponent.hpp"

#include "JuceHeader.h"

Expand Down
2 changes: 1 addition & 1 deletion include/OutputNumberComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef OUTPUT_NUMBER_COMPONENT_HPP
#define OUTPUT_NUMBER_COMPONENT_HPP

#include "NumberComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "NumberComponent.hpp"

#include "JuceHeader.h"

Expand Down
2 changes: 1 addition & 1 deletion include/OutputStringComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#ifndef OUTPUT_STRING_COMPONENT_HPP
#define OUTPUT_STRING_COMPONENT_HPP

#include "TextDrawingComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_objects.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp"
#include "TextDrawingComponent.hpp"

#include "JuceHeader.h"

Expand Down
11 changes: 6 additions & 5 deletions include/ServerMainComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "ConfigureHardwareWindow.hpp"
#include "DataMaskRenderAreaComponent.hpp"
#include "LoggerComponent.hpp"
#include "SoftKeyMaskComponent.hpp"
#include "SoftKeyMaskRenderAreaComponent.hpp"
#include "WorkingSetSelectorComponent.hpp"
#include "isobus/isobus/isobus_virtual_terminal_server.hpp"
Expand All @@ -24,9 +25,11 @@ class ServerMainComponent : public juce::Component
VTVersion get_version() const override;
std::uint8_t get_number_of_navigation_soft_keys() const override;
std::uint8_t get_soft_key_descriptor_x_pixel_width() const override;
std::uint8_t get_soft_key_descriptor_y_pixel_width() const override;
std::uint8_t get_soft_key_descriptor_y_pixel_height() const override;
std::uint8_t get_number_of_possible_virtual_soft_keys_in_soft_key_mask() const override;
std::uint8_t get_number_of_physical_soft_keys() const override;
std::uint8_t get_physical_soft_key_rows() const;
std::uint8_t get_physical_soft_key_columns() const;
std::uint16_t get_data_mask_area_size_x_pixels() const override;
std::uint16_t get_data_mask_area_size_y_pixels() const override;
void suspend_working_set(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSetWithError) override;
Expand Down Expand Up @@ -127,6 +130,8 @@ class ServerMainComponent : public juce::Component
AutoStart
};

SoftKeyMaskDimensions softKeyMaskDimensions;

class LanguageCommandConfigClosed
{
public:
Expand Down Expand Up @@ -178,10 +183,6 @@ class ServerMainComponent : public juce::Component
std::uint32_t alarmAckKeyMaskId = isobus::NULL_OBJECT_ID;
int alarmAckKeyCode = juce::KeyPress::escapeKey;
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;
bool autostart = false;
Expand Down
30 changes: 27 additions & 3 deletions include/SoftKeyMaskComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,36 @@

#include "JuceHeader.h"

class SoftKeyMaskDimensions
{
public:
SoftKeyMaskDimensions() = default;

/**
* @brief total_width
* @return The total width of the softkeymask (including inner and outer column paddings)
*/
int total_width() const;

/**
* @brief key_count
* @return the number of the possible key positions in the softkey mask
*/
int key_count() const;

int keyHeight = 60;
int keyWidth = 60;
int rowCount = 6;
int columnCount = 1;
int height = 480;
static constexpr std::uint8_t PADDING = 10;
};

class SoftKeyMaskComponent : public isobus::SoftKeyMask
, public Component
{
public:
SoftKeyMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::SoftKeyMask sourceObject, int dataAndAlarmMaskSize, int keyHeight, int keyWidth);
SoftKeyMaskComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::SoftKeyMask sourceObject, SoftKeyMaskDimensions dimensions);

void on_content_changed(bool initial = false);

Expand All @@ -27,8 +52,7 @@ class SoftKeyMaskComponent : public isobus::SoftKeyMask
private:
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
std::vector<std::shared_ptr<Component>> childComponents;
int softKeyHeight = 60;
int softKeyWidth = 60;
SoftKeyMaskDimensions dimensionInfo;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SoftKeyMaskComponent)
};
Expand Down
6 changes: 3 additions & 3 deletions include/TextDrawingComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class TextDrawingComponent : public Component

protected:
static Justification convert_justification(isobus::TextualVTObject::HorizontalJustification horizontalJustification,
isobus::TextualVTObject::VerticalJustification verticalJustification);
isobus::TextualVTObject::VerticalJustification verticalJustification);
uint8_t prepare_text_painting(Graphics &g,
std::shared_ptr<isobus::FontAttributes> font_attributes,
char referenceCharForWidthCalc);
std::shared_ptr<isobus::FontAttributes> font_attributes,
char referenceCharForWidthCalc);

void paintText(Graphics &g, const std::string &text, bool enabled = true);
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> parentWorkingSet;
Expand Down
3 changes: 3 additions & 0 deletions src/AppImages.cpp

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/DataMaskRenderAreaComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,20 @@ void DataMaskRenderAreaComponent::mouseUp(const MouseEvent &event)
}
}
this->inputListModal->exitModalState();
parentWorkingSet->set_object_focus(isobus::NULL_OBJECT_ID);
if (nullptr != parentWorkingSet)
{
parentWorkingSet->set_object_focus(isobus::NULL_OBJECT_ID);
}
ownerServer.repaint_on_next_update();
ownerServer.process_macro(clickedList, isobus::EventID::OnInputFieldDeselection, isobus::VirtualTerminalObjectType::InputList, parentWorkingSet);
inputListModal.reset();
repaint();
};
inputListModal->enterModalState(true, ModalCallbackFunction::create(std::move(resultCallback)), false);
parentWorkingSet->set_object_focus(clickedObject->get_id());
if (nullptr != parentWorkingSet)
{
parentWorkingSet->set_object_focus(clickedObject->get_id());
}
ownerServer.process_macro(clickedObject, isobus::EventID::OnInputFieldSelection, isobus::VirtualTerminalObjectType::InputList, parentWorkingSet);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/InputNumberComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ InputNumberComponent::InputNumberComponent(std::shared_ptr<isobus::VirtualTermin
setOpaque(true);
}
}

25 changes: 8 additions & 17 deletions src/JuceManagedWorkingSetCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@

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

std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, std::shared_ptr<isobus::VTObject> sourceObject)
{
Expand Down Expand Up @@ -90,13 +89,15 @@ std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::sha

case isobus::VirtualTerminalObjectType::SoftKeyMask:
{
retVal = std::make_shared<SoftKeyMaskComponent>(workingSet, *std::static_pointer_cast<isobus::SoftKeyMask>(sourceObject), dataAndAlarmMaskSize, keyHeight, keyWidth);
retVal = std::make_shared<SoftKeyMaskComponent>(workingSet,
*std::static_pointer_cast<isobus::SoftKeyMask>(sourceObject),
softKeyDimensionInfo);
}
break;

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

Expand Down Expand Up @@ -210,7 +211,7 @@ std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::sha

case isobus::VirtualTerminalObjectType::WorkingSet:
{
retVal = std::make_shared<WorkingSetComponent>(workingSet, *std::static_pointer_cast<isobus::WorkingSet>(sourceObject), keyHeight, keyWidth);
retVal = std::make_shared<WorkingSetComponent>(workingSet, *std::static_pointer_cast<isobus::WorkingSet>(sourceObject), softKeyDimensionInfo.keyHeight, softKeyDimensionInfo.keyWidth);
}
break;

Expand All @@ -228,17 +229,7 @@ std::shared_ptr<Component> JuceManagedWorkingSetCache::create_component(std::sha
return retVal;
}

void JuceManagedWorkingSetCache::set_data_alarm_mask_size(int size)
void JuceManagedWorkingSetCache::set_softkey_mask_dimension_info(const SoftKeyMaskDimensions &info)
{
dataAndAlarmMaskSize = size;
}

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

void JuceManagedWorkingSetCache::set_soft_key_height(int size)
{
keyHeight = size;
softKeyDimensionInfo = info;
}
10 changes: 10 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <JuceHeader.h>
#include "ASCIILogFile.hpp"
#include "AppImages.h"
#include "ServerMainComponent.hpp"
#include "isobus/hardware_integration/can_hardware_interface.hpp"
#include "isobus/isobus/can_internal_control_function.hpp"
Expand Down Expand Up @@ -113,6 +114,15 @@ class AgISOVirtualTerminalApplication : public juce::JUCEApplication
centreWithSize(getWidth(), getHeight());
#endif

setIcon(ImageCache::getFromMemory(AppImages::logosmall_png, AppImages::logosmall_pngSize));
#if JUCE_LINUX
// this hack is needed on Linux
ComponentPeer *peer = getPeer();
if (peer)
{
peer->setIcon(ImageCache::getFromMemory(AppImages::logosmall_png, AppImages::logosmall_pngSize));
}
#endif
setVisible(true);
}

Expand Down
17 changes: 7 additions & 10 deletions src/NumberComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
#include <sstream>

NumberComponent::NumberComponent(
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet) :
parentWorkingSet(workingSet),
TextDrawingComponent(workingSet)
std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet) :
parentWorkingSet(workingSet),
TextDrawingComponent(workingSet)
{

}

void NumberComponent::paint(Graphics &g)
Expand All @@ -23,7 +22,7 @@ void NumberComponent::paint(Graphics &g)
return;
}

auto sourceNumber = static_cast<isobus::NumberVTObject*>(sourceObject);
auto sourceNumber = static_cast<isobus::NumberVTObject *>(sourceObject);

if (isOpaque())
{
Expand All @@ -41,7 +40,7 @@ void NumberComponent::paint(Graphics &g)
auto child = sourceNumber->get_object_by_id(sourceNumber->get_font_attributes(), parentWorkingSet->get_object_tree());

if ((nullptr != child) &&
(isobus::VirtualTerminalObjectType::FontAttributes == child->get_object_type()))
(isobus::VirtualTerminalObjectType::FontAttributes == child->get_object_type()))
{
auto font = std::static_pointer_cast<isobus::FontAttributes>(child);
strikeThrough = font->get_style(isobus::FontAttributes::FontStyleBits::CrossedOut);
Expand All @@ -54,20 +53,18 @@ void NumberComponent::paint(Graphics &g)
auto child = sourceNumber->get_object_by_id(sourceNumber->get_variable_reference(), parentWorkingSet->get_object_tree());

if ((nullptr != child) &&
(isobus::VirtualTerminalObjectType::NumberVariable == child->get_object_type()))
(isobus::VirtualTerminalObjectType::NumberVariable == child->get_object_type()))
{
scaledValue = (std::static_pointer_cast<isobus::NumberVariable>(child)->get_value() + sourceNumber->get_offset()) * sourceNumber->get_scale();
}
}

std::ostringstream valueText;
valueText << std::fixed << std::setprecision(sourceNumber->get_number_of_decimals()) << scaledValue;
g.drawText(valueText.str(), 0, 0, sourceNumber->get_width(), sourceNumber->get_height(),
convert_justification(sourceNumber->get_horizontal_justification(), sourceNumber->get_vertical_justification()), false);
g.drawText(valueText.str(), 0, 0, sourceNumber->get_width(), sourceNumber->get_height(), convert_justification(sourceNumber->get_horizontal_justification(), sourceNumber->get_vertical_justification()), false);

if (strikeThrough)
{
drawStrikeThrough(g, sourceNumber->get_width(), sourceNumber->get_height(), valueText.str(), sourceNumber->get_horizontal_justification());
}
}

2 changes: 0 additions & 2 deletions src/OutputNumberComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ OutputNumberComponent::OutputNumberComponent(std::shared_ptr<isobus::VirtualTerm
setOpaque(true);
}
}


Loading

0 comments on commit 48a6ab5

Please sign in to comment.