13#include <emscripten.h>
14#include <emscripten/val.h>
15#include <emscripten/bind.h>
16#include <emscripten/html5.h>
25using namespace emscripten;
28BEGIN_IGRAPHICS_NAMESPACE
30static val GetPreloadedImages()
32 return val::global(
"Browser")[
"preloadedImages"];
35extern void GetScreenDimensions(
int& width,
int& height);
61 void DrawResize()
override;
63 const char* GetPlatformAPIStr()
override {
return "WEB"; }
65 void HideMouseCursor(
bool hide,
bool lock)
override;
66 void MoveMouseCursor(
float x,
float y)
override { }
67 ECursor SetMouseCursor(ECursor cursorType)
override;
68 void GetMouseLocation(
float& x,
float&y)
const override;
70 void ForceEndUserEdit()
override {}
71 void* OpenWindow(
void* pParent)
override;
72 void CloseWindow()
override {}
73 void* GetWindow()
override {
return nullptr; }
74 bool WindowIsOpen()
override {
return GetWindow(); }
75 bool GetTextFromClipboard(WDL_String& str)
override { str.Set(mClipboardText.Get());
return true; }
76 bool SetTextInClipboard(
const char* str)
override { mClipboardText.Set(str);
return true; }
77 void UpdateTooltips()
override {}
78 EMsgBoxResult ShowMessageBox(
const char* str,
const char* title, EMsgBoxType type, IMsgBoxCompletionHandlerFunc completionHandler)
override;
80 void PromptForFile(WDL_String& filename, WDL_String& path, EFileAction action,
const char* ext, IFileDialogCompletionHandlerFunc completionHandler)
override;
81 void PromptForDirectory(WDL_String& path, IFileDialogCompletionHandlerFunc completionHandler)
override;
82 bool PromptForColor(
IColor& color,
const char* str, IColorPickerHandlerFunc func)
override;
83 bool OpenURL(
const char* url,
const char* msgWindowTitle,
const char* confirmMsg,
const char* errMsgOnFailure)
override;
85 bool PlatformSupportsMultiTouch()
const override {
return true; }
88 static void OnMainLoopTimer();
94 void CreatePlatformTextEntry(
int paramIdx,
const IText& text,
const IRECT& bounds,
int length,
const char* str)
override;
97 void RegisterCanvasEvents();
98 void UnregisterCanvasEvents();
100 PlatformFontPtr LoadPlatformFont(
const char* fontID,
const char* fileNameOrResID)
override;
101 PlatformFontPtr LoadPlatformFont(
const char* fontID,
const char* fontName, ETextStyle style)
override;
102 PlatformFontPtr LoadPlatformFont(
const char* fontID,
void* pData,
int dataSize)
override;
103 void CachePlatformFont(
const char* fontID,
const PlatformFontPtr& font)
override {}
105 WDL_String mClipboardText;
106 val mCanvas = val::undefined();
107 val mRootNode = val::undefined();
108 bool mInShadowDOM =
false;
109 std::string mCanvasSelector;
112END_IGRAPHICS_NAMESPACE
Used for choosing a drawing backend.
An editor delegate base class that uses IGraphics for the UI.
IGraphics platform class for the web.
bool IsInShadowDOM() const
Check if this instance is running inside Shadow DOM.
val GetCanvas() const
Get the canvas element for this instance.
Used to manage color data, independent of draw class/platform.
Used to manage a rectangular area, independent of draw class/platform.
IText is used to manage font and text/text entry style for a piece of text on the UI,...