void Button::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
- text.build(part, geom, part_cache);
+ text.build(part, state, geom, part_cache);
if(part.get_name()=="icon")
{
if(icon)
void Dropdown::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
- text.build(part, geom, part_cache);
+ text.build(part, state, geom, part_cache);
else
Widget::rebuild_special(part);
}
void Entry::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
- text.build(part, geom, first_row, part_cache);
+ text.build(part, state, geom, first_row, part_cache);
else if(part.get_name()=="cursor")
{
const Graphic *graphic = part.get_graphic(state);
void Label::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
- text.build(part, geom, part_cache);
+ text.build(part, state, geom, part_cache);
}
void Label::on_style_change()
return *font;
}
+const GL::Color &Style::get_font_color(State s) const
+{
+ if(s>N_STATES_)
+ throw invalid_argument("Style::get_font_color");
+
+ return font_color[s];
+}
+
const Part *Style::get_part(const string &name) const
{
for(PartSeq::const_iterator i=parts.begin(); i!=parts.end(); ++i)
}
add("font", &Loader::font);
+ add("font_color", &Loader::font_color_normal);
add("font_color", &Loader::font_color);
add("font_size", &Style::font_size);
add("part", &Loader::part);
obj.font_size = obj.font->get_native_size();
}
-void Style::Loader::font_color(float r, float g, float b)
+void Style::Loader::font_color_normal(float r, float g, float b)
+{
+ font_color(NORMAL, r, g, b);
+}
+
+void Style::Loader::font_color(State s, float r, float g, float b)
{
- obj.font_color = GL::Color(r, g, b);
+ for(unsigned i=0; i<N_STATES_; ++i)
+ if((i&s)==s)
+ obj.font_color[i] = GL::Color(r, g, b);
}
void Style::Loader::part(const string &n)
private:
void font(const std::string &);
- void font_color(float, float, float);
+ void font_color_normal(float, float, float);
+ void font_color(State, float, float, float);
void part(const std::string &);
void unnamed_part();
};
private:
const GL::Font *font;
unsigned font_size;
- GL::Color font_color;
+ GL::Color font_color[N_STATES_];
PartSeq parts;
public:
Style();
const GL::Font &get_font() const;
unsigned get_font_size() const { return font_size; }
- const GL::Color &get_font_color() const { return font_color; }
+ const GL::Color &get_font_color(State) const;
const PartSeq &get_parts() const { return parts; }
const Part *get_part(const std::string &) const;
};
return data.result;
}
-void Text::build(const Part &part, const Geometry &parent, PartCache &cache) const
+void Text::build(const Part &part, State state, const Geometry &parent, PartCache &cache) const
{
- build(part, parent, 0, cache);
+ build(part, state, parent, 0, cache);
}
-void Text::build(const Part &part, const Geometry &parent, unsigned first_row, PartCache &cache) const
+void Text::build(const Part &part, State state, const Geometry &parent, unsigned first_row, PartCache &cache) const
{
if(!style || lines.empty())
return;
const GL::Font &font = style->get_font();
GL::MeshBuilder bld(cache.create_mesh(part, font.get_texture()));
- bld.color(style->get_font_color());
+ bld.color(style->get_font_color(state));
RenderData data;
data.bld = &bld;
#include <string>
#include <vector>
+#include "state.h"
namespace Msp {
namespace GLtk {
unsigned coords_to_offset(unsigned, unsigned) const;
Geometry coords_to_geometry(const Part &, const Geometry &, unsigned, unsigned, unsigned) const;
- void build(const Part &, const Geometry &, PartCache &) const;
- void build(const Part &, const Geometry &, unsigned, PartCache &) const;
+ void build(const Part &, State, const Geometry &, PartCache &) const;
+ void build(const Part &, State, const Geometry &, unsigned, PartCache &) const;
Text &operator=(const std::string &);
private:
void Toggle::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
- text.build(part, geom, part_cache);
+ text.build(part, state, geom, part_cache);
}
void Toggle::button_press(int, int, unsigned btn)
void set_state(State s) { set_state(s, s); }
void clear_state(State s) { set_state(s, NORMAL); }
void set_state(State, State);
+public:
+ State get_state() const { return state; }
+protected:
void rebuild();
virtual void rebuild_special(const Part &);