Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
ultralight::View Class Referenceabstract

A View is similar to a tab in a browser– you load web content into it and display it however you want. More...

#include <View.h>

Inheritance diagram for ultralight::View:
ultralight::RefCounted

Public Member Functions

virtual String url ()=0
 Get the URL of the current page loaded into this View, if any.
 
virtual String title ()=0
 Get the title of the current page loaded into this View, if any.
 
virtual bool is_loading ()=0
 Check if the main frame of the page is currently loading.
 
virtual RenderTarget render_target ()=0
 Get the RenderTarget for the View. More...
 
virtual bool is_bitmap_dirty ()=0
 Check if bitmap is dirty (has changed since last call to View::bitmap) More...
 
virtual RefPtr< Bitmapbitmap ()=0
 Get the bitmap for the View (calling this resets the dirty state).
 
virtual void LoadHTML (const String &html)=0
 Load a raw string of HTML, the View will navigate to it as a new page.
 
virtual void LoadURL (const String &url)=0
 Load a URL, the View will navigate to it as a new page. More...
 
virtual void Resize (uint32_t width, uint32_t height)=0
 Resize View to a certain size. More...
 
virtual JSContextRef js_context ()=0
 Get the page's JSContext for use with the JavaScriptCore API. More...
 
virtual JSValueRef EvaluateScript (const String &script)=0
 Evaluate a raw string of JavaScript and return results as a native JavaScriptCore JSValueRef (. More...
 
virtual bool CanGoBack ()=0
 Whether or not we can navigate backwards in history.
 
virtual bool CanGoForward ()=0
 Whether or not we can navigate forwards in history.
 
virtual void GoBack ()=0
 Navigate backwards in history.
 
virtual void GoForward ()=0
 Navigate forwards in history.
 
virtual void GoToHistoryOffset (int offset)=0
 Navigate to an arbitrary offset in history.
 
virtual void Reload ()=0
 Reload current page.
 
virtual void Stop ()=0
 Stop all page loads.
 
virtual void FireKeyEvent (const KeyEvent &evt)=0
 Fire a keyboard event. More...
 
virtual void FireMouseEvent (const MouseEvent &evt)=0
 Fire a mouse event.
 
virtual void FireScrollEvent (const ScrollEvent &evt)=0
 Fire a scroll event.
 
virtual void set_view_listener (ViewListener *listener)=0
 Set a ViewListener to receive callbacks for View-related events. More...
 
virtual ViewListenerview_listener () const =0
 Get the active ViewListener, if any.
 
virtual void set_load_listener (LoadListener *listener)=0
 Set a LoadListener to receive callbacks for Load-related events. More...
 
virtual LoadListenerload_listener () const =0
 Get the active LoadListener, if any.
 
virtual void set_needs_paint (bool needs_paint)=0
 Set whether or not this View should be repainted during the next call to Renderer::Render. More...
 
virtual bool needs_paint () const =0
 Whether or not this View should be repainted during the next call to Renderer::Render.
 

Detailed Description

A View is similar to a tab in a browser– you load web content into it and display it however you want.

See also
Renderer::CreateView
Note
The API is currently not thread-safe, all calls must be made on the main thread.

Definition at line 34 of file View.h.

Member Function Documentation

◆ EvaluateScript()

virtual JSValueRef ultralight::View::EvaluateScript ( const String script)
pure virtual

Evaluate a raw string of JavaScript and return results as a native JavaScriptCore JSValueRef (.

See also
<JavaScriptCore/JSValueRef.h>)
Note
This is just a wrapper for JSEvaluateScript() in JavaScriptCore

◆ FireKeyEvent()

virtual void ultralight::View::FireKeyEvent ( const KeyEvent evt)
pure virtual

Fire a keyboard event.

Note
Only 'Char' events actually generate text in input fields.

◆ is_bitmap_dirty()

virtual bool ultralight::View::is_bitmap_dirty ( )
pure virtual

Check if bitmap is dirty (has changed since last call to View::bitmap)

Note
Only valid when using the default, offscreen GPUDriver.

◆ js_context()

virtual JSContextRef ultralight::View::js_context ( )
pure virtual

Get the page's JSContext for use with the JavaScriptCore API.

Note
We expose the entire JavaScriptCore API to users for maximum flexibility. Each page has its own JSContext that gets reset after each page navigation. You should make all your initial JavaScript calls to the page within the DOMReady event,
See also
ViewListener::OnDOMReady

◆ LoadURL()

virtual void ultralight::View::LoadURL ( const String url)
pure virtual

Load a URL, the View will navigate to it as a new page.

Note
You can use File URLs (eg, file:///page.html) but you must define your own FileSystem implementation.
See also
Platform::set_file_system

◆ render_target()

virtual RenderTarget ultralight::View::render_target ( )
pure virtual

Get the RenderTarget for the View.

Note
The RenderTarget is only used when you define a custom GPUDriver.
   During each call to Renderer::Render, each View will be drawn to
   an offscreen texture/render-buffer. You should use RenderTarget
   to obtain the internal texture ID for the View and then display
   it in some quad (eg, call  GPUDriver::BindTexture with the texture
   ID, then draw a textured quad in your 3D engine, making sure to
   use the UV coords specified in the RenderTarget).

   @see Overlay.cpp within the AppCore source for an example.

◆ Resize()

virtual void ultralight::View::Resize ( uint32_t  width,
uint32_t  height 
)
pure virtual

Resize View to a certain size.

Parameters
widthThe initial width, in device coordinates.
heightThe initial height, in device coordinates.
Note
The device coordinates are scaled to pixels by multiplying them with the current DPI scale (
See also
Config::device_scale_hint) and rounding to the nearest integer value.

◆ set_load_listener()

virtual void ultralight::View::set_load_listener ( LoadListener listener)
pure virtual

Set a LoadListener to receive callbacks for Load-related events.

Note
Ownership remains with the caller.

◆ set_needs_paint()

virtual void ultralight::View::set_needs_paint ( bool  needs_paint)
pure virtual

Set whether or not this View should be repainted during the next call to Renderer::Render.

Note
This flag is automatically set whenever the page content changes but you can set it directly in case you need to force a repaint.

◆ set_view_listener()

virtual void ultralight::View::set_view_listener ( ViewListener listener)
pure virtual

Set a ViewListener to receive callbacks for View-related events.

Note
Ownership remains with the caller.

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