Skip to content
Browse files

move list alpha values to skin config

  • Loading branch information...
1 parent eb39e5b commit fdb8016e607b5d39ac2dfc8b4a765974f67ddcb2 @robn robn committed Oct 9, 2012
Showing with 22 additions and 9 deletions.
  1. +3 −0 data/ui/Skin.ini
  2. +4 −9 src/ui/List.cpp
  3. +8 −0 src/ui/Skin.cpp
  4. +7 −0 src/ui/Skin.h
View
3 data/ui/Skin.ini
@@ -13,3 +13,6 @@ CheckboxCheckedDisabled=120,17,25,25
CheckboxCheckedNormal=120,87,25,25
CheckboxCheckedHover=120,152,25,25
CheckboxCheckedActive=120,212,25,25
+ListAlphaNormal=0.0
+ListAlphaHover=0.4
+ListAlphaSelect=0.6
View
13 src/ui/List.cpp
@@ -6,11 +6,6 @@
namespace UI {
-// XXX skin
-static const float ALPHA_NORMAL = 0.0f;
-static const float ALPHA_HOVER = 0.4f;
-static const float ALPHA_SELECT = 0.6f;
-
List::List(Context *context) : Container(context), m_selected(-1)
{
Context *c = GetContext();
@@ -39,7 +34,7 @@ List *List::AddOption(const std::string &text)
int index = m_optionBackgrounds.size();
- ColorBackground *background = c->ColorBackground(Color(0,0,0, m_selected == index ? ALPHA_SELECT : ALPHA_NORMAL));
+ ColorBackground *background = c->ColorBackground(Color(0,0,0, m_selected == index ? c->GetSkin().ListAlphaSelect() : c->GetSkin().ListAlphaNormal()));
vbox->PackEnd(background->SetInnerWidget(c->Label(text)));
background->onMouseOver.connect(sigc::bind(sigc::mem_fun(this, &List::HandleOptionMouseOver), index));
@@ -73,21 +68,21 @@ void List::Clear()
bool List::HandleOptionMouseOver(int index)
{
- m_optionBackgrounds[index]->SetColor(Color(0,0,0, ALPHA_HOVER));
+ m_optionBackgrounds[index]->SetColor(Color(0,0,0, GetContext()->GetSkin().ListAlphaHover()));
return false;
}
bool List::HandleOptionMouseOut(int index)
{
- m_optionBackgrounds[index]->SetColor(Color(0,0,0, m_selected == index ? ALPHA_SELECT : ALPHA_NORMAL));
+ m_optionBackgrounds[index]->SetColor(Color(0,0,0, m_selected == index ? GetContext()->GetSkin().ListAlphaSelect() : GetContext()->GetSkin().ListAlphaNormal()));
return false;
}
bool List::HandleOptionClick(int index)
{
if (m_selected != index) {
if (m_selected >= 0)
- m_optionBackgrounds[m_selected]->SetColor(Color(0,0,0, ALPHA_NORMAL));
+ m_optionBackgrounds[m_selected]->SetColor(Color(0,0,0, GetContext()->GetSkin().ListAlphaNormal()));
m_selected = index;
onOptionSelected.emit(index, m_options[index]);
}
View
8 src/ui/Skin.cpp
@@ -35,6 +35,10 @@ Skin::Skin(const std::string &filename, Graphics::Renderer *renderer) :
m_checkboxCheckedNormal = LoadRectElement(m_config.String("CheckboxCheckedNormal"));
m_checkboxCheckedHover = LoadRectElement(m_config.String("CheckboxCheckedHover"));
m_checkboxCheckedActive = LoadRectElement(m_config.String("CheckboxCheckedActive"));
+
+ m_listAlphaNormal = m_config.Float("ListAlphaNormal");
+ m_listAlphaSelect = m_config.Float("ListAlphaSelect");
+ m_listAlphaHover = m_config.Float("ListAlphaHover");
}
static inline vector2f scaled(const vector2f &v)
@@ -134,6 +138,10 @@ Skin::BorderedRectElement Skin::LoadBorderedRectElement(const std::string &spec)
Skin::Config::Config(const std::string &filename) : IniConfig(filename)
{
+ m_map["ListAlphaNormal"] = "0.0";
+ m_map["ListAlphaHover"] = "0.4";
+ m_map["ListAlphaSelect"] = "0.6";
+
Load();
}
View
7 src/ui/Skin.h
@@ -101,6 +101,10 @@ class Skin {
const RectElement &CheckboxCheckedHover() const { return m_checkboxCheckedHover; }
const RectElement &CheckboxCheckedActive() const { return m_checkboxCheckedActive; }
+ float ListAlphaNormal() const { return m_listAlphaNormal; }
+ float ListAlphaSelect() const { return m_listAlphaSelect; }
+ float ListAlphaHover() const { return m_listAlphaHover; }
+
private:
class Config : public IniConfig {
public:
@@ -137,6 +141,9 @@ class Skin {
RectElement m_checkboxCheckedHover;
RectElement m_checkboxCheckedActive;
+ float m_listAlphaNormal;
+ float m_listAlphaSelect;
+ float m_listAlphaHover;
};
}

0 comments on commit fdb8016

Please sign in to comment.
Something went wrong with that request. Please try again.