本文整理汇总了C++中PixelRect::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect::GetHeight方法的具体用法?C++ PixelRect::GetHeight怎么用?C++ PixelRect::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelRect
的用法示例。
在下文中一共展示了PixelRect::GetHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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: 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());
}
示例3: pt
static void
Draw(Canvas &canvas, PixelRect rc,
const ThermalMapItem &item,
RoughTimeDelta utc_offset,
const TwoTextRowsRenderer &row_renderer,
const MapLook &look)
{
const unsigned line_height = rc.GetHeight();
const unsigned text_padding = Layout::GetTextPadding();
const ThermalSource &thermal = item.thermal;
const PixelPoint pt(rc.left + line_height / 2,
rc.top + line_height / 2);
look.thermal_source_icon.Draw(canvas, pt);
rc.left += line_height + text_padding;
row_renderer.DrawFirstRow(canvas, rc, _("Thermal"));
StaticString<256> buffer;
TCHAR lift_buffer[32];
FormatUserVerticalSpeed(thermal.lift_rate, lift_buffer, 32);
int timespan = BrokenDateTime::NowUTC().GetSecondOfDay() - (int)thermal.time;
if (timespan < 0)
timespan += 24 * 60 * 60;
buffer.Format(_T("%s: %s - left %s ago (%s)"),
_("Avg. lift"), lift_buffer,
FormatTimespanSmart(timespan).c_str(),
FormatLocalTimeHHMM((int)thermal.time, utc_offset).c_str());
row_renderer.DrawSecondRow(canvas, rc, buffer);
}
示例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;
}
示例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: 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);
}
示例7: 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);
}
示例8: CopyNot
void
Canvas::InvertRectangle(PixelRect r)
{
if (r.IsEmpty())
return;
CopyNot(r.left, r.top, r.GetWidth(), r.GetHeight(),
buffer, r.left, r.top);
}
示例9: 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);
}
示例10: Clamp
void
GlueMapWindow::DrawStallRatio(Canvas &canvas, const PixelRect &rc) const
{
if (Basic().stall_ratio_available) {
// JMW experimental, display stall sensor
auto s = Clamp(Basic().stall_ratio, 0., 1.);
int m = rc.GetHeight() * s * s;
canvas.SelectBlackPen();
canvas.DrawLine(rc.right - 1, rc.bottom - m, rc.right - 11, rc.bottom - m);
}
}
示例11: 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;
}
示例12:
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);
}
示例13:
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;
}
}
示例14: scissor_rc
void
ListControl::DrawItems(Canvas &canvas, unsigned start, unsigned end) const
{
PixelRect rc = item_rect(start);
canvas.SetBackgroundColor(look.list.background_color);
canvas.SetBackgroundTransparent();
canvas.Select(*look.list.font);
#ifdef ENABLE_OPENGL
/* enable clipping */
const PixelRect scissor_rc(0, 0, scroll_bar.GetLeft(GetSize()),
canvas.GetHeight());
GLCanvasScissor scissor(scissor_rc);
#endif
unsigned last_item = std::min(length, end);
const bool focused = !HasCursorKeys() || HasFocus();
for (unsigned i = start; i < last_item; i++) {
const bool selected = i == cursor;
const bool pressed = selected && drag_mode == DragMode::CURSOR;
canvas.DrawFilledRectangle(rc,
look.list.GetBackgroundColor(selected,
focused,
pressed));
canvas.SetTextColor(look.list.GetTextColor(selected, focused, pressed));
if (item_renderer != nullptr)
item_renderer->OnPaintItem(canvas, rc, i);
if (focused && selected)
canvas.DrawFocusRectangle(rc);
rc.Offset(0, rc.GetHeight());
}
/* paint the bottom part below the last item */
rc.bottom = canvas.GetHeight();
if (rc.bottom > rc.top)
canvas.DrawFilledRectangle(rc, look.list.background_color);
}
示例15: GetClientRect
void
KnobTextEntryWindow::OnPaint(Canvas &canvas)
{
const PixelRect rc = GetClientRect();
canvas.Clear(Color(0x40, 0x40, 0x00));
// Do the actual painting of the text
const DialogLook &look = UIGlobals::GetDialogLook();
canvas.Select(look.text_font);
PixelSize tsize = canvas.CalcTextSize(buffer);
PixelSize tsizec = canvas.CalcTextSize(buffer, cursor);
PixelSize tsizea = canvas.CalcTextSize(buffer, cursor + 1);
BulkPixelPoint p[5];
p[0].x = 10;
p[0].y = (rc.GetHeight() - tsize.cy - 5) / 2;
p[2].x = p[0].x + tsizec.cx;
p[2].y = p[0].y + tsize.cy + 5;
p[3].x = p[0].x + tsizea.cx;
p[3].y = p[0].y + tsize.cy + 5;
p[1].x = p[2].x;
p[1].y = p[2].y - 2;
p[4].x = p[3].x;
p[4].y = p[3].y - 2;
canvas.SelectWhitePen();
canvas.DrawPolyline(p + 1, 4);
canvas.SetBackgroundTransparent();
canvas.SetTextColor(COLOR_WHITE);
canvas.DrawText(p[0].x, p[0].y, buffer);
}