Sirikata
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends
Sirikata::Graphics::WebView Class Reference

A 'WebView' is essentially an offscreen browser window rendered to a dynamic texture (encapsulated as an Ogre Material) that can optionally be contained within a viewport overlay. More...

#include <WebView.hpp>

Inheritance diagram for Sirikata::Graphics::WebView:
Collaboration diagram for Sirikata::Graphics::WebView:

List of all members.

Classes

class  WebViewBorderSize

Public Types

typedef std::tr1::function< void()> ReadyCallback
typedef std::tr1::function< void()> ResetReadyCallback
typedef std::tr1::function
< void(const String &)> 
NavigatedCallback
typedef std::tr1::function
< void(int32 left, int32 top,
int32 right, int32 bottom)> 
UpdateViewportCallback

Public Member Functions

void loadURL (const std::string &url)
 Loads a URL into the main frame.
void loadFile (const std::string &file)
 Loads a local file into the main frame.
void loadHTML (const std::string &html)
 Loads a string of HTML directly into the main frame.
void evaluateJS (const std::string &javascript)
 Evaluates Javascript in the context of the current page.
void defaultEvent (const String &name)
 If we can't actually render pages, invoke the given callback so that processing can continue.
void setUpdateViewportCallback (UpdateViewportCallback cb)
void setReadyCallback (ReadyCallback cb)
void setResetReadyCallback (ResetReadyCallback cb)
void setNavigatedCallback (NavigatedCallback cb)
void bind (const std::string &name, JSDelegate callback)
 Sets a global 'Client' callback that can be invoked via Javascript from within all pages loaded into this WebView.
void setViewport (Ogre::Viewport *newViewport)
void setTransparent (bool isTransparent)
void setIgnoreBounds (bool ignoreBounds=true)
 Normally, mouse movement is only injected into a specific WebView from WebViewManager if the mouse is within the boundaries of a WebView and over an opaque area (not transparent).
void setIgnoreTransparent (bool ignoreTrans, float threshold=0.05)
 Using alpha-masking/transparency doesn't just affect the visuals of a WebView; by default, WebViews 'ignore' mouse movement/clicks over 'transparent' areas of a WebView (Areas with opacity less than 5%).
void setMaxUPS (unsigned int maxUPS=0)
 Adjusts the number of times per second this WebView may update.
void setOpacity (float opacity)
 Changes the overall opacity of this WebView to a certain percentage.
void setPosition (const OverlayPosition &viewPosition)
 Sets the default position of this WebView to a new position and then moves the WebView to that position.
void resetPosition ()
 Resets the position of this WebView to its default position.
void hide ()
void hide (bool fade, unsigned short fadeDurationMS=300)
 Hides this WebView.
void show ()
void show (bool fade, unsigned short fadeDurationMS=300)
 Shows this WebView.
void focus ()
 Sends a focus message to this webView to highlight active form elements, etc.
void unfocus ()
 Sends a 'blurs'/unfocus message to this webview, which causes form elements to become grayed out.
void raise ()
 'Raises' this WebView by popping it to the front of all other WebViews.
void move (int deltaX, int deltaY)
 Moves this WebView by relative amounts.
void getExtents (unsigned short &width, unsigned short &height)
 Retrieves the width and height that this WebView was created with.
int getRelativeX (int absX)
 Transforms an X-coordinate in screen-space to that of this WebView's relative space.
int getRelativeY (int absY)
 Transforms a Y-coordinate in screen-space to that of this WebView's relative space.
bool inDraggableRegion (int relX, int relY)
 Returns true if given relative X,Y coordinate is inside the draggable region.
bool isMaterialOnly ()
 Returns whether or not this WebView was created as a material.
ViewportOverlaygetOverlay ()
std::string getName ()
 Returns the name of this WebView.
std::string getType ()
 Returns the type of this WebView.
std::string getURL ()
 Returns the current URL of this WebView.
std::string getViewTextureName ()
 Returns the name of the Ogre::Material used internally by this WebView.
std::string getMaterialName ()
 Returns the name of the Ogre::Material used internally by this WebView.
bool getVisibility ()
 Returns whether or not this WebView is currently visible.
bool getNonStrictVisibility ()
 Returns whether or not this WebView is visible, ignoring fading.
void getDerivedUV (Ogre::Real &u1, Ogre::Real &v1, Ogre::Real &u2, Ogre::Real &v2)
 Gets the derived UV's of this WebView's internal texture.
void injectMouseMove (int xPos, int yPos)
 Injects the mouse's current coordinates (in this WebView's own local coordinate space, see WebView::getRelativeX and WebView::getRelativeY) into this WebView.
void injectMouseWheel (int scrollX, int scrollY)
 Injects mouse wheel events into this WebView.
void injectMouseDown (int xPos, int yPos)
 Injects mouse down events into this WebView.
void injectMouseUp (int xPos, int yPos)
 Injects mouse up events into this WebView.
void injectCut ()
void injectCopy ()
void injectPaste ()
void injectKeyEvent (bool press, int modifiers, int vk_code, int raw_scancode)
void injectTextEvent (std::string utf8)
void resize (int width, int height)

Static Public Attributes

static const WebViewBorderSize mDefaultBorder

Protected Member Functions

 WebView (Context *ctx, const std::string &name, const std::string &type, unsigned short width, unsigned short height, const OverlayPosition &viewPosition, Ogre::uchar zOrder, Tier tier, Ogre::Viewport *viewport, Network::IOStrandPtr postBackStrand, const WebViewBorderSize &border=mDefaultBorder)
 WebView (Context *ctx, const std::string &name, const std::string &type, unsigned short width, unsigned short height, Ogre::FilterOptions texFiltering, Network::IOStrandPtr postBackStrand)
 ~WebView ()
void createWebView (bool resetting)
void initializeWebView (bool resetting)
void cleanupWebView ()
void createMaterial ()
void loadResource (Ogre::Resource *resource)
void update ()
void updateFade ()
bool isPointOverMe (int x, int y)
boost::any dispatchToDelegate (const String &name, const JSArguments &args)
void dispatchToDelegateNoReturn (const String &name, const JSArguments &args)
virtual boost::any invoke (std::vector< boost::any > &params)
boost::any translateParamsAndInvoke (Invokable *, WebView *, const JSArguments &)
void forwardOnNavigateToInvokable (Invokable *_invokable, const String &url)
boost::any handleReadyCallback (WebView *wv, const JSArguments &args)
 Handle a callback from the page saying it is ready.
boost::any handleSetUIViewport (WebView *wv, const JSArguments &args)
 Handle callback from page indicating what portion of the screen should be drawn to, i.e.
boost::any userLog (WebView *wv, const JSArguments &args)
 Pass user logging request on to logging system.
boost::any handleOpenBrowser (WebView *wv, const JSArguments &args)
 Handle request by UI to open a *new* browser, not a link in a browser.
boost::any handleListenToBrowser (WebView *wv, const JSArguments &args)
 Handle a request to listen to a browser.
boost::any handleGetBrowserURL (WebView *wv, const JSArguments &args)
 Handle a request for the current URL of a browser.
void forwardBrowserNavigatedCallback (Liveness::Token alive, const String &cb_name, const String &url)
boost::any handleCloseBrowser (WebView *wv, const JSArguments &args)
 Close child browser by the given name.
void handleUnresponsiveTimeout (Liveness::Token alive)
void restartPage ()

Protected Attributes

ContextmContext
Network::IOStrandPtr postingStrand
std::string viewName
 the name of the webview, so as to allocate predictable ogre names to the textures and materials
std::string viewType
 The type of the webview, which is used when generating events.
String viewURL
 Currently loading URL of this WebView.
unsigned short viewWidth
 the width of the overlay and observed pixel view of the web page
unsigned short viewHeight
 the height of the overlay and observed pixel view of the web page
unsigned short mBorderLeft
 The left border of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.
unsigned short mBorderRight
 The right border of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.
unsigned short mBorderTop
 The top border/titlebar of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.
unsigned short mBorderBottom
 The bottom border of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.
ViewportOverlayoverlay
 Ogre overlay that may manage displaying this webpage perpendicular to the screen. NULL if webview is on a 3d element.
unsigned int maxUpdatePS
 How often the alpha mask and other items are updated on the web view.
Ogre::Timer timer
 Used to time the time between updates.
unsigned long lastUpdateTime
 last update time in milliseconds
float opacity
 how opaque this window is, set every update() to the ogre material (polling)
bool usingMask
 Whether the window is using a transparency mask.
unsigned char * alphaCache
 A cache of alpha values as observed upon every IPC call.
size_t alphaCachePitch
 the pitch of the alpha cache value (actual width always equal to texWidth and actual height always equal texHeight)
Ogre::Pass * matPass
 References into ogre internal materials.
Ogre::TextureUnitState * baseTexUnit
Ogre::TextureUnitState * maskTexUnit
bool ignoringTrans
 Whether mouse clicks over transparent areas of the webview is transparent.
float transparent
bool isWebViewTransparent
bool ignoringBounds
Ogre::TexturePtr viewTexture
Ogre::TexturePtr backingTexture
std::map< Berkelium::Widget
*, Ogre::TexturePtr > 
widgetTextures
double fadeValue
bool isFading
double deltaFadePerMS
double lastFadeTimeMS
bool compensateNPOT
 Whether the nearest power of two is used instead of the desired width/height (useful on apple machines where the graphics system gets kicked into software if a NPOT texture encountered.
bool okayToDelete
unsigned short texWidth
 The actual texture width (and alpha cache width ) allocated in ogre.
unsigned short texHeight
 The actual texture height (and alpha cache width ) allocated in ogre.
std::map< std::string, JSDelegatedelegateMap
 map from callback name to function1's
InvokablemExceptionHandler
Ogre::FilterOptions texFiltering
std::pair< std::string,
std::string > 
maskImageParameters
UpdateViewportCallback mUpdateViewportCallback
bool mReady
ReadyCallback mReadyCallback
ResetReadyCallback mResetReadyCallback
NavigatedCallback mNavigatedCallback
bool mUnresponsive

Friends

class WebViewManager

Detailed Description

A 'WebView' is essentially an offscreen browser window rendered to a dynamic texture (encapsulated as an Ogre Material) that can optionally be contained within a viewport overlay.


Member Typedef Documentation

typedef std::tr1::function<void(const String&)> Sirikata::Graphics::WebView::NavigatedCallback
typedef std::tr1::function<void()> Sirikata::Graphics::WebView::ReadyCallback
typedef std::tr1::function<void()> Sirikata::Graphics::WebView::ResetReadyCallback
typedef std::tr1::function<void(int32 left, int32 top, int32 right, int32 bottom)> Sirikata::Graphics::WebView::UpdateViewportCallback

Constructor & Destructor Documentation

Sirikata::Graphics::WebView::WebView ( Context ctx,
const std::string &  name,
const std::string &  type,
unsigned short  width,
unsigned short  height,
const OverlayPosition viewPosition,
Ogre::uchar  zOrder,
Tier  tier,
Ogre::Viewport *  viewport,
Network::IOStrandPtr  postBackStrand,
const WebViewBorderSize border = mDefaultBorder 
) [protected]
Sirikata::Graphics::WebView::WebView ( Context ctx,
const std::string &  name,
const std::string &  type,
unsigned short  width,
unsigned short  height,
Ogre::FilterOptions  texFiltering,
Network::IOStrandPtr  postBackStrand 
) [protected]
Sirikata::Graphics::WebView::~WebView ( ) [protected]

Member Function Documentation

void Sirikata::Graphics::WebView::bind ( const std::string &  name,
JSDelegate  callback 
)

Sets a global 'Client' callback that can be invoked via Javascript from within all pages loaded into this WebView.

Parameters:
nameThe name of the callback.
callbackThe C++ callback to invoke when called via Javascript.

References delegateMap, and name().

Referenced by Sirikata::Graphics::WebViewManager::createWebView(), Sirikata::Graphics::WebViewManager::createWebViewMaterial(), Sirikata::Graphics::OgreSystemInputHandler::ensureUI(), initializeWebView(), and invoke().

void Sirikata::Graphics::WebView::cleanupWebView ( ) [protected]

Referenced by ~WebView().

void Sirikata::Graphics::WebView::createMaterial ( ) [protected]
void Sirikata::Graphics::WebView::createWebView ( bool  resetting) [protected]
void Sirikata::Graphics::WebView::defaultEvent ( const String &  name)

If we can't actually render pages, invoke the given callback so that processing can continue.

This is useful if you expect an event from the WebView but Berkelium isn't available. Note that this is deferred by posting it so that it will be processed *after* the current event handler exits.

References dispatchToDelegateNoReturn(), Sirikata::Context::mainStrand, mContext, and Sirikata::Network::IOStrand::post().

Referenced by Sirikata::Graphics::OgreSystem::addModuleToUI(), and Sirikata::Graphics::OgreSystem::addTextModuleToUI().

boost::any Sirikata::Graphics::WebView::dispatchToDelegate ( const String &  name,
const JSArguments args 
) [protected]

References delegateMap.

void Sirikata::Graphics::WebView::dispatchToDelegateNoReturn ( const String &  name,
const JSArguments args 
) [inline, protected]

Referenced by defaultEvent().

void Sirikata::Graphics::WebView::evaluateJS ( const std::string &  javascript)
void Sirikata::Graphics::WebView::focus ( )

Sends a focus message to this webView to highlight active form elements, etc.

Referenced by Sirikata::Graphics::WebViewManager::focusWebView(), and raise().

void Sirikata::Graphics::WebView::forwardBrowserNavigatedCallback ( Liveness::Token  alive,
const String &  cb_name,
const String &  url 
) [protected]

References evaluateJS().

Referenced by handleListenToBrowser().

void Sirikata::Graphics::WebView::forwardOnNavigateToInvokable ( Invokable _invokable,
const String &  url 
) [protected]
void Sirikata::Graphics::WebView::getDerivedUV ( Ogre::Real &  u1,
Ogre::Real &  v1,
Ogre::Real &  u2,
Ogre::Real &  v2 
)

Gets the derived UV's of this WebView's internal texture.

On certain systems we must compensate for lack of NPOT-support on the videocard by using the next-highest POT texture. Normal WebViews compensate their UV's accordingly however WebViews created as materials will need to adjust their own by use of this function.

Parameters:
[out]u1The Ogre::Real that will be used to store the retrieved u1-coordinate.
[out]v1The Ogre::Real that will be used to store the retrieved v1-coordinate.
[out]u2The Ogre::Real that will be used to store the retrieved u2-coordinate.
[out]v2The Ogre::Real that will be used to store the retrieved v2-coordinate.

References compensateNPOT, texHeight, texWidth, viewHeight, and viewWidth.

Referenced by resize().

void Sirikata::Graphics::WebView::getExtents ( unsigned short &  width,
unsigned short &  height 
)

Retrieves the width and height that this WebView was created with.

Parameters:
[out]widthThe unsigned short that will be used to store the retrieved width.
[out]heightThe unsigned short that will be used to store the retrieved height.

References viewHeight, and viewWidth.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseMove().

std::string Sirikata::Graphics::WebView::getMaterialName ( )

Returns the name of the Ogre::Material used internally by this WebView.

References viewName.

Referenced by createMaterial(), WebView(), and ~WebView().

std::string Sirikata::Graphics::WebView::getName ( )

Returns the name of this WebView.

References viewName.

Referenced by Sirikata::Graphics::WebViewManager::onRaiseWebViewEvent().

bool Sirikata::Graphics::WebView::getNonStrictVisibility ( )

Returns whether or not this WebView is visible, ignoring fading.

In other words, this will return true if show() was called last, false if hide() was called last, even if the WebView is still fading out.

References isFading, Sirikata::Graphics::ViewportOverlay::isVisible, and overlay.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseMove().

ViewportOverlay * Sirikata::Graphics::WebView::getOverlay ( )

References overlay.

int Sirikata::Graphics::WebView::getRelativeX ( int  absX)

Transforms an X-coordinate in screen-space to that of this WebView's relative space.

Parameters:
absXThe X-coordinate in screen-space to transform.
Returns:
The X-coordinate in this WebView's relative space.

References Sirikata::Graphics::ViewportOverlay::getRelativeX(), isMaterialOnly(), and overlay.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseDown(), Sirikata::Graphics::WebViewManager::injectMouseMove(), and Sirikata::Graphics::WebViewManager::injectMouseUp().

int Sirikata::Graphics::WebView::getRelativeY ( int  absY)

Transforms a Y-coordinate in screen-space to that of this WebView's relative space.

Parameters:
absYThe Y-coordinate in screen-space to transform.
Returns:
The Y-coordinate in this WebView's relative space.

References Sirikata::Graphics::ViewportOverlay::getRelativeY(), isMaterialOnly(), and overlay.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseDown(), Sirikata::Graphics::WebViewManager::injectMouseMove(), and Sirikata::Graphics::WebViewManager::injectMouseUp().

std::string Sirikata::Graphics::WebView::getType ( )

Returns the type of this WebView.

References viewType.

std::string Sirikata::Graphics::WebView::getURL ( )

Returns the current URL of this WebView.

References viewURL.

std::string Sirikata::Graphics::WebView::getViewTextureName ( )

Returns the name of the Ogre::Material used internally by this WebView.

References viewName.

Referenced by createMaterial(), and resize().

bool Sirikata::Graphics::WebView::getVisibility ( )

Returns whether or not this WebView is currently visible.

(See WebView::hide and WebView::show)

References fadeValue, isMaterialOnly(), Sirikata::Graphics::ViewportOverlay::isVisible, and overlay.

boost::any Sirikata::Graphics::WebView::handleCloseBrowser ( WebView wv,
const JSArguments args 
) [protected]
boost::any Sirikata::Graphics::WebView::handleGetBrowserURL ( WebView wv,
const JSArguments args 
) [protected]

Handle a request for the current URL of a browser.

References Sirikata::Graphics::WebViewManager::getSingleton(), Sirikata::Graphics::WebViewManager::getWebView(), name(), and viewURL.

Referenced by initializeWebView().

boost::any Sirikata::Graphics::WebView::handleListenToBrowser ( WebView wv,
const JSArguments args 
) [protected]
boost::any Sirikata::Graphics::WebView::handleOpenBrowser ( WebView wv,
const JSArguments args 
) [protected]

Handle request by UI to open a *new* browser, not a link in a browser.

This is critical because it is necessary to isolate the browser instead of just, e.g., using an iframe.

References Sirikata::Graphics::WebViewManager::createWebView(), Sirikata::Graphics::WebViewManager::getSingleton(), loadURL(), mContext, name(), postingStrand, Sirikata::RP_CENTER, setTransparent(), Sirikata::Graphics::TIER_MIDDLE, and url.

Referenced by initializeWebView().

boost::any Sirikata::Graphics::WebView::handleReadyCallback ( WebView wv,
const JSArguments args 
) [protected]

Handle a callback from the page saying it is ready.

This isn't guaranteed to always occur -- it only happens if sirikata.event('__ready') is triggered from within the page.

References mReady, mReadyCallback, and mResetReadyCallback.

Referenced by initializeWebView().

boost::any Sirikata::Graphics::WebView::handleSetUIViewport ( WebView wv,
const JSArguments args 
) [protected]

Handle callback from page indicating what portion of the screen should be drawn to, i.e.

the region unobscured by UI elements.

References mUpdateViewportCallback.

Referenced by initializeWebView().

void Sirikata::Graphics::WebView::handleUnresponsiveTimeout ( Liveness::Token  alive) [protected]
void Sirikata::Graphics::WebView::hide ( bool  fade,
unsigned short  fadeDurationMS = 300 
)

Hides this WebView.

Parameters:
fadeWhether or not to fade this WebView down.
fadeDurationMSIf fading, the number of milliseconds to fade for.

References deltaFadePerMS, fadeValue, Sirikata::Graphics::ViewportOverlay::hide(), isFading, lastFadeTimeMS, overlay, timer, and updateFade().

void Sirikata::Graphics::WebView::hide ( )
bool Sirikata::Graphics::WebView::inDraggableRegion ( int  relX,
int  relY 
)

Returns true if given relative X,Y coordinate is inside the draggable region.

Parameters:
relXThe relative X-coordinate
relYThe relative Y-coordinate
Returns:
Whether or not the coordinate is in the draggable region

References mBorderTop.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseDown(), and Sirikata::Graphics::WebViewManager::injectMouseUp().

void Sirikata::Graphics::WebView::initializeWebView ( bool  resetting) [protected]
void Sirikata::Graphics::WebView::injectCopy ( )
void Sirikata::Graphics::WebView::injectCut ( )
void Sirikata::Graphics::WebView::injectKeyEvent ( bool  press,
int  modifiers,
int  vk_code,
int  raw_scancode 
)
void Sirikata::Graphics::WebView::injectMouseDown ( int  xPos,
int  yPos 
)

Injects mouse down events into this WebView.

You must supply the current coordinates of the mouse in this WebView's own local coordinate space. (see WebView::getRelativeX and WebView::getRelativeY)

Parameters:
xPosThe absolute X-Value of the mouse, relative to this WebView's origin.
yPosThe absolute Y-Value of the mouse, relative to this WebView's origin.

References mBorderLeft, mBorderRight, mBorderTop, and viewWidth.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseDown().

void Sirikata::Graphics::WebView::injectMouseMove ( int  xPos,
int  yPos 
)

Injects the mouse's current coordinates (in this WebView's own local coordinate space, see WebView::getRelativeX and WebView::getRelativeY) into this WebView.

Parameters:
xPosThe X-coordinate of the mouse, relative to this WebView's origin.
yPosThe Y-coordinate of the mouse, relative to this WebView's origin.

References mBorderLeft, mBorderRight, mBorderTop, and viewWidth.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseMove().

void Sirikata::Graphics::WebView::injectMouseUp ( int  xPos,
int  yPos 
)

Injects mouse up events into this WebView.

You must supply the current coordinates of the mouse in this WebView's own local coordinate space. (see WebView::getRelativeX and WebView::getRelativeY)

Parameters:
xPosThe absolute X-Value of the mouse, relative to this WebView's origin.
yPosThe absolute Y-Value of the mouse, relative to this WebView's origin.

References mBorderLeft, mBorderRight, mBorderTop, and viewWidth.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseUp().

void Sirikata::Graphics::WebView::injectMouseWheel ( int  scrollX,
int  scrollY 
)

Injects mouse wheel events into this WebView.

Parameters:
scrollXscroll distance on X axis
scrollYscroll distance on Y axis

Referenced by Sirikata::Graphics::WebViewManager::injectMouseWheel().

void Sirikata::Graphics::WebView::injectPaste ( )
void Sirikata::Graphics::WebView::injectTextEvent ( std::string  utf8)
boost::any Sirikata::Graphics::WebView::invoke ( std::vector< boost::any > &  params) [protected, virtual]
bool Sirikata::Graphics::WebView::isMaterialOnly ( )

Returns whether or not this WebView was created as a material.

References overlay.

Referenced by getRelativeX(), getRelativeY(), getVisibility(), Sirikata::Graphics::WebViewManager::injectMouseMove(), and isPointOverMe().

bool Sirikata::Graphics::WebView::isPointOverMe ( int  x,
int  y 
) [protected]
void Sirikata::Graphics::WebView::loadFile ( const std::string &  file)
void Sirikata::Graphics::WebView::loadHTML ( const std::string &  html)

Loads a string of HTML directly into the main frame.

Note:
Relative URLs will be resolved using the base directory.

Referenced by Sirikata::Graphics::OgreSystem::createWindow().

void Sirikata::Graphics::WebView::loadResource ( Ogre::Resource *  resource) [protected]
void Sirikata::Graphics::WebView::loadURL ( const std::string &  url)
void Sirikata::Graphics::WebView::move ( int  deltaX,
int  deltaY 
)

Moves this WebView by relative amounts.

(not applicable to WebViews created as materials)

Parameters:
deltaXThe relative X amount to move this WebView by. Positive amounts move it right.
deltaYThe relative Y amount to move this WebView by. Positive amounts move it down.

References Sirikata::Graphics::ViewportOverlay::move(), and overlay.

Referenced by Sirikata::Graphics::WebViewManager::injectMouseMove().

void Sirikata::Graphics::WebView::raise ( )

'Raises' this WebView by popping it to the front of all other WebViews.

(not applicable to WebViews created as materials)

References focus(), Sirikata::Graphics::WebViewManager::focusWebView(), Sirikata::Graphics::WebViewManager::getSingleton(), and overlay.

void Sirikata::Graphics::WebView::resetPosition ( )

Resets the position of this WebView to its default position.

(not applicable to WebViews created as materials)

References overlay, and Sirikata::Graphics::ViewportOverlay::resetPosition().

void Sirikata::Graphics::WebView::resize ( int  width,
int  height 
)
void Sirikata::Graphics::WebView::restartPage ( ) [protected]
void Sirikata::Graphics::WebView::setIgnoreBounds ( bool  ignoreBounds = true)

Normally, mouse movement is only injected into a specific WebView from WebViewManager if the mouse is within the boundaries of a WebView and over an opaque area (not transparent).

This behavior may be detrimental to certain WebViews, for example an animated 'dock' with floating icons on a transparent background: the mouse-out event would never be invoked on each icon because the WebView only received mouse movement input over opaque areas. Use this function to makes this WebView always inject mouse movement, regardless of boundaries or transparency.

Parameters:
ignoreBoundsWhether or not this WebView should ignore bounds/transparency when injecting mouse movement.
Note:
The occlusivity of each WebView will still be respected, mouse movement will not be injected if another WebView is occluding this WebView.

References ignoringBounds.

void Sirikata::Graphics::WebView::setIgnoreTransparent ( bool  ignoreTrans,
float  threshold = 0.05 
)

Using alpha-masking/transparency doesn't just affect the visuals of a WebView; by default, WebViews 'ignore' mouse movement/clicks over 'transparent' areas of a WebView (Areas with opacity less than 5%).

You may disable this behavior or redefine the 'transparent' threshold of opacity to something else other than 5%.

Parameters:
ignoreTransWhether or not this WebView should ignore 'transparent' areas when mouse-picking.
thresholdAreas with opacity less than this percent will be ignored (if ignoreTrans is true, of course). Default is 5% (0.05).

References ignoringTrans, and transparent.

void Sirikata::Graphics::WebView::setMaxUPS ( unsigned int  maxUPS = 0)

Adjusts the number of times per second this WebView may update.

Parameters:
maxUPSThe maximum number of times per second this WebView can update. Set this to '0' to use no update limiting (default).

References maxUpdatePS.

void Sirikata::Graphics::WebView::setNavigatedCallback ( NavigatedCallback  cb)

References mNavigatedCallback.

Referenced by handleListenToBrowser(), and invoke().

void Sirikata::Graphics::WebView::setOpacity ( float  opacity)

Changes the overall opacity of this WebView to a certain percentage.

Parameters:
opacityThe opacity percentage as a float. Fully Opaque = 1.0, Fully Transparent = 0.0.

References opacity.

void Sirikata::Graphics::WebView::setPosition ( const OverlayPosition viewPosition)

Sets the default position of this WebView to a new position and then moves the WebView to that position.

(not applicable to WebViews created as materials)

Parameters:
viewPositionThe new OverlayPosition to set the WebView to.

References overlay, and Sirikata::Graphics::ViewportOverlay::setPosition().

Referenced by Sirikata::Graphics::WebViewManager::injectMouseMove(), and Sirikata::Graphics::WebViewManager::onResizeTooltip().

void Sirikata::Graphics::WebView::setReadyCallback ( ReadyCallback  cb)
void Sirikata::Graphics::WebView::setResetReadyCallback ( ResetReadyCallback  cb)
void Sirikata::Graphics::WebView::setTransparent ( bool  isTransparent)
void Sirikata::Graphics::WebView::setUpdateViewportCallback ( UpdateViewportCallback  cb)
void Sirikata::Graphics::WebView::setViewport ( Ogre::Viewport *  newViewport)
void Sirikata::Graphics::WebView::show ( )
void Sirikata::Graphics::WebView::show ( bool  fade,
unsigned short  fadeDurationMS = 300 
)

Shows this WebView.

Parameters:
fadeWhether or not to fade the WebView up.
fadeDurationMSIf fading, the number of milliseconds to fade for.

References deltaFadePerMS, fadeValue, isFading, lastFadeTimeMS, overlay, Sirikata::Graphics::ViewportOverlay::show(), timer, and updateFade().

boost::any Sirikata::Graphics::WebView::translateParamsAndInvoke ( Invokable _invokable,
WebView wv,
const JSArguments args 
) [protected]
void Sirikata::Graphics::WebView::unfocus ( )

Sends a 'blurs'/unfocus message to this webview, which causes form elements to become grayed out.

void Sirikata::Graphics::WebView::update ( ) [protected]
void Sirikata::Graphics::WebView::updateFade ( ) [protected]
boost::any Sirikata::Graphics::WebView::userLog ( WebView wv,
const JSArguments args 
) [protected]

Friends And Related Function Documentation

friend class WebViewManager [friend]

Member Data Documentation

unsigned char* Sirikata::Graphics::WebView::alphaCache [protected]

A cache of alpha values as observed upon every IPC call.

Referenced by isPointOverMe(), resize(), setTransparent(), WebView(), and ~WebView().

the pitch of the alpha cache value (actual width always equal to texWidth and actual height always equal texHeight)

Referenced by isPointOverMe(), resize(), setTransparent(), and WebView().

Ogre::TexturePtr Sirikata::Graphics::WebView::backingTexture [protected]

Referenced by resize().

Ogre::TextureUnitState* Sirikata::Graphics::WebView::baseTexUnit [protected]

Whether the nearest power of two is used instead of the desired width/height (useful on apple machines where the graphics system gets kicked into software if a NPOT texture encountered.

Referenced by createMaterial(), getDerivedUV(), resize(), and WebView().

std::map<std::string, JSDelegate> Sirikata::Graphics::WebView::delegateMap [protected]

map from callback name to function1's

Referenced by bind(), and dispatchToDelegate().

Referenced by hide(), show(), updateFade(), and WebView().

Referenced by setIgnoreBounds(), and WebView().

Whether mouse clicks over transparent areas of the webview is transparent.

Referenced by isPointOverMe(), setIgnoreTransparent(), and WebView().

Referenced by setTransparent(), update(), and WebView().

Referenced by hide(), show(), updateFade(), and WebView().

last update time in milliseconds

Referenced by update(), and WebView().

std::pair<std::string, std::string> Sirikata::Graphics::WebView::maskImageParameters [protected]
Ogre::TextureUnitState* Sirikata::Graphics::WebView::maskTexUnit [protected]

Referenced by resize(), and WebView().

Ogre::Pass* Sirikata::Graphics::WebView::matPass [protected]

References into ogre internal materials.

Referenced by createMaterial(), resize(), and WebView().

unsigned int Sirikata::Graphics::WebView::maxUpdatePS [protected]

How often the alpha mask and other items are updated on the web view.

Referenced by setMaxUPS(), update(), and WebView().

unsigned short Sirikata::Graphics::WebView::mBorderBottom [protected]

The bottom border of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.

Referenced by initializeWebView(), resize(), and WebView().

unsigned short Sirikata::Graphics::WebView::mBorderLeft [protected]

The left border of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.

Referenced by initializeWebView(), injectMouseDown(), injectMouseMove(), injectMouseUp(), resize(), and WebView().

unsigned short Sirikata::Graphics::WebView::mBorderRight [protected]

The right border of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.

Referenced by initializeWebView(), injectMouseDown(), injectMouseMove(), injectMouseUp(), resize(), and WebView().

unsigned short Sirikata::Graphics::WebView::mBorderTop [protected]

The top border/titlebar of the frame around the window. Chrome is told about a window that's viewWidth-mBorderLeft-mBorderRight. May be 0.

Referenced by inDraggableRegion(), initializeWebView(), injectMouseDown(), injectMouseMove(), injectMouseUp(), resize(), and WebView().

Referenced by invoke(), and WebView().

Referenced by setNavigatedCallback().

Referenced by handleReadyCallback(), and WebView().

Referenced by WebView().

how opaque this window is, set every update() to the ogre material (polling)

Referenced by createMaterial(), setOpacity(), update(), and WebView().

Referenced by handleOpenBrowser().

Ogre::FilterOptions Sirikata::Graphics::WebView::texFiltering [protected]

Referenced by createMaterial(), resize(), and WebView().

unsigned short Sirikata::Graphics::WebView::texHeight [protected]

The actual texture height (and alpha cache width ) allocated in ogre.

Referenced by createMaterial(), getDerivedUV(), resize(), setTransparent(), and WebView().

unsigned short Sirikata::Graphics::WebView::texWidth [protected]

The actual texture width (and alpha cache width ) allocated in ogre.

Referenced by createMaterial(), getDerivedUV(), resize(), setTransparent(), and WebView().

Ogre::Timer Sirikata::Graphics::WebView::timer [protected]

Used to time the time between updates.

Referenced by hide(), show(), update(), and updateFade().

Whether the window is using a transparency mask.

Referenced by setTransparent(), update(), and WebView().

unsigned short Sirikata::Graphics::WebView::viewHeight [protected]

the height of the overlay and observed pixel view of the web page

Referenced by createMaterial(), getDerivedUV(), getExtents(), initializeWebView(), resize(), and WebView().

std::string Sirikata::Graphics::WebView::viewName [protected]

the name of the webview, so as to allocate predictable ogre names to the textures and materials

Referenced by getMaterialName(), getName(), getViewTextureName(), and WebView().

Ogre::TexturePtr Sirikata::Graphics::WebView::viewTexture [protected]

Referenced by createMaterial(), resize(), and ~WebView().

std::string Sirikata::Graphics::WebView::viewType [protected]

The type of the webview, which is used when generating events.

Referenced by getType(), and WebView().

Currently loading URL of this WebView.

Loading may still be in progress!

Referenced by getURL(), handleGetBrowserURL(), invoke(), and WebView().

unsigned short Sirikata::Graphics::WebView::viewWidth [protected]

the width of the overlay and observed pixel view of the web page

Referenced by createMaterial(), getDerivedUV(), getExtents(), initializeWebView(), injectMouseDown(), injectMouseMove(), injectMouseUp(), resize(), and WebView().

std::map<Berkelium::Widget*,Ogre::TexturePtr> Sirikata::Graphics::WebView::widgetTextures [protected]

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