MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
mostly_harmless::gui::WebviewBase Class Referenceabstract

Convenience wrapper layer implementing the creation and management of a choc::ui::WebView. Still abstract, as setParams is left up to the user to implement in a way they see fit. More...

#include <mostlyharmless_WebviewBase.h>

Inheritance diagram for mostly_harmless::gui::WebviewBase:
mostly_harmless::core::IEditor mostly_harmless::gui::WebviewEditor

Classes

struct  Options
 Contains a set of options to construct the internal webview with. More...
 
struct  Resource
 Tiny container struct for web resources. More...
 

Public Member Functions

 WebviewBase (std::uint32_t initialWidth, std::uint32_t initialHeight, Colour backgroundColour)
 
 ~WebviewBase () noexcept override
 
void setOptions (Options &&options) noexcept
 
void initialise () override
 
void destroy () override
 
void setSize (std::uint32_t width, std::uint32_t height) override
 
void getSize (std::uint32_t *width, std::uint32_t *height) override
 
void setParent (void *parentHandle) override
 
void show () override
 
void hide () override
 
void onParamEvent (events::ProcToGuiParamEvent event) override=0
 
- Public Member Functions inherited from mostly_harmless::core::IEditor
virtual ~IEditor () noexcept=default
 

Protected Attributes

choc::ui::WebView * m_internalWebview { nullptr }
 

Detailed Description

Convenience wrapper layer implementing the creation and management of a choc::ui::WebView. Still abstract, as setParams is left up to the user to implement in a way they see fit.

Provides a "clean slate" for a webview based gui, providing windowing, a handle to the internal choc webview, and not much else. If you want a more complete solution, consider deriving from (or directly using) WebviewEditor instead, which has opinionated parameter handling, etc. This class' raison d'etre, then, is for a situation where you have your own strong opinions about how events etc should be handled, but don't want to deal with windowing yourself.

The underlying choc::ui::WebView can be accessed via the protected m_internalWebview member. If you don't call setOptions before initialise is called, then the internal webview will be constructed with some default options, namely:

enableDebug = false
transparentBackground = true

Constructor & Destructor Documentation

◆ WebviewBase()

mostly_harmless::gui::WebviewBase::WebviewBase ( std::uint32_t initialWidth,
std::uint32_t initialHeight,
Colour backgroundColour )

◆ ~WebviewBase()

mostly_harmless::gui::WebviewBase::~WebviewBase ( )
overridenoexcept

Member Function Documentation

◆ destroy()

void mostly_harmless::gui::WebviewBase::destroy ( )
overridevirtual

Called when the editor is closed.

Implements mostly_harmless::core::IEditor.

◆ getSize()

void mostly_harmless::gui::WebviewBase::getSize ( std::uint32_t * width,
std::uint32_t * height )
overridevirtual

Queries the editor about the size of its window. Initially, the parent window's size depends entirely on this call.

Parameters
widthA pointer to the width, to set.
heightA pointer to the height, to set.

Implements mostly_harmless::core::IEditor.

◆ hide()

void mostly_harmless::gui::WebviewBase::hide ( )
overridevirtual

Called when the editor should hide.

Implements mostly_harmless::core::IEditor.

◆ initialise()

void mostly_harmless::gui::WebviewBase::initialise ( )
overridevirtual

Called immediately after the gui has been created - use this to perform any post-creation initialisation.

Implements mostly_harmless::core::IEditor.

Reimplemented in mostly_harmless::gui::WebviewEditor.

◆ onParamEvent()

void mostly_harmless::gui::WebviewBase::onParamEvent ( events::ProcToGuiParamEvent event)
overridepure virtual

Called via the internal gui dispatch thread when a new parameter event is sent by the host - use this hook to sync the changes with the gui!

Implements mostly_harmless::core::IEditor.

Implemented in mostly_harmless::gui::WebviewEditor.

◆ setOptions()

void mostly_harmless::gui::WebviewBase::setOptions ( Options && options)
noexcept

◆ setParent()

void mostly_harmless::gui::WebviewBase::setParent ( void * parentHandle)
overridevirtual

Use this function to add your custom window to the parent view.

Parameters
parentHandleA void* to the parent window's handle - the actual type is platform specific (HWND on Windows, NSView on macOS).

Implements mostly_harmless::core::IEditor.

◆ setSize()

void mostly_harmless::gui::WebviewBase::setSize ( std::uint32_t width,
std::uint32_t height )
overridevirtual

Called when the size of the parent window has been changed.

Parameters
widthThe new parent width.
heightThe new parent height.

Implements mostly_harmless::core::IEditor.

◆ show()

void mostly_harmless::gui::WebviewBase::show ( )
overridevirtual

Called when the editor should show.

Implements mostly_harmless::core::IEditor.

Member Data Documentation

◆ m_internalWebview

choc::ui::WebView* mostly_harmless::gui::WebviewBase::m_internalWebview { nullptr }
protected

The documentation for this class was generated from the following file: