本文整理汇总了C++中Rect2D::x0方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect2D::x0方法的具体用法?C++ Rect2D::x0怎么用?C++ Rect2D::x0使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect2D
的用法示例。
在下文中一共展示了Rect2D::x0方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPopup
Rect2D App::drawPopup(const char* title) {
int w = renderDevice->width();
int h = renderDevice->height();
// Drop shadow
renderDevice->pushState();
renderDevice->setBlendFunc(RenderDevice::BLEND_SRC_ALPHA, RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA);
Rect2D rect = Rect2D::xywh(w/2 - 20, h/2 - 20, w/2, h/2);
Draw::rect2D(rect + Vector2(5, 5), renderDevice, Color4(0, 0, 0, 0.15f));
renderDevice->popState();
// White box
Draw::rect2D(rect, renderDevice, Color3::white());
Draw::rect2DBorder(rect, renderDevice, Color3::black());
// The close box
Draw::rect2DBorder(Rect2D::xywh(rect.x1() - 16, rect.y0(), 16, 16), renderDevice, Color3::black());
renderDevice->setColor(Color3::black());
renderDevice->beginPrimitive(PrimitiveType::LINES);
renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 2));
renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 14));
renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 2));
renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 14));
renderDevice->endPrimitive();
float s = w * 0.013;
titleFont->draw2D(renderDevice, title, Vector2(rect.x0() + 4, rect.y0()), s * 1.5, Color3::black(), Color4::clear(), GFont::XALIGN_LEFT, GFont::YALIGN_TOP);
return rect;
}
示例2: setDimensions
void SDLWindow::setDimensions(const Rect2D& dims) {
#ifdef G3D_WIN32
int W = screenWidth();
int H = screenHeight();
int x = iClamp((int)dims.x0(), 0, W);
int y = iClamp((int)dims.y0(), 0, H);
int w = iClamp((int)dims.width(), 1, W);
int h = iClamp((int)dims.height(), 1, H);
SetWindowPos(_Win32HWND, NULL, x, y, w, h, SWP_NOZORDER);
// Do not update settings-- wait for an event to notify us
#endif
#ifdef G3D_LINUX
//TODO: Linux
#endif
// TODO: OS X
}
示例3: convertFromUnitToNormal
Vector3 Camera::convertFromUnitToNormal(const Vector3& in, const Rect2D& viewport) const{
return (in + Vector3(1.0f, 1.0f, 1.0f)) * 0.5f * Vector3(viewport.width(), viewport.height(), 1.0f) +
Vector3(viewport.x0(), viewport.y0(), 0.0f);
}
示例4: onEvent
bool _GuiSliderBase::onEvent(const GEvent& event) {
if (! m_visible) {
return false;
}
if (event.type == GEventType::MOUSE_BUTTON_DOWN) {
Vector2 mouse = Vector2(event.button.x, event.button.y);
float v = floatValue();
Rect2D thumbRect = theme()->horizontalSliderToThumbBounds(m_rect, v, m_captionSize);
Rect2D trackRect = theme()->horizontalSliderToTrackBounds(m_rect, m_captionSize);
if (thumbRect.contains(mouse)) {
// Begin drag
m_inDrag = true;
m_dragStart = mouse;
m_dragStartValue = v;
GEvent response;
response.gui.type = GEventType::GUI_DOWN;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
return true;
} else if (trackRect.contains(mouse)) {
// Jump to this position
float p = clamp((mouse.x - trackRect.x0()) / trackRect.width(), 0.0f, 1.0f);
setFloatValue(p);
m_inDrag = false;
GEvent response;
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
fireEvent(GEventType::GUI_ACTION);
return true;
}
} else if (event.type == GEventType::MOUSE_BUTTON_UP) {
if (m_inDrag) {
// End the drag
m_inDrag = false;
fireEvent(GEventType::GUI_DOWN);
fireEvent(GEventType::GUI_ACTION);
return true;
}
} else if (m_inDrag && (event.type == GEventType::MOUSE_MOTION)) {
// We'll only receive these events if we have the keyFocus, but we can't
// help receiving the key focus if the user clicked on the control!
Vector2 mouse = Vector2(event.button.x, event.button.y);
Rect2D trackRect = theme()->horizontalSliderToTrackBounds(m_rect, m_captionSize);
float delta = (mouse.x - m_dragStart.x) / trackRect.width();
float p = clamp(m_dragStartValue + delta, 0.0f, 1.0f);
setFloatValue(p);
GEvent response;
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
return true;
}
return false;
}
示例5: setDimensions
void GlutWindow::setDimensions(const Rect2D& dims) {
setPosition((int)dims.x0(), (int)dims.x1());
glutReshapeWindow((int)dims.width(), (int)dims.height());
}
示例6: onGraphics
void App::onGraphics (RenderDevice *rd, Array< SurfaceRef > &posed3D, Array< Surface2DRef > &posed2D) {
rd->setColorClearValue(Color3::white());
rd->clear();
doFunStuff();
rd->push2D();
int w = rd->width();
int h = rd->height();
///////////////////////////////////////
// Left panel
# define LABEL(str) p.y += titleFont->draw2D(rd, str, p - Vector2((float)w * 0.0075f, 0), s * 2, Color3::white() * 0.4f).y
# define PRINT(str) p.y += reportFont->draw2D(rd, str, p, s, Color3::black()).y
int x0 = int(w * 0.015f);
// Cursor position
Vector2 p(x0, h * 0.02f);
// Font size
float s = w * 0.013;
LABEL("Shaders");
PRINT(std::string("Combiners: ") + combineShader);
PRINT(std::string("Assembly: ") + asmShader);
PRINT(std::string("GLSL: ") + glslShader);
p.y += s * 2;
LABEL("Extensions");
PRINT(std::string("FSAA: ") + ((GLCaps::supports("WGL_ARB_multisample") || GLCaps::supports("GL_ARB_multisample")) ? "Yes" : "No"));
PRINT(std::string("Two-sided Stencil: ") + ((GLCaps::supports_two_sided_stencil() ? "Yes" : "No")));
PRINT(std::string("Stencil Wrap: ") + (GLCaps::supports("GL_EXT_stencil_wrap") ? "Yes" : "No"));
PRINT(std::string("Texture Compression: ") + (GLCaps::supports("GL_EXT_texture_compression_s3tc") ? "Yes" : "No"));
PRINT(std::string("Shadow Maps: ") + (GLCaps::supports("GL_ARB_shadow") ? "Yes" : "No"));
PRINT(std::string("Frame Buffer Object: ") + (GLCaps::supports("GL_EXT_framebuffer_object") ? "Yes" : "No"));
PRINT(std::string("Vertex Arrays: ") + (GLCaps::supports_GL_ARB_vertex_buffer_object() ? "Yes" : "No"));
///////////////////////////////////////
// Right Panel
x0 = int(w * 0.6f);
// Cursor position
p = Vector2(x0, h * 0.02f);
// Graphics Card
LABEL("Graphics Card");
rd->setTexture(0, cardLogo);
Draw::rect2D(Rect2D::xywh(p.x - s * 6, p.y, s * 5, s * 5), rd);
rd->setTexture(0, NULL);
PRINT(GLCaps::vendor().c_str());
PRINT(GLCaps::renderer().c_str());
PRINT(format("Driver Version %s", GLCaps::driverVersion().c_str()));
# ifdef G3D_WIN32
PRINT(format("%d MB Video RAM", DXCaps::videoMemorySize() / (1024 * 1024)));
{
uint32 ver = DXCaps::version();
PRINT(format("DirectX %d.%d", ver/100, ver%100));
}
# endif
p.y += s * 2;
// Processor
LABEL("Processor");
rd->setTexture(0, chipLogo);
Draw::rect2D(Rect2D::xywh(p.x - s * 6, p.y, s * 5, s * 5), rd);
rd->setTexture(0, NULL);
PRINT(System::cpuVendor().c_str());
PRINT(System::cpuArchitecture().c_str());
Array<std::string> features;
if (System::has3DNow()) {
features.append("3DNow");
}
if (System::hasMMX()) {
features.append("MMX");
}
if (System::hasSSE()) {
features.append("SSE");
}
if (System::hasSSE2()) {
features.append("SSE2");
}
if (chipSpeed != "") {
PRINT(chipSpeed + " " + stringJoin(features, '/'));
} else {
PRINT(stringJoin(features, '/'));
}
p.y += s * 2;
// Operating System
LABEL("OS");
rd->setTexture(0, osLogo);
Draw::rect2D(Rect2D::xywh(p.x - s * 6, p.y - s * 2, s * 5, s * 5), rd);
rd->setTexture(0, NULL);
//.........这里部分代码省略.........
示例7: onEvent
bool GuiScrollBar::onEvent(const GEvent& event) {
if (! m_visible) {
return false;
}
float m = maxValue();
Rect2D topB;
Rect2D bottomB;
Rect2D barBounds;
Rect2D thumbBounds;
getAllBounds(topB, bottomB, barBounds, thumbBounds);
if (event.type == GEventType::MOUSE_BUTTON_DOWN) {
const Vector2& mouse = Vector2(event.button.x, event.button.y);
if(bottomB.contains(mouse)) {
*m_value = min<float>( m * m_extent, *m_value + m_extent * BUTTON_PRESS_SCROLL);
m_state = ARROW_DOWN_SCROLLING;
GEvent response;
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
fireEvent(GEventType::GUI_ACTION);
return true;
} else if (topB.contains(mouse)) {
*m_value = max<float>( 0.0f, *m_value - m_extent*BUTTON_PRESS_SCROLL);
m_state = ARROW_UP_SCROLLING;
GEvent response;
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
fireEvent(GEventType::GUI_ACTION);
return true;
} else if (thumbBounds.contains(mouse)) {
m_state = IN_DRAG;
m_dragStart = mouse;
m_dragStartValue = floatValue();
GEvent response;
response.gui.type = GEventType::GUI_DOWN;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
return true;
} else if (barBounds.contains(mouse)) {
// Jump to this position
float p;
if(m_vertical) {
p = ( mouse.y - (float)barBounds.y0() ) / ((float)barBounds.height()/(m + 1)) - .5f;
} else {
p = ( mouse.x - (float)barBounds.x0() ) / ((float)barBounds.width()/(m + 1)) - .5f;
}
p = max<float>(0, p);
p = min<float>(p, m);
setFloatValue(p);
m_state = NONE;
GEvent response;
response.gui.type = GEventType::GUI_CHANGE;
response.gui.control = m_eventSource;
m_gui->fireEvent(response);
fireEvent(GEventType::GUI_ACTION);
return true;
}
return false;
} else if (event.type == GEventType::MOUSE_BUTTON_UP) {
m_state = NONE;
fireEvent(GEventType::GUI_ACTION);
if (m_state == IN_DRAG) {
// End the drag
fireEvent(GEventType::GUI_DOWN);
fireEvent(GEventType::GUI_ACTION);
return true;
}
} else if (event.type == GEventType::MOUSE_MOTION) {
// We'll only receive these events if we have the keyFocus, but we can't
// help receiving the key focus if the user clicked on the control!
//.........这里部分代码省略.........
示例8: setDimensions
void wxGWindow::setDimensions (const Rect2D &dims) {
window->SetSize(dims.x0(), dims.y0(), dims.width(), dims.height());
}