void Widget::resize(const Size<int>& size) { if(!size.isValid() || size_ == size) return; int width = bound(minimumSize_.width(), size.width(), maximumSize_.width()); int height = bound(minimumSize_.height(), size.height(), maximumSize_.height()); if(!parent_) { ws_->resizeWindow(handle_, Size<int>(width, height)); ws_->sync(); } else { // Calculate invalidated rectangle int x = pos_.x(); int y = pos_.y(); width = maxOf(size_.width(), width); height = maxOf(size_.height(), height); Rect<int> rect(x, y, width, height); // Send event ResizeEvent e; e.setOldSize(size_, {}); e.setSize(size, {}); processEvent(&e, {}); rect.intersect(parent_->rect()); parent_->repaint(); } }
void OpenGLLightingApp::resize( ResizeEvent event ) { Log("OpenGLLightingApp::resize (%d,%d) aspect %f", event.getWidth(), event.getHeight(), getWindowAspectRatio()); mCam.lookAt( Vec3f( 0.0f, 0.0f, 750.0f ), Vec3f::zero() ); mCam.setPerspective( 60, getWindowAspectRatio(), 1, 1000 ); gl::setMatrices( mCam ); }
void Widget::setGeometry(const Rect<int>& geometry) { if(!geometry.size().isValid()) return; if(!parent_) { ws_->moveWindow(handle_, geometry.topLeft()); ws_->resizeWindow(handle_, geometry.size()); ws_->sync(); } else { // Calculate invalidated rectangle int x = minOf(pos_.x(), geometry.x()); int y = minOf(pos_.y(), geometry.y()); int width = maxOf(size_.width(), geometry.size().width()); int height = maxOf(size_.height(), geometry.size().height()); Rect<int> rect(x, y, width, height); // Send events MoveEvent me; me.setOldPos(pos_, {}); me.setPos(geometry.topLeft(), {}); processEvent(&me, {}); ResizeEvent re; re.setOldSize(size_, {}); re.setSize(geometry.size(), {}); processEvent(&re, {}); rect.intersect(parent_->rect()); parent_->repaint(); } }
virtual void framebufferResizeEvent(ResizeEvent & event) override { glViewport(0, 0, event.width(), event.height()); CheckGLError(); m_camera.setViewport(event.width(), event.height()); }
virtual void framebufferResizeEvent(ResizeEvent & event) override { const int width = event.width(); const int height = event.height(); const int side = std::min<int>(width, height); glViewport((width - side) / 2, (height - side) / 2, side, side); }
void CameraLensShiftTestApp::resize( ResizeEvent event ) { mCamera.setAspectRatio( event.getAspectRatio() * 0.5f ); CameraPersp cam( mOverview.getCamera() ); cam.setAspectRatio( event.getAspectRatio() * 0.5f ); mOverview.setCurrentCam( cam ); }
virtual void framebufferResizeEvent(ResizeEvent & event) override { const int width = event.width(); const int height = event.height(); glViewport(0, 0, width, height); m_camera.setViewport(width, height); }
virtual void framebufferResizeEvent(ResizeEvent & event) override { glViewport(0, 0, event.width(), event.height()); CheckGLError(); m_camera->setViewport(event.size()); for (auto technique : m_techniques) technique.second->resize(); }
void onResize(ResizeEvent& ev) override { ResourceListItem::onResize(ev); if (m_comment) { auto reqSz = m_comment->sizeHint(); m_comment->setBounds( gfx::Rect(ev.bounds().x+ev.bounds().w-reqSz.w, ev.bounds().y+ev.bounds().h/2-reqSz.h/2, reqSz.w, reqSz.h)); } }
//---------------------------------------------------------------------------------------------------------------------- void View::resize(ResizeEvent event) { // adjust aspect ratio CameraPersp cam = m_cam3d.getCamera(); cam.setAspectRatio( getWindowAspectRatio() ); m_cam3d.setCurrentCam( cam ); // Update window size m_windowSize = Rectf(0.0f, 0.0f, (float)event.getWidth(), (float)event.getHeight()); // let ui interface adjust m_scene2d.onResize(event); }
void StatusBar::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Rect rc = ev.getBounds(); rc.x = rc.x2() - m_notificationsBox->getPreferredSize().w; rc.w = m_notificationsBox->getPreferredSize().w; m_notificationsBox->setBounds(rc); rc = ev.getBounds(); rc.w -= rc.w/4 + 4*jguiscale(); m_commandsBox->setBounds(rc); }
void StereoscopicRenderingApp::resize( ResizeEvent event ) { // make sure the camera's aspect ratio remains correct mCamera.setAspectRatio( event.getAspectRatio() ); mMayaCam.setCurrentCam( mCamera ); // create/resize the FBO's required for anaglyph rendering gl::Fbo::Format fmt; fmt.setMagFilter( GL_LINEAR ); fmt.setSamples(8); mAnaglyphLeft = gl::Fbo( event.getWidth(), event.getHeight(), fmt ); mAnaglyphRight = gl::Fbo( event.getWidth(), event.getHeight(), fmt ); }
void EditorView::onResize(ResizeEvent& ev) { // This avoid the displacement of the widgets in the viewport setBoundsQuietly(ev.getBounds()); updateView(); }
void HexagonMirrorApp::resize( ResizeEvent event ) { // adjust the camera aspect ratio CameraPersp cam = mCamera.getCamera(); cam.setAspectRatio( event.getAspectRatio() ); mCamera.setCurrentCam( cam ); }
void FastTrailsApp::resize( ResizeEvent event ) { // adjust aspect ratio CameraPersp cam = mCamera.getCamera(); cam.setAspectRatio( event.getAspectRatio() ); mCamera.setCurrentCam( cam ); }
void ListItem::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.bounds()); Rect crect = childrenBounds(); for (auto child : children()) child->setBounds(crect); }
void ListItem::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Rect crect = getChildrenBounds(); UI_FOREACH_WIDGET(getChildren(), it) (*it)->setBounds(crect); }
void GeometryShaderApp::resize( ResizeEvent event ) { // keep points centered Vec2f offset = 0.5f * Vec2f( event.getSize() - mWindowSize ); std::vector<Vec2f>::iterator itr; for(itr=mPoints.begin();itr!=mPoints.end();++itr) *itr += offset; mWindowSize = event.getSize(); // invalidate mesh mVboMesh = gl::VboMesh(); // force redraw update(); }
void TextRenderingApp::resize( ResizeEvent event ) { // allow 20 pixels margin Area box( Vec2i::zero(), event.getSize() ); box.expand(-20, -20); mTextBox.setSize( box.getSize() ); }
void resize( ResizeEvent event ) { mCam.lookAt( Vec3f( 0.0f, 0.0f, 10.0f ), Vec3f::zero()); mCam.setPerspective( 90, event.getAspectRatio(), 0.01f, 1000 ); mArcball.setWindowSize( getWindowSize() ); mArcball.setCenter( Vec2f( getWindowWidth() / 2.0f, getWindowHeight() / 2.0f ) ); mArcball.setRadius( 150 ); }
void StatusBar::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Border border = this->border(); Rect rc = ev.getBounds(); bool docControls = (rc.w > 300*ui::guiscale()); if (docControls) { int prefWidth = m_docControls->getPreferredSize().w; int toolBarWidth = ToolBar::instance()->getPreferredSize().w; rc.x += rc.w - prefWidth - border.right() - toolBarWidth; rc.w = prefWidth; m_docControls->setVisible(m_doc != nullptr); m_docControls->setBounds(rc); } else m_docControls->setVisible(false); }
void CinderParticlesApp::resize( ResizeEvent event ) { int w = event.getWidth(); int h = event.getHeight(); mParticleSystem->setWindowSize( Vec2i( w, h ) ); // clean data if(mBlurX != NULL) delete mBlurX; if(mBlurY != NULL) delete mBlurY; // create FBOs at new window size gl::Fbo::Format format; format.setColorInternalFormat( GL_RGBA ); format.enableDepthBuffer(true); format.enableMipmapping(); format.setWrap(GL_CLAMP,GL_CLAMP); format.setMinFilter(GL_LINEAR); format.setMagFilter(GL_LINEAR); //format.setSamples(4); mBlurX = new gl::Fbo(w, h, format); mBlurY = new gl::Fbo(w, h, format); }
void StatusBar::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Border border = getBorder(); Rect rc = ev.getBounds(); bool frameControls = (rc.w > 300*ui::guiscale()); if (frameControls) { m_slider->setVisible(rc.w > 400*ui::guiscale()); int prefWidth = m_commandsBox->getPreferredSize().w; int toolBarWidth = ToolBar::instance()->getPreferredSize().w; rc.x += rc.w - prefWidth - border.right() - toolBarWidth; rc.w = prefWidth; m_commandsBox->setVisible(true && m_hasDoc); m_commandsBox->setBounds(rc); } else m_commandsBox->setVisible(false); }
void ComboBox::onResize(ResizeEvent& ev) { gfx::Rect bounds = ev.getBounds(); setBoundsQuietly(bounds); // Button Size buttonSize = m_button->getPreferredSize(); m_button->setBounds(Rect(bounds.x2() - buttonSize.w, bounds.y, buttonSize.w, bounds.h)); // Entry m_entry->setBounds(Rect(bounds.x, bounds.y, bounds.w - buttonSize.w, bounds.h)); }
void ListBox::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Rect cpos = getChildrenBounds(); UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; cpos.h = child->getPreferredSize().h; child->setBounds(cpos); cpos.y += child->getBounds().h + this->childSpacing(); }
void Splitter::onResize(ResizeEvent& ev) { #define FIXUP(x, y, w, h, l, t, r, b) \ do { \ avail = rect.w - this->child_spacing; \ \ pos.x = rect.x; \ pos.y = rect.y; \ switch (m_type) { \ case ByPercentage: \ pos.w = avail*m_pos/100; \ break; \ case ByPixel: \ pos.w = m_pos; \ break; \ } \ \ /* TODO uncomment this to make a restricted splitter */ \ /* pos.w = MID(reqSize1.w, pos.w, avail-reqSize2.w); */ \ pos.h = rect.h; \ \ child1->setBounds(pos); \ gfx::Rect child1Pos = child1->getBounds(); \ \ pos.x = child1Pos.x + child1Pos.w + this->child_spacing; \ pos.y = rect.y; \ pos.w = avail - child1Pos.w; \ pos.h = rect.h; \ \ child2->setBounds(pos); \ } while(0) gfx::Rect rect(ev.getBounds()); gfx::Rect pos(0, 0, 0, 0); int avail; setBoundsQuietly(rect); if (getChildren().size() == 2) { Widget* child1 = getChildren()[0]; Widget* child2 = getChildren()[1]; if (this->getAlign() & JI_HORIZONTAL) FIXUP(x, y, w, h, l, t, r, b); else FIXUP(y, x, h, w, t, l, b, r); } }
void Menu::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.getBounds()); Rect cpos = getChildrenBounds(); bool isBar = (getParent()->type == kMenuBarWidget); UI_FOREACH_WIDGET(getChildren(), it) { Widget* child = *it; Size reqSize = child->getPreferredSize(); if (isBar) cpos.w = reqSize.w; else cpos.h = reqSize.h; child->setBounds(cpos); if (isBar) cpos.x += cpos.w; else cpos.y += cpos.h; }
void Menu::onResize(ResizeEvent& ev) { setBoundsQuietly(ev.bounds()); Rect cpos = childrenBounds(); bool isBar = (parent()->type() == kMenuBarWidget); for (auto child : children()) { Size reqSize = child->sizeHint(); if (isBar) cpos.w = reqSize.w; else cpos.h = reqSize.h; child->setBounds(cpos); if (isBar) cpos.x += cpos.w; else cpos.y += cpos.h; } }
void Grid::onResize(ResizeEvent& ev) { gfx::Rect rect = ev.getBounds(); int pos_x, pos_y; Size reqSize; int x, y, w, h; int col, row; setBoundsQuietly(rect); calculateSize(); distributeSize(rect); pos_y = rect.y + this->border_width.t; for (row=0; row<(int)m_rowstrip.size(); ++row) { pos_x = rect.x + this->border_width.l; for (col=0; col<(int)m_colstrip.size(); ++col) { Cell* cell = m_cells[row][col]; if (cell->child != NULL && cell->parent == NULL && !(cell->child->flags & JI_HIDDEN)) { x = pos_x; y = pos_y; calculateCellSize(col, cell->hspan, m_colstrip, w); calculateCellSize(row, cell->vspan, m_rowstrip, h); reqSize = cell->child->getPreferredSize(); if (cell->align & JI_LEFT) { w = reqSize.w; } else if (cell->align & JI_CENTER) { x += w/2 - reqSize.w/2; w = reqSize.w; } else if (cell->align & JI_RIGHT) { x += w - reqSize.w; w = reqSize.w; } if (cell->align & JI_TOP) { h = reqSize.h; } else if (cell->align & JI_MIDDLE) { y += h/2 - reqSize.h/2; h = reqSize.h; } else if (cell->align & JI_BOTTOM) { y += h - reqSize.h; h = reqSize.h; } cell->child->setBounds(Rect(x, y, w, h)); } if (m_colstrip[col].size > 0) pos_x += m_colstrip[col].size + this->child_spacing; } if (m_rowstrip[row].size > 0) pos_y += m_rowstrip[row].size + this->child_spacing; } }
void Window::onResize(ResizeEvent& ev) { windowSetPosition(ev.getBounds()); }