当前位置: 首页>>代码示例>>C++>>正文


C++ PixelRect::GetWidth方法代码示例

本文整理汇总了C++中PixelRect::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect::GetWidth方法的具体用法?C++ PixelRect::GetWidth怎么用?C++ PixelRect::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PixelRect的用法示例。


在下文中一共展示了PixelRect::GetWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: glTexParameteriv

inline void
GLTexture::DrawFlippedOES(PixelRect dest, PixelRect src) const
{
  const GLint rect[4] = { src.left, src.top,
                          (GLint)src.GetWidth(), (GLint)src.GetHeight() };
  glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);

  /* glDrawTexiOES() circumvents the projection settings, thus we must
     roll our own translation */
  glDrawTexiOES(OpenGL::translate.x + dest.left,
                OpenGL::viewport_size.y - OpenGL::translate.y - dest.bottom,
                0, dest.GetWidth(), dest.GetHeight());
}
开发者ID:nkgautam,项目名称:XCSoar,代码行数:13,代码来源:Texture.cpp

示例2: renderer

void
InfoBoxContentWindArrow::OnCustomPaint(Canvas &canvas, const PixelRect &rc)
{
  const auto &info = CommonInterface::Calculated();

  const auto pt = rc.GetCenter();

  const unsigned padding = Layout::FastScale(10u);
  unsigned size = std::min(rc.GetWidth(), rc.GetHeight());

  if (size > padding)
    size -= padding;

  // Normalize the size because the Layout::Scale is applied
  // by the DrawArrow() function again
  size = size * 100 / Layout::Scale(100);

  auto angle = info.wind.bearing - CommonInterface::Basic().attitude.heading;

  const int length =
    std::min(size, std::max(10u, uround(Quadruple(info.wind.norm))));

  const int offset = -length / 2;

  auto style = CommonInterface::GetMapSettings().wind_arrow_style;

  WindArrowRenderer renderer(UIGlobals::GetLook().wind_arrow_info_box);
  renderer.DrawArrow(canvas, pt, angle, length, style, offset);
}
开发者ID:nkgautam,项目名称:XCSoar,代码行数:29,代码来源:Weather.cpp

示例3: assert

void
SymbolRenderer::DrawArrow(Canvas &canvas, PixelRect rc, Direction direction)
{
  assert(direction == UP || direction == DOWN ||
         direction == LEFT || direction == RIGHT);

  auto size = std::min(rc.GetWidth(), rc.GetHeight()) / 5;
  auto center = rc.GetCenter();
  BulkPixelPoint arrow[3];

  if (direction == LEFT || direction == RIGHT) {
    arrow[0].x = center.x + (direction == LEFT ? size : -size);
    arrow[0].y = center.y + size;
    arrow[1].x = center.x + (direction == LEFT ? -size : size);
    arrow[1].y = center.y;
    arrow[2].x = center.x + (direction == LEFT ? size : -size);
    arrow[2].y = center.y - size;
  } else if (direction == UP || direction == DOWN) {
    arrow[0].x = center.x + size;
    arrow[0].y = center.y + (direction == UP ? size : -size);
    arrow[1].x = center.x;
    arrow[1].y = center.y + (direction == UP ? -size : size);
    arrow[2].x = center.x - size;
    arrow[2].y = center.y + (direction == UP ? size : -size);
  }

  canvas.DrawTriangleFan(arrow, 3);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:28,代码来源:SymbolRenderer.cpp

示例4: button_rc

PixelRect
ButtonPanel::HorizontalRange(PixelRect rc, unsigned start, unsigned end)
{
  const unsigned n = end - start;
  assert(n > 0);

  const unsigned total_width = rc.GetWidth();
  const unsigned total_height = rc.GetHeight();
  const unsigned max_row_height = Layout::GetMaximumControlHeight();
  const unsigned row_height = max_row_height < total_height / 2
    ? max_row_height
    : std::max(Layout::GetMinimumControlHeight(),
               total_height / 2);
  const unsigned width = total_width / n;
  assert(width > 0);

  PixelRect button_rc(rc.left, rc.bottom - row_height,
                      rc.left + width, rc.bottom);
  rc.bottom -= row_height;

  for (unsigned i = start; i < end; ++i) {
    buttons[i]->Move(button_rc);

    button_rc.left = button_rc.right;
    button_rc.right += width;
  }

  return rc;
}
开发者ID:nkgautam,项目名称:XCSoar,代码行数:29,代码来源:ButtonPanel.cpp

示例5: Clamp

void
HorizonRenderer::Draw(Canvas &canvas, const PixelRect &rc,
                      const HorizonLook &look,
                      const AttitudeState &attitude)
{
  /*
  This feature of having a backup artificial horizon based on inferred
  orientation from GPS and vario data is useful, and reasonably well
  tested, but has the issue of potentially invalidating use of XCSoar in
  FAI contests due to rule ref Annex A to Section 3 (2010 Edition) 4.1.2
  "No instruments permitting pilots to fly without visual reference to
  the ground may be carried on board, even if made unserviceable."  The
  quality of XCSoar's pseudo-AH is arguably good enough that this
  violates the rule.  We need to seek clarification as to whether this
  is the case or not.
  */

  const auto center = rc.GetCenter();

  const int radius = std::min(rc.GetWidth(), rc.GetHeight()) / 2
    - Layout::Scale(1);

  auto bank_degrees = attitude.IsBankAngleUseable()
    ? attitude.bank_angle.Degrees()
    : 0.;

  auto pitch_degrees = attitude.IsPitchAngleUseable()
    ? attitude.pitch_angle.Degrees()
    : 0.;

  auto phi = Clamp(bank_degrees, -89., 89.);
  auto alpha = Angle::acos(Clamp(pitch_degrees / 50,
                                 -1., 1.));
  auto sphi = Angle::HalfCircle() - Angle::Degrees(phi);
  auto alpha1 = sphi - alpha;
  auto alpha2 = sphi + alpha;

  // draw sky part
  canvas.Select(look.sky_pen);
  canvas.Select(look.sky_brush);
  canvas.DrawSegment(center, radius, alpha2, alpha1, true);

  // draw ground part
  canvas.Select(look.terrain_pen);
  canvas.Select(look.terrain_brush);
  canvas.DrawSegment(center, radius, alpha1, alpha2, true);

  // draw aircraft symbol
  canvas.Select(look.aircraft_pen);
  canvas.DrawLine(center.x + radius / 2, center.y, center.x - radius / 2, center.y);
  canvas.DrawLine(center.x, center.y - radius / 4, center.x, center.y);

  // draw 45 degree dash marks
  const int rr2p = uround(radius * M_SQRT1_2) + Layout::Scale(1);
  const int rr2n = rr2p - Layout::Scale(2);
  canvas.DrawLine(center.x + rr2p, center.y - rr2p,
              center.x + rr2n, center.y - rr2n);
  canvas.DrawLine(center.x - rr2p, center.y - rr2p,
              center.x - rr2n, center.y - rr2n);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:60,代码来源:HorizonRenderer.cpp

示例6: CopyNot

void
Canvas::InvertRectangle(PixelRect r)
{
  if (r.IsEmpty())
    return;

  CopyNot(r.left, r.top, r.GetWidth(), r.GetHeight(),
          buffer, r.left, r.top);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:9,代码来源:Canvas.cpp

示例7: LeftLayout

PixelRect
ButtonPanel::UpdateLayout(const PixelRect rc)
{
  if (buttons.empty())
    return rc;

  const bool landscape = rc.GetWidth() > rc.GetHeight();
  return landscape
    ? LeftLayout(rc)
    : BottomLayout(rc);
}
开发者ID:nkgautam,项目名称:XCSoar,代码行数:11,代码来源:ButtonPanel.cpp

示例8: if

gcc_pure
static PixelRect
GetButtonPosition(unsigned i, PixelRect rc)
{
  unsigned hwidth = rc.GetWidth(), hheight = rc.GetHeight();

  if (hheight > hwidth) {
    // portrait

    hheight /= 6;

    if (i == 0) {
      rc.left = rc.right;
      rc.top = rc.bottom;
    } else if (i < 5) {
      hwidth /= 4;

      rc.left += hwidth * (i - 1);
      rc.top = rc.bottom - hheight;
    } else {
      hwidth /= 3;

      rc.left = rc.right - hwidth;
      rc.top += (i - 5) * hheight;
    }

    rc.right = rc.left + hwidth;
    rc.bottom = rc.top + hheight;
  } else {
    // landscape

    hwidth /= 5;
    hheight /= 5;

    if (i == 0) {
      rc.left = rc.right;
      rc.top = rc.bottom;
    } else if (i < 5) {
      rc.top += hheight * (i - 1);
    } else {
      rc.left += hwidth * (i - 5);
      rc.top = rc.bottom - hheight;
    }

    rc.right = rc.left + hwidth;
    rc.bottom = rc.top + hheight;
  }

  return rc;
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:50,代码来源:MenuBar.cpp

示例9:

void
SymbolRenderer::DrawSign(Canvas &canvas, PixelRect rc, bool plus)
{
  unsigned size = std::min(rc.GetWidth(), rc.GetHeight()) / 5;
  auto center = rc.GetCenter();

  // Draw horizontal bar
  canvas.Rectangle(center.x - size, center.y - size / 3,
                   center.x + size, center.y + size / 3);

  if (plus)
    // Draw vertical bar
    canvas.Rectangle(center.x - size / 3, center.y - size,
                     center.x + size / 3, center.y + size);
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:15,代码来源:SymbolRenderer.cpp

示例10:

AnalysisWidget::Layout::Layout(const PixelRect rc)
{
  const unsigned width = rc.GetWidth(), height = rc.GetHeight();
  const unsigned button_height = ::Layout::GetMaximumControlHeight();

  main = rc;

  /* close button on the bottom left */

  close_button.left = rc.left;
  close_button.right = rc.left + ::Layout::Scale(70);
  close_button.bottom = rc.bottom;
  close_button.top = close_button.bottom - button_height;

  /* previous/next buttons above the close button */

  previous_button = close_button;
  previous_button.bottom = previous_button.top;
  previous_button.top = previous_button.bottom - button_height;
  previous_button.right = (previous_button.left + previous_button.right) / 2;

  next_button = previous_button;
  next_button.left = next_button.right;
  next_button.right = close_button.right;

  /* "details" button above "previous/next" */

  details_button = close_button;
  details_button.bottom = previous_button.top;
  details_button.top = details_button.bottom - button_height;

  if (width > height) {
    info = close_button;
    info.top = rc.top;
    info.bottom = details_button.top;

    main.left = close_button.right;
  } else {
    main.bottom = details_button.top;
    info.left = close_button.right;
    info.right = rc.right;
    info.top = main.bottom;
    info.bottom = rc.bottom;
  }
}
开发者ID:rkohel,项目名称:XCSoar,代码行数:45,代码来源:dlgAnalysis.cpp

示例11: assert

void
DigitEntry::Create(ContainerWindow &parent, const PixelRect &rc,
                   const WindowStyle style,
                   unsigned _length)
{
    assert(_length > 0);
    assert(_length <= MAX_LENGTH);

    length = _length;
    cursor = length - 1;
    valid = true;

    for (unsigned i = 0; i < length; ++i) {
        Column &digit = columns[i];
        digit.type = Column::Type::DIGIT;
        digit.value = 0;
    }

    max_width = rc.GetWidth();

    CalculateLayout();

    PaintWindow::Create(parent, rc, style);
}
开发者ID:rkohel,项目名称:XCSoar,代码行数:24,代码来源:DigitEntry.cpp

示例12: if

void
LogoView::draw(Canvas &canvas, const PixelRect &rc)
{
  const unsigned width = rc.GetWidth(), height = rc.GetHeight();

  enum {
    LANDSCAPE, PORTRAIT, SQUARE,
  } orientation;

  if (width == height)
    orientation = SQUARE;
  else if (width > height)
    orientation = LANDSCAPE;
  else
    orientation = PORTRAIT;

  /* load bitmaps */
  const bool use_big =
    (orientation == LANDSCAPE && width >= 510 && height >= 170) ||
    (orientation == PORTRAIT && width >= 330 && height >= 250) ||
    (orientation == SQUARE && width >= 210 && height >= 210);
  const Bitmap &bitmap_logo = use_big ? big_logo : logo;
  const Bitmap &bitmap_title = use_big ? big_title : title;

  // Determine logo size
  PixelSize logo_size = bitmap_logo.GetSize();

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

  unsigned spacing = title_size.cy / 2;

  unsigned estimated_width, estimated_height;
  switch (orientation) {
  case LANDSCAPE:
    estimated_width = logo_size.cx + spacing + title_size.cx;
    estimated_height = logo_size.cy;
    break;

  case PORTRAIT:
    estimated_width = title_size.cx;
    estimated_height = logo_size.cy + spacing + title_size.cy;
    break;

  case SQUARE:
    estimated_width = logo_size.cx;
    estimated_height = logo_size.cy;
    break;
  }

  const unsigned magnification =
    std::min((width - 16u) / estimated_width,
             (height - 16u) / estimated_height);

  if (magnification > 1) {
    logo_size.cx *= magnification;
    logo_size.cy *= magnification;
    title_size.cx *= magnification;
    title_size.cy *= magnification;
    spacing *= magnification;
  }

  int logox, logoy, titlex, titley;

  // Determine logo and title positions
  switch (orientation) {
  case LANDSCAPE:
    logox = Center(width, logo_size.cx + spacing + title_size.cx);
    logoy = Center(height, logo_size.cy);
    titlex = logox + logo_size.cx + spacing;
    titley = Center(height, title_size.cy);
    break;
  case PORTRAIT:
    logox = Center(width, logo_size.cx);
    logoy = Center(height, logo_size.cy + spacing + title_size.cy);
    titlex = Center(width, title_size.cx);
    titley = logoy + logo_size.cy + spacing;
    break;
  case SQUARE:
    logox = Center(width, logo_size.cx);
    logoy = Center(height, logo_size.cy);
    // not needed - silence compiler "may be used uninitialized"
    titlex = 0;
    titley = 0;
    break;
  }

  // Draw 'XCSoar N.N' title
  if (orientation != SQUARE)
    canvas.Stretch(titlex, titley, title_size.cx, title_size.cy, bitmap_title);

  // Draw XCSoar swift logo
  canvas.Stretch(logox, logoy, logo_size.cx, logo_size.cy, bitmap_logo);

  // Draw full XCSoar version number

#ifndef USE_GDI
  canvas.Select(font);
#endif

//.........这里部分代码省略.........
开发者ID:Advi42,项目名称:XCSoar,代码行数:101,代码来源:LogoView.cpp

示例13: IsLandscape

 gcc_pure
 static bool IsLandscape(const PixelRect &rc) {
   return rc.GetWidth() >= rc.GetHeight();
 }
开发者ID:Exadios,项目名称:xcsoar-exp,代码行数:4,代码来源:KeyboardWidget.hpp

示例14: if

void
GlueMapWindow::UpdateProjection()
{
  const PixelRect rc = GetClientRect();

  /* not using MapWindowBlackboard here because these methods are
     called by the main thread */
  const NMEAInfo &basic = CommonInterface::Basic();
  const DerivedInfo &calculated = CommonInterface::Calculated();
  const MapSettings &settings_map = CommonInterface::GetMapSettings();
  const bool circling =
    CommonInterface::GetUIState().display_mode == DisplayMode::CIRCLING;

  const auto center = rc.GetCenter();

  if (circling || !IsNearSelf())
    visible_projection.SetScreenOrigin(center.x, center.y);
  else if (settings_map.cruise_orientation == MapOrientation::NORTH_UP ||
           settings_map.cruise_orientation == MapOrientation::WIND_UP) {
    PixelPoint offset{0, 0};
    if (settings_map.glider_screen_position != 50 &&
        settings_map.map_shift_bias != MapShiftBias::NONE) {
      double x = 0, y = 0;
      if (settings_map.map_shift_bias == MapShiftBias::TRACK) {
        if (basic.track_available &&
            basic.ground_speed_available &&
             /* 8 m/s ~ 30 km/h */
            basic.ground_speed > 8) {
          auto angle = basic.track.Reciprocal() - visible_projection.GetScreenAngle();

          const auto sc = angle.SinCos();
          x = sc.first;
          y = sc.second;
        }
      } else if (settings_map.map_shift_bias == MapShiftBias::TARGET) {
        if (calculated.task_stats.current_leg.solution_remaining.IsDefined()) {
          auto angle = calculated.task_stats.current_leg.solution_remaining
              .vector.bearing.Reciprocal() - visible_projection.GetScreenAngle();

          const auto sc = angle.SinCos();
          x = sc.first;
          y = sc.second;
        }
      }
      double position_factor = (50. - settings_map.glider_screen_position) / 100.;
      offset.x = int(x * rc.GetWidth() * position_factor);
      offset.y = int(-y * rc.GetHeight() * position_factor);
      offset_history.Add(offset);
      offset = offset_history.GetAverage();
    }
    visible_projection.SetScreenOrigin(center.x + offset.x, center.y + offset.y);
  } else
    visible_projection.SetScreenOrigin(center.x,
        ((rc.top - rc.bottom) * settings_map.glider_screen_position / 100) + rc.bottom);

  if (!IsNearSelf()) {
    /* no-op - the Projection's location is updated manually */
  } else if (circling && calculated.thermal_locator.estimate_valid) {
    const auto d_t = calculated.thermal_locator.estimate_location.DistanceS(basic.location);
    if (d_t <= 0) {
      SetLocationLazy(basic.location);
    } else {
      const auto d_max = 2 * visible_projection.GetMapScale();
      const auto t = std::min(d_t, d_max)/d_t;
      SetLocation(basic.location.Interpolate(calculated.thermal_locator.estimate_location,
                                               t));
    }
  } else if (basic.location_available)
    // Pan is off
    SetLocationLazy(basic.location);
  else if (!visible_projection.IsValid() && terrain != nullptr)
    /* if there's no GPS fix yet and no home waypoint, start at the
       map center, to avoid showing a fully white map, which confuses
       users */
    SetLocation(terrain->GetTerrainCenter());

  OnProjectionModified();
}
开发者ID:Advi42,项目名称:XCSoar,代码行数:78,代码来源:GlueMapWindowDisplayMode.cpp

示例15: size

PixelRect
ButtonPanel::BottomLayout(PixelRect rc)
{
  assert(!buttons.empty());

  const unsigned n_buttons = buttons.size();
  const unsigned total_width = rc.GetWidth();

  /* naive button distribution algorithm: distribute as many buttons
     as possible into each row; weakness: the last row may have only
     one button */

  struct Row {
    unsigned start, end;

    constexpr unsigned size() const {
      return end - start;
    }
  };

  StaticArray<Row, 8u> rows;

  for (unsigned i = 0; i < n_buttons;) {
    unsigned end = FitButtonRow(i, total_width);
    assert(end > i);

    auto &row = rows.append();
    row.start = i;
    row.end = i = end;
  }

  assert(!rows.empty());

  /* optimise the naive result: try to move buttons down until we see
     no further chance for improvement */

  bool modified;
  do {
    modified = false;

    for (unsigned i = rows.size() - 1; i > 0; --i) {
      auto &dest_row = rows[i];
      auto &src_row = rows[i - 1];

      /* the upper row has many more buttons than the lower row */
      if (dest_row.size() + 2 <= src_row.size()) {
        unsigned max_width = RangeMaxWidth(dest_row.start - 1, dest_row.end);
        unsigned row_width = (dest_row.size() + 1) * max_width;

        /* yes, we can move one button down */
        if (row_width <= total_width) {
          --src_row.end;
          --dest_row.start;
          modified = true;
        }
      }
    }
  } while (modified);

  /* now do the actual layout based on row metadata */

  for (int i = rows.size() - 1; i >= 0; --i) {
    const auto &row = rows[i];

    rc = HorizontalRange(rc, row.start, row.end);
  }

  return rc;
}
开发者ID:nkgautam,项目名称:XCSoar,代码行数:69,代码来源:ButtonPanel.cpp


注:本文中的PixelRect::GetWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。