コード例 #1
0
ファイル: title-bar.cpp プロジェクト: lineCode/framework
void TitleBar::MinimizeButton::OnDraw(const Context &context) {
  Canvas *canvas = context.canvas();
  int scale = context.surface()->GetScale();
  const RectF &rect = GetBounds();

  canvas->Scale(scale, scale);

  Paint paint;
  paint.SetAntiAlias(true);

  if (IsHovered()) {
    if (IsPressed()) {
      paint.SetColor(Theme::GetData().title_bar.highlight.foreground.colors[0]);
      paint.SetStyle(Paint::Style::kStyleFill);
      canvas->DrawCircle(rect.center_x(), rect.center_y(), 7.f, paint);
      paint.Reset();
      paint.SetAntiAlias(true);
    }

    paint.SetStyle(Paint::Style::kStyleStroke);
    paint.SetColor(Theme::GetData().title_bar.active.foreground.colors[0]);
    paint.SetStrokeWidth(1.f);
    canvas->DrawCircle(rect.center_x(), rect.center_y(), 6.5f, paint);
  }

  paint.SetColor(Theme::GetData().title_bar.active.foreground.colors[0]);
  paint.SetStrokeWidth(1.5f);
  canvas->DrawLine(rect.center_x() - 4.f, rect.center_y(),
                   rect.center_x() + 4.f, rect.center_y(),
                   paint);
}
コード例 #2
0
ファイル: title-bar.cpp プロジェクト: lineCode/framework
void TitleBar::CloseButton::OnDraw(const Context &context) {
  Canvas *canvas = context.canvas();
  int scale = context.surface()->GetScale();
  const RectF &rect = GetBounds();

  canvas->Scale(scale, scale);

  Paint paint;
  paint.SetAntiAlias(true);
  base::ColorF background = 0xFFDD6666;

  if (IsHovered()) {
    if (IsPressed()) {
      background -= 45;
    } else {
      background += 35;
    }
  }

  paint.SetStyle(Paint::Style::kStyleFill);
  paint.SetColor(background);
  canvas->DrawCircle(rect.center_x(), rect.center_y(), 7.f, paint);

//  paint.SetColor(Theme::GetData().title_bar.active.foreground.color);
  paint.SetColor(0xFFDDDDDD);
  paint.SetStrokeWidth(1.5f);
  canvas->DrawLine(rect.center_x() - 3.f, rect.center_y() - 3.f,
                   rect.center_x() + 3.f, rect.center_y() + 3.f,
                   paint);
  canvas->DrawLine(rect.center_x() + 3.f, rect.center_y() - 3.f,
                   rect.center_x() - 3.f, rect.center_y() + 3.f,
                   paint);
}
コード例 #3
0
ファイル: spinner.cpp プロジェクト: lineCode/framework
void Spinner::Private::Draw(const Context &context) {
  angle += 5.f;
  if (angle > 360.f) angle = 0.f;

  Canvas *canvas = context.canvas();
  int scale = context.surface()->GetScale();
  canvas->Scale(scale, scale);

  const RectF &rect = proprietor()->GetBounds();
  float radius = base::Clamp(std::min(rect.width(), rect.height()) / 2.f - 50.f,
                             50.f, 200.f);

  Paint paint;
  paint.SetAntiAlias(true);

  paint.SetColor(background);
  paint.SetStyle(Paint::Style::kStyleFill);
  canvas->DrawRect(rect, paint);

  paint.SetColor(ColorF(foreground));
  paint.SetStyle(Paint::Style::kStyleStroke);
  paint.SetStrokeWidth(6.f);

  canvas->DrawArc(RectF(rect.center_x() - radius,
                        rect.center_y() - radius,
                        rect.center_x() + radius,
                        rect.center_y() + radius),
                  angle, 300.f, false, paint);

  frame_callback.Setup(context.surface());
}
コード例 #4
0
ファイル: title-bar.cpp プロジェクト: lineCode/framework
void TitleBar::FullscreenButton::OnDraw(const Context &context) {
  Canvas *canvas = context.canvas();
  int scale = context.surface()->GetScale();
  const RectF &rect = GetBounds();

  canvas->Scale(scale, scale);

  Paint paint;
  paint.SetAntiAlias(true);

  if (IsHovered()) {
    if (IsPressed()) {
      paint.SetColor(Theme::GetData().title_bar.active.foreground.colors[0]);
      paint.SetStyle(Paint::Style::kStyleFill);
      canvas->DrawCircle(rect.center_x(), rect.center_y(), 7.f, paint);
      paint.Reset();
      paint.SetAntiAlias(true);
    }

    paint.SetStyle(Paint::Style::kStyleStroke);
    paint.SetColor(Theme::GetData().title_bar.active.foreground.colors[0]);
    paint.SetStrokeWidth(1.f);
    canvas->DrawCircle(rect.center_x(), rect.center_y(), 6.5f, paint);
  }

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

  Path path;
  path.MoveTo(-5.f, 0.f);
  path.RelativeLineTo(3.5f, -3.5f);
  path.RelativeLineTo(0.f, 7.f);
  path.Close();

  canvas->Translate(rect.center_x(), rect.center_y());
  canvas->Rotate(-45.f);
  canvas->DrawPath(path, paint);
  canvas->Rotate(180.f);
  canvas->DrawPath(path, paint);
}