summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-07-15 11:06:22 -0700
committerRichard Linden <none@none>2013-07-15 11:06:22 -0700
commitc03e366a6022d13fcf7b7e502daff8c72f7b64ee (patch)
tree6f92e21824332b5357f8befe4c978b83dbaa1aef /indra/llui
parent27de692bd7b297c9cd0fd6abcdee4b3e2486ec52 (diff)
parent11e14cd3b0f58225a96b9b7a9839a7f030fe4045 (diff)
Automated merge with https://bitbucket.org/lindenlab/viewer-interesting
Diffstat (limited to 'indra/llui')
-rwxr-xr-xindra/llui/llcontainerview.cpp2
-rwxr-xr-xindra/llui/llstatbar.cpp425
-rwxr-xr-xindra/llui/llstatbar.h74
-rwxr-xr-xindra/llui/lltooltip.cpp3
4 files changed, 304 insertions, 200 deletions
diff --git a/indra/llui/llcontainerview.cpp b/indra/llui/llcontainerview.cpp
index 06f8e72c9c..6b1e3ce669 100755
--- a/indra/llui/llcontainerview.cpp
+++ b/indra/llui/llcontainerview.cpp
@@ -167,7 +167,7 @@ void LLContainerView::arrange(S32 width, S32 height, BOOL called_from_parent)
//LLView *childp;
// These will be used for the children
- left = 4;
+ left = 10;
top = getRect().getHeight() - 4;
right = width - 2;
bottom = top;
diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp
index fd88565de4..a0a14f4610 100755
--- a/indra/llui/llstatbar.cpp
+++ b/indra/llui/llstatbar.cpp
@@ -37,32 +37,156 @@
#include "lluictrlfactory.h"
#include "lltracerecording.h"
#include "llcriticaldamp.h"
+#include "lltooltip.h"
+#include "lllocalcliprect.h"
+#include <iostream>
+
+F32 calc_tick_value(F32 min, F32 max)
+{
+ F32 range = max - min;
+ const S32 DIVISORS[] = {6, 8, 10, 4, 5};
+ // try storing
+ S32 best_decimal_digit_count = S32_MAX;
+ S32 best_divisor = 10;
+ for (U32 divisor_idx = 0; divisor_idx < LL_ARRAY_SIZE(DIVISORS); divisor_idx++)
+ {
+ S32 divisor = DIVISORS[divisor_idx];
+ F32 possible_tick_value = range / divisor;
+ S32 num_whole_digits = llceil(logf(min + possible_tick_value) * OO_LN10);
+ for (S32 digit_count = -(num_whole_digits - 1); digit_count < 6; digit_count++)
+ {
+ F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count));
+
+ if (is_approx_equal((F32)(S32)test_tick_value, test_tick_value))
+ {
+ if (digit_count < best_decimal_digit_count)
+ {
+ best_decimal_digit_count = digit_count;
+ best_divisor = divisor;
+ }
+ break;
+ }
+ }
+ }
+
+ return is_approx_equal(range, 0.f) ? 0.f : range / best_divisor;
+}
+
+void calc_auto_scale_range(F32& min, F32& max, F32& tick)
+{
+ min = llmin(0.f, min, max);
+ max = llmax(0.f, min, max);
+
+ const F32 RANGES[] = {0.f, 1.f, 1.5f, 2.f, 3.f, 5.f, 10.f};
+ const F32 TICKS[] = {0.f, 0.25f, 0.5f, 1.f, 1.f, 1.f, 2.f };
+
+ const S32 num_digits_max = is_approx_equal(fabs(max), 0.f)
+ ? S32_MIN + 1
+ : llceil(logf(fabs(max)) * OO_LN10);
+ const S32 num_digits_min = is_approx_equal(fabs(min), 0.f)
+ ? S32_MIN + 1
+ : llceil(logf(fabs(min)) * OO_LN10);
+
+ const S32 num_digits = llmax(num_digits_max, num_digits_min);
+ const F32 power_of_10 = pow(10.0, num_digits - 1);
+ const F32 starting_max = power_of_10 * ((max < 0.f) ? -1 : 1);
+ const F32 starting_min = power_of_10 * ((min < 0.f) ? -1 : 1);
+
+ F32 cur_max = starting_max;
+ F32 cur_min = starting_min;
+ F32 out_max = max;
+ F32 out_min = min;
+
+ F32 cur_tick_min = 0.f;
+ F32 cur_tick_max = 0.f;
+
+ for (S32 range_idx = 0; range_idx < LL_ARRAY_SIZE(RANGES); range_idx++)
+ {
+ cur_max = starting_max * RANGES[range_idx];
+ cur_min = starting_min * RANGES[range_idx];
+
+ if (min > 0.f && cur_min <= min)
+ {
+ out_min = cur_min;
+ cur_tick_min = TICKS[range_idx];
+ }
+ if (max < 0.f && cur_max >= max)
+ {
+ out_max = cur_max;
+ cur_tick_max = TICKS[range_idx];
+ }
+ }
+
+ cur_max = starting_max;
+ cur_min = starting_min;
+ for (S32 range_idx = LL_ARRAY_SIZE(RANGES) - 1; range_idx >= 0; range_idx--)
+ {
+ cur_max = starting_max * RANGES[range_idx];
+ cur_min = starting_min * RANGES[range_idx];
+
+ if (min < 0.f && cur_min <= min)
+ {
+ out_min = cur_min;
+ cur_tick_min = TICKS[range_idx];
+ }
+ if (max > 0.f && cur_max >= max)
+ {
+ out_max = cur_max;
+ cur_tick_max = TICKS[range_idx];
+ }
+ }
+
+ tick = power_of_10 * llmax(cur_tick_min, cur_tick_max);
+ min = out_min;
+ max = out_max;
+}
///////////////////////////////////////////////////////////////////////////////////
LLStatBar::LLStatBar(const Params& p)
- : LLView(p),
- mLabel(p.label),
- mUnitLabel(p.unit_label),
- mMinBar(p.bar_min),
- mMaxBar(p.bar_max),
- mCurMaxBar(p.bar_max),
- mTickSpacing(p.tick_spacing),
- mPrecision(p.precision),
- mUpdatesPerSec(p.update_rate),
- mUnitScale(p.unit_scale),
- mNumFrames(p.num_frames),
- mMaxHeight(p.max_height),
- mPerSec(p.show_per_sec),
- mDisplayBar(p.show_bar),
- mDisplayHistory(p.show_history),
- mDisplayMean(p.show_mean),
- mOrientation(p.orientation),
- mScaleRange(p.scale_range)
+: LLView(p),
+ mLabel(p.label),
+ mUnitLabel(p.unit_label),
+ mMinBar(llmin(p.bar_min, p.bar_max)),
+ mMaxBar(llmax(p.bar_max, p.bar_min)),
+ mCurMaxBar(p.bar_max),
+ mDecimalDigits(p.decimal_digits),
+ mNumFrames(p.num_frames),
+ mMaxHeight(p.max_height),
+ mPerSec(p.show_per_sec),
+ mDisplayBar(p.show_bar),
+ mDisplayHistory(p.show_history),
+ mOrientation(p.orientation),
+ mAutoScaleMax(!p.bar_max.isProvided()),
+ mAutoScaleMin(!p.bar_min.isProvided()),
+ mTickValue(p.tick_spacing)
{
+ // tick value will be automatically calculated later
+ if (!p.tick_spacing.isProvided() && p.bar_min.isProvided() && p.bar_max.isProvided())
+ {
+ mTickValue = calc_tick_value(mMinBar, mMaxBar);
+ }
+
setStat(p.stat);
}
+BOOL LLStatBar::handleHover(S32 x, S32 y, MASK mask)
+{
+ if (mCountFloatp)
+ {
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mCountFloatp->getDescription()).sticky_rect(calcScreenRect()));
+ }
+ else if ( mEventFloatp)
+ {
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mEventFloatp->getDescription()).sticky_rect(calcScreenRect()));
+ }
+ else if (mSampleFloatp)
+ {
+ LLToolTipMgr::instance().show(LLToolTip::Params().message(mSampleFloatp->getDescription()).sticky_rect(calcScreenRect()));
+ }
+ return TRUE;
+}
+
BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask)
{
BOOL handled = LLView::handleMouseDown(x, y, mask);
@@ -96,19 +220,22 @@ BOOL LLStatBar::handleMouseDown(S32 x, S32 y, MASK mask)
void LLStatBar::draw()
{
- F32 current = 0.f,
- min = 0.f,
- max = 0.f,
- mean = 0.f;
+ F32 current = 0,
+ min = 0,
+ max = 0,
+ mean = 0;
+ LLLocalClipRect _(getLocalRect());
LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+ std::string unit_label;
if (mCountFloatp)
{
LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording();
-
+ unit_label = mUnitLabel.empty() ? mCountFloatp->getUnitLabel() : mUnitLabel;
if (mPerSec)
{
+ unit_label += "/s";
current = last_frame_recording.getPerSec(*mCountFloatp);
min = frame_recording.getPeriodMinPerSec(*mCountFloatp, mNumFrames);
max = frame_recording.getPeriodMaxPerSec(*mCountFloatp, mNumFrames);
@@ -125,6 +252,7 @@ void LLStatBar::draw()
else if (mEventFloatp)
{
LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording();
+ unit_label = mUnitLabel.empty() ? mEventFloatp->getUnitLabel() : mUnitLabel;
current = last_frame_recording.getMean(*mEventFloatp);
min = frame_recording.getPeriodMin(*mEventFloatp, mNumFrames);
@@ -134,31 +262,14 @@ void LLStatBar::draw()
else if (mSampleFloatp)
{
LLTrace::Recording& last_frame_recording = frame_recording.getLastRecording();
+ unit_label = mUnitLabel.empty() ? mSampleFloatp->getUnitLabel() : mUnitLabel;
- current = last_frame_recording.getLastValue(*mSampleFloatp);
+ current = last_frame_recording.getMean(*mSampleFloatp);
min = frame_recording.getPeriodMin(*mSampleFloatp, mNumFrames);
max = frame_recording.getPeriodMax(*mSampleFloatp, mNumFrames);
mean = frame_recording.getPeriodMean(*mSampleFloatp, mNumFrames);
}
- current *= mUnitScale;
- min *= mUnitScale;
- max *= mUnitScale;
- mean *= mUnitScale;
-
- if ((mUpdatesPerSec == 0.f) || (mUpdateTimer.getElapsedTimeF32() > 1.f/mUpdatesPerSec) || (mValue == 0.f))
- {
- if (mDisplayMean)
- {
- mValue = mean;
- }
- else
- {
- mValue = current;
- }
- mUpdateTimer.reset();
- }
-
S32 bar_top, bar_left, bar_right, bar_bottom;
if (mOrientation == HORIZONTAL)
{
@@ -177,41 +288,50 @@ void LLStatBar::draw()
const S32 tick_length = 4;
const S32 tick_width = 1;
- if (mScaleRange && min < max)
+ if ((mAutoScaleMax && max >= mCurMaxBar)|| (mAutoScaleMin && min <= mCurMinBar))
{
- F32 cur_max = mTickSpacing;
- while(max > cur_max && mMaxBar > cur_max)
+ F32 range_min = mAutoScaleMin ? llmin(mMinBar, min) : mMinBar;
+ F32 range_max = mAutoScaleMax ? llmax(mMaxBar, max) : mMaxBar;
+ F32 tick_value = 0.f;
+ calc_auto_scale_range(range_min, range_max, tick_value);
+ if (mAutoScaleMin) { mMinBar = range_min; }
+ if (mAutoScaleMax) { mMaxBar = range_max; }
+ if (mAutoScaleMin && mAutoScaleMax)
{
- cur_max += mTickSpacing;
+ mTickValue = tick_value;
+ }
+ else
+ {
+ mTickValue = calc_tick_value(mMinBar, mMaxBar);
}
- mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, cur_max, 0.05f);
+ }
+
+ mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f);
+ mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f);
+
+ F32 value_scale;
+ if (mCurMaxBar == mCurMinBar)
+ {
+ value_scale = 0.f;
}
else
{
- mCurMaxBar = mMaxBar;
+ value_scale = (mOrientation == HORIZONTAL)
+ ? (bar_top - bar_bottom)/(mCurMaxBar - mCurMinBar)
+ : (bar_right - bar_left)/(mCurMaxBar - mCurMinBar);
}
- F32 value_scale = (mOrientation == HORIZONTAL)
- ? (bar_top - bar_bottom)/(mCurMaxBar - mMinBar)
- : (bar_right - bar_left)/(mCurMaxBar - mMinBar);
-
LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f),
LLFontGL::LEFT, LLFontGL::TOP);
-
- std::string value_format;
- std::string value_str;
- if (!mUnitLabel.empty())
- {
- value_format = llformat( "%%.%df%%s", mPrecision);
- value_str = llformat( value_format.c_str(), mValue, mUnitLabel.c_str());
- }
- else
+
+ S32 decimal_digits = mDecimalDigits;
+ if (is_approx_equal((F32)(S32)mean, mean))
{
- value_format = llformat( "%%.%df", mPrecision);
- value_str = llformat( value_format.c_str(), mValue);
+ decimal_digits = 0;
}
+ std::string value_str = llformat("%10.*f %s", decimal_digits, mean, unit_label.c_str());
- // Draw the value.
+ // Draw the current value.
if (mOrientation == HORIZONTAL)
{
LLFontGL::getFontMonospace()->renderUTF8(value_str, 0, bar_right, getRect().getHeight(),
@@ -225,58 +345,73 @@ void LLStatBar::draw()
LLFontGL::RIGHT, LLFontGL::TOP);
}
- value_format = llformat( "%%.%df", mPrecision);
if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp))
{
- std::string tick_label;
-
// Draw the tick marks.
LLGLSUIDefault gls_ui;
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
S32 last_tick = 0;
S32 last_label = 0;
const S32 MIN_TICK_SPACING = mOrientation == HORIZONTAL ? 20 : 30;
- const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 40 : 60;
- for (F32 tick_value = mMinBar + mTickSpacing; tick_value <= mCurMaxBar; tick_value += mTickSpacing)
+ const S32 MIN_LABEL_SPACING = mOrientation == HORIZONTAL ? 30 : 60;
+ // start counting from actual min, not current, animating min, so that ticks don't float between numbers
+ // ensure ticks always hit 0
+ if (mTickValue > 0.f)
{
- const S32 begin = llfloor((tick_value - mMinBar)*value_scale);
- const S32 end = begin + tick_width;
- if (begin - last_tick < MIN_TICK_SPACING)
- {
- continue;
- }
- last_tick = begin;
-
- tick_label = llformat( value_format.c_str(), tick_value);
-
- if (mOrientation == HORIZONTAL)
+ F32 start = mCurMinBar < 0.f
+ ? llceil(-mCurMinBar / mTickValue) * -mTickValue
+ : 0.f;
+ for (F32 tick_value = start; ;tick_value += mTickValue)
{
- if (begin - last_label > MIN_LABEL_SPACING)
+ const S32 begin = llfloor((tick_value - mCurMinBar)*value_scale);
+ const S32 end = begin + tick_width;
+ if (begin - last_tick < MIN_TICK_SPACING)
{
- gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f));
- LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, bar_right, begin,
- LLColor4(1.f, 1.f, 1.f, 0.5f),
- LLFontGL::LEFT, LLFontGL::VCENTER);
- last_label = begin;
+ continue;
}
- else
+ last_tick = begin;
+
+ S32 decimal_digits = mDecimalDigits;
+ if (is_approx_equal((F32)(S32)tick_value, tick_value))
{
- gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f));
+ decimal_digits = 0;
}
- }
- else
- {
- if (begin - last_label > MIN_LABEL_SPACING)
+ std::string tick_string = llformat("%10.*f", decimal_digits, tick_value);
+
+ if (mOrientation == HORIZONTAL)
{
- gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f));
- LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, begin - 1, bar_bottom - tick_length,
- LLColor4(1.f, 1.f, 1.f, 0.5f),
- LLFontGL::RIGHT, LLFontGL::TOP);
- last_label = begin;
+ if (begin - last_label > MIN_LABEL_SPACING)
+ {
+ gl_rect_2d(bar_left, end, bar_right - tick_length, begin, LLColor4(1.f, 1.f, 1.f, 0.25f));
+ LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, bar_right, begin,
+ LLColor4(1.f, 1.f, 1.f, 0.5f),
+ LLFontGL::LEFT, LLFontGL::VCENTER);
+ last_label = begin;
+ }
+ else
+ {
+ gl_rect_2d(bar_left, end, bar_right - tick_length/2, begin, LLColor4(1.f, 1.f, 1.f, 0.1f));
+ }
}
else
{
- gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f));
+ if (begin - last_label > MIN_LABEL_SPACING)
+ {
+ gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length, LLColor4(1.f, 1.f, 1.f, 0.25f));
+ LLFontGL::getFontMonospace()->renderUTF8(tick_string, 0, begin - 1, bar_bottom - tick_length,
+ LLColor4(1.f, 1.f, 1.f, 0.5f),
+ LLFontGL::RIGHT, LLFontGL::TOP);
+ last_label = begin;
+ }
+ else
+ {
+ gl_rect_2d(begin, bar_top, end, bar_bottom - tick_length/2, LLColor4(1.f, 1.f, 1.f, 0.1f));
+ }
+ }
+ // always draw one tick value past end, so we can see part of the text, if possible
+ if (tick_value > mCurMaxBar)
+ {
+ break;
}
}
}
@@ -291,7 +426,7 @@ void LLStatBar::draw()
}
// draw min and max
- S32 begin = (S32) ((min - mMinBar) * value_scale);
+ S32 begin = (S32) ((min - mCurMinBar) * value_scale);
if (begin < 0)
{
@@ -299,7 +434,7 @@ void LLStatBar::draw()
llwarns << "Min:" << min << llendl;
}
- S32 end = (S32) ((max - mMinBar) * value_scale);
+ S32 end = (S32) ((max - mCurMinBar) * value_scale);
if (mOrientation == HORIZONTAL)
{
gl_rect_2d(bar_left, end, bar_right, begin, LLColor4(1.f, 0.f, 0.f, 0.25f));
@@ -316,8 +451,7 @@ void LLStatBar::draw()
if (mDisplayHistory && (mCountFloatp || mEventFloatp || mSampleFloatp))
{
const S32 num_values = frame_recording.getNumRecordedPeriods() - 1;
- F32 begin = 0;
- F32 end = 0;
+ F32 value = 0;
S32 i;
gGL.color4f( 1.f, 0.f, 0.f, 1.f );
gGL.begin( LLRender::QUADS );
@@ -327,74 +461,49 @@ void LLStatBar::draw()
{
F32 offset = ((F32)i / (F32)mNumFrames) * span;
LLTrace::Recording& recording = frame_recording.getPrevRecording(i);
- if (mPerSec)
+
+ if (mCountFloatp)
{
- if (mCountFloatp)
- {
- begin = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale);
- end = ((recording.getPerSec(*mCountFloatp) - mMinBar) * value_scale) + 1;
- num_samples = recording.getSampleCount(*mCountFloatp);
- }
- else if (mEventFloatp)
- {
- //rate isn't defined for measurement stats, so use mean
- begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale);
- end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1;
- num_samples = recording.getSampleCount(*mEventFloatp);
- }
- else if (mSampleFloatp)
- {
- //rate isn't defined for sample stats, so use mean
- begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale);
- end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1;
- num_samples = recording.getSampleCount(*mSampleFloatp);
- }
+ value = mPerSec
+ ? recording.getPerSec(*mCountFloatp)
+ : recording.getSum(*mCountFloatp);
+ num_samples = recording.getSampleCount(*mCountFloatp);
}
- else
+ else if (mEventFloatp)
{
- if (mCountFloatp)
- {
- begin = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale);
- end = ((recording.getSum(*mCountFloatp) - mMinBar) * value_scale) + 1;
- num_samples = recording.getSampleCount(*mCountFloatp);
- }
- else if (mEventFloatp)
- {
- begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale);
- end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1;
- num_samples = recording.getSampleCount(*mEventFloatp);
- }
- else if (mSampleFloatp)
- {
- begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale);
- end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1;
- num_samples = recording.getSampleCount(*mSampleFloatp);
- }
- }
+ value = recording.getMean(*mEventFloatp);
+ num_samples = recording.getSampleCount(*mEventFloatp);
+ }
+ else if (mSampleFloatp)
+ {
+ value = recording.getMean(*mSampleFloatp);
+ num_samples = recording.getSampleCount(*mSampleFloatp);
+ }
if (!num_samples) continue;
+ F32 begin = (value - mCurMinBar) * value_scale;
if (mOrientation == HORIZONTAL)
{
- gGL.vertex2f((F32)bar_right - offset, end);
+ gGL.vertex2f((F32)bar_right - offset, begin + 1);
gGL.vertex2f((F32)bar_right - offset, begin);
- gGL.vertex2f((F32)bar_right - offset - 1.f, begin);
- gGL.vertex2f((F32)bar_right - offset - 1.f, end);
+ gGL.vertex2f((F32)bar_right - offset - 1, begin);
+ gGL.vertex2f((F32)bar_right - offset - 1, begin + 1);
}
else
{
- gGL.vertex2f(begin, (F32)bar_bottom+offset+1.f);
- gGL.vertex2f(begin, (F32)bar_bottom+offset);
- gGL.vertex2f(end, (F32)bar_bottom+offset);
- gGL.vertex2f(end, (F32)bar_bottom+offset+1.f);
+ gGL.vertex2f(begin, (F32)bar_bottom + offset + 1);
+ gGL.vertex2f(begin, (F32)bar_bottom + offset);
+ gGL.vertex2f(begin + 1, (F32)bar_bottom + offset);
+ gGL.vertex2f(begin + 1, (F32)bar_bottom + offset + 1 );
}
}
gGL.end();
}
else
{
- S32 begin = (S32) ((current - mMinBar) * value_scale) - 1;
- S32 end = (S32) ((current - mMinBar) * value_scale) + 1;
+ S32 begin = (S32) ((current - mCurMinBar) * value_scale) - 1;
+ S32 end = (S32) ((current - mCurMinBar) * value_scale) + 1;
// draw current
if (mOrientation == HORIZONTAL)
{
@@ -408,8 +517,8 @@ void LLStatBar::draw()
// draw mean bar
{
- const S32 begin = (S32) ((mean - mMinBar) * value_scale) - 1;
- const S32 end = (S32) ((mean - mMinBar) * value_scale) + 1;
+ const S32 begin = (S32) ((mean - mCurMinBar) * value_scale) - 1;
+ const S32 end = (S32) ((mean - mCurMinBar) * value_scale) + 1;
if (mOrientation == HORIZONTAL)
{
gl_rect_2d(bar_left - 2, begin, bar_right + 2, end, LLColor4(0.f, 1.f, 0.f, 1.f));
@@ -432,11 +541,11 @@ void LLStatBar::setStat(const std::string& stat_name)
}
-void LLStatBar::setRange(F32 bar_min, F32 bar_max, F32 tick_spacing)
+void LLStatBar::setRange(F32 bar_min, F32 bar_max)
{
- mMinBar = bar_min;
- mMaxBar = bar_max;
- mTickSpacing = tick_spacing;
+ mMinBar = llmin(bar_min, bar_max);
+ mMaxBar = llmax(bar_min, bar_max);
+ mTickValue = calc_tick_value(mMinBar, mMaxBar);
}
LLRect LLStatBar::getRequiredRect()
diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h
index 3daec297bb..fc925b1a74 100755
--- a/indra/llui/llstatbar.h
+++ b/indra/llui/llstatbar.h
@@ -42,16 +42,13 @@ public:
Optional<F32> bar_min,
bar_max,
- tick_spacing,
- update_rate,
- unit_scale;
+ tick_spacing;
- Optional<U32> precision;
+ Optional<U32> decimal_digits;
Optional<bool> show_per_sec,
show_bar,
show_history,
- show_mean,
scale_range;
Optional<S32> num_frames,
@@ -60,23 +57,20 @@ public:
Optional<EOrientation> orientation;
Params()
- : label("label"),
- unit_label("unit_label"),
- bar_min("bar_min", 0.0f),
- bar_max("bar_max", 50.0f),
- tick_spacing("tick_spacing", 10.0f),
- precision("precision", 0),
- update_rate("update_rate", 5.0f),
- unit_scale("unit_scale", 1.f),
- show_per_sec("show_per_sec", true),
- show_bar("show_bar", true),
- show_history("show_history", false),
- show_mean("show_mean", true),
- scale_range("scale_range", true),
- num_frames("num_frames", 300),
- max_height("max_height", 200),
- stat("stat"),
- orientation("orientation", VERTICAL)
+ : label("label"),
+ unit_label("unit_label"),
+ bar_min("bar_min", 0.f),
+ bar_max("bar_max", 0.f),
+ tick_spacing("tick_spacing", 0.f),
+ decimal_digits("decimal_digits", 3),
+ show_per_sec("show_per_sec", true),
+ show_bar("show_bar", false),
+ show_history("show_history", false),
+ scale_range("scale_range", true),
+ num_frames("num_frames", 200),
+ max_height("max_height", 100),
+ stat("stat"),
+ orientation("orientation", VERTICAL)
{
changeDefault(follows.flags, FOLLOWS_TOP | FOLLOWS_LEFT);
}
@@ -85,40 +79,38 @@ public:
virtual void draw();
virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+ virtual BOOL handleHover(S32 x, S32 y, MASK mask);
void setStat(const std::string& stat_name);
- void setRange(F32 bar_min, F32 bar_max, F32 tick_spacing);
+ void setRange(F32 bar_min, F32 bar_max);
void getRange(F32& bar_min, F32& bar_max) { bar_min = mMinBar; bar_max = mMaxBar; }
/*virtual*/ LLRect getRequiredRect(); // Return the height of this object, given the set options.
private:
- F32 mMinBar;
- F32 mMaxBar;
- F32 mCurMaxBar;
- F32 mTickSpacing;
- F32 mLabelSpacing;
- U32 mPrecision;
- F32 mUpdatesPerSec;
- F32 mUnitScale;
+ F32 mMinBar,
+ mMaxBar,
+ mCurMaxBar,
+ mCurMinBar,
+ mLabelSpacing;
+ F32 mTickValue;
+ U32 mDecimalDigits;
S32 mNumFrames;
S32 mMaxHeight;
- 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
- bool mScaleRange;
+ bool mPerSec, // Use the per sec stats.
+ mDisplayBar, // Display the bar graph.
+ mDisplayHistory,
+ mAutoScaleMax,
+ mAutoScaleMin;
EOrientation mOrientation;
- LLTrace::TraceType<LLTrace::CountAccumulator>* mCountFloatp;
- LLTrace::TraceType<LLTrace::EventAccumulator>* mEventFloatp;
- LLTrace::TraceType<LLTrace::SampleAccumulator>* mSampleFloatp;
+ LLTrace::TraceType<LLTrace::CountAccumulator>* mCountFloatp;
+ LLTrace::TraceType<LLTrace::EventAccumulator>* mEventFloatp;
+ LLTrace::TraceType<LLTrace::SampleAccumulator>* mSampleFloatp;
- LLFrameTimer mUpdateTimer;
LLUIString mLabel;
std::string mUnitLabel;
- F32 mValue;
};
#endif
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index f52a3b3323..782d26fccb 100755
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -476,6 +476,9 @@ void LLToolTipMgr::show(const std::string& msg)
void LLToolTipMgr::show(const LLToolTip::Params& params)
{
+ if (!params.styled_message.isProvided()
+ && (!params.message.isProvided() || params.message().empty())) return;
+
// fill in default tooltip params from tool_tip.xml
LLToolTip::Params params_with_defaults(params);
params_with_defaults.fillFrom(LLUICtrlFactory::instance().getDefaultParams<LLToolTip>());