summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2009-07-10 00:23:41 +0000
committerJames Cook <james@lindenlab.com>2009-07-10 00:23:41 +0000
commit91f9835176d011e963a6df7d183a3f9c093a1989 (patch)
tree8ff0efbbf5e6579803f2e6ce132c2b7956c6ec22 /indra/newview
parente8bc8264f96d179cccf7cd09de774dd7fb50bc46 (diff)
DEV-35118 Converted voice volume feedback icon on bottom tray to use real artwork. Converted LLOutputMonitorCtrl to use ParamBlocks to specify art. Added output_monitor.xml to specify art. Bottom bar gives volume feedback even when triggering voice with middle-mouse or keyboard binding. Reviewed with Richard.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llchiclet.cpp10
-rw-r--r--indra/newview/lloutputmonitorctrl.cpp165
-rw-r--r--indra/newview/lloutputmonitorctrl.h32
-rw-r--r--indra/newview/skins/default/xui/en/widgets/output_monitor.xml9
4 files changed, 147 insertions, 69 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 4413212361..4999d05e44 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -792,6 +792,8 @@ LLTalkButton::LLTalkButton(const LLUICtrl::Params& p)
monitor_param.rect(LLRect(rc.getWidth()-20,18,rc.getWidth()-3,2));
monitor_param.visible(true);
mOutputMonitor = LLUICtrlFactory::create<LLOutputMonitorCtrl>(monitor_param);
+ // never show "muted" because you can't mute yourself
+ mOutputMonitor->setIsMuted(false);
mSpeakBtn->addChild(mOutputMonitor);
@@ -804,10 +806,9 @@ LLTalkButton::~LLTalkButton()
void LLTalkButton::draw()
{
- if(mSpeakBtn->getToggleState())
- {
- mOutputMonitor->setPower(gVoiceClient->getCurrentPower(gAgent.getID()));
- }
+ // Always provide speaking feedback. User can trigger speaking
+ // with keyboard or middle-mouse shortcut.
+ mOutputMonitor->setPower(gVoiceClient->getCurrentPower(gAgent.getID()));
LLUICtrl::draw();
}
@@ -816,7 +817,6 @@ void LLTalkButton::onClick_SpeakBtn()
{
bool speaking = mSpeakBtn->getToggleState();
gVoiceClient->setUserPTTState(speaking);
- mOutputMonitor->setIsMuted(!speaking);
}
void LLTalkButton::onClick_ShowBtn()
diff --git a/indra/newview/lloutputmonitorctrl.cpp b/indra/newview/lloutputmonitorctrl.cpp
index 60a86ed253..340cb8187d 100644
--- a/indra/newview/lloutputmonitorctrl.cpp
+++ b/indra/newview/lloutputmonitorctrl.cpp
@@ -39,41 +39,62 @@
// viewer includes
#include "llvoiceclient.h"
+// 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()
+: 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),
+ 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 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_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);
+ //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 +110,48 @@ 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.
+ LLPointer<LLUIImage> icon;
+ if (mIsMuted)
+ {
+ icon = mImageMute;
+ }
+ else if (mPower == 0.f)
+ {
+ icon = mImageOff;
+ }
+ else if (mPower < LLVoiceClient::OVERDRIVEN_POWER_LEVEL)
+ {
+ S32 icon_image_idx = llmin(2, llfloor((mPower / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
+ switch(icon_image_idx)
+ {
+ default:
+ case 0:
+ icon = mImageOn;
+ break;
+ case 1:
+ icon = mImageLevel1;
+ break;
+ case 2:
+ icon = mImageLevel2;
+ break;
+ }
+ }
+ 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 +161,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);
- }
+ //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 rectangle filled with the color.
- gl_rect_2d(xpos, recttop, xpos+rectw, rectbtm, rect_color, TRUE);
- xpos += period;
- }
-
//
// Draw bounding box.
//
diff --git a/indra/newview/lloutputmonitorctrl.h b/indra/newview/lloutputmonitorctrl.h
index 881ad0f010..e391c14e40 100644
--- a/indra/newview/lloutputmonitorctrl.h
+++ b/indra/newview/lloutputmonitorctrl.h
@@ -50,14 +50,14 @@ public:
struct Params : public LLInitParam::Block<Params, LLView::Params>
{
Optional<bool> draw_border;
+ Mandatory<LLUIImage*> image_mute,
+ image_off,
+ image_on,
+ image_level_1,
+ image_level_2,
+ image_level_3;
- Params()
- {
- draw_border = true;
- name = "output_monitor";
- follows.flags(FOLLOWS_LEFT|FOLLOWS_TOP);
- mouse_opaque = false;
- };
+ Params();
};
protected:
bool mBorder;
@@ -77,16 +77,22 @@ public:
void setIsMuted(bool val) { mIsMuted = val; }
private:
- static LLColor4 sColorMuted;
- static LLColor4 sColorNormal;
- static LLColor4 sColorOverdriven;
+ //static LLColor4 sColorMuted;
+ //static LLColor4 sColorNormal;
+ //static LLColor4 sColorOverdriven;
static LLColor4 sColorBound;
- static S32 sRectsNumber;
- static F32 sRectWidthRatio;
- static F32 sRectHeightRatio;
+ //static S32 sRectsNumber;
+ //static F32 sRectWidthRatio;
+ //static F32 sRectHeightRatio;
F32 mPower;
bool mIsMuted;
+ LLPointer<LLUIImage> mImageMute;
+ LLPointer<LLUIImage> mImageOff;
+ LLPointer<LLUIImage> mImageOn;
+ LLPointer<LLUIImage> mImageLevel1;
+ LLPointer<LLUIImage> mImageLevel2;
+ LLPointer<LLUIImage> mImageLevel3;
};
#endif
diff --git a/indra/newview/skins/default/xui/en/widgets/output_monitor.xml b/indra/newview/skins/default/xui/en/widgets/output_monitor.xml
new file mode 100644
index 0000000000..2f6d808125
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/widgets/output_monitor.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<output_monitor
+ image_mute="mute_icon.tga"
+ image_off="icn_voice_ptt-off.tga"
+ image_on="icn_voice_ptt-on.tga"
+ image_level_1="icn_voice_ptt-on-lvl1.tga"
+ image_level_2="icn_voice_ptt-on-lvl2.tga"
+ image_level_3="icn_voice_ptt-on-lvl3.tga"
+ />