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

@@ -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;