Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Skin::render(const PushButton& button) const
- {
- const auto& _pos = button.pos();
- const auto& _size = button.size();
- const Style style = button.getStyle();
- unsigned frame = static_cast<unsigned>(button.state());
- if(button.disabled()) {
- frame = 3;
- }
- drawButton(style, _pos, _size, frame);
- Pos w = _pos;
- w.x += _size.wid / 2.f;
- w.y += _size.hei / 2.f;
- if(button.state() == PushButton::State::Down) {
- w += Pos(1, 1);
- }
- if(button.disabled()) {
- glColor3f(0.6f, 0.6f, 0.6f);
- }
- float dx = 0.f;
- if(button._icon != -1) {
- /// @todo define json parameter for sep
- int sep = button._text.empty()?0:4;
- if(button._icon_policy == IconPolicy::GluedLeft) {
- dx = int( (_icons.getWidth(button._icon) + sep) / 2.f);
- _icons.draw(button._icon, 0,
- int(w.x - button._text_width/2.f - dx),
- int(w.y - _icons.getHeight(button._icon)/2.f));
- }
- else if(button._icon_policy == IconPolicy::GluedRight) {
- dx = - int( (_icons.getWidth(button._icon) + sep) / 2.f);
- _icons.draw(button._icon, 0,
- int(w.x + button._text_width/2.f + dx + sep),
- int(w.y - _icons.getHeight(button._icon)/2.f));
- }
- /// @todo geometry update, etc ... (atm it's WIP / not finished)
- else if(button._icon_policy == IconPolicy::Left) {
- /// @todo define json parameter for '+ 8'
- _icons.draw(button._icon, 0,
- int(_pos.x + 8),
- int(w.y - _icons.getHeight(button._icon)/2.f));
- }
- }
- const auto& attribs = _attribs.at(style.skin);
- const auto& attr = attribs.button.at(style.style);
- drawSetColor(attr.text.color);
- _fonts[attr.text.font_index]->draw(w + Pos(dx, 0), button._text,
- Font::Middle, Font::Center);
- glColor3f(1, 1, 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment