Skip to content

Commit

Permalink
Made room for a menu bar, improved drawing some disabled objects
Browse files Browse the repository at this point in the history
Also fixed not drawing output string backgrounds when they aren't transparent.
  • Loading branch information
ad3154 committed Nov 16, 2023
1 parent 45de7b4 commit abbe13b
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 13 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16)

project(
"AgISOUniversalTerminal"
"AgISOVirtualTerminal"
LANGUAGES CXX
VERSION 0.0.1)

Expand All @@ -15,18 +15,18 @@ find_package(Threads REQUIRED)
# add_subdirectory(ISO11783-CAN-Stack)

juce_add_gui_app(
AgISOUniversalTerminal
AgISOVirtualTerminal
# ICON_BIG ... # ICON_* arguments specify a path to an
# image file to use as an icon ICON_SMALL ...
COMPANY_NAME
"Open-Agriculture"
PRODUCT_NAME
"AgISOUniversalTerminal")
"AgISOVirtualTerminal")

juce_generate_juce_header(AgISOUniversalTerminal)
juce_generate_juce_header(AgISOVirtualTerminal)

target_sources(
AgISOUniversalTerminal
AgISOVirtualTerminal
PRIVATE src/Main.cpp
"src/ServerMainComponent.cpp"
"src/DataMaskComponent.cpp"
Expand Down Expand Up @@ -56,11 +56,11 @@ target_sources(
"src/AlarmMaskAudio.cpp"
"src/InputListComponent.cpp")

target_include_directories(AgISOUniversalTerminal
target_include_directories(AgISOVirtualTerminal
PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)

target_link_libraries(
AgISOUniversalTerminal
AgISOVirtualTerminal
PRIVATE juce::juce_gui_extra juce::juce_audio_basics juce::juce_audio_utils isobus::Isobus isobus::HardwareIntegration
isobus::Utility
PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_lto_flags
Expand Down
1 change: 1 addition & 0 deletions include/InputListComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class InputListComponent : public isobus::InputList
InputListComponent(std::shared_ptr<isobus::VirtualTerminalServerManagedWorkingSet> workingSet, isobus::InputList sourceObject);

void paint(Graphics &g) override;
void paintOverChildren(Graphics &g) override;

void onChanged(bool initial);

Expand Down
1 change: 0 additions & 1 deletion src/DataMaskRenderAreaComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ void DataMaskRenderAreaComponent::on_change_active_mask(std::shared_ptr<isobus::
parentWorkingSet = workingSet;

auto workingSetObject = std::static_pointer_cast<isobus::WorkingSet>(parentWorkingSet->get_working_set_object());
setBounds(100, 0, 500, 500);

if ((nullptr != workingSetObject) && (isobus::NULL_OBJECT_ID != workingSetObject->get_active_mask()))
{
Expand Down
6 changes: 6 additions & 0 deletions src/InputBooleanComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ void InputBooleanComponent::paint(Graphics &g)
g.drawLine(0, get_height() / 2, get_width() / 2, get_height());
g.drawLine(get_width() / 2, get_height(), get_width(), 0);
}

// If disabled, try and show that by drawing some semi-transparent grey
if (!get_enabled())
{
g.fillAll(Colour::fromFloatRGBA(0.5f, 0.5f, 0.5f, 0.5f));
}
}
11 changes: 10 additions & 1 deletion src/InputListComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ InputListComponent::InputListComponent(std::shared_ptr<isobus::VirtualTerminalSe
onChanged(true);
}

void InputListComponent::paint(Graphics &)
void InputListComponent::paint(Graphics&)
{

}

void InputListComponent::paintOverChildren(Graphics &g)
{
if (!get_option(Options::Enabled))
{
g.fillAll(Colour::fromFloatRGBA(0.5f, 0.5f, 0.5f, 0.5f));
}
}

void InputListComponent::onChanged(bool initial)
Expand Down
6 changes: 3 additions & 3 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include "isobus/isobus/can_internal_control_function.hpp"

//==============================================================================
class AgISOUniversalTerminalApplication : public juce::JUCEApplication
class AgISOVirtualTerminalApplication : public juce::JUCEApplication
{
public:
//==============================================================================
AgISOUniversalTerminalApplication() {}
AgISOVirtualTerminalApplication() {}

const juce::String getApplicationName() override
{
Expand Down Expand Up @@ -137,4 +137,4 @@ class AgISOUniversalTerminalApplication : public juce::JUCEApplication

//==============================================================================
// This macro generates the main() routine that launches the app.
START_JUCE_APPLICATION(AgISOUniversalTerminalApplication)
START_JUCE_APPLICATION(AgISOVirtualTerminalApplication)
7 changes: 7 additions & 0 deletions src/OutputStringComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ void OutputStringComponent::paint(Graphics &g)
{
std::string value = get_value();
std::uint8_t fontHeight = 0;

if (!get_option(Options::Transparent))
{
auto vtColour = colourTable.get_colour(get_background_color());
g.fillAll(Colour::fromFloatRGBA(vtColour.r, vtColour.g, vtColour.b, 1.0f));
}

g.setColour(getLookAndFeel().findColour(ListBox::textColourId));

// Get font data
Expand Down
5 changes: 5 additions & 0 deletions src/ServerMainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ void ServerMainComponent::resized()
// This is called when the MainContentComponent is resized.
// If you add any child components, this is where you should
// update their positions.
auto lMenuBarHeight = juce::LookAndFeel::getDefaultLookAndFeel().getDefaultMenuBarHeight();

workingSetSelector.setBounds(0, lMenuBarHeight + 4, 100, 600);
dataMaskRenderer.setBounds(100, lMenuBarHeight + 4, 500, 500);
softKeyMaskRenderer.setBounds(580, lMenuBarHeight + 4, 100, 480);
loggerViewport.setSize(getWidth(), getHeight() - 600);
loggerViewport.setTopLeftPosition(0, 600);
}
Expand Down
1 change: 0 additions & 1 deletion src/SoftkeyMaskRenderArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ void SoftKeyMaskRenderAreaComponent::on_change_active_mask(std::shared_ptr<isobu
parentWorkingSet = workingSet;

auto workingSetObject = std::static_pointer_cast<isobus::WorkingSet>(parentWorkingSet->get_working_set_object());
setBounds(580, 0, 100, 480);

if ((nullptr != workingSetObject) && (isobus::NULL_OBJECT_ID != workingSetObject->get_active_mask()))
{
Expand Down

0 comments on commit abbe13b

Please sign in to comment.