//================================================================================================ /// @file DataMaskRenderArea.hpp /// /// @brief A component to hold all the data mask render components. /// @author Adrian Del Grosso /// /// @copyright 2023 Adrian Del Grosso //================================================================================================ #ifndef DATA_MASK_RENDER_AREA_COMPONENT_HPP #define DATA_MASK_RENDER_AREA_COMPONENT_HPP #include "isobus/isobus/isobus_virtual_terminal_objects.hpp" #include "isobus/isobus/isobus_virtual_terminal_server_managed_working_set.hpp" #include "JuceHeader.h" class ServerMainComponent; class DataMaskRenderAreaComponent : public Component { public: DataMaskRenderAreaComponent(ServerMainComponent &parentServer); void on_change_active_mask(std::shared_ptr workingSet); void on_working_set_disconnect(std::shared_ptr workingSet); void paint(Graphics &g) override; // Used to calculate button press events void mouseDown(const MouseEvent &event) override; // Used to calculate button release events void mouseUp(const MouseEvent &event) override; bool needsRepaint() const; void set_has_started(bool started); private: class InputNumberListener : public Slider::Listener { public: InputNumberListener() = default; void sliderValueChanged(Slider *slider) override; std::uint32_t get_last_value() const; void set_last_value(std::uint32_t value); std::shared_ptr get_target(); void set_target(std::shared_ptr objectBeingModified); private: std::shared_ptr targetObject; std::uint32_t lastValue = 0; }; std::shared_ptr getClickedChildRecursive(std::shared_ptr object, int x, int y); static bool objectCanBeClicked(std::shared_ptr object); static bool isClickWithinBounds(int clickXRelative, int clickYRelative, int objectX, int objectY, int objectWidth, int objectHeight); std::shared_ptr parentWorkingSet; std::unique_ptr inputListModal; std::unique_ptr inputNumberModal; std::unique_ptr inputStringModal; std::unique_ptr inputNumberSlider; std::vector> childComponents; std::vector> currentModalComponentCache; ServerMainComponent &ownerServer; InputNumberListener inputNumberListener; bool needToRepaintActiveArea = false; bool hasStarted = false; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DataMaskRenderAreaComponent) }; #endif // DATA_MASK_RENDER_AREA_COMPONENT_HPP