Further pluggged in LLView::Params. For now just used for a few exclusively hard-coded elements. XUI parsing not yet implemented. New element registry not yet implemented.

This commit is contained in:
Shyotl
2013-05-17 14:45:23 -05:00
parent 182b15aee5
commit b1d69d05c3
18 changed files with 443 additions and 140 deletions

View File

@@ -2244,6 +2244,11 @@ void LLMenuGL::removeChild( LLView* ctrl)
return LLUICtrl::removeChild(ctrl);
}
BOOL LLMenuGL::postBuild()
{
return LLUICtrl::postBuild();
}
// are we the childmost active menu and hence our jump keys should be enabled?
// or are we a free-standing torn-off menu (which uses jump keys too)
BOOL LLMenuGL::jumpKeysActive()

View File

@@ -33,8 +33,7 @@
#include "llrootview.h"
LLRootView::LLRootView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows)
: LLView(name,rect,mouse_opaque,follows)
{ }
LLRootView::LLRootView(const Params& p)
: LLView(p)
{}
// pretty exciting file, eh?

View File

@@ -30,15 +30,15 @@
* $/LicenseInfo$
*/
#ifndef LLROOTVIEW_H
#define LLROOTVIEW_H
#ifndef LL_LLROOTVIEW_H
#define LL_LLROOTVIEW_H
#include "llview.h"
class LLRootView : public LLView
{
public:
LLRootView(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE);
LLRootView(const Params& p) ;
};
#endif

View File

@@ -32,6 +32,7 @@
#include "linden_common.h"
#define LLUICTRLFACTORY_CPP
#include "lluictrlfactory.h"
#include <fstream>
@@ -70,6 +71,10 @@
#include "lluiimage.h"
#include "llviewborder.h"
LLFastTimer::DeclareTimer FTM_WIDGET_CONSTRUCTION("Widget Construction");
LLFastTimer::DeclareTimer FTM_INIT_FROM_PARAMS("Widget InitFromParams");
LLFastTimer::DeclareTimer FTM_WIDGET_SETUP("Widget Setup");
const char XML_HEADER[] = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n";
const S32 HPAD = 4;
@@ -110,6 +115,9 @@ public:
static LLRegisterWidget<LLUICtrlLocate> r1("locate");
static LLRegisterWidget<LLUICtrlLocate> r2("pad");
// Build time optimization, generate this once in .cpp file
template class LLUICtrlFactory* LLSingleton<class LLUICtrlFactory>::getInstance();
//-----------------------------------------------------------------------------
// LLUICtrlFactory()
//-----------------------------------------------------------------------------
@@ -556,12 +564,19 @@ LLView* LLUICtrlFactory::createWidget(LLPanel *parent, LLXMLNodePtr node)
if (view)
{
parent->addChild(view, tab_group);
setCtrlParent(view, parent, tab_group);
}
return view;
}
//static
void LLUICtrlFactory::setCtrlParent(LLView* view, LLView* parent, S32 tab_group)
{
if (tab_group == S32_MAX) tab_group = parent->getLastTabGroup();
parent->addChild(view, tab_group);
}
//-----------------------------------------------------------------------------
// createFactoryPanel()
//-----------------------------------------------------------------------------

View File

@@ -41,17 +41,54 @@
#include "llinitparam.h"
class LLView;
class LLPanel;
extern LLFastTimer::DeclareTimer FTM_WIDGET_SETUP;
extern LLFastTimer::DeclareTimer FTM_WIDGET_CONSTRUCTION;
extern LLFastTimer::DeclareTimer FTM_INIT_FROM_PARAMS;
// Build time optimization, generate this once in .cpp file
#ifndef LLUICTRLFACTORY_CPP
extern template class LLUICtrlFactory* LLSingleton<class LLUICtrlFactory>::getInstance();
#endif
class LLUICtrlFactory : public LLSingleton<LLUICtrlFactory>
{
public:
private:
friend class LLSingleton<LLUICtrlFactory>;
LLUICtrlFactory();
// do not call! needs to be public so run-time can clean up the singleton
virtual ~LLUICtrlFactory();
~LLUICtrlFactory();
// only partial specialization allowed in inner classes, so use extra dummy parameter
template <typename PARAM_BLOCK, int DUMMY>
class ParamDefaults : public LLSingleton<ParamDefaults<PARAM_BLOCK, DUMMY> >
{
public:
ParamDefaults()
{
// recursively fill from base class param block
((typename PARAM_BLOCK::base_block_t&)mPrototype).fillFrom(ParamDefaults<typename PARAM_BLOCK::base_block_t, DUMMY>::instance().get());
}
const PARAM_BLOCK& get() { return mPrototype; }
private:
PARAM_BLOCK mPrototype;
};
// base case for recursion, there are NO base classes of LLInitParam::BaseBlock
template<int DUMMY>
class ParamDefaults<LLInitParam::BaseBlock, DUMMY> : public LLSingleton<ParamDefaults<LLInitParam::BaseBlock, DUMMY> >
{
public:
const LLInitParam::BaseBlock& get() { return mBaseBlock; }
private:
LLInitParam::BaseBlock mBaseBlock;
};
public:
void setupPaths();
void buildFloater(LLFloater* floaterp, const std::string &filename,
const LLCallbackMap::map_t* factory_map = NULL, BOOL open = TRUE);
void buildFloaterFromBuffer(LLFloater *floaterp, const std::string &buffer,
@@ -82,8 +119,22 @@ public:
LLPanel* createFactoryPanel(const std::string& name);
virtual LLView* createCtrlWidget(LLPanel *parent, LLXMLNodePtr node);
virtual LLView* createWidget(LLPanel *parent, LLXMLNodePtr node);
LLView* createCtrlWidget(LLPanel *parent, LLXMLNodePtr node);
LLView* createWidget(LLPanel *parent, LLXMLNodePtr node);
template<typename T>
static T* create(typename T::Params& params, LLView* parent = NULL)
{
params.fillFrom(ParamDefaults<typename T::Params, 0>::instance().get());
T* widget = createWidgetImpl<T>(params, parent);
if (widget)
{
widget->postBuild();
}
return widget;
}
static bool getLayeredXMLNode(const std::string &filename, LLXMLNodePtr& root);
static bool getLayeredXMLNodeFromBuffer(const std::string &buffer, LLXMLNodePtr& root);
@@ -93,6 +144,43 @@ public:
private:
bool getLayeredXMLNodeImpl(const std::string &filename, LLXMLNodePtr& root);
void buildFloaterInternal(LLFloater *floaterp, LLXMLNodePtr &root, const std::string &filename,
const LLCallbackMap::map_t *factory_map, BOOL open);
BOOL buildPanelInternal(LLPanel* panelp, LLXMLNodePtr &root, const std::string &filename,
const LLCallbackMap::map_t* factory_map = NULL);
template<typename T>
static T* createWidgetImpl(const typename T::Params& params, LLView* parent = NULL)
{
T* widget = NULL;
if (!params.validateBlock())
{
llwarns << /*getInstance()->getCurFileName() <<*/ ": Invalid parameter block for " << typeid(T).name() << llendl;
//return NULL;
}
{ LLFastTimer _(FTM_WIDGET_CONSTRUCTION);
widget = new T(params);
}
{ LLFastTimer _(FTM_INIT_FROM_PARAMS);
widget->initFromParams(params);
}
if (parent)
{
S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : S32_MAX;
setCtrlParent(widget, parent, tab_group);
}
return widget;
}
// this exists to get around dependency on llview
static void setCtrlParent(LLView* view, LLView* parent, S32 tab_group);
LLPanel* mDummyPanel;
typedef std::map<LLHandle<LLPanel>, std::string> built_panel_t;
built_panel_t mBuiltPanels;
@@ -102,13 +190,6 @@ private:
std::deque<const LLCallbackMap::map_t*> mFactoryStack;
static std::vector<std::string> sXUIPaths;
LLPanel* mDummyPanel;
void buildFloaterInternal(LLFloater *floaterp, LLXMLNodePtr &root, const std::string &filename,
const LLCallbackMap::map_t *factory_map, BOOL open);
BOOL buildPanelInternal(LLPanel* panelp, LLXMLNodePtr &root, const std::string &filename,
const LLCallbackMap::map_t* factory_map = NULL);
};

View File

@@ -146,7 +146,7 @@ void LLView::init(const LLView::Params& p)
// create rect first, as this will supply initial follows flags
setShape(p.rect);
mReshapeFlags = p.follows.flags;
parseFollowsFlags(p);
}
LLView::LLView()
@@ -2409,6 +2409,78 @@ const S32 FLOATER_H_MARGIN = 15;
const S32 MIN_WIDGET_HEIGHT = 10;
const S32 VPAD = 4;
void LLView::initFromParams(const LLView::Params& params)
{
LLRect required_rect = getRequiredRect();
S32 width = llmax(getRect().getWidth(), required_rect.getWidth());
S32 height = llmax(getRect().getHeight(), required_rect.getHeight());
reshape(width, height);
// call virtual methods with most recent data
// use getters because these values might not come through parameter block
setEnabled(getEnabled());
setVisible(getVisible());
if (!params.name().empty())
{
setName(params.name());
}
}
void LLView::parseFollowsFlags(const LLView::Params& params)
{
// preserve follows flags set by code if user did not override
/*if (!params.follows.isProvided())
{
return;
}*/
// interpret either string or bitfield version of follows
if (params.follows.string.isChosen())
{
setFollows(FOLLOWS_NONE);
std::string follows = params.follows.string;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("|");
tokenizer tokens(follows, sep);
tokenizer::iterator token_iter = tokens.begin();
while(token_iter != tokens.end())
{
const std::string& token_str = *token_iter;
if (token_str == "left")
{
setFollowsLeft();
}
else if (token_str == "right")
{
setFollowsRight();
}
else if (token_str == "top")
{
setFollowsTop();
}
else if (token_str == "bottom")
{
setFollowsBottom();
}
else if (token_str == "all")
{
setFollowsAll();
}
++token_iter;
}
}
else if (params.follows.flags.isChosen())
{
setFollows(params.follows.flags);
}
}
// static
U32 LLView::createRect(LLXMLNodePtr node, LLRect &rect, LLView* parent_view, const LLRect &required_rect)
{

View File

@@ -307,7 +307,9 @@ public:
// remove the specified child from the view, and set it's parent to NULL.
virtual void removeChild(LLView* view);
child_tab_order_t getCtrlOrder() const { return mCtrlOrder; }
virtual BOOL postBuild() { return TRUE; }
const child_tab_order_t& getCtrlOrder() const { return mCtrlOrder; }
ctrl_list_t getCtrlList() const;
ctrl_list_t getCtrlListSorted() const;
@@ -410,6 +412,8 @@ public:
virtual void draw();
void parseFollowsFlags(const LLView::Params& params);
virtual LLXMLNodePtr getXML(bool save_children = true) const;
//FIXME: make LLView non-instantiable from XML
static LLView* fromXML(LLXMLNodePtr node, LLView *parent, class LLUICtrlFactory *factory);

View File

@@ -42,12 +42,13 @@
#include "llstring.h"
#include "llscrollcontainer.h"
LLContainerView::LLContainerView(const std::string& name, const LLRect& rect)
: LLView(name, rect, FALSE)
LLContainerView::LLContainerView(const LLContainerView::Params& p)
: LLView(p),
mShowLabel(p.show_label),
mLabel(p.label),
mDisplayChildren(p.display_children)
{
mShowLabel = TRUE;
mCollapsible = TRUE;
mDisplayChildren = TRUE;
mScrollContainer = NULL;
}
@@ -56,6 +57,13 @@ LLContainerView::~LLContainerView()
// Children all cleaned up by default view destructor.
}
BOOL LLContainerView::postBuild()
{
setDisplayChildren(mDisplayChildren);
reshape(getRect().getWidth(), getRect().getHeight(), FALSE);
return TRUE;
}
BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;

View File

@@ -41,15 +41,27 @@ class LLScrollableContainerView;
class LLContainerView : public LLView
{
public:
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
Optional<std::string> label;
Optional<bool> show_label;
Optional<bool> display_children;
Params()
: label("label"),
show_label("show_label", FALSE),
display_children("display_children", TRUE)
{
changeDefault(mouse_opaque, false);
}
};
protected:
BOOL mDisplayChildren;
std::string mLabel;
LLContainerView(const Params& p);
friend class LLUICtrlFactory;
public:
BOOL mCollapsible;
public:
LLContainerView(const std::string& name, const LLRect& rect);
~LLContainerView();
/*virtual*/ BOOL postBuild();
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
@@ -67,5 +79,12 @@ public:
LLScrollableContainerView* mScrollContainer;
void arrange(S32 width, S32 height, BOOL called_from_parent = TRUE);
BOOL mShowLabel;
protected:
BOOL mDisplayChildren;
std::string mLabel;
public:
BOOL mCollapsible;
};
#endif // LL_CONTAINERVIEW_

View File

@@ -44,6 +44,7 @@
#include "llvelocitybar.h"
#include "llviewerwindow.h"
#include "llfloaterstats.h"
#include "lluictrlfactory.h"
//
// Globals
@@ -84,29 +85,30 @@ LLDebugView::LLDebugView(const std::string& name, const LLRect &rect)
addChild(mFastTimerView);
r.set(150, rect.getHeight() - 50, 870, 100);
gTextureView = new LLTextureView("gTextureView", r);
gTextureView->setRect(r);
gTextureView->setFollowsBottom();
gTextureView->setFollowsLeft();
LLTextureView::Params tvp;
tvp.name("gTextureView");
tvp.rect(r);
tvp.visible(false);
gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp);
addChild(gTextureView);
//gTextureView->reshape(r.getWidth(), r.getHeight(), TRUE);
if(gAuditTexture)
{
r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureLoadedCounter.size() * 30, 100);
gTextureSizeView = new LLTextureSizeView("gTextureSizeView");
gTextureSizeView->setRect(r);
gTextureSizeView->setFollowsBottom();
gTextureSizeView->setFollowsLeft();
gTextureSizeView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_SIZE) ;
LLTextureSizeView::Params tsvp;
tsvp.name = "gTextureSizeView";
tsvp.rect = r;
tsvp.type = LLTextureSizeView::TEXTURE_MEM_OVER_SIZE;
gTextureSizeView = LLUICtrlFactory::create<LLTextureSizeView>(tsvp);
addChild(gTextureSizeView);
r.set(150, rect.getHeight() - 50, 900 + LLImageGL::sTextureMemByCategory.size() * 30, 100);
gTextureCategoryView = new LLTextureSizeView("gTextureCategoryView");
gTextureCategoryView->setRect(r);
gTextureCategoryView->setFollowsBottom();
gTextureCategoryView->setFollowsLeft();
gTextureCategoryView->setType(LLTextureSizeView::TEXTURE_MEM_OVER_CATEGORY);
LLTextureSizeView::Params tscp;
tscp.name = "gTextureCategoryView";
tscp.rect = r;
tscp.type = LLTextureSizeView::TEXTURE_MEM_OVER_CATEGORY;
gTextureSizeView = LLUICtrlFactory::create<LLTextureSizeView>(tscp);
addChild(gTextureCategoryView);
}

View File

@@ -99,8 +99,13 @@ BOOL LLFloaterJoystick::postBuild()
rect = LLRect(350, r.mTop, r.mRight + 200, 0);
}
mAxisStatsView = new LLStatView("axis values", joystick, "", rect);
mAxisStatsView->setDisplayChildren(TRUE);
LLStatView::Params params;
params.name("axis values");
params.rect(rect);
params.show_label(true);
params.label(joystick);
mAxisStatsView = LLUICtrlFactory::create<LLStatView>(params);
for (U32 i = 0; i < 6; i++)
{

View File

@@ -63,7 +63,14 @@ void LLFloaterStats::buildStats()
//
// Viewer Basic
//
stat_viewp = new LLStatView("basic stat view", "Basic", "OpenDebugStatBasic", rect);
LLStatView::Params params;
params.name("basic stat view");
params.show_label(true);
params.label("Basic");
params.setting("OpenDebugStatBasic");
params.rect(rect);
stat_viewp = LLUICtrlFactory::create<LLStatView>(params);
addStatView(stat_viewp);
stat_barp = stat_viewp->addStat("FPS", &(LLViewerStats::getInstance()->mFPSStat),
@@ -113,11 +120,20 @@ void LLFloaterStats::buildStats()
stat_barp->mDisplayMean = FALSE;
}
stat_viewp = new LLStatView("advanced stat view", "Advanced", "OpenDebugStatAdvanced", rect);
params.name("advanced stat view");
params.show_label(true);
params.label("Advanced");
params.setting("OpenDebugStatAdvanced");
params.rect(rect);
stat_viewp = LLUICtrlFactory::create<LLStatView>(params);
addStatView(stat_viewp);
LLStatView *render_statviewp = stat_viewp->addStatView("render stat view", "Render", "OpenDebugStatRender", rect);
params.name("render stat view");
params.show_label(true);
params.label("Render");
params.setting("OpenDebugStatRender");
params.rect(rect);
LLStatView *render_statviewp = stat_viewp->addStatView(params);
stat_barp = render_statviewp->addStat("KTris Drawn", &(LLViewerStats::getInstance()->mTrianglesDrawnStat), "DebugStatModeKTrisDrawnFr");
stat_barp->setUnitLabel("/fr");
@@ -162,7 +178,12 @@ void LLFloaterStats::buildStats()
stat_barp->mPerSec = FALSE;
// Texture statistics
LLStatView *texture_statviewp = render_statviewp->addStatView("texture stat view", "Texture", "OpenDebugStatTexture", rect);
params.name("texture stat view");
params.show_label(true);
params.label("Texture");
params.setting("OpenDebugStatTexture");
params.rect(rect);
LLStatView *texture_statviewp = render_statviewp->addStatView(params);
stat_barp = texture_statviewp->addStat("Cache Hit Rate", &(LLTextureFetch::sCacheHitRate), std::string(), false, true);
stat_barp->setLabel("Cache Hit Rate");
@@ -233,10 +254,14 @@ void LLFloaterStats::buildStats()
stat_barp->mLabelSpacing = 200.f;
stat_barp->mPrecision = 1;
stat_barp->mPerSec = FALSE;
// Network statistics
LLStatView *net_statviewp = stat_viewp->addStatView("network stat view", "Network", "OpenDebugStatNet", rect);
params.name("network stat view");
params.show_label(true);
params.label("Network");
params.setting("OpenDebugStatNet");
params.rect(rect);
LLStatView *net_statviewp = stat_viewp->addStatView(params);
stat_barp = net_statviewp->addStat("UDP Packets In", &(LLViewerStats::getInstance()->mPacketsInStat), "DebugStatModePacketsIn");
stat_barp->setUnitLabel("/sec");
@@ -307,7 +332,12 @@ void LLFloaterStats::buildStats()
// Simulator stats
LLStatView *sim_statviewp = new LLStatView("sim stat view", "Simulator", "OpenDebugStatSim", rect);
params.name("sim stat view");
params.show_label(true);
params.label("Simulator");
params.setting("OpenDebugStatSim");
params.rect(rect);
LLStatView *sim_statviewp = LLUICtrlFactory::create<LLStatView>(params);
addStatView(sim_statviewp);
stat_barp = sim_statviewp->addStat("Time Dilation", &(LLViewerStats::getInstance()->mSimTimeDilation), "DebugStatModeTimeDialation");
@@ -336,7 +366,12 @@ void LLFloaterStats::buildStats()
stat_barp->mPerSec = FALSE;
stat_barp->mDisplayMean = FALSE;
LLStatView *phys_details_viewp = sim_statviewp->addStatView("phys detail view", "Physics Details", "OpenDebugStatPhysicsDetails", rect);
params.name("phys detail view");
params.show_label(true);
params.label("Physics Details");
params.setting("OpenDebugStatPhysicsDetails");
params.rect(rect);
LLStatView *phys_details_viewp = sim_statviewp->addStatView(params);
stat_barp = phys_details_viewp->addStat("Pinned Objects", &(LLViewerStats::getInstance()->mPhysicsPinnedTasks), "DebugStatModePinnedObjects");
stat_barp->mPrecision = 0;
@@ -439,7 +474,12 @@ void LLFloaterStats::buildStats()
stat_barp->mPerSec = FALSE;
stat_barp->mDisplayMean = FALSE;
LLStatView *pathfinding_viewp = sim_statviewp->addStatView("pathfinding view", "Pathfinding Details", std::string(), rect);
params.name("pathfinding view");
params.show_label(true);
params.label("Pathfinding Details");
params.rect(rect);
LLStatView *pathfinding_viewp = sim_statviewp->addStatView(params);
stat_barp = pathfinding_viewp->addStat("AI Step Time", &(LLViewerStats::getInstance()->mSimSimAIStepMsec));
stat_barp->setUnitLabel("ms");
stat_barp->mPrecision = 3;
@@ -516,7 +556,12 @@ void LLFloaterStats::buildStats()
stat_barp->mPerSec = FALSE;
stat_barp->mDisplayMean = FALSE;
LLStatView *sim_time_viewp = sim_statviewp->addStatView("sim perf view", "Time (ms)", "OpenDebugStatSimTime", rect);
params.name("sim perf view");
params.show_label(true);
params.label("Time (ms)");
params.setting("OpenDebugStatSimTime");
params.rect(rect);
LLStatView *sim_time_viewp = sim_statviewp->addStatView(params);
stat_barp = sim_time_viewp->addStat("Total Frame Time", &(LLViewerStats::getInstance()->mSimFrameMsec), "DebugStatModeSimFrameMsec");
stat_barp->setUnitLabel("ms");
@@ -600,7 +645,12 @@ void LLFloaterStats::buildStats()
// 2nd level time blocks under 'Details' second
LLStatView *detailed_time_viewp = sim_time_viewp->addStatView("sim perf view", "Time Details (ms)", "OpenDebugStatSimTimeDetails", rect);
params.name("sim perf view");
params.show_label(true);
params.label("Time (ms)");
params.setting("OpenDebugStatSimTimeDetails");
params.rect(rect);
LLStatView *detailed_time_viewp = sim_time_viewp->addStatView(params);
{
stat_barp = detailed_time_viewp->addStat(" Physics Step", &(LLViewerStats::getInstance()->mSimSimPhysicsStepMsec), "DebugStatModeSimSimPhysicsStepMsec");
stat_barp->setUnitLabel("ms");
@@ -670,8 +720,11 @@ LLFloaterStats::LLFloaterStats(const LLSD& val)
LLRect stats_rect(0, getRect().getHeight() - LLFLOATER_HEADER_SIZE,
getRect().getWidth() - LLFLOATER_CLOSE_BOX_SIZE, 0);
mStatsContainer = new LLContainerView("statistics_view", stats_rect);
mStatsContainer->showLabel(FALSE);
LLContainerView::Params rvp;
rvp.name("statistics_view");
rvp.rect(stats_rect);
mStatsContainer = LLUICtrlFactory::create<LLContainerView>(rvp);
LLRect scroll_rect(LL_SCROLL_BORDER, getRect().getHeight() - LLFLOATER_HEADER_SIZE - LL_SCROLL_BORDER,
getRect().getWidth() - LL_SCROLL_BORDER, LL_SCROLL_BORDER);

View File

@@ -64,12 +64,12 @@ public:
F32 mTickSpacing;
F32 mLabelSpacing;
U32 mPrecision;
F32 mUpdatesPerSec;
BOOL mPerSec; // Use the per sec stats.
BOOL mDisplayBar; // Display the bar graph.
BOOL mDisplayHistory;
BOOL mDisplayMean; // If true, display mean, if false, display current value
F32 mUpdatesPerSec;
LLStat *mStatp;
private:
LLFrameTimer mUpdateTimer;

View File

@@ -43,19 +43,19 @@
#include "llstatbar.h"
#include "llviewercontrol.h"
LLStatView::LLStatView(const std::string& name, const std::string& label, const std::string& setting, const LLRect& rect)
: LLContainerView(name, rect),
mNumStatBars(0),
mSetting(setting)
#include "lluictrlfactory.h"
LLStatView::LLStatView(const LLStatView::Params& p)
: LLContainerView(p),
mNumStatBars(0),
mSetting(p.setting)
{
setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
setLabel(label);
BOOL open = FALSE;
BOOL isopen = getDisplayChildren();
if (mSetting.length() > 0)
{
open = gSavedSettings.getBOOL(mSetting);
isopen = gSavedSettings.getBOOL(mSetting);
}
setDisplayChildren(open); /* Flawfinder: ignore */
setDisplayChildren(isopen);
}
LLStatView::~LLStatView()
@@ -63,8 +63,8 @@ LLStatView::~LLStatView()
// Children all cleaned up by default view destructor.
if (mSetting.length() > 0)
{
BOOL open = getDisplayChildren();
gSavedSettings.setBOOL(mSetting, open); /* Flawfinder: ignore */
BOOL isopen = getDisplayChildren();
gSavedSettings.setBOOL(mSetting, isopen); /* Flawfinder: ignore */
}
}
@@ -74,12 +74,6 @@ LLStatBar *LLStatView::addStat(const std::string& name, LLStat *statp,
LLStatBar *stat_barp;
LLRect r;
// if (getStatBar(name))
// {
// llinfos << "LLStatView::addStat - Stat already exists!" << llendl;
// return NULL;
// }
mNumStatBars++;
stat_barp = new LLStatBar(name, r, setting, default_bar, default_history);
@@ -94,27 +88,10 @@ LLStatBar *LLStatView::addStat(const std::string& name, LLStat *statp,
return stat_barp;
}
LLStatView *LLStatView::addStatView(const std::string& name, const std::string& label, const std::string& setting, const LLRect& rect)
LLStatView *LLStatView::addStatView(LLStatView::Params& p)
{
LLStatView *statview = new LLStatView(name, label, setting, rect);
LLStatView* statview = LLUICtrlFactory::create<LLStatView>(p);
statview->setVisible(mDisplayChildren);
addChildInBack(statview);
return statview;
}
LLStatBar *LLStatView::getStatBar(const std::string& name)
{
sb_vector_t::iterator iter;
for(iter = mStatBars.begin(); iter != mStatBars.end(); ++iter)
{
LLStatBar *stat_barp = *iter;
if (stat_barp->getLabel() == name)
{
return stat_barp;
}
}
// Not found!
return NULL;
}
}

View File

@@ -42,20 +42,25 @@ class LLStatBar;
class LLStatView : public LLContainerView
{
public:
LLStatView(const std::string& name, const std::string& label, const std::string& setting, const LLRect& rect);
struct Params : public LLInitParam::Block<Params, LLContainerView::Params>
{
Optional<std::string> setting;
Params()
: setting("setting")
{
changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT);
}
};
~LLStatView();
/*
virtual void draw();
virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
virtual LLRect getRequiredRect(); // Return the height of this object, given the set options.
*/
protected:
LLStatView(const Params&);
friend class LLUICtrlFactory;
public:
LLStatBar *addStat(const std::string& name, LLStat *statp,
const std::string& setting = std::string(), BOOL default_bar = FALSE, BOOL default_history = FALSE);
LLStatBar *getStatBar(const std::string& name);
LLStatView *addStatView(const std::string& name, const std::string& label, const std::string& setting, const LLRect& rect);
LLStatView *addStatView(LLStatView::Params& p);
protected:
typedef std::vector<LLStatBar *> sb_vector_t;
sb_vector_t mStatBars;

View File

@@ -48,6 +48,7 @@
#include "llviewertexturelist.h"
#include "llvovolume.h"
#include "llviewerstats.h"
#include "lluictrlfactory.h"
// For avatar texture view
#include "llvoavatarself.h"
@@ -96,12 +97,20 @@ public:
S32 mHilite;
public:
LLTextureBar(const std::string& name, const LLRect& r, LLTextureView* texview)
: LLView(name, r, FALSE),
mHilite(0),
mTextureView(texview)
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
}
Mandatory<LLTextureView*> texture_view;
Params()
: texture_view("texture_view")
{
changeDefault(mouse_opaque, false);
}
};
LLTextureBar(const Params& p)
: LLView(p),
mHilite(0),
mTextureView(p.texture_view)
{}
virtual void draw();
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
@@ -393,14 +402,21 @@ LLRect LLTextureBar::getRequiredRect()
class LLAvatarTexBar : public LLView
{
public:
LLAvatarTexBar(const std::string& name, LLTextureView* texview)
: LLView(name, FALSE),
mTextureView(texview)
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
setRect(LLRect(0,0,100,line_height * 4));
}
Mandatory<LLTextureView*> texture_view;
Params()
: texture_view("texture_view")
{
S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
changeDefault(rect, LLRect(0,0,100,line_height * 4));
}
};
LLAvatarTexBar(const Params& p)
: LLView(p),
mTextureView(p.texture_view)
{}
virtual void draw();
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
@@ -485,13 +501,21 @@ LLRect LLAvatarTexBar::getRequiredRect()
class LLGLTexMemBar : public LLView
{
public:
LLGLTexMemBar(const std::string& name, LLTextureView* texview)
: LLView(name, FALSE),
mTextureView(texview)
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
setRect(LLRect(0,0,100,line_height * 4));
}
Mandatory<LLTextureView*> texture_view;
Params()
: texture_view("texture_view")
{
S32 line_height = (S32)(LLFontGL::getFontMonospace()->getLineHeight() + .5f);
changeDefault(rect, LLRect(0,0,100,line_height * 4));
}
};
LLGLTexMemBar(const Params& p)
: LLView(p),
mTextureView(p.texture_view)
{}
virtual void draw();
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
@@ -744,8 +768,8 @@ void LLGLTexSizeBar::draw()
}
////////////////////////////////////////////////////////////////////////////
LLTextureView::LLTextureView(const std::string& name, const LLRect& rect)
: LLContainerView(name, rect),
LLTextureView::LLTextureView(const LLTextureView::Params& p)
: LLContainerView(p),
mFreezeView(FALSE),
mOrderFetch(FALSE),
mPrintList(FALSE),
@@ -971,11 +995,24 @@ void LLTextureView::draw()
else
sortChildren(LLTextureBar::sort());
mGLTexMemBar = new LLGLTexMemBar("gl texmem bar", this);
LLGLTexMemBar::Params tmbp;
LLRect tmbr;
tmbp.name("gl texmem bar");
tmbp.rect(tmbr);
tmbp.follows.flags = FOLLOWS_LEFT|FOLLOWS_TOP;
tmbp.texture_view(this);
mGLTexMemBar = LLUICtrlFactory::create<LLGLTexMemBar>(tmbp);
addChild(mGLTexMemBar);
mAvatarTexBar = new LLAvatarTexBar("gl avatartex bar", this);
//sendChildToFront(mGLTexMemBar);
LLAvatarTexBar::Params atbp;
LLRect atbr;
atbp.name("gl avatartex bar");
atbp.texture_view(this);
atbp.rect(atbr);
mAvatarTexBar = LLUICtrlFactory::create<LLAvatarTexBar>(atbp);
addChild(mAvatarTexBar);
//sendChildToFront(mAvatarTexBar);
reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
@@ -1011,7 +1048,11 @@ BOOL LLTextureView::addBar(LLViewerFetchedTexture *imagep, S32 hilite)
mNumTextureBars++;
barp = new LLTextureBar("texture bar", r, this);
LLTextureBar::Params tbp;
tbp.name("texture bar");
tbp.rect(r);
tbp.texture_view(this);
barp = LLUICtrlFactory::create<LLTextureBar>(tbp);
barp->mImagep = imagep;
barp->mHilite = hilite;
@@ -1057,10 +1098,8 @@ BOOL LLTextureView::handleKey(KEY key, MASK mask, BOOL called_from_parent)
}
//-----------------------------------------------------------------
LLTextureSizeView::LLTextureSizeView(const std::string& name) : LLContainerView(name, LLRect())
LLTextureSizeView::LLTextureSizeView(const Params& p) : LLContainerView(p)
{
setVisible(FALSE) ;
mTextureSizeBarWidth = 30 ;
}

View File

@@ -39,8 +39,10 @@ class LLTextureView : public LLContainerView
friend class LLTextureBar;
friend class LLGLTexMemBar;
friend class LLAvatarTexBar;
protected:
LLTextureView(const Params&);
friend class LLUICtrlFactory;
public:
LLTextureView(const std::string& name, const LLRect& rect);
~LLTextureView();
/*virtual*/ void draw();
@@ -76,7 +78,19 @@ class LLGLTexSizeBar;
class LLTextureSizeView : public LLContainerView
{
public:
LLTextureSizeView(const std::string& name);
struct Params : public LLInitParam::Block<Params, LLContainerView::Params>
{
Mandatory<S32> type;
Params() :
type("type")
{
changeDefault(visible, false);
changeDefault(follows.flags, FOLLOWS_BOTTOM | FOLLOWS_LEFT);
}
};
LLTextureSizeView(const Params& p);
~LLTextureSizeView();
/*virtual*/ void draw();

View File

@@ -1656,7 +1656,12 @@ LLViewerWindow::LLViewerWindow(
LLUICtrlFactory::getXUIPaths());
}
// Create container for all sub-views
mRootView = new LLRootView("root", mWindowRectScaled, FALSE);
LLView::Params rvp;
rvp.name("root");
rvp.rect(mWindowRectScaled);
rvp.mouse_opaque(false);
rvp.follows.flags(FOLLOWS_NONE);
mRootView = LLUICtrlFactory::create<LLRootView>(rvp);
// Make avatar head look forward at start
mCurrentMousePoint.mX = getWindowWidthScaled() / 2;