Beispiel #1
0
void TitleBar::OnDraw(const Context &context) {
  using namespace base;
  using namespace graphic;

  int scale = context.surface()->GetScale();

  const RectF bounds = GetBounds() * scale;
  float factor = 0.5f * scale;

  Paint paint;
  paint.SetAntiAlias(true);
  paint.SetStyle(Paint::kStyleFill);

  Point2F points[2] = {{factor, bounds.top + factor}, {factor, bounds.bottom}};
  uint32_t colors[2] = {0xFFE7E7E7, 0xFFD7D7D7};
  float pos[2] = {0.f, 1.f};

  Shader shader = GradientShader::MakeLinear(points, colors, pos, 2, Shader::kTileModeClamp);
  paint.SetShader(shader);

  context.canvas()->DrawRect(RectF::FromLTRB(bounds.left + factor,
                                             bounds.top + factor,
                                             bounds.right - factor,
                                             bounds.bottom), paint);

  paint.Reset();
  paint.SetAntiAlias(true);
  paint.SetStyle(Paint::kStyleFill);
  paint.SetFont(font_);
  paint.SetTextSize(font_.GetSize() * scale);

  paint.SetColor(Theme::GetData().title_bar.active.foreground.colors[0]);

  float text_width = paint.MeasureText(title_.c_str(), title_.length());

  SkTextBox text_box;
  // Put the foreground at the center
  text_box.setBox(bounds.l + (bounds.width() - text_width) / 2.f,
                  bounds.t + 1.f, // move down a little for better look
                  bounds.r - (bounds.width() - text_width) / 2.f,
                  bounds.b);
  text_box.setSpacingAlign(SkTextBox::kCenter_SpacingAlign);
  text_box.setText(title_.c_str(), title_.length(), paint.GetSkPaint());
  text_box.draw(context.canvas()->GetSkCanvas());

}
Beispiel #2
0
void TitleBar::OnSaveGeometry(const RectF &old_geometry, const RectF &new_geometry) {
  SetBounds(0.f, 0.f, new_geometry.width(), new_geometry.height());

  int y = ((int) new_geometry.height() - close_button_->GetHeight()) / 2;
  int x = y;
  close_button_->MoveTo(x, y);

//  new_x += close_button_->GetWidth() + kButtonSpace;
//  maximize_button_->MoveTo(new_x, new_y);
//
//  new_x += maximize_button_->GetWidth() + kButtonSpace;
//  minimize_button_->MoveTo(new_x, new_y);

  x = (int) new_geometry.width() - y - fullscreen_button_->GetWidth();
  fullscreen_button_->MoveTo(x, y);

  x -= maximize_button_->GetWidth() + kButtonSpace;
  maximize_button_->MoveTo(x, y);

  x -= minimize_button_->GetWidth() + kButtonSpace;
  minimize_button_->MoveTo(x, y);
}
Beispiel #3
0
void Spinner::OnSaveGeometry(const RectF &old_rect, const RectF &new_rect) {
  SetBounds(0.f, 0.f, new_rect.width(), new_rect.height());
  Update();
}
Beispiel #4
0
void TitleBar::OnConfigureGeometry(const RectF &old_geometry, const RectF &new_geometry) {
  RequestSaveGeometry(new_geometry);
  SetBounds(0.f, 0.f, new_geometry.width(), new_geometry.height());
}
// 範囲選択終了
void GridLabel::mouseReleaseEvent(QMouseEvent *ev)
{
    if (!m_pEditData || !m_bCatchable)
    {
        return;
    }
    if (!bCatching)
    {
        return;
    }

    bCatching = false;
    if (m_bRectMove)
    { // 範囲移動中
        m_bRectMove = false;
        return;
    }
    m_bRectMove = false;

    EditData::ImageData *p = m_pEditData->getImageDataFromNo(m_Index);
    if (!p)
    {
        return;
    }

    int img_w = p->Image.width();
    int img_h = p->Image.height();

    RectF r = m_pEditData->getCatchRect();

    float x = ev->pos().x() / mScale;
    float y = ev->pos().y() / mScale;

    if (x < 0)
    {
        x = 0;
    }
    if (x > img_w)
    {
        x = img_w;
    }
    if (x < r.left())
    {
        x = r.left();
    }
    if (y < 0)
    {
        y = 0;
    }
    if (y > img_h)
    {
        y = img_h;
    }
    if (y < r.top())
    {
        y = r.top();
    }

    r.setRight(x);
    r.setBottom(y);
    if (r.width() <= 1 || r.height() <= 1)
    {
        r.setLeft(-2);
        r.setRight(-2);
        r.setTop(-1);
        r.setBottom(-1);
    }
    m_pEditData->setCatchRect(r);
    emit sig_changeCatchRect(r);

    repaint();
}