Sirikata
|
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>
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. | |
ViewportOverlay * | getOverlay () |
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 > ¶ms) |
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 | |
Context * | mContext |
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. | |
ViewportOverlay * | overlay |
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, JSDelegate > | delegateMap |
map from callback name to function1's | |
Invokable * | mExceptionHandler |
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 |
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.
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 |
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] |
References alphaCache, alphaCachePitch, baseTexUnit, compensateNPOT, createMaterial(), deltaFadePerMS, fadeValue, getMaterialName(), ignoringBounds, ignoringTrans, isFading, isWebViewTransparent, lastFadeTimeMS, lastUpdateTime, maskTexUnit, matPass, maxUpdatePS, Sirikata::Graphics::WebView::WebViewBorderSize::mBorderBottom, mBorderBottom, Sirikata::Graphics::WebView::WebViewBorderSize::mBorderLeft, mBorderLeft, Sirikata::Graphics::WebView::WebViewBorderSize::mBorderRight, mBorderRight, Sirikata::Graphics::WebView::WebViewBorderSize::mBorderTop, mBorderTop, mExceptionHandler, mReady, mUnresponsive, name(), okayToDelete, opacity, overlay, Sirikata::Graphics::ViewportOverlay::panel, texFiltering, texHeight, texWidth, transparent, usingMask, viewHeight, viewName, viewType, viewURL, and viewWidth.
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] |
References alphaCache, alphaCachePitch, baseTexUnit, compensateNPOT, createMaterial(), deltaFadePerMS, fadeValue, ignoringBounds, ignoringTrans, isFading, lastFadeTimeMS, lastUpdateTime, maskTexUnit, matPass, maxUpdatePS, mBorderBottom, mBorderLeft, mBorderRight, mBorderTop, mExceptionHandler, mReady, mUnresponsive, name(), okayToDelete, opacity, overlay, texFiltering, texHeight, texWidth, transparent, usingMask, viewHeight, viewName, viewType, and viewWidth.
Sirikata::Graphics::WebView::~WebView | ( | ) | [protected] |
References alphaCache, cleanupWebView(), getMaterialName(), Sirikata::Liveness::letDie(), overlay, and viewTexture.
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.
name | The name of the callback. |
callback | The 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] |
References baseTexUnit, compensateNPOT, getMaterialName(), getViewTextureName(), matPass, opacity, texFiltering, texHeight, texWidth, viewHeight, viewTexture, and viewWidth.
Referenced by WebView().
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 | ) |
Evaluates Javascript in the context of the current page.
javascript | The Javascript to evaluate/execute. |
References Sirikata::Logging::detailed, and SILOG.
Referenced by Sirikata::Graphics::OgreSystem::addModuleToUI(), Sirikata::Graphics::OgreSystem::addTextModuleToUI(), Sirikata::Graphics::OgreSystemInputHandler::alert(), Sirikata::Graphics::OgreSystem::evalInUI(), forwardBrowserNavigatedCallback(), Sirikata::Graphics::WebViewManager::handleTooltip(), and invoke().
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] |
References Sirikata::Invokable::asAny(), and Sirikata::Invokable::invoke().
Referenced by invoke().
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.
[out] | u1 | The Ogre::Real that will be used to store the retrieved u1-coordinate. |
[out] | v1 | The Ogre::Real that will be used to store the retrieved v1-coordinate. |
[out] | u2 | The Ogre::Real that will be used to store the retrieved u2-coordinate. |
[out] | v2 | The 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.
[out] | width | The unsigned short that will be used to store the retrieved width. |
[out] | height | The 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.
absX | The X-coordinate in screen-space to transform. |
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.
absY | The Y-coordinate in screen-space to transform. |
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 | ( | ) |
std::string Sirikata::Graphics::WebView::getURL | ( | ) |
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] |
Close child browser by the given name.
References Sirikata::Graphics::WebViewManager::destroyWebView(), Sirikata::Graphics::WebViewManager::getSingleton(), and name().
Referenced by initializeWebView().
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] |
Handle a request to listen to a browser.
References forwardBrowserNavigatedCallback(), Sirikata::Graphics::WebViewManager::getSingleton(), Sirikata::Graphics::WebViewManager::getWebView(), Sirikata::Liveness::livenessToken(), name(), and setNavigatedCallback().
Referenced by initializeWebView().
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.
fade | Whether or not to fade this WebView down. |
fadeDurationMS | If 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 | ( | ) |
Referenced by Sirikata::Graphics::WebViewManager::handleTooltip(), and invoke().
bool Sirikata::Graphics::WebView::inDraggableRegion | ( | int | relX, |
int | relY | ||
) |
Returns true if given relative X,Y coordinate is inside the draggable region.
relX | The relative X-coordinate |
relY | The relative Y-coordinate |
References mBorderTop.
Referenced by Sirikata::Graphics::WebViewManager::injectMouseDown(), and Sirikata::Graphics::WebViewManager::injectMouseUp().
void Sirikata::Graphics::WebView::initializeWebView | ( | bool | resetting | ) | [protected] |
References bind(), handleCloseBrowser(), handleGetBrowserURL(), handleListenToBrowser(), handleOpenBrowser(), handleReadyCallback(), handleSetUIViewport(), mBorderBottom, mBorderLeft, mBorderRight, mBorderTop, userLog(), viewHeight, and viewWidth.
Referenced by createWebView().
void Sirikata::Graphics::WebView::injectCopy | ( | ) |
Referenced by Sirikata::Graphics::WebViewManager::injectCopy().
void Sirikata::Graphics::WebView::injectCut | ( | ) |
Referenced by Sirikata::Graphics::WebViewManager::injectCut().
void Sirikata::Graphics::WebView::injectKeyEvent | ( | bool | press, |
int | modifiers, | ||
int | vk_code, | ||
int | raw_scancode | ||
) |
Referenced by Sirikata::Graphics::WebViewManager::injectKeyEvent().
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)
xPos | The absolute X-Value of the mouse, relative to this WebView's origin. |
yPos | The 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.
xPos | The X-coordinate of the mouse, relative to this WebView's origin. |
yPos | The 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)
xPos | The absolute X-Value of the mouse, relative to this WebView's origin. |
yPos | The 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.
scrollX | scroll distance on X axis |
scrollY | scroll distance on Y axis |
Referenced by Sirikata::Graphics::WebViewManager::injectMouseWheel().
void Sirikata::Graphics::WebView::injectPaste | ( | ) |
Referenced by Sirikata::Graphics::WebViewManager::injectPaste().
void Sirikata::Graphics::WebView::injectTextEvent | ( | std::string | utf8 | ) |
Referenced by Sirikata::Graphics::WebViewManager::injectTextEvent().
boost::any Sirikata::Graphics::WebView::invoke | ( | std::vector< boost::any > & | params | ) | [protected, virtual] |
Reimplemented from Sirikata::Invokable.
References Sirikata::Invokable::anyAsInvokable(), Sirikata::Invokable::anyAsString(), Sirikata::Invokable::anyIsInvokable(), Sirikata::Invokable::anyIsString(), Sirikata::Invokable::asAny(), bind(), Sirikata::Logging::detailed, Sirikata::Logging::error, evaluateJS(), Sirikata::Graphics::WebViewManager::focusWebView(), forwardOnNavigateToInvokable(), Sirikata::Graphics::WebViewManager::getSingleton(), hide(), mExceptionHandler, setNavigatedCallback(), show(), SILOG, translateParamsAndInvoke(), and viewURL.
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] |
References alphaCache, alphaCachePitch, Sirikata::Graphics::ViewportOverlay::getRelativeX(), Sirikata::Graphics::ViewportOverlay::getRelativeY(), ignoringTrans, isMaterialOnly(), Sirikata::Graphics::ViewportOverlay::isVisible, overlay, transparent, and Sirikata::Graphics::ViewportOverlay::viewport.
Referenced by Sirikata::Graphics::WebViewManager::injectMouseMove().
void Sirikata::Graphics::WebView::loadFile | ( | const std::string & | file | ) |
Loads a local file into the main frame.
References Sirikata::Graphics::WebViewManager::getBaseDir(), Sirikata::Graphics::WebViewManager::getSingleton(), and url.
Referenced by Sirikata::Graphics::OgreSystemInputHandler::createUIAction(), Sirikata::Graphics::OgreSystem::createWindow(), and Sirikata::Graphics::OgreSystemInputHandler::ensureUI().
void Sirikata::Graphics::WebView::loadHTML | ( | const std::string & | html | ) |
Loads a string of HTML directly into the main frame.
Referenced by Sirikata::Graphics::OgreSystem::createWindow().
void Sirikata::Graphics::WebView::loadResource | ( | Ogre::Resource * | resource | ) | [protected] |
void Sirikata::Graphics::WebView::loadURL | ( | const std::string & | url | ) |
Loads a URL into the main frame.
Referenced by Sirikata::Graphics::OgreSystem::createWindow(), handleOpenBrowser(), and Sirikata::Graphics::PriorityDownloadPlanner::loadDependentTextures().
void Sirikata::Graphics::WebView::move | ( | int | deltaX, |
int | deltaY | ||
) |
Moves this WebView by relative amounts.
(not applicable to WebViews created as materials)
deltaX | The relative X amount to move this WebView by. Positive amounts move it right. |
deltaY | The 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 | ||
) |
References alphaCache, alphaCachePitch, backingTexture, baseTexUnit, compensateNPOT, getDerivedUV(), getViewTextureName(), maskTexUnit, matPass, mBorderBottom, mBorderLeft, mBorderRight, mBorderTop, overlay, Sirikata::Graphics::ViewportOverlay::panel, Sirikata::Graphics::ViewportOverlay::resize(), texFiltering, texHeight, texWidth, viewHeight, viewTexture, and viewWidth.
Referenced by Sirikata::Graphics::WebViewManager::handleTooltip(), Sirikata::Graphics::WebViewManager::injectMouseMove(), Sirikata::Graphics::WebViewManager::onResizeTooltip(), and Sirikata::Graphics::OgreSystemInputHandler::windowResized().
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.
ignoreBounds | Whether or not this WebView should ignore bounds/transparency when injecting mouse movement. |
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%.
ignoreTrans | Whether or not this WebView should ignore 'transparent' areas when mouse-picking. |
threshold | Areas 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.
maxUPS | The 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 | ) |
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)
viewPosition | The 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 | ) |
References Sirikata::Context::mainStrand, mContext, mReadyCallback, and Sirikata::Network::IOStrand::post().
Referenced by Sirikata::Graphics::OgreSystem::initialize().
void Sirikata::Graphics::WebView::setResetReadyCallback | ( | ResetReadyCallback | cb | ) |
References mResetReadyCallback.
Referenced by Sirikata::Graphics::OgreSystem::initialize().
void Sirikata::Graphics::WebView::setTransparent | ( | bool | isTransparent | ) |
References alphaCache, alphaCachePitch, isWebViewTransparent, texHeight, texWidth, and usingMask.
Referenced by Sirikata::Graphics::OgreSystemInputHandler::ensureUI(), and handleOpenBrowser().
void Sirikata::Graphics::WebView::setUpdateViewportCallback | ( | UpdateViewportCallback | cb | ) |
References mUpdateViewportCallback.
Referenced by Sirikata::Graphics::OgreSystem::initialize().
void Sirikata::Graphics::WebView::setViewport | ( | Ogre::Viewport * | newViewport | ) |
References overlay, and Sirikata::Graphics::ViewportOverlay::setViewport().
void Sirikata::Graphics::WebView::show | ( | ) |
void Sirikata::Graphics::WebView::show | ( | bool | fade, |
unsigned short | fadeDurationMS = 300 |
||
) |
Shows this WebView.
fade | Whether or not to fade the WebView up. |
fadeDurationMS | If 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] |
References Sirikata::Invokable::asAny(), and Sirikata::Invokable::invoke().
Referenced by invoke().
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] |
References baseTexUnit, fadeValue, isWebViewTransparent, lastUpdateTime, maxUpdatePS, opacity, timer, updateFade(), and usingMask.
Referenced by Sirikata::Graphics::WebViewManager::Update().
void Sirikata::Graphics::WebView::updateFade | ( | ) | [protected] |
References deltaFadePerMS, fadeValue, Sirikata::Graphics::ViewportOverlay::hide(), isFading, lastFadeTimeMS, overlay, and timer.
boost::any Sirikata::Graphics::WebView::userLog | ( | WebView * | wv, |
const JSArguments & | args | ||
) | [protected] |
Pass user logging request on to logging system.
References Sirikata::Logging::debug, Sirikata::Logging::detailed, Sirikata::Logging::error, Sirikata::Logging::fatal, Sirikata::Logging::info, Sirikata::Logging::insane, SILOG, and Sirikata::Logging::warning.
Referenced by initializeWebView().
friend class WebViewManager [friend] |
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().
size_t Sirikata::Graphics::WebView::alphaCachePitch [protected] |
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] |
Referenced by createMaterial(), resize(), update(), and WebView().
bool Sirikata::Graphics::WebView::compensateNPOT [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().
double Sirikata::Graphics::WebView::deltaFadePerMS [protected] |
Referenced by hide(), show(), updateFade(), and WebView().
double Sirikata::Graphics::WebView::fadeValue [protected] |
Referenced by getVisibility(), hide(), show(), update(), updateFade(), and WebView().
bool Sirikata::Graphics::WebView::ignoringBounds [protected] |
Referenced by setIgnoreBounds(), and WebView().
bool Sirikata::Graphics::WebView::ignoringTrans [protected] |
Whether mouse clicks over transparent areas of the webview is transparent.
Referenced by isPointOverMe(), setIgnoreTransparent(), and WebView().
bool Sirikata::Graphics::WebView::isFading [protected] |
Referenced by getNonStrictVisibility(), hide(), show(), updateFade(), and WebView().
bool Sirikata::Graphics::WebView::isWebViewTransparent [protected] |
Referenced by setTransparent(), update(), and WebView().
double Sirikata::Graphics::WebView::lastFadeTimeMS [protected] |
Referenced by hide(), show(), updateFade(), and WebView().
unsigned long Sirikata::Graphics::WebView::lastUpdateTime [protected] |
std::pair<std::string, std::string> Sirikata::Graphics::WebView::maskImageParameters [protected] |
Ogre::TextureUnitState* Sirikata::Graphics::WebView::maskTexUnit [protected] |
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().
Context* Sirikata::Graphics::WebView::mContext [protected] |
Referenced by defaultEvent(), handleOpenBrowser(), and setReadyCallback().
Invokable* Sirikata::Graphics::WebView::mExceptionHandler [protected] |
Referenced by setNavigatedCallback().
bool Sirikata::Graphics::WebView::mReady [protected] |
Referenced by handleReadyCallback(), and WebView().
Referenced by handleReadyCallback(), and setReadyCallback().
Referenced by handleReadyCallback(), and setResetReadyCallback().
bool Sirikata::Graphics::WebView::mUnresponsive [protected] |
Referenced by WebView().
Referenced by handleSetUIViewport(), and setUpdateViewportCallback().
bool Sirikata::Graphics::WebView::okayToDelete [protected] |
Referenced by Sirikata::Graphics::WebViewManager::destroyWebView(), and WebView().
float Sirikata::Graphics::WebView::opacity [protected] |
how opaque this window is, set every update() to the ogre material (polling)
Referenced by createMaterial(), setOpacity(), update(), and WebView().
ViewportOverlay* Sirikata::Graphics::WebView::overlay [protected] |
Ogre overlay that may manage displaying this webpage perpendicular to the screen. NULL if webview is on a 3d element.
Referenced by Sirikata::Graphics::WebViewManager::createWebView(), Sirikata::Graphics::WebViewManager::focusWebView(), getNonStrictVisibility(), getOverlay(), getRelativeX(), getRelativeY(), Sirikata::Graphics::WebViewManager::getTopWebView(), getVisibility(), hide(), Sirikata::Graphics::WebViewManager::injectMouseMove(), isMaterialOnly(), isPointOverMe(), move(), raise(), resetPosition(), resize(), setPosition(), setViewport(), show(), updateFade(), WebView(), 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().
float Sirikata::Graphics::WebView::transparent [protected] |
Referenced by isPointOverMe(), setIgnoreTransparent(), and WebView().
bool Sirikata::Graphics::WebView::usingMask [protected] |
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] |
String Sirikata::Graphics::WebView::viewURL [protected] |
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] |