summaryrefslogtreecommitdiff
path: root/indra/llui/llui.h
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2009-08-04 01:12:59 +0000
committerRichard Nelson <richard@lindenlab.com>2009-08-04 01:12:59 +0000
commiteb853f55c07ae4a3c3f2aa05fbabcf2e4b4dc115 (patch)
tree7707fccb8d0946b6257d5ed7c5dfd3941c53eec0 /indra/llui/llui.h
parentdb5cda26676f376f18816013c0c5e3fbad5b20d0 (diff)
svn merge -r 128442:129343 svn+ssh://svn.lindenlab.com/svn/linden/branches/skinning/skinning-18 into svn+ssh://svn.lindenlab.com/svn/linden/branches/viewer/viewer-2.0.0-3
Diffstat (limited to 'indra/llui/llui.h')
-rw-r--r--indra/llui/llui.h187
1 files changed, 0 insertions, 187 deletions
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index 413733a50b..b1943a7b02 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -222,193 +222,6 @@ private:
static std::vector<std::string> sXUIPaths;
};
-// FactoryPolicy is a static class that controls the creation and lookup of UI elements,
-// such as floaters.
-// The key parameter is used to provide a unique identifier and/or associated construction
-// parameters for a given UI instance
-//
-// Specialize this traits for different types, or provide a class with an identical interface
-// in the place of the traits parameter
-//
-// For example:
-//
-// template <>
-// class FactoryPolicy<MyClass> /* FactoryPolicy specialized for MyClass */
-// {
-// public:
-// static MyClass* findInstance(const LLSD& key = LLSD())
-// {
-// /* return instance of MyClass associated with key */
-// }
-//
-// static MyClass* createInstance(const LLSD& key = LLSD())
-// {
-// /* create new instance of MyClass using key for construction parameters */
-// }
-// }
-//
-// class MyClass : public LLUIFactory<MyClass>
-// {
-// /* uses FactoryPolicy<MyClass> by default */
-// }
-
-template <class T>
-class FactoryPolicy
-{
-public:
- // basic factory methods
- static T* findInstance(const LLSD& key); // unimplemented, provide specialiation
- static T* createInstance(const LLSD& key); // unimplemented, provide specialiation
-};
-
-// VisibilityPolicy controls the visibility of UI elements, such as floaters.
-// The key parameter is used to store the unique identifier of a given UI instance
-//
-// Specialize this traits for different types, or duplicate this interface for specific instances
-// (see above)
-
-template <class T>
-class VisibilityPolicy
-{
-public:
- // visibility methods
- static bool visible(T* instance, const LLSD& key); // unimplemented, provide specialiation
- static void show(T* instance, const LLSD& key); // unimplemented, provide specialiation
- static void hide(T* instance, const LLSD& key); // unimplemented, provide specialiation
-};
-
-// Manages generation of UI elements by LLSD, such that (generally) there is
-// a unique instance per distinct LLSD parameter
-// Class T is the instance type being managed, and the FACTORY_POLICY and VISIBILITY_POLICY
-// classes provide static methods for creating, accessing, showing and hiding the associated
-// element T
-template <class T, class FACTORY_POLICY = FactoryPolicy<T>, class VISIBILITY_POLICY = VisibilityPolicy<T> >
-class LLUIFactory
-{
-public:
- // give names to the template parameters so derived classes can refer to them
- // except this doesn't work in gcc
- typedef FACTORY_POLICY factory_policy_t;
- typedef VISIBILITY_POLICY visibility_policy_t;
-
- LLUIFactory()
- {
- }
-
- virtual ~LLUIFactory()
- {
- }
-
- // default show and hide methods
- static T* showInstance(const LLSD& key = LLSD())
- {
- T* instance = getInstance(key);
- if (instance != NULL)
- {
- VISIBILITY_POLICY::show(instance, key);
- }
- return instance;
- }
-
- static void hideInstance(const LLSD& key = LLSD())
- {
- T* instance = getInstance(key);
- if (instance != NULL)
- {
- VISIBILITY_POLICY::hide(instance, key);
- }
- }
-
- static void toggleInstance(const LLSD& key = LLSD())
- {
- if (instanceVisible(key))
- {
- hideInstance(key);
- }
- else
- {
- showInstance(key);
- }
- }
-
- static bool instanceVisible(const LLSD& key = LLSD())
- {
- T* instance = FACTORY_POLICY::findInstance(key);
- return instance != NULL && VISIBILITY_POLICY::visible(instance, key);
- }
-
- static T* getInstance(const LLSD& key = LLSD())
- {
- T* instance = FACTORY_POLICY::findInstance(key);
- if (instance == NULL)
- {
- instance = FACTORY_POLICY::createInstance(key);
- }
- return instance;
- }
-
-};
-
-
-// Creates a UI singleton by ignoring the identifying parameter
-// and always generating the same instance via the LLUIFactory interface.
-// Note that since UI elements can be destroyed by their hierarchy, this singleton
-// pattern uses a static pointer to an instance that will be re-created as needed.
-//
-// Usage Pattern:
-//
-// class LLFloaterFoo : public LLFloater, public LLUISingleton<LLFloaterFoo>
-// {
-// friend class LLUISingleton<LLFloaterFoo>;
-// private:
-// LLFloaterFoo(const LLSD& key);
-// };
-//
-// Note that LLUISingleton takes an option VisibilityPolicy parameter that defines
-// how showInstance(), hideInstance(), etc. work.
-//
-// https://wiki.lindenlab.com/mediawiki/index.php?title=LLUISingleton&oldid=79352
-
-template <class T, class VISIBILITY_POLICY = VisibilityPolicy<T> >
-class LLUISingleton: public LLUIFactory<T, LLUISingleton<T, VISIBILITY_POLICY>, VISIBILITY_POLICY>
-{
-protected:
-
- // T must derive from LLUISingleton<T>
- LLUISingleton() { sInstance = static_cast<T*>(this); }
- ~LLUISingleton() { sInstance = NULL; }
-
-public:
- static T* findInstance(const LLSD& key = LLSD())
- {
- return sInstance;
- }
-
- static T* createInstance(const LLSD& key = LLSD())
- {
- if (sInstance == NULL)
- {
- sInstance = new T(key);
- }
- return sInstance;
- }
-
- static void destroyInstance()
- {
- delete sInstance;
- sInstance = NULL;
- }
-
- static bool instanceExists() { return NULL != sInstance; }
-
-private:
- LLUISingleton(const LLUISingleton&){}
- LLUISingleton& operator=(const LLUISingleton&){}
-private:
- static T* sInstance;
-};
-
-template <class T, class U> T* LLUISingleton<T,U>::sInstance = NULL;
class LLScreenClipRect
{