|
From: Johnny O. <js...@us...> - 2010-10-28 21:12:56
|
Module: performous
Branch: opengl2
Commit: 477b575fdb0acf645f7b8eed33846f38c42e5f5e
Author: Tapio Vierros <tap...@gm...>
Date: Wed Oct 27 20:27:49 2010 +0300
Use an SVG for the device selection indicator.
---
game/screen_audiodevices.cc | 14 +++++++++-----
game/screen_audiodevices.hh | 1 +
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/game/screen_audiodevices.cc b/game/screen_audiodevices.cc
index 4bf0afd..74055e3 100644
--- a/game/screen_audiodevices.cc
+++ b/game/screen_audiodevices.cc
@@ -20,6 +20,7 @@ namespace {
}
ScreenAudioDevices::ScreenAudioDevices(std::string const& name, Audio& audio): Screen(name), m_audio(audio) {
+ m_selector.reset(new Surface(getThemePath("device_selector.svg")));
m_mic_icon.reset(new Surface(getThemePath("sing_pbox.svg")));
m_pdev_icon.reset(new Surface(getThemePath("icon_pdev.svg")));
m_colorMap["blue"] = Color(0.2, 0.5, 0.7);
@@ -96,6 +97,7 @@ void ScreenAudioDevices::draw() {
const float ystep = yoff*2 / m_devs.size();
// Device text & bg
m_theme->device_bg.dimensions.stretch(std::abs(xoff*2), m_mic_icon->dimensions.h()*0.9).middle();
+ m_selector->dimensions.stretch(m_mic_icon->dimensions.w() * 1.75, m_mic_icon->dimensions.h() * 1.75);
for (size_t i = 0; i <= m_devs.size(); ++i) {
const float y = -yoff + i*ystep;
float alpha = 1.0f;
@@ -110,14 +112,16 @@ void ScreenAudioDevices::draw() {
// Icons
for (size_t i = 0; i < m_mics.size(); ++i) {
Surface& srf = (i < m_mics.size()-1) ? *m_mic_icon : *m_pdev_icon;
- glutil::Color c(m_colorMap[m_mics[i].name]);
- srf.dimensions.middle(-xoff + xstep*0.5 + i*xstep).center(-yoff+m_mics[i].dev*ystep);
- srf.draw();
+ {
+ glutil::Color c(m_colorMap[m_mics[i].name]);
+ srf.dimensions.middle(-xoff + xstep*0.5 + i*xstep).center(-yoff+m_mics[i].dev*ystep);
+ srf.draw();
+ }
// Selection indicator
- // TODO: Some nice arrow icons would be nice, in any case, current square is temporary
if (m_selected_column == i)
- glutil::Square sq(srf.dimensions.xc(), srf.dimensions.yc(), m_mic_icon->dimensions.w()*0.75);
+ m_selector->dimensions.middle(srf.dimensions.xc()).center(srf.dimensions.yc());
}
+ m_selector->draw(); // Position already set in the loop
}
// Key help
m_theme->comment_bg.dimensions.stretch(1.0, 0.025).middle().screenBottom(-0.054);
diff --git a/game/screen_audiodevices.hh b/game/screen_audiodevices.hh
index d833252..10509d0 100644
--- a/game/screen_audiodevices.hh
+++ b/game/screen_audiodevices.hh
@@ -35,6 +35,7 @@ class ScreenAudioDevices: public Screen {
portaudio::DeviceInfos m_devs;
std::vector<Mic> m_mics;
std::map<std::string, Color> m_colorMap;
+ boost::scoped_ptr<Surface> m_selector;
boost::scoped_ptr<Surface> m_mic_icon;
boost::scoped_ptr<Surface> m_pdev_icon;
};
|