Browse Source

Separate plOperationProgress titles and statuses.

Now we render titles above the progress bar and the status below (in the
same color as the progress bar!). Also, introduce a new info field that is
guaranteed to be right justified.
Adam Johnson 11 years ago
parent
commit
275f15087c
  1. 10
      Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp
  2. 98
      Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp
  3. 7
      Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h

10
Sources/Plasma/PubUtilLib/plNetClient/plNetCliAgeJoiner.cpp

@ -252,12 +252,10 @@ void plNCAgeJoiner::ExecNextOp () {
LogMsg(kLogPerf, L"AgeJoiner: Exec:kLoadAge"); LogMsg(kLogPerf, L"AgeJoiner: Exec:kLoadAge");
// Start progress bar // Start progress bar
char str[256]; char str[128];
#ifdef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
StrCopy(str, "Loading age...", arrsize(str)); snprintf(str, arrsize(str), "Loading age... %s", age.ageDatasetName);
#else #endif
StrPrintf(str, arrsize(str), "Loading age %s...", age.ageDatasetName);
#endif
progressBar = plProgressMgr::GetInstance()->RegisterOperation(0, str, plProgressMgr::kNone, false, true); progressBar = plProgressMgr::GetInstance()->RegisterOperation(0, str, plProgressMgr::kNone, false, true);
plDispatch::SetMsgRecieveCallback(IDispatchMsgReceiveCallback); plDispatch::SetMsgRecieveCallback(IDispatchMsgReceiveCallback);
((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(IResMgrProgressBarCallback); ((plResManager*)hsgResMgr::ResMgr())->SetProgressBarProc(IResMgrProgressBarCallback);

98
Sources/Plasma/PubUtilLib/plPipeline/plDTProgressMgr.cpp

@ -57,6 +57,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h" #include "hsTimer.h"
// Draw Colors
enum
{
kTitleColor = 0xccb0b0b0,
kProgressBarColor = 0xff302b3a,
kInfoColor = 0xff635e6d,
};
//// Constructor & Destructor //////////////////////////////////////////////// //// Constructor & Destructor ////////////////////////////////////////////////
@ -178,85 +186,51 @@ bool plDTProgressMgr::IDrawTheStupidThing(plPipeline *p, plOperationProgress
{ {
plDebugText &text = plDebugText::Instance(); plDebugText &text = plDebugText::Instance();
bool drew_something = false; bool drew_something = false;
uint16_t downsz = (text.GetFontSize() << 1) + 4;
// Lets just set the color to blue // draw the title
uint32_t color = 0xff302b3a; if (!prog->GetTitle().IsEmpty()) {
y -= downsz;
text.DrawString_TEMP(x, y, prog->GetTitle(), kTitleColor);
y += downsz;
drew_something = true;
}
if( prog->GetMax() > 0.f ) // draw a progress bar
{ if (prog->GetMax() > 0.f) {
text.Draw3DBorder(x, y, x + width - 1, y + height - 1, color, color); text.Draw3DBorder(x, y, x + width - 1, y + height - 1, kProgressBarColor, kProgressBarColor);
x += 2; x += 2;
y += 2; y += 2;
width -= 4; width -= 4;
height -= 4; height -= 4;
uint16_t drawWidth = width; uint16_t drawWidth = width;
int16_t drawX = x; int16_t drawX = x;
uint16_t rightX = drawX + drawWidth; uint16_t rightX = drawX + drawWidth;
if (prog->GetProgress() <= prog->GetMax()) if (prog->GetProgress() <= prog->GetMax())
drawWidth = (uint16_t)( (float)width * prog->GetProgress() / prog->GetMax() ); drawWidth = (uint16_t)((float)width * prog->GetProgress() / prog->GetMax());
rightX = drawX + drawWidth; rightX = drawX + drawWidth;
if (drawWidth > 0)
text.DrawRect(drawX, y, rightX, y + height, kProgressBarColor);
y += height + 2;
if( drawWidth > 0 )
text.DrawRect( drawX, y, rightX, y + height, color );
uint32_t timeRemain = prog->fRemainingSecs;
if (timeRemain > 0) {
plStringStream ss;
ss << "APPROXIMATELY ";
if (timeRemain > 3600)
{
uint32_t hours = timeRemain / 3600;
const char* plural = (hours > 1) ? "S" : "";
ss << hours << " HOUR" << plural << " ";
timeRemain %= 3600;
}
if (timeRemain > 60)
{
uint32_t minutes = timeRemain / 60;
const char* plural = (minutes > 1) ? "S" : "";
ss << minutes << " MINUTE" << plural << " ";
timeRemain %= 60;
}
if (timeRemain > 0)
{
const char* plural = (timeRemain > 1) ? "S" : "";
ss << timeRemain << " SECOND" << plural << " ";
}
ss << "REMAINING";
text.DrawString(x, y + height + 2, ss.GetString().c_str(), (uint32_t)0xff635e6d);
}
x -= 2;
y -= 2;
drew_something = true; drew_something = true;
} }
y -= ( text.GetFontSize() << 1 ) + 4; // draw the left justified status text
if (!prog->GetStatusText().IsEmpty()) {
#ifndef PLASMA_EXTERNAL_RELEASE text.DrawString_TEMP(x, y, prog->GetStatusText(), kInfoColor);
static bool drawText = true; drew_something = true;
#else }
static bool drawText = false;
#endif
if (drawText)
{
if (!prog->GetTitle().IsEmpty())
{
text.DrawString_TEMP( x, y, prog->GetTitle(), (uint32_t)0xccb0b0b0 );
x += (uint16_t)text.CalcStringWidth_TEMP( prog->GetTitle() );
drew_something = true;
}
if (!prog->GetStatusText().IsEmpty()) // draw the right justified info text
{ if (!prog->GetInfoText().IsEmpty()) {
text.DrawString_TEMP( x, y, prog->GetStatusText(), (uint32_t)0xccb0b0b0 ); uint16_t right_x = 2 + x + width - text.CalcStringWidth_TEMP(prog->GetInfoText());
drew_something = true; text.DrawString_TEMP(right_x, y, prog->GetInfoText(), kInfoColor);
} drew_something = true;
} }
// return whether or not we drew stuff // return whether or not we drew stuff

7
Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h

@ -76,6 +76,7 @@ class plOperationProgress
float fValue, fMax; float fValue, fMax;
plString fTitle; plString fTitle;
plString fStatusText; plString fStatusText;
plString fInfoText;
uint32_t fContext; uint32_t fContext;
double fStartTime; double fStartTime;
@ -113,6 +114,7 @@ class plOperationProgress
float GetProgress() const { return fValue; } float GetProgress() const { return fValue; }
plString GetTitle() const { return fTitle; } plString GetTitle() const { return fTitle; }
plString GetStatusText() const { return fStatusText; } plString GetStatusText() const { return fStatusText; }
plString GetInfoText() const { return fInfoText; }
uint32_t GetContext() const { return fContext; } uint32_t GetContext() const { return fContext; }
uint32_t GetElapsedSecs() { return fElapsedSecs; } uint32_t GetElapsedSecs() { return fElapsedSecs; }
uint32_t GetRemainingSecs() { return fRemainingSecs; } uint32_t GetRemainingSecs() { return fRemainingSecs; }
@ -127,7 +129,10 @@ class plOperationProgress
// Set the length // Set the length
void SetLength( float length ); void SetLength( float length );
/** Sets the progress bar's status text */ /** Sets the progress bar's right justified info text */
void SetInfoText(const plString& info) { fInfoText = info; }
/** Sets the progress bar's left justified status text */
void SetStatusText(const plString& status) { fStatusText = status; } void SetStatusText(const plString& status) { fStatusText = status; }
/** Sets the progress bar's title */ /** Sets the progress bar's title */

Loading…
Cancel
Save