本文整理汇总了C++中PixelRect类的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect类的具体用法?C++ PixelRect怎么用?C++ PixelRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PixelRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBottomWidgetRect
gcc_pure
static PixelRect
GetBottomWidgetRect(const PixelRect &rc, const Widget *bottom_widget)
{
if (bottom_widget == nullptr) {
/* no bottom widget: return empty rectangle, map uses the whole
main area */
PixelRect result = rc;
result.top = result.bottom;
return result;
}
const unsigned requested_height = bottom_widget->GetMinimumSize().cy;
unsigned height;
if (requested_height > 0) {
const unsigned max_height = rc.GetHeight() / 2;
height = std::min(max_height, requested_height);
} else {
const unsigned recommended_height = rc.GetHeight() / 3;
height = recommended_height;
}
PixelRect result = rc;
result.top = result.bottom - height;
return result;
}
示例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);
}
示例3: 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);
}
示例4: GetButtonPosition
PixelRect GetButtonPosition(unsigned MenuID, const PixelRect& rcScreen) {
PixelRect rc = rcScreen;
rc.Grow(-1); // remove Margin
unsigned i = MenuID - 1;
assert(i < MenuButtons.size());
const PixelScalar row = ScreenLandscape ? LandscapeLayout[i].row : PortraitLayout[i].row;
const PixelScalar col = ScreenLandscape ? LandscapeLayout[i].col :PortraitLayout[i].col;
const PixelScalar nbRow = ScreenLandscape ? 5 : 7;
const PixelScalar nbCol = ScreenLandscape ? 5 : 4;
const PixelSize size = {
std::min<PixelScalar>((rc.GetSize().cx-(nbCol-1))/nbCol, NIBLSCALE(80)),
std::min<PixelScalar>((rc.GetSize().cy-nbRow-1)/nbRow, NIBLSCALE(40))
};
const double x_interval = (rc.GetSize().cx - size.cx * nbCol) / (nbCol-1);
const double y_interval = (rc.GetSize().cy - size.cy * nbRow) / (nbRow-1);
const RasterPoint origin = {
rc.left + (PixelScalar)(col * (size.cx + x_interval)),
rc.top + (PixelScalar)(row * (size.cy + y_interval))
};
return PixelRect(origin, size);
}
示例5: 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);
}
示例6: assert
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;
}
示例7: assert
void
Window::Create(ContainerWindow *parent, PixelRect rc,
const WindowStyle window_style)
{
assert(IsScreenInitialized());
assert(rc.left <= rc.right);
assert(rc.right - rc.left < 0x8000);
assert(rc.top <= rc.bottom);
assert(rc.bottom - rc.top < 0x8000);
double_clicks = window_style.double_clicks;
this->parent = parent;
position = rc.GetOrigin();
size = rc.GetSize();
tab_stop = window_style.tab_stop;
control_parent = window_style.control_parent;
visible = window_style.visible;
enabled = window_style.enabled;
has_border = window_style.has_border;
text_style = window_style.text_style;
if (parent != NULL)
parent->AddChild(*this);
OnCreate();
OnResize(size);
}
示例8:
PixelRect
ButtonFrameRenderer::GetDrawingRect(PixelRect rc, bool pressed) const
{
rc.Grow(-2);
if (pressed)
rc.Offset(1, 1);
return rc;
}
示例9: GetMainMenuButtonSize
inline void
TabMenuDisplay::PaintMainMenuBorder(Canvas &canvas) const
{
PixelRect rc = GetMainMenuButtonSize(0);
rc.bottom = GetMainMenuButtonSize(GetNumMainMenuItems() - 1).bottom;
rc.Grow(GetTabLineHeight());
canvas.DrawFilledRectangle(rc, COLOR_BLACK);
}
示例10: Draw
static void
Draw(Canvas &canvas)
{
PixelRect rc = canvas.GetRect();
rc.Grow(-16);
DrawBanner(canvas, rc);
DrawFlights(canvas, rc);
}
示例11: CopyNot
void
Canvas::InvertRectangle(PixelRect r)
{
if (r.IsEmpty())
return;
CopyNot(r.left, r.top, r.GetWidth(), r.GetHeight(),
buffer, r.left, r.top);
}
示例12: GetSubMenuButtonSize
inline void
TabMenuDisplay::PaintSubMenuBorder(Canvas &canvas,
const MainMenuButton &main_button) const
{
PixelRect rc = GetSubMenuButtonSize(main_button.first_page_index);
rc.bottom = GetSubMenuButtonSize(main_button.last_page_index).bottom;
rc.Grow(GetTabLineHeight());
canvas.DrawFilledRectangle(rc, COLOR_BLACK);
}
示例13: 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);
}
示例14: OnPaint
virtual void OnPaint(Canvas &canvas) override {
canvas.ClearWhite();
const PixelRect rc = canvas.GetRect();
PixelPoint pt = rc.GetCenter();
canvas.SelectBlackPen();
canvas.SelectHollowBrush();
canvas.DrawCircle(pt.x, pt.y, 2);
renderer.Draw(canvas, Angle::Zero(), wind, pt, rc, WindArrowStyle::ARROW_HEAD);
}
示例15: GetClientRect
unsigned
WndFrame::GetTextHeight() const
{
PixelRect rc = GetClientRect();
const int padding = Layout::GetTextPadding();
rc.Grow(-padding);
AnyCanvas canvas;
canvas.Select(look.text_font);
return text_renderer.GetHeight(canvas, rc, text.c_str());
}