本文整理汇总了C++中Rect2D::width方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect2D::width方法的具体用法?C++ Rect2D::width怎么用?C++ Rect2D::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect2D
的用法示例。
在下文中一共展示了Rect2D::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pack
void GuiScrollPane::pack() {
float scrollBarWidth = theme()->scrollBarWidth();
m_viewPane->setPosition(0,0);
m_viewPane->pack();
Rect2D viewRect = m_viewPane->rect();
if (verticalEnabled) {
if (viewRect.width() > MIN_WINDOW_SIZE) {
setWidth(viewRect.width() + scrollBarWidth);
}
}
if (horizontalEnabled) {
if(viewRect.height() < m_rect.height() && viewRect.height() > MIN_WINDOW_SIZE) {
setHeight(viewRect.height() + scrollBarWidth);
}
}
}
示例2: setRect
void CameraControlWindow::setRect(const Rect2D& r) {
GuiWindow::setRect(r);
if (drawerButtonPane) {
float s = 12;
const Rect2D& r = clientRect();
drawerButtonPane->setPosition((r.width() - s) / 2.0f, r.height() - s);
}
}
示例3: setRect
void GuiCheckBox::setRect(const Rect2D& rect) {
if (m_style == GuiTheme::NORMAL_CHECK_BOX_STYLE) {
// TODO: use the actual font size etc. to compute bounds
// Prevent the checkbox from stealing clicks very far away
m_rect = rect;
m_clickRect = Rect2D::xywh(rect.x0y0(), Vector2(min(rect.width(), 30.0f), rect.height()));
} else {
GuiControl::setRect(rect);
}
}
示例4: allocateTextures
void allocateTextures(const Rect2D& screenRect) {
if (depth.isNull() ||
(depth->vector2Bounds() != screenRect.wh())) {
/*
Texture::Parameters depthParameters;
depthParameters.autoMipMap = false;
depthParameters.maxAnisotropy = 1;
depthParameters.wrapMode = Texture::CLAMP;
depthParameters.interpolateMode = Texture::NO_INTERPOLATION;
*/
depth = Texture::createEmpty("Depth Buffer", screenRect.width(), screenRect.height(),
TextureFormat::depth(), Texture::DIM_2D_NPOT, Texture::Parameters::video());
color = Texture::createEmpty("Color Buffer", screenRect.width(), screenRect.height(),
TextureFormat::RGB8, Texture::DIM_2D_NPOT, Texture::Parameters::video());
shader->args.set("depth", depth);
shader->args.set("color", color);
}
}
示例5: onGraphics
void FontViewer::onGraphics(RenderDevice* rd, App* app, const shared_ptr<LocalLightingEnvironment>& lighting, Array<shared_ptr<Surface> >& surfaceArray) {
app->colorClear = Color3::white();
rd->push2D();
Rect2D windowBounds = rd->viewport();
rd->setLineWidth(0.5f);
rd->setColor(Color3::black());
rd->setObjectToWorldMatrix(Vector3(0.375, 0.375, 0));
rd->beginPrimitive(PrimitiveType::LINES);
for (int i = 0; i <= 16; ++i) {
// Horizontal line
float y = i * windowBounds.height() / 16;
rd->sendVertex(Vector2(0, y));
rd->sendVertex(Vector2(windowBounds.width(), y));
// Vertical line
float x = i * windowBounds.width() / 16;
rd->sendVertex(Vector2(x, 0));
rd->sendVertex(Vector2(x, windowBounds.height()));
}
rd->endPrimitive();
double size = windowBounds.height()/16.0 /2.0 ;
const Color4 color = Color3::black();
const Color4 outline = Color4::clear();
for (int y = 0; y < 16; ++y ) {
for (int x = 0; x < 16; ++x ) {
int i = x + y*16;
std::string s = "";
s += (char)i;
// Character in the current font
m_font->draw2D( rd, s, Vector2( x* windowBounds.width()/16.0f + windowBounds.width()/32.0f,
y*windowBounds.height()/16.0f + windowBounds.height()/32.0f),
(float)size, color, outline, GFont::XALIGN_CENTER, GFont::YALIGN_CENTER );
// Character in the normal font
m_basefont->draw2D( rd, s, Vector2( x* windowBounds.width()/16.0f + windowBounds.width()/64.0f,
y* windowBounds.height()/16.0f + windowBounds.height()/20.0f),
(float)size/2.0f, color, outline, GFont::XALIGN_CENTER, GFont::YALIGN_CENTER );
// Character number
m_basefont->draw2D( rd, format("\\x%x", i), Vector2( x* windowBounds.width()/16.0f + windowBounds.width()/20.0f-(float)size * 0.5f,
y* windowBounds.height()/16.0f + windowBounds.height()/20.0f),
(float)size/2.0f, color, outline, GFont::XALIGN_CENTER, GFont::YALIGN_CENTER );
}
}
rd->pop2D();
}
示例6: 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
}
示例7: 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);
}
示例8: 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;
}
示例9: intersect
shared_ptr<Entity> Scene::intersectEyeRay(const shared_ptr<Camera>& camera, const Vector2& pixel, const Rect2D& viewport, const Vector2int16 guardBandThickness, bool hitMarkers, const Array<shared_ptr<Entity> >& exclude, Model::HitInfo& selectionInfo) const {
const Ray& ray = camera->worldRay(pixel.x + guardBandThickness.x, pixel.y + guardBandThickness.y, Rect2D(Vector2(viewport.width() + 2 * guardBandThickness.x, viewport.height() + 2 * guardBandThickness.y)));
// clear old selection info
selectionInfo.clear();
float distance = finf();
return intersect(ray, distance, hitMarkers, exclude, selectionInfo);
}
示例10: setDimensions
void GlutWindow::setDimensions(const Rect2D& dims) {
setPosition((int)dims.x0(), (int)dims.x1());
glutReshapeWindow((int)dims.width(), (int)dims.height());
}
示例11: maxPhysicalBlurRadius
/** Limit the maximum radius allowed for physical blur to 2% of the viewport */
static float maxPhysicalBlurRadius(const shared_ptr<Camera>& camera, const Rect2D& viewport) {
return min(max(camera->circleOfConfusionRadius(camera->nearPlaneZ(), viewport),
camera->circleOfConfusionRadius(camera->farPlaneZ(), viewport)),
viewport.width() / 50.0f);
}
示例12: 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);
//.........这里部分代码省略.........
示例13: 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!
//.........这里部分代码省略.........
示例14: setDimensions
void wxGWindow::setDimensions (const Rect2D &dims) {
window->SetSize(dims.x0(), dims.y0(), dims.width(), dims.height());
}
示例15: setRect
void GuiTabPane::setRect(const Rect2D& rect) {
m_rect = rect;
float y = m_tabButtonPane->rect().height() - OVERLAP;
m_viewPane->setRect(Rect2D::xywh(0, y, rect.width(), rect.height() - y));
m_clientRect = m_rect;//m_viewPane->rect() + rect.x0y0();
}