void Widget::addChild_( Widget* child ) { if (child) { child->grab(); // prevent destruction when removed child->remove(); // remove from old parent child->_d->lastParentRect = getAbsoluteRect(); child->_d->parent = this; _d->children.push_back(child); } }
void FalagardMenubar::sizeToContent_impl(void) { Rect renderArea(getItemRenderArea()); Rect wndArea(getAbsoluteRect()); // get size of content Size sz(getContentSize()); // calculate the full size with the frame accounted for and resize the window to this sz.d_width += wndArea.getWidth() - renderArea.getWidth(); sz.d_height += wndArea.getHeight() - renderArea.getHeight(); setSize(Absolute,sz); }
void GuiInfoGranary::showSpecialOrdersWindow() { Point pos; if( getTop() > (int)getParent()->getHeight() / 2 ) { pos = Point( getScreenLeft(), getScreenBottom() - 450 ); } else { pos = getAbsoluteRect().UpperLeftCorner; } new GranarySpecialOrdersWindow( getParent(), pos, _gd->building ); }
void InfoBoxWarehouse::showSpecialOrdersWindow() { Point pos; if( getTop() > (int)getParent()->getHeight() / 2 ) { pos = Point( getScreenLeft(), getScreenBottom() - 450 ); } else { pos = getAbsoluteRect().UpperLeftCorner; } new WarehouseSpecialOrdersWindow( getParent(), pos, _warehouse ); }
void FalagardPopupMenu::sizeToContent_impl(void) { Rect renderArea(getItemRenderArea()); Rect wndArea(getAbsoluteRect()); // get size of content Size sz(getContentSize()); // calculate the full size with the frame accounted for and resize the window to this sz.d_width += wndArea.getWidth() - renderArea.getWidth(); sz.d_height += wndArea.getHeight() - renderArea.getHeight(); sz.d_width /= System::getSingleton().getRenderer()->getSize().d_width; sz.d_height /= System::getSingleton().getRenderer()->getSize().d_height; setSize(Relative,sz); }
void InventoryInfoWindow::onPaint() { Common::ScopedPtr<Graphics::Surface> background(_vm->_gfx->getBitmap(IDB_INVENTORY_INFO_BACKGROUND)); // Draw the title uint32 textColor = _vm->_gfx->getColor(212, 109, 0); Common::Rect titleRect(10, 56, 263, 71); Common::String title = _vm->getString(IDES_ITEM_TITLE_BASE + _currentItemID); assert(!title.empty()); _vm->_gfx->renderText(background.get(), _textFont, title, titleRect.left, titleRect.top, titleRect.width(), titleRect.height(), textColor, _fontHeight); // Draw the description Common::Rect descRect(10, 89, 263, 186); Common::String desc = _vm->getString(IDES_ITEM_DESC_BASE + _currentItemID * 5); assert(!desc.empty()); _vm->_gfx->renderText(background.get(), _textFont, desc, descRect.left, descRect.top, descRect.width(), descRect.height(), textColor, _fontHeight); Common::Rect absoluteRect = getAbsoluteRect(); _vm->_gfx->blit(background.get(), absoluteRect.left, absoluteRect.top); }
void MenuBar::setItemSelect(size_t _index) { if (mIndexSelect == _index) return; MYGUI_ASSERT(_index < mVectorMenuItemInfo.size() || _index == ITEM_NONE, "index '" << _index << "' out of range"); if (mIndexSelect != ITEM_NONE) { mVectorMenuItemInfo[mIndexSelect].button->setButtonPressed(false); mVectorMenuItemInfo[mIndexSelect].menu->hidePopupMenu(); } mIndexSelect = _index; if (mIndexSelect != ITEM_NONE) { mVectorMenuItemInfo[mIndexSelect].button->setButtonPressed(true); mVectorMenuItemInfo[mIndexSelect].menu->showPopupMenu( IntPoint(mVectorMenuItemInfo[mIndexSelect].button->getAbsoluteLeft(), getAbsoluteRect().bottom)); } }
//! draws the element and its children void ScrollBar::draw( GfxEngine& painter ) { if (!isVisible()) return; //draw background if( _d->texture.isValid() ) { painter.drawPicture( _d->texture, getAbsoluteRect().UpperLeftCorner ); } //draw slider if( _d->sliderTexture.isValid() ) { painter.drawPicture( _d->sliderTexture, _d->sliderRect.UpperLeftCorner ); } // draw buttons Widget::draw( painter ); }
void QRCodeWidget::draw(const touchgfx::Rect& invalidatedArea) const { if(!code) { return; } touchgfx::Rect absolute = getAbsoluteRect(); uint16_t *framebuffer = touchgfx::HAL::getInstance()->lockFrameBuffer(); for(int y = invalidatedArea.y; y < invalidatedArea.bottom(); y++) { for(int x = invalidatedArea.x; x < invalidatedArea.right(); x++) { framebuffer[absolute.x + x + (absolute.y + y) * touchgfx::HAL::DISPLAY_WIDTH] = code->at(x / scale, y / scale) ? 0x0000 : 0xffff; } } touchgfx::HAL::getInstance()->unlockFrameBuffer(); }
void BurnedLetterViewWindow::onPaint() { if (_rebuildPage) { delete _preBuffer; _preBuffer = _stillFrames->getFrameCopy(_curView); if (!_preBuffer) error("Failed to get burned letter section"); _rebuildPage = false; } Common::Rect absoluteRect = getAbsoluteRect(); _vm->_gfx->opaqueTransparentBlit(_vm->_gfx->getScreen(), absoluteRect.left, absoluteRect.top, absoluteRect.width(), absoluteRect.height(), _preBuffer, 0, 0, 0, 0, 0, 0); if (_curLineIndex >= 0 && ((SceneViewWindow *)_parent)->getGlobalFlags().bcTranslateEnabled == 1) { int numLines = _viewLineCount[_curView]; uint32 boxColor = _vm->_gfx->getColor(255, 0, 0); Common::Rect box(1, (187 / numLines) * _curLineIndex, 430, (187 / numLines) * (_curLineIndex + 1) - 1); box.translate(absoluteRect.left, absoluteRect.top); _vm->_gfx->getScreen()->frameRect(box, boxColor); } }
void FalagardPaoPao::updateSelfSize() { FalagardSelfFitWindow::updateSelfSize(); const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName); if( wlf.isNamedAreaDefined( "TextArea" ) ) { const Rect rectBorder(wlf.getNamedArea("TextArea").getArea().getPixelRect(*this)); Rect wndArea(getAbsoluteRect()); Size size(getAbsoluteSize()); size.d_width += wndArea.getWidth() - rectBorder.getWidth(); size.d_height += wndArea.getHeight() - rectBorder.getHeight(); setSize(Absolute, size); } if( d_ArrowImage.getImage() ) { Size size = d_ArrowImage.getImage()->getSize(); Rect area( getAbsoluteWidth() / 2 - size.d_width / 2, getAbsoluteHeight() - size.d_height, getAbsoluteWidth() / 2 + size.d_width / 2, getAbsoluteHeight() ); d_ArrowImage.setRect( area ); } }
int Widget::getScreenTop() const { return getAbsoluteRect().getTop(); }
void Widget::recalculateAbsolutePosition( bool recursive ) { Rect parentAbsolute(0,0,0,0); Rect parentAbsoluteClip; //float fw=0.f, fh=0.f; if ( getParent() ) { parentAbsolute = getParent()->getAbsoluteRect(); if (_noClip) { Widget* p=this; while( p && p->getParent() ) p = p->getParent(); parentAbsoluteClip = p->getAbsoluteClippingRect(); } else parentAbsoluteClip = getParent()->getAbsoluteClippingRect(); } const int diffx = parentAbsolute.getWidth() - _d->lastParentRect.getWidth(); const int diffy = parentAbsolute.getHeight() - _d->lastParentRect.getHeight(); /* QUESTION: garbage code????? if (_alignLeft == alignScale || _alignRight == alignScale) fw = (float)parentAbsolute.getWidth(); if (_alignTop == alignScale || _alignBottom == alignScale) fh = (float)parentAbsolute.getHeight(); */ switch (_alignLeft) { case alignAuto: case alignUpperLeft: break; case alignLowerRight: _d->desiredRect.UpperLeftCorner += Point( diffx, 0 ); break; case alignCenter: _d->desiredRect.UpperLeftCorner += Point( diffx/2, 0 ); break; case alignScale: //_d->desiredRect.UpperLeftCorner.setX( _d->scaleRect.UpperLeftCorner.X * fw ); break; } switch (_alignRight) { case alignAuto: case alignUpperLeft: break; case alignLowerRight: _d->desiredRect.LowerRightCorner += Point( diffx, 0 ); break; case alignCenter: _d->desiredRect.LowerRightCorner += Point( diffx/2, 0 ); break; case alignScale: //_d->desiredRect.LowerRightCorner.X = math::round_(_d->scaleRect.LowerRightCorner.X * fw); break; } switch (_alignTop) { case alignAuto: case alignUpperLeft: break; case alignLowerRight: _d->desiredRect.UpperLeftCorner += Point( 0, diffy ); break; case alignCenter: _d->desiredRect.UpperLeftCorner += Point( 0, diffy/2 ); break; case alignScale: //_d->desiredRect.UpperLeftCorner.Y = math::round_(_d->scaleRect.UpperLeftCorner.Y * fh); break; } switch (_alignBottom) { case alignAuto: case alignUpperLeft: break; case alignLowerRight: _d->desiredRect.LowerRightCorner += Point( 0, diffy ); break; case alignCenter: _d->desiredRect.LowerRightCorner += Point( 0, diffy/2 ); break; case alignScale: //_d->desiredRect.LowerRightCorner.Y = math::round_(_d->scaleRect.LowerRightCorner.Y * fh); break; } _d->relativeRect = _d->desiredRect; const int w = _d->relativeRect.getWidth(); const int h = _d->relativeRect.getHeight(); // make sure the desired rectangle is allowed if (w < (int)_d->minSize.getWidth() ) _d->relativeRect.LowerRightCorner.setX( _d->relativeRect.UpperLeftCorner.getX() + _d->minSize.getWidth() ); if (h < (int)_d->minSize.getHeight() ) _d->relativeRect.LowerRightCorner.setY( _d->relativeRect.UpperLeftCorner.getY() + _d->minSize.getHeight() ); if (_d->maxSize.getWidth() > 0 && w > (int)_d->maxSize.getWidth() ) _d->relativeRect.LowerRightCorner.setX( _d->relativeRect.UpperLeftCorner.getX() + _d->maxSize.getWidth() ); if (_d->maxSize.getHeight() > 0 && h > (int)_d->maxSize.getHeight() ) _d->relativeRect.LowerRightCorner.setY( _d->relativeRect.UpperLeftCorner.getY() + _d->maxSize.getHeight() ); _d->relativeRect.repair(); _d->absoluteRect = _d->relativeRect + parentAbsolute.UpperLeftCorner; if (!getParent()) parentAbsoluteClip = getAbsoluteRect(); _d->absoluteClippingRect = getAbsoluteRect(); _d->absoluteClippingRect.clipAgainst(parentAbsoluteClip); _d->lastParentRect = parentAbsolute; if ( recursive ) { // update all children ChildIterator it = _d->children.begin(); for (; it != _d->children.end(); ++it) { (*it)->recalculateAbsolutePosition(recursive); } } }
PixelVector ComponentContainer::getRelativeCursorPosition() const { return Screen::getCursorPosition() - getAbsoluteRect().getPosition(); }
void Icon::render() const { Screen::drawGraphicsID(getAbsoluteRect(), getTextureID()); }
void MenuControl::_setItemChildVisibleAt(size_t _index, bool _visible, bool _smooth) { MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "MenuControl::setItemChildVisibleAt"); if (_visible) { if (mItemsInfo[_index].submenu && mItemsInfo[_index].submenu->getItemCount()) { int offset = mItemsInfo[0].item->getAbsoluteTop() - getAbsoluteTop(); const IntCoord& coord = mItemsInfo[_index].item->getAbsoluteCoord(); IntPoint point(getAbsoluteRect().right, coord.top - offset); MenuControl* menu = mItemsInfo[_index].submenu; if (mVerticalAlignment) { // too wide if (point.left + menu->getWidth() > menu->getParentSize().width) { // move to the left side if possible if (point.left - menu->getWidth() - getWidth() > 0) point.left -= menu->getWidth() + getWidth(); // or put near right parent border (window) if too wide for left side too else point.left = menu->getParentSize().width - menu->getWidth(); } // too high (same logic as for too wide) if (point.top + menu->getHeight() > menu->getParentSize().height) { // move to the top side if possible if (point.top - menu->getHeight() - getHeight() > 0) point.top -= menu->getHeight() + getHeight(); // or put near bottom parent border (window) if too high for top side too else point.top = menu->getParentSize().height - menu->getHeight(); } } else { point.set(coord.left, getAbsoluteRect().bottom); } menu->setPosition(point); if (_smooth) menu->setVisibleSmooth(true); else menu->setVisible(true); MyGUI::LayerManager::getInstance().upLayerItem(menu); } } else { if (mItemsInfo[_index].submenu) { if (_smooth) mItemsInfo[_index].submenu->setVisibleSmooth(false); else mItemsInfo[_index].submenu->setVisible(false); } } }
bool InventoryInfoWindow::onEraseBackground() { _vm->_gfx->fillRect(getAbsoluteRect(), _vm->_gfx->getColor(0, 0, 0)); return true; }
void Panel::render() const { Screen::fillRect(getAbsoluteRect(), sf::Color(255, 255, 255, 40)); ComponentContainer::render(); }
int Widget::getScreenRight() const { return getAbsoluteRect().getRight(); }
int Widget::getScreenLeft() const { return getAbsoluteRect().getLeft(); }
void ScrollBar::beforeDraw( GfxEngine& painter ) { if( !isVisible() ) return; bool needRecalculateSliderParams = (_sliderPos != _lastSliderPos); if( !(_d->needRecalculateParams || needRecalculateSliderParams) ) return; if( _d->needRecalculateParams ) { _d->backgroundRect = getAbsoluteRect(); if( _horizontal ) { if( _d->upButton && _d->upButton->isVisible() ) _d->backgroundRect.UpperLeftCorner += Point( _d->upButton->getWidth(), 0 ); if( _d->downButton && _d->downButton->isVisible() ) _d->backgroundRect.LowerRightCorner -= Point( _d->downButton->getWidth(), 0 ); } else { if( _d->upButton && _d->upButton->isVisible() ) _d->backgroundRect.UpperLeftCorner += Point( 0, _d->upButton->getHeight() ); if( _d->downButton && _d->downButton->isVisible() ) _d->backgroundRect.LowerRightCorner -= Point( 0, _d->downButton->getHeight() ); } } _isSliderHovered = _d->sliderRect.isPointInside( _d->cursorPos ); ElementState st = _dragging && _draggedBySlider ? stPressed : (_lastSliderHovered ? stHovered : stNormal); _d->sliderTexture = (st == stPressed) ? _d->sliderPictureDown : _d->sliderPictureUp; if( needRecalculateSliderParams ) { _lastSliderPos = _sliderPos; _d->sliderRect = getAbsoluteRect(); if( !math::isEqual( getRange(), 0.f ) ) { // recalculate slider rectangle if( _horizontal ) { _d->sliderRect.UpperLeftCorner.setX( getScreenLeft() + _lastSliderPos - _drawLenght/2 ); if( _d->upButton && _d->upButton->isVisible() ) _d->sliderRect.UpperLeftCorner += Point( _d->upButton->getWidth(), 0 ); _d->sliderRect.LowerRightCorner.setX( _d->sliderRect.UpperLeftCorner.getX() + _drawLenght ); } else { _d->sliderRect.UpperLeftCorner.setY( getScreenTop() + _lastSliderPos - _drawLenght/2 ); if( _d->upButton && _d->upButton->isVisible() ) _d->sliderRect.UpperLeftCorner += Point( 0, _d->upButton->getHeight() ); _d->sliderRect.LowerRightCorner.setY( _d->sliderRect.UpperLeftCorner.getY() + _drawLenght ); } } } Widget::beforeDraw( painter ); }
int Widget::getScreenBottom() const { return getAbsoluteRect().getBottom(); }
void EditField::render() const { Screen::fillRect(getAbsoluteRect(), sf::Color::Blue); Screen::drawText(text, getAbsoluteRect().getPosition(), sf::Color::Black); }
unsigned int Widget::getArea() const { return getAbsoluteRect().getArea(); }
void FalagardSuperTooltip::resizeSelf(void) { // get child count int nElementNum = (int)d_VectorElements.size(); if(nElementNum == 0) return; Rect rcAbsoluteRect = getAbsoluteRect(); // The part height(Absolute). std::vector< float > vPartHeight(nElementNum); //AxTrace(0, 1, "--------------"); float fAbsHeight = 0; for(int i=0; i<nElementNum; ++i) { Elements& element = d_VectorElements[i]; if(element.bDynamicSize) { //Ignore empty resize text control. if(element.pWindow->getText().empty()) { element.pWindow->setText((utf8*)" "); } vPartHeight[i] = ((ResizeText*)element.pWindow)->_resizeSelf(); fAbsHeight += vPartHeight[i]; //AxTrace(0, 0, "D[%d] = %f", i, vPartHeight[i]); } //Static part else { vPartHeight[i] = element.pWindow->getAbsoluteHeight(); fAbsHeight += element.pWindow->getAbsoluteRect().getHeight(); //AxTrace(0, 0, "S[%d] = %f", i, vPartHeight[i]); } } // get named area"DynamicPartBorderSize" /* | It's fake!! | Left - LeftBorder Width | Top - TopBorder Height | Width - RightBorder Width | Height - BottomBorder Height | */ //const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName); //const Rect rectBorder(wlf.getNamedArea("DynamicPartBorderSize").getArea().getPixelRect(*this)); //Add header and footer size //fAbsHeight += rectBorder.d_top + rectBorder.getHeight(); setHeight(Absolute, fAbsHeight); //Resize and reposition all sub window. float fHeightStep = 0.0f; //rectBorder.d_top; for(int i=0; i<nElementNum; ++i) { Elements& element = d_VectorElements[i]; //Ignore empty resize text control. if(element.bDynamicSize && element.pWindow->getText().empty()) continue; element.pWindow->setHeight(Absolute, vPartHeight[i]); element.pWindow->setPosition(Absolute, Point(element.pWindow->getAbsoluteXPosition(), fHeightStep)); fHeightStep += element.pWindow->getAbsoluteHeight(); } }