本文整理汇总了C++中Rect::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::Left方法的具体用法?C++ Rect::Left怎么用?C++ Rect::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::Left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void EditField::Render(Rect& rectArea) throw()
{
if (!m_text.IsInit())
UpdateTexture();
m_text.Render(rectArea);
// render border
{
glLineWidth(2.0f);
//if (m_bShowBorder) // TODO
{
glBegin(GL_LINE_LOOP);
Color m_cForeground = Color::Black(); // TODO
glColor4ubv(m_cForeground.m_color);
glVertex2i(rectArea.Left(), rectArea.Top());
glVertex2i(rectArea.Left(), rectArea.Bottom());
glVertex2i(rectArea.Right(), rectArea.Bottom());
glVertex2i(rectArea.Right(), rectArea.Top());
glEnd();
}
}
// draw caret
if (m_bFocused)
{
glBegin(GL_LINES);
glColor4ubv(Color::Blue().m_color);
glVertex2i(rectArea.Left() + m_uiCaretX, rectArea.Top() + 2);
glVertex2i(rectArea.Left() + m_uiCaretX, rectArea.Top() + m_uiCaretHeight + 2);
glEnd();
}
}
示例2: RenderCheck
void Checkbox::RenderCheck(Rect& rectArea)
{
Rect rectBox = rectArea;
int iBoxMargin = int(rectArea.Height() * 0.2);
int iBoxMarginRight = int(rectArea.Height() * 0.8 * 0.75);
rectBox.Left(rectBox.Left() + iBoxMargin);
rectBox.Right(rectBox.Left() + iBoxMarginRight);
rectBox.Top(rectBox.Top() + iBoxMargin);
rectBox.Bottom(rectBox.Bottom() - iBoxMargin);
OpenGL::PushedAttributes attr(GL_ENABLE_BIT | GL_LINE_BIT | GL_POINT_BIT);
glDisable(GL_TEXTURE_2D);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POINT_SMOOTH);
Color cBox = GetAttrAsColor(CheckboxAttr::BoxColor);
glColor4ubv(cBox.m_color);
glLineWidth(2.0);
glBegin(GL_LINE_LOOP);
glVertex2i(rectBox.Left(), rectBox.Bottom());
glVertex2i(rectBox.Right(), rectBox.Bottom());
glVertex2i(rectBox.Right(), rectBox.Top());
glVertex2i(rectBox.Left(), rectBox.Top());
glEnd();
if (IsChecked())
{
double iCheckUnit = rectBox.Height() * 0.1;
Point point1(int(rectBox.Left() + 3 * iCheckUnit), int(rectBox.Bottom() - 6 * iCheckUnit));
Point point2(int(rectBox.Left() + 6 * iCheckUnit), int(rectBox.Bottom() - 3 * iCheckUnit));
Point point3(int(rectBox.Left() + 11* iCheckUnit), int(rectBox.Bottom() - 11* iCheckUnit));
Color cCheck = GetAttrAsColor(CheckboxAttr::CheckColor);
glColor4ubv(cCheck.m_color);
glLineWidth(4.0);
glBegin(GL_LINES);
glVertex2i(point1.X(), point1.Y());
glVertex2i(point2.X(), point2.Y());
glVertex2i(point2.X(), point2.Y());
glVertex2i(point3.X(), point3.Y());
glEnd();
glPointSize(3.0);
glBegin(GL_POINTS);
glVertex2i(point1.X(), point1.Y());
glVertex2i(point2.X(), point2.Y());
glVertex2i(point3.X(), point3.Y());
glEnd();
}
// adjust rect for size of checkbox
int iOffset = int(rectArea.Height() * 1.1);
rectArea.Left(rectArea.Left() + iOffset);
}
示例3: SetRect
static void SetRect(RECT* r, const Rect& rect)
{
r->left = rect.Left();
r->top = rect.Top();
r->right = rect.Right();
r->bottom = rect.Bottom();
}
示例4: OnMouseButtonEvent
bool Slider::OnMouseButtonEvent(bool bPressed, int iMouseButton, unsigned int x, unsigned int y)
{
if (bPressed && IsInsideSliderArea(Point(x, y)))
{
// set focus to ourselves
GetWindowManager().SetFocus(shared_from_this());
m_bFocused = true;
// start sliding
m_bMouseButtonDown = true;
// calc drag x offset
Rect rect = Window::GetRect();
unsigned int uiMid = DividerPoint();
m_iDragOffset = x - int(rect.Left() + uiMid);
// start mouse motion tracking until mouse button is up
GetWindowManager().TrackMouseUp(shared_from_this(), iMouseButton);
}
else
m_bMouseButtonDown = false;
return true;
}
示例5: RenderSlider
void Slider::RenderSlider(Rect& rectArea)
{
int iMid = rectArea.Left() + int(DividerPoint());
double dAspect = 1.33333;
unsigned int uiRemainingHeight = unsigned(rectArea.Height() * (1.0 - c_dBarHeightPercent));
unsigned int y = static_cast<unsigned int>((c_uiSliderWidth * dAspect / 2.0) / c_dSquareRoot2);
unsigned int x = (uiRemainingHeight < y) ? 0 : (uiRemainingHeight - y);
for (int i = 0; i<2; i++)
{
glBegin(i == 0 ? GL_POLYGON : GL_LINE_LOOP);
if (i == 0)
glColor4ubv(m_sliderColor.m_color);
else
glColor3ub(0, 0, 0);
glVertex2i(iMid - c_uiSliderWidth / 2, rectArea.Top());
glVertex2i(iMid - c_uiSliderWidth / 2, rectArea.Top() + x);
glVertex2i(iMid, rectArea.Top() + uiRemainingHeight);
glVertex2i(iMid + c_uiSliderWidth / 2, rectArea.Top() + x);
glVertex2i(iMid + c_uiSliderWidth / 2, rectArea.Top());
glEnd();
}
}
示例6: IsIntersects
bool Rect::IsIntersects(const Rect& rect) const
{
return !(
Right() < rect.Left() ||
rect.Right() < Left() ||
Bottom() < rect.Top() ||
rect.Bottom() < Top());
}
示例7: IsInsideSliderArea
bool Slider::IsInsideSliderArea(Point pt) const
{
try
{
Rect rect = Window::GetRect();
rect.Add(Parent()->GetPos());
unsigned int uiMid = DividerPoint() + rect.Left();
rect.Left(uiMid - c_uiSliderWidth/2);
rect.Right(uiMid + c_uiSliderWidth/2);
return rect.IsInside(pt);
}
catch (...)
{
return false;
}
}
示例8: Merge
void Rect::Merge(const Rect& rect)
{
float left = min(Left(), rect.Left());
float right = max(Right(), rect.Right());
float top = min(Top(), rect.Top());
float bottom = max(Bottom(), rect.Bottom());
origin.x = left;
origin.y = top;
size.width = right - left;
size.height = bottom - top;
}
示例9: Render
void ProgressBar::Render(Rect& rectArea)
{
int iMid = int(rectArea.Left() + DividerPoint());
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
// render background quad
glColor4ubv(m_backColor.m_color);
glVertex2i(rectArea.Left(), rectArea.Top());
glVertex2i(rectArea.Left(), rectArea.Bottom());
glVertex2i(rectArea.Right(), rectArea.Bottom());
glVertex2i(rectArea.Right(), rectArea.Top());
// render foreground quad
glColor4ubv(m_color.m_color);
glVertex2i(rectArea.Left(), rectArea.Top());
glVertex2i(rectArea.Left(), rectArea.Bottom());
glVertex2i(iMid, rectArea.Bottom());
glVertex2i(iMid, rectArea.Top());
glEnd();
}
示例10: SliderPosByOffset
unsigned int Slider::SliderPosByOffset(unsigned int uiAbsPosX)
{
Rect rect = Window::GetRect();
if (uiAbsPosX < unsigned(rect.Left()))
return 0;
if (uiAbsPosX >= unsigned(rect.Right()))
return BaseClass::Max();
// else calculate
unsigned int uiRelPos = uiAbsPosX - rect.Left();
double dPos = double(uiRelPos) / rect.Width();
// add rounding factor
dPos += 0.5 / BaseClass::Max();
unsigned int uiSliderPos = static_cast<unsigned int>(dPos * BaseClass::Max());
return uiSliderPos;
}
示例11: Render
void TextTexture::Render(Rect rc)
{
// draw text
glEnable(GL_TEXTURE_2D);
m_tex.Bind();
double u = 1.0;
double v = 1.0;
glBegin(GL_QUADS);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glTexCoord2d(0.0, 0.0); glVertex2i(rc.Left(), rc.Top());
glTexCoord2d(0.0, v); glVertex2i(rc.Left(), rc.Bottom());
glTexCoord2d( u, v); glVertex2i(rc.Right(), rc.Bottom());
glTexCoord2d( u, 0.0); glVertex2i(rc.Right(), rc.Top());
glEnd();
glDisable(GL_TEXTURE_2D);
}
示例12: Draw
//=================================================================================================
void ListBox::Draw(ControlDrawData*)
{
if(collapsed)
{
// box
GUI.DrawItem(GUI.tBox, global_pos, size, WHITE, 8, 32);
// element
if(selected != -1)
{
Rect rc = { global_pos.x + 2, global_pos.y + 2, global_pos.x + size.x - 12, global_pos.y + size.y - 2 };
GUI.DrawText(GUI.default_font, items[selected]->ToString(), DT_SINGLELINE, BLACK, rc, &rc);
}
// obrazek
GUI.DrawSprite(GUI.tDown, Int2(global_pos.x + size.x - 10, global_pos.y + (size.y - 10) / 2));
// powinno byæ tu ale wtedy by³a by z³a kolejnoœæ rysowania
//if(menu->visible)
// menu->Draw();
}
else
{
// box
GUI.DrawItem(GUI.tBox, global_pos, real_size, WHITE, 8, 32);
// zaznaczenie
Rect rc = { global_pos.x, global_pos.y, global_pos.x + real_size.x, global_pos.y + real_size.y };
if(selected != -1)
{
Rect rs = { global_pos.x + 2, global_pos.y - int(scrollbar.offset) + 2 + selected*item_height, global_pos.x + real_size.x - 2, 0 };
rs.Bottom() = rs.Top() + item_height;
Rect out;
if(Rect::Intersect(rs, rc, out))
GUI.DrawSpriteRect(GUI.tPix, out, COLOR_RGBA(0, 255, 0, 128));
}
// elementy
Rect r = { global_pos.x + 2, global_pos.y - int(scrollbar.offset) + 2, global_pos.x + real_size.x - 2, rc.Bottom() - 2 };
int orig_x = global_pos.x + 2;
Matrix mat;
for(GuiElement* e : items)
{
if(e->tex)
{
Int2 required_size = force_img_size, img_size;
Vec2 scale;
Control::ResizeImage(e->tex, required_size, img_size, scale);
mat = Matrix::Transform2D(nullptr, 0.f, &scale, nullptr, 0.f, &Vec2((float)orig_x, float(r.Top() + (item_height - required_size.y) / 2)));
GUI.DrawSprite2(e->tex, mat, nullptr, &rc, WHITE);
r.Left() = orig_x + required_size.x;
}
else
r.Left() = orig_x;
if(!GUI.DrawText(GUI.default_font, e->ToString(), DT_SINGLELINE, BLACK, r, &rc))
break;
r.Top() += item_height;
}
// pasek przewijania
if(require_scrollbar)
scrollbar.Draw();
}
}
示例13: WinMain
//.........这里部分代码省略.........
{
const string& clas = cfg.GetString("class", "");
if(!clas.empty())
{
ClassInfo* ci = ClassInfo::Find(clas);
if(ci)
{
if(ClassInfo::IsPickable(ci->class_id))
game.quickstart_class = ci->class_id;
else
Warn("Settings [class]: Class '%s' is not pickable by players.", clas.c_str());
}
else
Warn("Settings [class]: Invalid class '%s'.", clas.c_str());
}
}
game.quickstart_name = cfg.GetString("name", "Test");
if(game.quickstart_name.empty())
game.quickstart_name = "Test";
game.change_title_a = ToBool(cfg.GetBool3("change_title", False));
// pozycja rozmiar okien
int con_pos_x = cfg.GetInt("con_pos_x"),
con_pos_y = cfg.GetInt("con_pos_y");
if(game.have_console && (con_pos_x != -1 || con_pos_y != -1))
{
HWND con = GetConsoleWindow();
Rect rect;
GetWindowRect(con, (RECT*)&rect);
if(con_pos_x != -1)
rect.Left() = con_pos_x;
if(con_pos_y != -1)
rect.Top() = con_pos_y;
SetWindowPos(con, 0, rect.Left(), rect.Top(), 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
}
options.force_size.x = cfg.GetInt("wnd_size_x");
options.force_size.y = cfg.GetInt("wnd_size_y");
options.force_pos.x = cfg.GetInt("wnd_pos_x");
options.force_pos.y = cfg.GetInt("wnd_pos_y");
// multisampling
int multisampling = cfg.GetInt("multisampling", 0),
multisampling_quality = cfg.GetInt("multisampling_quality", 0);
game.SetStartingMultisampling(multisampling, multisampling_quality);
// inne
game.cl_postfx = cfg.GetBool("cl_postfx", true);
game.cl_normalmap = cfg.GetBool("cl_normalmap", true);
game.cl_specularmap = cfg.GetBool("cl_specularmap", true);
game.cl_glow = cfg.GetBool("cl_glow", true);
game.shader_version = cfg.GetInt("cl_shader_version");
if(game.shader_version != -1 && game.shader_version != 2 && game.shader_version != 3)
{
Warn("Settings: Unknown shader version %d.", game.shader_version);
game.shader_version = -1;
}
options.vsync = cfg.GetBool("vsync", true);
game.grass_range = cfg.GetFloat("grass_range", 40.f);
if(game.grass_range < 0.f)
game.grass_range = 0.f;
{
const string& screenshot_format = cfg.GetString("screenshot_format", "jpg");
示例14: Intersects
bool Intersects(const Rect<T>& value) const { return !(this->Left() > value.Right() || this->Right() < value.Left() || this->Bottom() < value.Top() || this->Top() > value.Bottom()); }
示例15: DrawText
//.........这里部分代码省略.........
else
{
std::wstring wideText = ToWide(text);
// parse colors and the lot
std::wstring noColorTextString;
std::vector<DWRITE_TEXT_RANGE> textRanges;
std::vector<RGBA> textColors;
{
std::wstringstream noColorText;
int count = 0;
static const RGBA colors[] = {
RGBA(0, 0, 0),
RGBA(255, 0, 0),
RGBA(0, 255, 0),
RGBA(255, 255, 0),
RGBA(0, 0, 255),
RGBA(0, 255, 255),
RGBA(255, 0, 255),
RGBA(255, 255, 255),
RGBA(100, 0, 0),
RGBA(0, 0, 100)
};
textRanges.reserve(50);
textColors.reserve(50);
textRanges.push_back({ 0, UINT32_MAX });
textColors.push_back(color);
for (int i = 0; i < wideText.length(); i++)
{
if (wideText[i] == '^' && (i + 1) < wideText.length() && isdigit(wideText[i + 1]))
{
textRanges.back().length = count - textRanges.back().startPosition;
textRanges.push_back({ (UINT32)count, UINT32_MAX });
textColors.push_back(colors[wideText[i + 1] - '0']);
++i;
continue;
}
noColorText << wideText[i];
++count;
}
textRanges.back().length = count - textRanges.back().startPosition;
noColorTextString = noColorText.str();
}
m_dwFactory->CreateTextLayout(noColorTextString.c_str(), static_cast<UINT32>(noColorTextString.length()), textFormat.Get(), rect.Width(), rect.Height(), textLayout.GetAddressOf());
m_textLayoutCache[layoutKey] = textLayout;
// set effect
for (size_t i : irange(textRanges.size()))
{
DWRITE_TEXT_RANGE effectRange = textRanges[i];
RGBA color = textColors[i];
static thread_local std::map<uint32_t, ComPtr<FrDrawingEffect>> effects;
auto it = effects.find(color.AsARGB());
if (it == effects.end())
{
ComPtr<FrDrawingEffect> effect = Make<FrDrawingEffect>();
effect->SetColor(textColors[i]);
it = effects.insert({ color.AsARGB(), effect }).first;
}
check(SUCCEEDED(textLayout->SetDrawingEffect((IUnknown*)it->second.Get(), effectRange)));
}
}
// draw
auto drawingContext = new FrDrawingContext();
textLayout->Draw(drawingContext, m_textRenderer.Get(), rect.Left(), rect.Top());
auto numRuns = drawingContext->glyphRuns.size();
if (numRuns)
{
for (auto& run : drawingContext->glyphRuns)
{
m_queuedRenderables.push_back(std::make_unique<FrGlyphRunRenderable>(run));
//m_queuedGlyphRuns.push_back(run);
}
}
delete drawingContext;
m_mutex.unlock();
}