From dc93fe6cc68115dd280881c0896fa3f0e8d46f2c Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2009 13:42:15 -0400 Subject: DEV-31980: Wrap LLViewerWindow::saveSnapshot() with an event API. Add LLViewerWindowListener per Incremental_Viewer_Automation/Event_API. Add LLViewerWindowListener pointer to LLViewerWindow, and initialize in ctor. Add llviewerwindowlistener.{h,cpp} to newview/CMakeLists.txt. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llviewerwindow.cpp | 8 +++- indra/newview/llviewerwindow.h | 4 ++ indra/newview/llviewerwindowlistener.cpp | 78 ++++++++++++++++++++++++++++++++ indra/newview/llviewerwindowlistener.h | 34 ++++++++++++++ 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 indra/newview/llviewerwindowlistener.cpp create mode 100644 indra/newview/llviewerwindowlistener.h (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 20c59faae0..53a59031ed 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -415,6 +415,7 @@ set(viewer_SOURCE_FILES llviewerthrottle.cpp llviewervisualparam.cpp llviewerwindow.cpp + llviewerwindowlistener.cpp llvlcomposition.cpp llvlmanager.cpp llvoavatar.cpp @@ -835,6 +836,7 @@ set(viewer_HEADER_FILES llviewerthrottle.h llviewervisualparam.h llviewerwindow.h + llviewerwindowlistener.h llvlcomposition.h llvlmanager.h llvoavatar.h diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 5c9f8af216..dcd37d85da 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -30,6 +30,10 @@ * $/LicenseInfo$ */ +#if defined(LL_WINDOWS) +#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally +#endif + #include "llviewerprecompiledheaders.h" // system library includes @@ -189,6 +193,7 @@ #include "llfloaternotificationsconsole.h" #include "llnearbychathistory.h" +#include "llviewerwindowlistener.h" #if LL_WINDOWS #include // For Unicode conversion methods @@ -1262,7 +1267,8 @@ LLViewerWindow::LLViewerWindow( mResDirty(false), mStatesDirty(false), mIsFullscreenChecked(false), - mCurrResolutionIndex(0) + mCurrResolutionIndex(0), + mViewerWindowListener(new LLViewerWindowListener("LLViewerWindow", this)) { LLNotificationChannel::buildChannel("VW_alerts", "Visible", LLNotificationFilters::filterBy(&LLNotification::getType, "alert")); LLNotificationChannel::buildChannel("VW_alertmodal", "Visible", LLNotificationFilters::filterBy(&LLNotification::getType, "alertmodal")); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index eae1bf0343..b729889631 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -50,6 +50,7 @@ #include "llnotifications.h" #include "llmousehandler.h" #include "llcursortypes.h" +#include class LLView; class LLViewerObject; @@ -62,6 +63,7 @@ class LLImageRaw; class LLHUDIcon; class LLWindow; class LLRootView; +class LLViewerWindowListener; #define PICK_HALF_WIDTH 5 #define PICK_DIAMETER (2 * PICK_HALF_WIDTH + 1) @@ -450,6 +452,8 @@ protected: bool mIsFullscreenChecked; // Did the user check the fullscreen checkbox in the display settings U32 mCurrResolutionIndex; + boost::scoped_ptr mViewerWindowListener; + protected: static std::string sSnapshotBaseName; static std::string sSnapshotDir; diff --git a/indra/newview/llviewerwindowlistener.cpp b/indra/newview/llviewerwindowlistener.cpp new file mode 100644 index 0000000000..ad90b1d2ab --- /dev/null +++ b/indra/newview/llviewerwindowlistener.cpp @@ -0,0 +1,78 @@ +/** + * @file llviewerwindowlistener.cpp + * @author Nat Goodspeed + * @date 2009-06-30 + * @brief Implementation for llviewerwindowlistener. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "llviewerwindowlistener.h" +// STL headers +#include +// std headers +// external library headers +// other Linden headers +#include "llviewerwindow.h" + +LLViewerWindowListener::LLViewerWindowListener(const std::string& pumpname, LLViewerWindow* llviewerwindow): + LLDispatchListener(pumpname, "op"), + mViewerWindow(llviewerwindow) +{ + // add() every method we want to be able to invoke via this event API. + LLSD saveSnapshotArgs; + saveSnapshotArgs["filename"] = LLSD::String(); + saveSnapshotArgs["reply"] = LLSD::String(); + // The following are optional, so don't build them into required prototype. +// saveSnapshotArgs["width"] = LLSD::Integer(); +// saveSnapshotArgs["height"] = LLSD::Integer(); +// saveSnapshotArgs["showui"] = LLSD::Boolean(); +// saveSnapshotArgs["rebuild"] = LLSD::Boolean(); +// saveSnapshotArgs["type"] = LLSD::String(); + add("saveSnapshot", &LLViewerWindowListener::saveSnapshot, saveSnapshotArgs); +} + +void LLViewerWindowListener::saveSnapshot(const LLSD& event) const +{ + LLReqID reqid(event); + typedef std::map TypeMap; + TypeMap types; +#define tp(name) types[#name] = LLViewerWindow::SNAPSHOT_TYPE_##name + tp(COLOR); + tp(DEPTH); + tp(OBJECT_ID); +#undef tp + // Our add() call should ensure that the incoming LLSD does in fact + // contain our required arguments. Deal with the optional ones. + S32 width (mViewerWindow->getWindowDisplayWidth()); + S32 height(mViewerWindow->getWindowDisplayHeight()); + if (event.has("width")) + width = event["width"].asInteger(); + if (event.has("height")) + height = event["height"].asInteger(); + // showui defaults to true, requiring special treatment + bool showui = true; + if (event.has("showui")) + showui = event["showui"].asBoolean(); + bool rebuild(event["rebuild"]); // defaults to false + LLViewerWindow::ESnapshotType type(LLViewerWindow::SNAPSHOT_TYPE_COLOR); + if (event.has("type")) + { + TypeMap::const_iterator found = types.find(event["type"]); + if (found == types.end()) + { + LL_ERRS("LLViewerWindowListener") << "LLViewerWindowListener::saveSnapshot(): " + << "unrecognized type " << event["type"] << LL_ENDL; + } + type = found->second; + } + bool ok = mViewerWindow->saveSnapshot(event["filename"], width, height, showui, rebuild, type); + LLSD response(reqid.makeResponse()); + response["ok"] = ok; + LLEventPumps::instance().obtain(event["reply"]).post(response); +} diff --git a/indra/newview/llviewerwindowlistener.h b/indra/newview/llviewerwindowlistener.h new file mode 100644 index 0000000000..f756a5310f --- /dev/null +++ b/indra/newview/llviewerwindowlistener.h @@ -0,0 +1,34 @@ +/** + * @file llviewerwindowlistener.h + * @author Nat Goodspeed + * @date 2009-06-30 + * @brief Event API for subset of LLViewerWindow methods + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLVIEWERWINDOWLISTENER_H) +#define LL_LLVIEWERWINDOWLISTENER_H + +#include "lleventdispatcher.h" + +class LLViewerWindow; +class LLSD; + +/// Listen on an LLEventPump with specified name for LLViewerWindow request events. +class LLViewerWindowListener: public LLDispatchListener +{ +public: + /// Specify the pump name on which to listen, and bind the LLViewerWindow + /// instance to use (e.g. gViewerWindow). + LLViewerWindowListener(const std::string& pumpname, LLViewerWindow* llviewerwindow); + +private: + void saveSnapshot(const LLSD& event) const; + + LLViewerWindow* mViewerWindow; +}; + +#endif /* ! defined(LL_LLVIEWERWINDOWLISTENER_H) */ -- cgit v1.2.3 From b082b5c9de83733f3d702a35ce60e6c0f61f7dc1 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Wed, 1 Jul 2009 18:47:48 -0400 Subject: Backed out setSetting listener: changeset 3c9127748425 --- indra/newview/llappviewerlistener.cpp | 13 ------------- indra/newview/llappviewerlistener.h | 1 - 2 files changed, 14 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewerlistener.cpp b/indra/newview/llappviewerlistener.cpp index befebae88e..a8c98b17a7 100644 --- a/indra/newview/llappviewerlistener.cpp +++ b/indra/newview/llappviewerlistener.cpp @@ -18,7 +18,6 @@ // external library headers // other Linden headers #include "llappviewer.h" -#include "llviewercontrol.h" LLAppViewerListener::LLAppViewerListener(const std::string& pumpname, LLAppViewer* llappviewer): LLDispatchListener(pumpname, "op"), @@ -26,21 +25,9 @@ LLAppViewerListener::LLAppViewerListener(const std::string& pumpname, LLAppViewe { // add() every method we want to be able to invoke via this event API. add("requestQuit", &LLAppViewerListener::requestQuit); - add("setSetting", &LLAppViewerListener::setSetting); } void LLAppViewerListener::requestQuit(const LLSD& event) const { mAppViewer->requestQuit(); } - -void LLAppViewerListener::setSetting(const LLSD & event) const -{ - std::string control_name = event["name"].asString(); - if (gSavedSettings.controlExists(control_name)) - { - LLControlVariable* control = gSavedSettings.getControl(control_name); - - control->set(event["value"]); - } -} diff --git a/indra/newview/llappviewerlistener.h b/indra/newview/llappviewerlistener.h index ff63b69c13..ab17dd1d90 100644 --- a/indra/newview/llappviewerlistener.h +++ b/indra/newview/llappviewerlistener.h @@ -27,7 +27,6 @@ public: private: void requestQuit(const LLSD& event) const; - void setSetting(const LLSD & event) const; LLAppViewer* mAppViewer; }; -- cgit v1.2.3