Sirikata
|
Supreme dictator and Singleton: WebViewManager. More...
#include <WebViewManager.hpp>
Public Member Functions | |
WebViewManager (Ogre::Viewport *defaultViewport, Sirikata::Input::InputManager *inputMgr, const std::string &binDirectory, const std::string &baseDirectory) | |
Creates the WebViewManager singleton. | |
~WebViewManager () | |
Destroys any active WebViews, the WebViewMouse singleton (if instantiated). | |
void | Update () |
Gives each active WebView a chance to update, each may or may not update their internal textures based on various conditions. | |
WebView * | createWebView (Context *ctx, const std::string &webViewName, const std::string &webViewType, unsigned short width, unsigned short height, const OverlayPosition &webViewPosition, Network::IOStrandPtr postStrand, bool asyncRender=false, int maxAsyncRenderRate=70, Tier tier=TIER_MIDDLE, Ogre::Viewport *viewport=0, const WebView::WebViewBorderSize &border=WebView::mDefaultBorder) |
Creates a WebView. | |
WebView * | createWebViewMaterial (Context *ctx, const std::string &webViewName, unsigned short width, unsigned short height, Network::IOStrandPtr postingStrand, bool asyncRender=false, int maxAsyncRenderRate=70, Ogre::FilterOptions texFiltering=Ogre::FO_ANISOTROPIC) |
Creates a WebViewMaterial. | |
WebView * | getWebView (const std::string &webViewName) |
Retrieve a pointer to a WebView by name. | |
void | destroyWebView (const std::string &webViewName) |
Destroys a WebView. | |
void | destroyWebView (WebView *webViewToDestroy) |
Destroys a WebView. | |
void | resetAllPositions () |
Resets the positions of all WebViews to their default positions. | |
bool | isAnyWebViewFocused () |
Checks whether or not a WebView is focused/selected. | |
WebView * | getFocusedWebView () |
Gets the currently focused/selected WebView. | |
bool | injectMouseMove (const WebViewCoord &coord) |
Injects the mouse's current position into WebViewManager. | |
bool | injectMouseWheel (const WebViewCoord &relScroll) |
Injects mouse wheel events into WebViewManager. | |
bool | injectMouseDown (int buttonID) |
Injects mouse down events into WebViewManager. | |
bool | injectMouseUp (int buttonID) |
Injects mouse up events into WebViewManager. | |
bool | injectCut () |
bool | injectCopy () |
bool | injectPaste () |
bool | injectKeyEvent (bool pressed, bool repeat, Sirikata::Input::Modifier mod, Sirikata::Input::KeyButton button) |
bool | injectTextEvent (std::string utf8) |
void | deFocusAllWebViews () |
De-Focuses any currently-focused WebViews. | |
bool | focusWebView (WebView *selection) |
void | setDefaultViewport (Ogre::Viewport *newViewport) |
const std::string & | getBaseDir () const |
Input::EventResponse | onMouseHover (Input::MouseHoverEventPtr evt) |
Input::EventResponse | onMousePressed (Input::MousePressedEventPtr evt) |
Input::EventResponse | onMouseDrag (Input::MouseDragEventPtr evt) |
Input::EventResponse | onMouseReleased (Input::MouseReleasedEventPtr evt) |
Input::EventResponse | onMouseClick (Input::MouseClickEventPtr evt) |
Input::EventResponse | onButton (Input::ButtonEventPtr evt) |
Input::EventResponse | onKeyTextInput (Input::TextInputEventPtr evt) |
Static Public Member Functions | |
static WebViewManager & | getSingleton () |
Gets the WebViewManager Singleton. | |
static WebViewManager * | getSingletonPtr () |
Gets the WebViewManager Singleton as a pointer. | |
Protected Types | |
typedef std::map< std::string, WebView * > | WebViewMap |
Protected Member Functions | |
WebView * | getTopWebView (int x, int y) |
void | onResizeTooltip (WebView *WebView, const JSArguments &args) |
void | handleTooltip (WebView *tooltipParent, const std::wstring &tipText) |
void | handleRequestDrag (WebView *caller) |
boost::any | onRaiseWebViewEvent (WebView *webview, const JSArguments &args) |
Callback which generates WebView events due to a script in a WebView. | |
Protected Attributes | |
WebViewMap | activeWebViews |
WebView * | focusedWebView |
WebView * | tooltipWebView |
WebView * | tooltipParent |
WebView * | chromeWebView |
WebView * | focusedNonChromeWebView |
Ogre::Viewport * | defaultViewport |
int | mouseXPos |
int | mouseYPos |
bool | isDragging |
bool | isResizing |
unsigned short | zOrderCounter |
Ogre::Timer | tooltipTimer |
double | lastTooltip |
double | tooltipShowTime |
bool | isDraggingFocusedWebView |
std::string | baseDirectory |
Sirikata::Input::InputManager * | mInputManager |
Friends | |
class | WebView |
Supreme dictator and Singleton: WebViewManager.
The class you will need to go to for all your WebView-related needs.
typedef std::map<std::string,WebView*> Sirikata::Graphics::WebViewManager::WebViewMap [protected] |
Sirikata::Graphics::WebViewManager::WebViewManager | ( | Ogre::Viewport * | defaultViewport, |
Sirikata::Input::InputManager * | inputMgr, | ||
const std::string & | binDirectory, | ||
const std::string & | baseDirectory | ||
) |
Creates the WebViewManager singleton.
defaultViewport | The default Ogre::Viewport to place WebViews in. This can be overriden per-WebView via the last parameter of WebViewManager::createWebView. input manager to gather input from |
binDirectory | Path to the binary directory, i.e. the one that holds the berkelium binary, liblibberkelium, etc. |
baseDirectory | The relative path to your base directory. This directory is used by WebView::loadFile and WebView::loadHTML (to resolve relative URLs). |
Ogre::Exception::ERR_INTERNAL_ERROR | When initialization fails |
References Sirikata::DynamicLibrary::AddLoadPath(), init, and tooltipWebView.
Sirikata::Graphics::WebViewManager::~WebViewManager | ( | ) |
Destroys any active WebViews, the WebViewMouse singleton (if instantiated).
References activeWebViews, and destroy.
WebView * Sirikata::Graphics::WebViewManager::createWebView | ( | Context * | ctx, |
const std::string & | webViewName, | ||
const std::string & | webViewType, | ||
unsigned short | width, | ||
unsigned short | height, | ||
const OverlayPosition & | webViewPosition, | ||
Network::IOStrandPtr | postStrand, | ||
bool | asyncRender = false , |
||
int | maxAsyncRenderRate = 70 , |
||
Tier | tier = TIER_MIDDLE , |
||
Ogre::Viewport * | viewport = 0 , |
||
const WebView::WebViewBorderSize & | border = WebView::mDefaultBorder |
||
) |
Creates a WebView.
{Network::IOStrand*} | postStrand -- where the webview will post its callbacks to. |
References activeWebViews, Sirikata::Graphics::WebView::bind(), Sirikata::Graphics::WebView::createWebView(), defaultViewport, Sirikata::Graphics::ViewportOverlay::getZOrder(), onRaiseWebViewEvent(), Sirikata::Graphics::WebView::overlay, and WebView.
Referenced by Sirikata::Graphics::OgreSystemInputHandler::createUIAction(), Sirikata::Graphics::OgreSystem::createWindow(), Sirikata::Graphics::OgreSystemInputHandler::ensureUI(), and Sirikata::Graphics::WebView::handleOpenBrowser().
WebView * Sirikata::Graphics::WebViewManager::createWebViewMaterial | ( | Context * | ctx, |
const std::string & | webViewName, | ||
unsigned short | width, | ||
unsigned short | height, | ||
Network::IOStrandPtr | postingStrand, | ||
bool | asyncRender = false , |
||
int | maxAsyncRenderRate = 70 , |
||
Ogre::FilterOptions | texFiltering = Ogre::FO_ANISOTROPIC |
||
) |
Creates a WebViewMaterial.
WebViewMaterials are just like WebViews except that they lack a movable overlay element. Instead, you handle the material and apply it to anything you like. Mouse input for WebViewMaterials should be injected via the WebView::injectMouse_____ API calls instead of the global WebViewManager::injectMouse_____ calls.
References activeWebViews, Sirikata::Graphics::WebView::bind(), Sirikata::Graphics::WebView::createWebView(), onRaiseWebViewEvent(), and WebView.
Referenced by Sirikata::Graphics::PriorityDownloadPlanner::loadDependentTextures().
void Sirikata::Graphics::WebViewManager::deFocusAllWebViews | ( | ) |
De-Focuses any currently-focused WebViews.
References activeWebViews, focusedWebView, and isDraggingFocusedWebView.
Referenced by focusWebView().
void Sirikata::Graphics::WebViewManager::destroyWebView | ( | WebView * | webViewToDestroy | ) |
Destroys a WebView.
webViewToDestroy | pointer to the WebView to be destroyed |
References Sirikata::Graphics::WebView::okayToDelete.
void Sirikata::Graphics::WebViewManager::destroyWebView | ( | const std::string & | webViewName | ) |
Destroys a WebView.
webViewName | The name of the WebView to destroy. |
References activeWebViews.
Referenced by Sirikata::Graphics::WebView::handleCloseBrowser(), Sirikata::Graphics::PriorityDownloadPlanner::Asset::~Asset(), and Sirikata::Graphics::OgreSystemInputHandler::~OgreSystemInputHandler().
bool Sirikata::Graphics::WebViewManager::focusWebView | ( | WebView * | selection | ) |
References activeWebViews, chromeWebView, deFocusAllWebViews(), Sirikata::Graphics::WebView::focus(), focusedNonChromeWebView, focusedWebView, Sirikata::Graphics::ViewportOverlay::getTier(), Sirikata::Graphics::ViewportOverlay::getZOrder(), isDraggingFocusedWebView, and Sirikata::Graphics::WebView::overlay.
Referenced by handleRequestDrag(), injectMouseDown(), Sirikata::Graphics::WebView::invoke(), and Sirikata::Graphics::WebView::raise().
const std::string& Sirikata::Graphics::WebViewManager::getBaseDir | ( | ) | const [inline] |
Referenced by Sirikata::Graphics::WebView::loadFile().
WebView * Sirikata::Graphics::WebViewManager::getFocusedWebView | ( | ) |
Gets the currently focused/selected WebView.
(not applicable to WebViewMaterials)
References focusedWebView.
WebViewManager & Sirikata::Graphics::WebViewManager::getSingleton | ( | ) | [static] |
Gets the WebViewManager Singleton.
Ogre::Exception::ERR_RT_ASSERTION_FAILED | Throws this if WebViewManager has not been instantiated yet. |
Referenced by Sirikata::Graphics::OgreSystemInputHandler::createUIAction(), Sirikata::Graphics::WebView::createWebView(), Sirikata::Graphics::OgreSystemInputHandler::ensureUI(), Sirikata::Graphics::WebView::handleCloseBrowser(), Sirikata::Graphics::WebView::handleGetBrowserURL(), Sirikata::Graphics::WebView::handleListenToBrowser(), Sirikata::Graphics::WebView::handleOpenBrowser(), Sirikata::Graphics::WebView::invoke(), Sirikata::Graphics::PriorityDownloadPlanner::loadDependentTextures(), Sirikata::Graphics::WebView::loadFile(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onAxisEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onKeyEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onMouseClickEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onMouseDragEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onMouseHoverEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onMousePressedEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onMouseReleasedEvent(), Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onTextInputEvent(), Sirikata::Graphics::WebView::raise(), Sirikata::Graphics::OgreSystem::renderOneFrame(), Sirikata::Graphics::PriorityDownloadPlanner::Asset::~Asset(), and Sirikata::Graphics::OgreSystemInputHandler::~OgreSystemInputHandler().
WebViewManager * Sirikata::Graphics::WebViewManager::getSingletonPtr | ( | ) | [static] |
Gets the WebViewManager Singleton as a pointer.
Referenced by Sirikata::Graphics::OgreSystem::createWindow(), and Sirikata::Graphics::OgreSystem::renderOneFrame().
WebView * Sirikata::Graphics::WebViewManager::getTopWebView | ( | int | x, |
int | y | ||
) | [protected] |
References activeWebViews, Sirikata::Graphics::WebView::overlay, and Sirikata::Graphics::ViewportOverlay::panel.
Referenced by injectMouseDown(), and injectMouseMove().
WebView * Sirikata::Graphics::WebViewManager::getWebView | ( | const std::string & | webViewName | ) |
Retrieve a pointer to a WebView by name.
webViewName | The name of the WebView to retrieve. |
References activeWebViews.
Referenced by Sirikata::Graphics::OgreSystem::createWindow(), Sirikata::Graphics::WebView::handleGetBrowserURL(), and Sirikata::Graphics::WebView::handleListenToBrowser().
void Sirikata::Graphics::WebViewManager::handleRequestDrag | ( | WebView * | caller | ) | [protected] |
References focusWebView(), and isDraggingFocusedWebView.
void Sirikata::Graphics::WebViewManager::handleTooltip | ( | WebView * | tooltipParent, |
const std::wstring & | tipText | ||
) | [protected] |
bool Sirikata::Graphics::WebViewManager::injectCopy | ( | ) |
References focusedWebView, and Sirikata::Graphics::WebView::injectCopy().
Referenced by onButton().
bool Sirikata::Graphics::WebViewManager::injectCut | ( | ) |
References focusedWebView, and Sirikata::Graphics::WebView::injectCut().
Referenced by onButton().
bool Sirikata::Graphics::WebViewManager::injectKeyEvent | ( | bool | pressed, |
bool | repeat, | ||
Sirikata::Input::Modifier | mod, | ||
Sirikata::Input::KeyButton | button | ||
) |
References focusedWebView, and Sirikata::Graphics::WebView::injectKeyEvent().
Referenced by onButton().
bool Sirikata::Graphics::WebViewManager::injectMouseDown | ( | int | buttonID | ) |
Injects mouse down events into WebViewManager.
Used to know when the user has pressed a mouse button and which button they used. (not applicable to WebViewMaterials)
buttonID | The ID of the button that was pressed. Left = 0, Right = 1, Middle = 2. |
References focusedWebView, focusWebView(), Sirikata::Graphics::WebView::getRelativeX(), Sirikata::Graphics::WebView::getRelativeY(), getTopWebView(), Sirikata::Graphics::WebView::inDraggableRegion(), Sirikata::Graphics::WebView::injectMouseDown(), isDragging, isResizing, Sirikata::Graphics::LeftMouseButton, Sirikata::Graphics::MiddleMouseButton, mouseXPos, and mouseYPos.
Referenced by onMousePressed().
bool Sirikata::Graphics::WebViewManager::injectMouseMove | ( | const WebViewCoord & | coord | ) |
Injects the mouse's current position into WebViewManager.
Used to generally keep track of where the mouse is for things like moving WebViews around, telling the internal pages of each WebView where the mouse is and where the user has clicked, etc. (not applicable to WebViewMaterials)
coord | The coordinates of the mouse. |
References activeWebViews, focusedWebView, Sirikata::Graphics::WebView::getExtents(), Sirikata::Graphics::WebView::getNonStrictVisibility(), Sirikata::Graphics::WebView::getRelativeX(), Sirikata::Graphics::WebView::getRelativeY(), getTopWebView(), handleTooltip(), Sirikata::Graphics::WebView::injectMouseMove(), isDragging, isDraggingFocusedWebView, Sirikata::Graphics::WebView::isMaterialOnly(), Sirikata::Graphics::WebView::isPointOverMe(), isResizing, mouseXPos, mouseYPos, Sirikata::Graphics::WebView::move(), Sirikata::Graphics::WebView::overlay, Sirikata::Graphics::ViewportOverlay::panel, Sirikata::Graphics::WebView::resize(), Sirikata::Graphics::WebView::setPosition(), tooltipParent, tooltipWebView, Sirikata::Graphics::WebViewCoord::x, and Sirikata::Graphics::WebViewCoord::y.
Referenced by onMouseClick(), onMouseDrag(), onMouseHover(), onMousePressed(), and onMouseReleased().
bool Sirikata::Graphics::WebViewManager::injectMouseUp | ( | int | buttonID | ) |
Injects mouse up events into WebViewManager.
Used to know when the user has released a mouse button and which button they used. (not applicable to WebViewMaterials)
buttonID | The ID of the button that was released. Left = 0, Right = 1, Middle = 2. |
References focusedWebView, Sirikata::Graphics::WebView::getRelativeX(), Sirikata::Graphics::WebView::getRelativeY(), Sirikata::Graphics::WebView::inDraggableRegion(), Sirikata::Graphics::WebView::injectMouseUp(), isDragging, isDraggingFocusedWebView, isResizing, Sirikata::Graphics::LeftMouseButton, Sirikata::Graphics::MiddleMouseButton, mouseXPos, and mouseYPos.
Referenced by onMouseClick(), and onMouseDrag().
bool Sirikata::Graphics::WebViewManager::injectMouseWheel | ( | const WebViewCoord & | relScroll | ) |
Injects mouse wheel events into WebViewManager.
Used to scroll the focused WebView. (not applicable to WebViewMaterials)
relScroll | The relative Scroll-Value of the mouse. |
References focusedWebView, Sirikata::Graphics::WebView::injectMouseWheel(), Sirikata::Graphics::WebViewCoord::x, and Sirikata::Graphics::WebViewCoord::y.
Referenced by Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onAxisEvent().
bool Sirikata::Graphics::WebViewManager::injectPaste | ( | ) |
References focusedWebView, and Sirikata::Graphics::WebView::injectPaste().
Referenced by onButton().
bool Sirikata::Graphics::WebViewManager::injectTextEvent | ( | std::string | utf8 | ) |
References focusedWebView, and Sirikata::Graphics::WebView::injectTextEvent().
Referenced by onKeyTextInput().
bool Sirikata::Graphics::WebViewManager::isAnyWebViewFocused | ( | ) |
Checks whether or not a WebView is focused/selected.
(not applicable to WebViewMaterials)
References focusedWebView.
Input::EventResponse Sirikata::Graphics::WebViewManager::onButton | ( | Input::ButtonEventPtr | evt | ) |
References Sirikata::Input::EventResponse::cancel(), injectCopy(), injectCut(), injectKeyEvent(), injectPaste(), Sirikata::Input::MOD_CTRL, Sirikata::Input::MOD_GUI, and Sirikata::Input::EventResponse::nop().
Referenced by Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onKeyEvent().
Input::EventResponse Sirikata::Graphics::WebViewManager::onKeyTextInput | ( | Input::TextInputEventPtr | evt | ) |
Input::EventResponse Sirikata::Graphics::WebViewManager::onMouseClick | ( | Input::MouseClickEventPtr | evt | ) |
Input::EventResponse Sirikata::Graphics::WebViewManager::onMouseDrag | ( | Input::MouseDragEventPtr | evt | ) |
References Sirikata::Input::EventResponse::cancel(), Sirikata::Input::DRAG_DEADBAND, Sirikata::Input::DRAG_DRAG, Sirikata::Input::DRAG_END, Sirikata::Input::DRAG_START, Sirikata::Logging::error, injectMouseMove(), injectMouseUp(), Sirikata::Input::EventResponse::nop(), SILOG, and Sirikata::Graphics::UnknownMouseButton.
Referenced by Sirikata::Graphics::OgreSystemInputHandler::WebViewInputListener::onMouseDragEvent().
Input::EventResponse Sirikata::Graphics::WebViewManager::onMouseHover | ( | Input::MouseHoverEventPtr | evt | ) |
Input::EventResponse Sirikata::Graphics::WebViewManager::onMousePressed | ( | Input::MousePressedEventPtr | evt | ) |
Input::EventResponse Sirikata::Graphics::WebViewManager::onMouseReleased | ( | Input::MouseReleasedEventPtr | evt | ) |
boost::any Sirikata::Graphics::WebViewManager::onRaiseWebViewEvent | ( | WebView * | webview, |
const JSArguments & | args | ||
) | [protected] |
Callback which generates WebView events due to a script in a WebView.
This is the portal from Javascript into the InputEvent system.
We expose an event() function on the WebView's DOM's Client object. A script may then call it to raise an event. The call Client.event(name, some, other, args) will generate a WebView event with the parameters WebViewEvent.webView = (the WebView that generated the callback) WebViewEvent.name = name WebViewEvent.args = [some, other, args] Note that if the first argument is not a string, then no event will be generated.
References Sirikata::Logging::error, Sirikata::Input::InputManager::fire(), Sirikata::Graphics::WebView::getName(), mInputManager, name(), and SILOG.
Referenced by createWebView(), and createWebViewMaterial().
void Sirikata::Graphics::WebViewManager::onResizeTooltip | ( | WebView * | WebView, |
const JSArguments & | args | ||
) | [protected] |
void Sirikata::Graphics::WebViewManager::resetAllPositions | ( | ) |
Resets the positions of all WebViews to their default positions.
(not applicable to WebViewMaterials)
References activeWebViews.
void Sirikata::Graphics::WebViewManager::setDefaultViewport | ( | Ogre::Viewport * | newViewport | ) |
References activeWebViews, and defaultViewport.
Referenced by Sirikata::Graphics::OgreSystem::renderOneFrame().
void Sirikata::Graphics::WebViewManager::Update | ( | ) |
Gives each active WebView a chance to update, each may or may not update their internal textures based on various conditions.
References activeWebViews, focusedNonChromeWebView, focusedWebView, isDraggingFocusedWebView, lastTooltip, Sirikata::Graphics::WebView::show(), tooltipShowTime, tooltipTimer, tooltipWebView, and Sirikata::Graphics::WebView::update().
Referenced by Sirikata::Graphics::OgreSystem::renderOneFrame().
friend class WebView [friend] |
Referenced by createWebView(), and createWebViewMaterial().
std::string Sirikata::Graphics::WebViewManager::baseDirectory [protected] |
WebView* Sirikata::Graphics::WebViewManager::chromeWebView [protected] |
Referenced by focusWebView().
Ogre::Viewport* Sirikata::Graphics::WebViewManager::defaultViewport [protected] |
Referenced by createWebView(), and setDefaultViewport().
Referenced by focusWebView(), and Update().
bool Sirikata::Graphics::WebViewManager::isDragging [protected] |
Referenced by injectMouseDown(), injectMouseMove(), and injectMouseUp().
bool Sirikata::Graphics::WebViewManager::isDraggingFocusedWebView [protected] |
Referenced by deFocusAllWebViews(), focusWebView(), handleRequestDrag(), injectMouseMove(), injectMouseUp(), and Update().
bool Sirikata::Graphics::WebViewManager::isResizing [protected] |
Referenced by injectMouseDown(), injectMouseMove(), and injectMouseUp().
double Sirikata::Graphics::WebViewManager::lastTooltip [protected] |
Referenced by onResizeTooltip(), and Update().
Referenced by onRaiseWebViewEvent().
int Sirikata::Graphics::WebViewManager::mouseXPos [protected] |
Referenced by injectMouseDown(), injectMouseMove(), injectMouseUp(), and onResizeTooltip().
int Sirikata::Graphics::WebViewManager::mouseYPos [protected] |
Referenced by injectMouseDown(), injectMouseMove(), injectMouseUp(), and onResizeTooltip().
WebView* Sirikata::Graphics::WebViewManager::tooltipParent [protected] |
Referenced by handleTooltip(), and injectMouseMove().
double Sirikata::Graphics::WebViewManager::tooltipShowTime [protected] |
Referenced by handleTooltip(), onResizeTooltip(), and Update().
Ogre::Timer Sirikata::Graphics::WebViewManager::tooltipTimer [protected] |
Referenced by onResizeTooltip(), and Update().
Referenced by handleTooltip(), injectMouseMove(), onResizeTooltip(), Update(), and WebViewManager().
unsigned short Sirikata::Graphics::WebViewManager::zOrderCounter [protected] |