#include "button_label.hpp"

#include "graphics_primitive.hpp"

namespace widget {

  const static float label_depth = 1.0 / 5.0;
  const static int label_color = 0xffffff;

  const static float label_shadow_depth = 1.0 / 6.0;
  const static int label_shadow_color = 0x000000;

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

    float cx = x() + width / 2 - (glyph::hori_advance * label_length) / 2;
    float cy = y() + height / 2 - glyph::vert_advance / 2 + y_offset;

    transfer_string(writer, label, cx, cy, label_depth, label_color);
  }

  void button_label::draw(ta_multiwriter& multi)
  {
    transfer_global_polygon_glyph(multi.pt);

    draw_label(multi.pt);

    button::draw(multi);
  }
}
