#include "button_icon.hpp"

#include "icons.hpp"

namespace widget {

  const static float icon_depth = 1.0 / 5.0;
  const static int icon_color = 0xffffff;

  const static float icon_shadow_depth = 1.0 / 5.5;
  const static int icon_shadow_color = 0x100000;

  void button_icon::draw_icon(ta_parameter_writer& writer) const
  {
    float y_offset = (float)(click_state != click_type::release);

    const icons::icon& icon = icons::icons[icon_type];

    float cx = x() + width / 2 - (icon.width) / 2;
    float cy = y() + height / 2 - (icon.height) / 2 + y_offset;

    icons::global_polygon_icon(writer);

    icons::draw(writer, icon_type, cx, cy, icon_depth, icon_color);

    if (click_state == click_type::release)
      icons::draw(writer, icon_type, cx + 1, cy + 1, icon_shadow_depth, icon_shadow_color);
  }

  void button_icon::draw(ta_multiwriter& multi)
  {
    draw_icon(multi.pt);

    button::draw(multi);
  }
}
