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

Supreme dictator and Singleton: WebViewManager. More...

#include <WebViewManager.hpp>

Inheritance diagram for Sirikata::Graphics::WebViewManager:
Collaboration diagram for Sirikata::Graphics::WebViewManager:

List of all members.

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.
WebViewcreateWebView (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.
WebViewcreateWebViewMaterial (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.
WebViewgetWebView (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.
WebViewgetFocusedWebView ()
 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 WebViewManagergetSingleton ()
 Gets the WebViewManager Singleton.
static WebViewManagergetSingletonPtr ()
 Gets the WebViewManager Singleton as a pointer.

Protected Types

typedef std::map< std::string,
WebView * > 
WebViewMap

Protected Member Functions

WebViewgetTopWebView (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
WebViewfocusedWebView
WebViewtooltipWebView
WebViewtooltipParent
WebViewchromeWebView
WebViewfocusedNonChromeWebView
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::InputManagermInputManager

Friends

class WebView

Detailed Description

Supreme dictator and Singleton: WebViewManager.

The class you will need to go to for all your WebView-related needs.


Member Typedef Documentation

typedef std::map<std::string,WebView*> Sirikata::Graphics::WebViewManager::WebViewMap [protected]

Constructor & Destructor Documentation

Sirikata::Graphics::WebViewManager::WebViewManager ( Ogre::Viewport *  defaultViewport,
Sirikata::Input::InputManager inputMgr,
const std::string &  binDirectory,
const std::string &  baseDirectory 
)

Creates the WebViewManager singleton.

Parameters:
defaultViewportThe 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
binDirectoryPath to the binary directory, i.e. the one that holds the berkelium binary, liblibberkelium, etc.
baseDirectoryThe relative path to your base directory. This directory is used by WebView::loadFile and WebView::loadHTML (to resolve relative URLs).
Exceptions:
Ogre::Exception::ERR_INTERNAL_ERRORWhen 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.


Member Function Documentation

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 
)
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.

Parameters:
webViewToDestroypointer to the WebView to be destroyed

References Sirikata::Graphics::WebView::okayToDelete.

void Sirikata::Graphics::WebViewManager::destroyWebView ( const std::string &  webViewName)
bool Sirikata::Graphics::WebViewManager::focusWebView ( WebView selection)
const std::string& Sirikata::Graphics::WebViewManager::getBaseDir ( ) const [inline]
WebView * Sirikata::Graphics::WebViewManager::getFocusedWebView ( )

Gets the currently focused/selected WebView.

(not applicable to WebViewMaterials)

Returns:
A pointer to the WebView that is currently focused, returns 0 if none are focused.

References focusedWebView.

WebViewManager & Sirikata::Graphics::WebViewManager::getSingleton ( ) [static]

Gets the WebViewManager Singleton.

Returns:
A reference to the WebViewManager Singleton.
Exceptions:
Ogre::Exception::ERR_RT_ASSERTION_FAILEDThrows 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.

Returns:
If the WebViewManager has been instantiated, returns a pointer to the WebViewManager Singleton, otherwise this returns 0.

Referenced by Sirikata::Graphics::OgreSystem::createWindow(), and Sirikata::Graphics::OgreSystem::renderOneFrame().

WebView * Sirikata::Graphics::WebViewManager::getTopWebView ( int  x,
int  y 
) [protected]
WebView * Sirikata::Graphics::WebViewManager::getWebView ( const std::string &  webViewName)

Retrieve a pointer to a WebView by name.

Parameters:
webViewNameThe name of the WebView to retrieve.
Returns:
If the WebView is found, returns a pointer to the WebView, otherwise returns 0.

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]
void Sirikata::Graphics::WebViewManager::handleTooltip ( WebView tooltipParent,
const std::wstring &  tipText 
) [protected]
bool Sirikata::Graphics::WebViewManager::injectCopy ( )
bool Sirikata::Graphics::WebViewManager::injectCut ( )
bool Sirikata::Graphics::WebViewManager::injectKeyEvent ( bool  pressed,
bool  repeat,
Sirikata::Input::Modifier  mod,
Sirikata::Input::KeyButton  button 
)
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)

Parameters:
buttonIDThe ID of the button that was pressed. Left = 0, Right = 1, Middle = 2.
Returns:
Returns True if the mouse went down over a WebView, False otherwise.

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)
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)

Parameters:
buttonIDThe ID of the button that was released. Left = 0, Right = 1, Middle = 2.
Returns:
Returns True if the mouse went up while a WebView was focused, False otherwise.

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)

Parameters:
relScrollThe relative Scroll-Value of the mouse.
Note:
To inject this using OIS: on a OIS::MouseListener::MouseMoved event, simply inject "arg.state.Z.rel" of the "MouseEvent".
Returns:
Returns True if the mouse wheel was scrolled while a WebView was focused, False otherwise.

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 ( )
bool Sirikata::Graphics::WebViewManager::injectTextEvent ( std::string  utf8)
bool Sirikata::Graphics::WebViewManager::isAnyWebViewFocused ( )

Checks whether or not a WebView is focused/selected.

(not applicable to WebViewMaterials)

Returns:
True if a WebView is focused, False otherwise.

References focusedWebView.

Input::EventResponse Sirikata::Graphics::WebViewManager::onButton ( Input::ButtonEventPtr  evt)
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)
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)
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().


Friends And Related Function Documentation

friend class WebView [friend]

Member Data Documentation

Referenced by focusWebView().

Referenced by focusWebView(), and Update().

Referenced by onResizeTooltip(), and Update().

Referenced by onRaiseWebViewEvent().

Referenced by handleTooltip(), and injectMouseMove().

Referenced by onResizeTooltip(), and Update().


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