MostlyHarmless 0.0.1
Loading...
Searching...
No Matches
mostlyharmless_WebviewEditor.h
Go to the documentation of this file.
1//
2// Created by Syl Morrison on 11/08/2024.
3//
4
5#ifndef MOSTLYHARMLESS_MOSTLYHARMLESS_WEBVIEWEDITOR_H
6#define MOSTLYHARMLESS_MOSTLYHARMLESS_WEBVIEWEDITOR_H
9#include <marvin/library/marvin_Concepts.h>
10#include <choc/gui/choc_WebView.h>
11#include <nlohmann/json.hpp>
12#include <optional>
13#include <string>
14#include <memory>
15namespace mostly_harmless::gui {
16
106 class WebviewEditor : public WebviewBase {
107 public:
113 WebviewEditor(core::ISharedState* sharedState, std::uint32_t initialWidth, std::uint32_t initialHeight, Colour backgroundColour);
114
118 ~WebviewEditor() noexcept override = default;
119
120 void initialise() override;
121
125 [[nodiscard]] bool allowResize() const noexcept override;
126
130 void onResizeRequested(std::uint32_t* newWidth, std::uint32_t* newHeight) override;
131
139 void onParamEvent(events::ProcToGuiParamEvent event) override;
140
146 virtual void sendEvent(events::WebEvent&& event) noexcept;
147
148
149 protected:
156 virtual choc::value::Value beginParamChangeGestureCallback(const choc::value::ValueView& args);
157
164 virtual choc::value::Value paramChangeGestureCallback(const choc::value::ValueView& args);
165
172 virtual choc::value::Value endParamChangeGestureCallback(const choc::value::ValueView& args);
173
174 core::ISharedState* m_sharedState{ nullptr };
175
176 struct {
177 std::optional<std::pair<std::uint32_t, std::uint32_t>> lastMouseDownLocation{};
178 std::optional<std::pair<std::uint32_t, std::uint32_t>> lastMousePosition{};
179 } m_cursorState;
180 };
181} // namespace mostly_harmless::gui
182#endif // MOSTLYHARMLESS_MOSTLYHARMLESS_WEBVIEWEDITOR_H
Base class for the plugin's shared state.
Definition mostlyharmless_ISharedState.h:26
WebviewBase(std::uint32_t initialWidth, std::uint32_t initialHeight, Colour backgroundColour)
~WebviewEditor() noexcept override=default
virtual choc::value::Value beginParamChangeGestureCallback(const choc::value::ValueView &args)
virtual void sendEvent(events::WebEvent &&event) noexcept
bool allowResize() const noexcept override
void onParamEvent(events::ProcToGuiParamEvent event) override
void onResizeRequested(std::uint32_t *newWidth, std::uint32_t *newHeight) override
WebviewEditor(core::ISharedState *sharedState, std::uint32_t initialWidth, std::uint32_t initialHeight, Colour backgroundColour)
Contains core functionality of the framework.
Definition mostlyharmless_PluginBase.h:16
Contains classes and functions related to events.
Definition mostlyharmless_InputEventContext.h:4
Contains GUI related classes & functions.
Definition mostlyharmless_WebviewBase.h:10
Convenience struct representing a colour.
Definition mostlyharmless_Colour.h:12