summaryrefslogtreecommitdiff
path: root/indra/newview/lloutputmonitorctrl.cpp
diff options
context:
space:
mode:
authorPalmer <palmer@lindenlab.com>2009-08-06 14:51:11 -0700
committerPalmer <palmer@lindenlab.com>2009-08-06 14:51:11 -0700
commitb2632c50efc12eacdcadace64e6c0f1906b86ff6 (patch)
treec32d7e9b29e37d5c30ac16dfac55733456d7eee0 /indra/newview/lloutputmonitorctrl.cpp
parent27cf39cdbf27fe52dcf9c70cfdadcc18ddf2e75c (diff)
parenta8d216e194327c7bee8a42c983f7f2ca01adb385 (diff)
Merge of my DEV-36732 work and all the main line login api work that went on.
Diffstat (limited to 'indra/newview/lloutputmonitorctrl.cpp')
-rw-r--r--indra/newview/lloutputmonitorctrl.cpp174
1 files changed, 120 insertions, 54 deletions
diff --git a/indra/newview/lloutputmonitorctrl.cpp b/indra/newview/lloutputmonitorctrl.cpp
index ff26707a56..d088c45710 100644
--- a/indra/newview/lloutputmonitorctrl.cpp
+++ b/indra/newview/lloutputmonitorctrl.cpp
@@ -39,41 +39,64 @@
// viewer includes
#include "llvoiceclient.h"
-static LLDefaultWidgetRegistry::Register<LLOutputMonitorCtrl> r("output_monitor");
+// default options set in output_monitor.xml
+static LLDefaultChildRegistry::Register<LLOutputMonitorCtrl> r("output_monitor");
// The defaults will be initialized in the constructor.
-LLColor4 LLOutputMonitorCtrl::sColorMuted;
-LLColor4 LLOutputMonitorCtrl::sColorOverdriven;
-LLColor4 LLOutputMonitorCtrl::sColorNormal;
+//LLColor4 LLOutputMonitorCtrl::sColorMuted;
+//LLColor4 LLOutputMonitorCtrl::sColorOverdriven;
+//LLColor4 LLOutputMonitorCtrl::sColorNormal;
LLColor4 LLOutputMonitorCtrl::sColorBound;
-S32 LLOutputMonitorCtrl::sRectsNumber = 0;
-F32 LLOutputMonitorCtrl::sRectWidthRatio = 0.f;
-F32 LLOutputMonitorCtrl::sRectHeightRatio = 0.f;
+//S32 LLOutputMonitorCtrl::sRectsNumber = 0;
+//F32 LLOutputMonitorCtrl::sRectWidthRatio = 0.f;
+//F32 LLOutputMonitorCtrl::sRectHeightRatio = 0.f;
+
+LLOutputMonitorCtrl::Params::Params()
+: draw_border("draw_border"),
+ image_mute("image_mute"),
+ image_off("image_off"),
+ image_on("image_on"),
+ image_level_1("image_level_1"),
+ image_level_2("image_level_2"),
+ image_level_3("image_level_3")
+{
+ draw_border = true;
+ name = "output_monitor";
+ follows.flags(FOLLOWS_LEFT|FOLLOWS_TOP);
+ mouse_opaque = false;
+};
LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p)
: LLView(p),
mPower(0),
- mIsMuted(true)
+ mIsMuted(true),
+ mIsTalking(false),
+ mImageMute(p.image_mute),
+ mImageOff(p.image_off),
+ mImageOn(p.image_on),
+ mImageLevel1(p.image_level_1),
+ mImageLevel2(p.image_level_2),
+ mImageLevel3(p.image_level_3)
{
- static LLUICachedControl<LLColor4> output_monitor_muted_color("OutputMonitorMutedColor", LLColor4::orange);
- static LLUICachedControl<LLColor4> output_monitor_overdriven_color("OutputMonitorOverdrivenColor", LLColor4::red);
- static LLUICachedControl<LLColor4> output_monitor_normal_color("OutputMonitorNotmalColor", LLColor4::green);
- static LLUICachedControl<LLColor4> output_monitor_bound_color("OutputMonitorBoundColor", LLColor4::white);
- static LLUICachedControl<S32> output_monitor_rects_number("OutputMonitorRectanglesNumber", 20);
- static LLUICachedControl<F32> output_monitor_rect_width_ratio("OutputMonitorRectangleWidthRatio", 0.5f);
- static LLUICachedControl<F32> output_monitor_rect_height_ratio("OutputMonitorRectangleHeightRatio", 0.8f);
+ //static LLUIColor output_monitor_muted_color = LLUIColorTable::instance().getColor("OutputMonitorMutedColor", LLColor4::orange);
+ //static LLUIColor output_monitor_overdriven_color = LLUIColorTable::instance().getColor("OutputMonitorOverdrivenColor", LLColor4::red);
+ //static LLUIColor output_monitor_normal_color = LLUIColorTable::instance().getColor("OutputMonitorNotmalColor", LLColor4::green);
+ static LLUIColor output_monitor_bound_color = LLUIColorTable::instance().getColor("OutputMonitorBoundColor", LLColor4::white);
+ //static LLUICachedControl<S32> output_monitor_rects_number("OutputMonitorRectanglesNumber", 20);
+ //static LLUICachedControl<F32> output_monitor_rect_width_ratio("OutputMonitorRectangleWidthRatio", 0.5f);
+ //static LLUICachedControl<F32> output_monitor_rect_height_ratio("OutputMonitorRectangleHeightRatio", 0.8f);
// IAN BUG compare to existing pattern where these are members - some will change per-widget and need to be anyway
// sent feedback to PE
// *TODO: it looks suboptimal to load the defaults every time an output monitor is constructed.
- sColorMuted = output_monitor_muted_color;
- sColorOverdriven = output_monitor_overdriven_color;
- sColorNormal = output_monitor_normal_color;
+ //sColorMuted = output_monitor_muted_color;
+ //sColorOverdriven = output_monitor_overdriven_color;
+ //sColorNormal = output_monitor_normal_color;
sColorBound = output_monitor_bound_color;
- sRectsNumber = output_monitor_rects_number;
- sRectWidthRatio = output_monitor_rect_width_ratio;
- sRectHeightRatio = output_monitor_rect_height_ratio;
+ //sRectsNumber = output_monitor_rects_number;
+ //sRectWidthRatio = output_monitor_rect_width_ratio;
+ //sRectHeightRatio = output_monitor_rect_height_ratio;
mBorder = p.draw_border;
}
@@ -89,6 +112,49 @@ void LLOutputMonitorCtrl::setPower(F32 val)
void LLOutputMonitorCtrl::draw()
{
+ // Copied from llmediaremotectrl.cpp
+ // *TODO: Give the LLOutputMonitorCtrl an agent-id to monitor, then
+ // call directly into gVoiceClient to ask if that agent-id is muted, is
+ // speaking, and what power. This avoids duplicating data, which can get
+ // out of sync.
+ const F32 LEVEL_0 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL / 3.f;
+ const F32 LEVEL_1 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL * 2.f / 3.f;
+ const F32 LEVEL_2 = LLVoiceClient::OVERDRIVEN_POWER_LEVEL;
+
+ LLPointer<LLUIImage> icon;
+ if (mIsMuted)
+ {
+ icon = mImageMute;
+ }
+ else if (mPower == 0.f && !mIsTalking)
+ {
+ // only show off if PTT is not engaged
+ icon = mImageOff;
+ }
+ else if (mPower < LEVEL_0)
+ {
+ // PTT is on, possibly with quiet background noise
+ icon = mImageOn;
+ }
+ else if (mPower < LEVEL_1)
+ {
+ icon = mImageLevel1;
+ }
+ else if (mPower < LEVEL_2)
+ {
+ icon = mImageLevel2;
+ }
+ else
+ {
+ // overdriven
+ icon = mImageLevel3;
+ }
+
+ if (icon)
+ {
+ icon->draw(0, 0);
+ }
+
//
// Fill the monitor with a bunch of small rectangles.
// The rectangles will be filled with gradient color,
@@ -98,41 +164,41 @@ void LLOutputMonitorCtrl::draw()
//
const int monh = getRect().getHeight();
const int monw = getRect().getWidth();
- int maxrects = sRectsNumber;
- const int period = llmax(1, monw / maxrects, 0, 0); // "1" - min value for the period
- const int rectw = llmax(1, llfloor(period * sRectWidthRatio), 0, 0); // "1" - min value for the rect's width
- const int recth = llfloor(monh * sRectHeightRatio);
+ //int maxrects = sRectsNumber;
+ //const int period = llmax(1, monw / maxrects, 0, 0); // "1" - min value for the period
+ //const int rectw = llmax(1, llfloor(period * sRectWidthRatio), 0, 0); // "1" - min value for the rect's width
+ //const int recth = llfloor(monh * sRectHeightRatio);
- if(period == 1 && rectw == 1) //if we have so small control, then "maxrects = monitor's_width - 2*monitor_border's_width
- maxrects = monw-2;
+ //if(period == 1 && rectw == 1) //if we have so small control, then "maxrects = monitor's_width - 2*monitor_border's_width
+ // maxrects = monw-2;
+
+ //const int nrects = mIsMuted ? maxrects : llfloor(mPower * maxrects); // how many rects to draw?
+ //const int rectbtm = (monh - recth) / 2;
+ //const int recttop = rectbtm + recth;
+ //
+ //LLColor4 rect_color;
+ //
+ //for (int i=1, xpos = 0; i <= nrects; i++)
+ //{
+ // // Calculate color to use for the current rectangle.
+ // if (mIsMuted)
+ // {
+ // rect_color = sColorMuted;
+ // }
+ // else
+ // {
+ // F32 frac = (mPower * i/nrects) / LLVoiceClient::OVERDRIVEN_POWER_LEVEL;
+ // // Use overdriven color if the power exceeds overdriven level.
+ // if (frac > 1.0f)
+ // frac = 1.0f;
+ // rect_color = lerp(sColorNormal, sColorOverdriven, frac);
+ // }
+
+ // // Draw rectangle filled with the color.
+ // gl_rect_2d(xpos, recttop, xpos+rectw, rectbtm, rect_color, TRUE);
+ // xpos += period;
+ //}
- const int nrects = mIsMuted ? maxrects : llfloor(mPower * maxrects); // how many rects to draw?
- const int rectbtm = (monh - recth) / 2;
- const int recttop = rectbtm + recth;
-
- LLColor4 rect_color;
-
- for (int i=1, xpos = 0; i <= nrects; i++)
- {
- // Calculate color to use for the current rectangle.
- if (mIsMuted)
- {
- rect_color = sColorMuted;
- }
- else
- {
- F32 frac = (mPower * i/nrects) / LLVoiceClient::OVERDRIVEN_POWER_LEVEL;
- // Use overdriven color if the power exceeds overdriven level.
- if (frac > 1.0f)
- frac = 1.0f;
- rect_color = lerp(sColorNormal, sColorOverdriven, frac);
- }
-
- // Draw rectangle filled with the color.
- gl_rect_2d(xpos, recttop, xpos+rectw, rectbtm, rect_color, TRUE);
- xpos += period;
- }
-
//
// Draw bounding box.
//