Exemple #1
1
static void
DrawBanner(Canvas &canvas, PixelRect &rc)
{
  const unsigned padding = 2;
  const Bitmap logo(IDB_LOGO);
  const unsigned banner_height = logo.GetHeight();

  /* draw the XCSoar logo */
  int x = rc.left + padding;
  canvas.Copy(x, rc.top + padding,
              logo.GetWidth(), logo.GetHeight(),
              logo, 0, 0);

  x += logo.GetWidth() + 8;

  canvas.Select(bold_font);
  canvas.SetTextColor(COLOR_BLACK);
  canvas.SetBackgroundTransparent();

  /* draw the XCSoar banner text with a larger font */
  Font large_font;
  large_font.LoadFile("/opt/xcsoar/share/fonts/VeraBd.ttf", 40);
  canvas.Select(large_font);
  const unsigned name_y = rc.top
    + (banner_height - large_font.GetHeight()) / 2;

  const TCHAR *const name1 = _T("XC");
  canvas.DrawText(x, name_y, name1);
  x += canvas.CalcTextWidth(name1);

  const TCHAR *const name2 = _T("Soar");
  canvas.SetTextColor(COLOR_GRAY);
  canvas.DrawText(x, name_y, name2);
  canvas.SetTextColor(COLOR_BLACK);
  x += canvas.CalcTextWidth(name2) + 30;

  /* some more text */
  const TCHAR *const website = _T("www.xcsoar.org");
  canvas.Select(normal_font);
  canvas.DrawText(x, rc.top + (banner_height - normal_font.GetHeight()) / 2,
                  website);

  const TCHAR *const comment = _T("powered off");
  canvas.DrawText(rc.right - canvas.CalcTextWidth(comment) - padding,
                  rc.top + padding, comment);

  rc.top += banner_height + 8;
}
Exemple #2
0
void
BufferWindow::OnPaint(Canvas &canvas)
{
#ifdef ENABLE_OPENGL
  if (!buffer.IsDefined()) {
    buffer.Create(canvas.GetSize());
    dirty = true;
  }

  if (dirty) {
    dirty = false;
    buffer.Begin(canvas);
    OnPaintBuffer(buffer);
    buffer.Commit(canvas);
  } else
    buffer.CopyTo(canvas);

#else

  if (dirty) {
    dirty = false;
    OnPaintBuffer(buffer);
  }

  canvas.Copy(buffer);
#endif
}
void
TaskMapButtonRenderer::DrawButton(Canvas &canvas, const PixelRect &rc,
                                  gcc_unused bool enabled,
                                  gcc_unused bool focused,
                                  bool pressed) const
{
  if (task == nullptr) {
    canvas.ClearWhite();
    return;
  }

  const PixelSize new_size(rc.right - rc.left,
                           rc.bottom - rc.top);
  if (!IsBufferValid(new_size)) {
    if (!buffer.IsDefined()) {
#ifdef ENABLE_OPENGL
      buffer.Create(new_size);
#else
      buffer.Create(canvas, new_size);
#endif
    } else
      buffer.Grow(new_size);

    size = new_size;

#ifdef ENABLE_OPENGL
    buffer.Begin(canvas);
#endif

    const PixelRect buffer_rc(0, 0, new_size.cx, new_size.cy);
    DrawTask(buffer, buffer_rc, look, *task);

#ifdef ENABLE_OPENGL
    buffer.Commit(canvas);
#endif
  } else {
#ifdef ENABLE_OPENGL
    buffer.CopyTo(canvas);
#endif
  }

#ifndef ENABLE_OPENGL
  canvas.Copy(buffer);
#endif

  if (pressed) {
#ifdef ENABLE_OPENGL
    const ScopeAlphaBlend alpha_blend;
    canvas.DrawFilledRectangle(rc, COLOR_YELLOW.WithAlpha(80));
#else
    canvas.InvertRectangle(rc);
#endif
  }
}
Exemple #4
0
  virtual void OnPaint(Canvas &canvas) override {
#ifndef ENABLE_OPENGL
    if (!buffered) {
#endif
      canvas.ClearWhite();

      paint(canvas);
#ifndef ENABLE_OPENGL
    } else
      canvas.Copy(buffer);
#endif

    SingleWindow::OnPaint(canvas);
  }
Exemple #5
0
static void
OnLogoPaint(gcc_unused WndOwnerDrawFrame *Sender, Canvas &canvas)
{
  const UPixelScalar width = canvas.GetWidth();
  PixelScalar x = Layout::FastScale(10), y = x;

  canvas.ClearWhite();

  Bitmap title(width > 360 ? IDB_TITLE_HD : IDB_TITLE);

  // Determine title image size
  PixelSize title_size = title.GetSize();

  // Draw 'XCSoar N.N' title
  canvas.Copy(x, y, title_size.cx, title_size.cy, title, 0, 0);
  y += title_size.cy + Layout::FastScale(20);

  Font font;
  font.Load(GetStandardFontFace(), Layout::FastScale(16));
  canvas.Select(font);
  canvas.SetTextColor(COLOR_BLACK);
  canvas.SetBackgroundTransparent();

  canvas.DrawText(x, y, _T("version: "));
  canvas.DrawText(x + Layout::FastScale(80), y, XCSoar_VersionString);
  y += Layout::FastScale(22);

  canvas.DrawText(x, y, _T("date: "));
  canvas.DrawText(x + Layout::FastScale(80), y, _T(__DATE__));
#ifdef GIT_COMMIT_ID
  y += Layout::FastScale(22);

  canvas.DrawText(x, y, _T("git: "));
  canvas.DrawText(x + Layout::FastScale(80), y, _T(GIT_COMMIT_ID));
#endif
  y += Layout::FastScale(37);

  canvas.DrawText(x, y, _T("more information at"));
  y += Layout::FastScale(22);

  canvas.SetTextColor(COLOR_XCSOAR);
  canvas.DrawText(x, y, _T("http://www.xcsoar.org"));
}
void
FPlayer::OnUserEventReceivedN(RequestId requestId, Osp::Base::Collection::IList* pArgs)
{
	if (requestId == THREADCALLBACK_REDRAW) {
		RedrawDisplayBuffer(displaybuffer_->GetBounds());
		if (controlsarevisible == false) {
			Canvas* formCanvas;
			formCanvas = GetCanvasN();
			formCanvas->Copy(Point(canvasredrawrect_.x, canvasredrawrect_.y), *displaybuffer_, canvasredrawrect_);
			formCanvas->Show(canvasredrawrect_);
			delete formCanvas;
		} else {
			this->RequestRedraw();
		}
		/*long long fpsbenchmarktimeold = fpsbenchmarktime;
		Osp::System::SystemTime::GetTicks(fpsbenchmarktime);
		AppLog("render frame %d ms", (int)(fpsbenchmarktime - fpsbenchmarktimeold));*/
		pPlayerThread_->SendUserEvent(pPlayerThread_->THREAD_FRAMEDRAWED, null);
	} else if (requestId == THREADCALLBACK_FILELOADED) {
		delete speedbtnbmpn_;
		delete speedbtnbmps_;
		speedbtnbmpn_ = CreateSpeedBtnBmp(164, Osp::Base::Integer::ToString((int)pPlayerThread_->fileinfo_.playframerate) + L" fps", false);
		speedbtnbmps_ = CreateSpeedBtnBmp(164, Osp::Base::Integer::ToString((int)pPlayerThread_->fileinfo_.playframerate) + L" fps", true);
		speedbtn->SetNormalBackgroundBitmap(*speedbtnbmpn_);
		speedbtn->SetPressedBackgroundBitmap(*speedbtnbmps_);
		this->RequestRedraw();
		if (this->autoplayonload == true) {
			this->OnActionPerformed(*this, APLAYPAUSE);
			/*pPlayerThread_->playing = false;
			pPlayerThread_->SendUserEvent(pPlayerThread_->THREAD_PLAYPAUSE, null);*/
		}
	} else if ((requestId == THREADCALLBACK_EXPORTDONE) || (requestId == THREADCALLBACK_EXPORTPROGRESSUPDATE)) {
		AppLog("player event recived");
		this->OnActionPerformed(*this, requestId);
	}
}
Exemple #7
0
void
DoubleBufferWindow::OnPaint(Canvas &canvas)
{
  ScopeLock protect(mutex);
  canvas.Copy(GetVisibleCanvas());
}
Exemple #8
0
void
DoubleBufferWindow::OnPaint(Canvas &canvas)
{
  std::lock_guard<Mutex> lock(mutex);
  canvas.Copy(GetVisibleCanvas());
}