void ScrollPane::add( Widget *widget ) { pChildContent->add(widget); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); updateScrollBars(); }
void ScrollPane::setSize( const Dimension &size ) { Widget::setSize(size); updateScrollBars(); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
void ScrollPane::sizeChanged( Widget* source, const Dimension &size ) { (void)source; (void)size; updateScrollBars(); if(source != pChildContent) pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
bool ScrollPane::isHScrollNeeded() const { if(getHScrollPolicy() == SHOW_NEVER) { return false; } if(getContentWidth() > getSize().getWidth()) { return true; } else if(getVScrollPolicy() != SHOW_NEVER && (getContentHeight() > getSize().getHeight() && getContentWidth() > (getSize().getWidth() - pChildVScroll->getWidth() ))) { return true; } return false; }
void ScrollPane::locationChanged( Widget* source, const Point &location ) { (void)source; (void)location; if(source != pChildContent) updateScrollBars(); if(source != pChildContent) pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); }
void ScrollPane::remove( Widget *widget ) { if(widget) { widget->removeMouseListener(this); widget->removeKeyboardListener(this); widget->removeWidgetListener(this); } pChildContent->remove(widget); pChildContent->setSize(Dimension(getContentWidth(),getContentHeight())); updateScrollBars(); }
void ScrollPane::resizeWidthToContents() { int vscroll = 0; if(getVScrollPolicy() == SHOW_ALWAYS) { vscroll = pChildVScroll->getWidth(); } setSize(getMargin(SIDE_LEFT) + getMargin(SIDE_RIGHT) + getContentWidth() + vscroll, getHeight()); }
void WidgetListBox::setText(const Common::UString &font, const Common::UString &text, float spacing) { lock(); clear(); Graphics::Aurora::FontHandle f = FontMan.get(font); std::vector<Common::UString> lines; f.getFont().split(text, lines, getContentWidth()); for (std::vector<Common::UString>::iterator l = lines.begin(); l != lines.end(); ++l) add(new WidgetListItemTextLine(*_gui, font, *l, spacing)); unlock(); }
void ScrollPane::adjustSBRanges() { int extraH = 0; int extraV = 0; if(pChildHScroll->isVisible()) { extraH += pChildHScroll->getHeight(); } if(pChildVScroll->isVisible()) { extraV += pChildVScroll->getWidth(); } //set vertical value pChildVScroll->setRangeFromPage(getInnerSize().getHeight() - extraH,getContentHeight()); //set horizontal value pChildHScroll->setRangeFromPage(getInnerSize().getWidth() - extraV,getContentWidth()); }
void WidgetContainer::render() { auto offsetTop = getOffsetTop() + getCoordY(style.margin.top); auto offsetLeft = getOffsetLeft() + getCoordX(style.margin.left); // Preparing vertex input auto x1 = -1.0 + 2 * (offsetLeft); auto x2 = -1.0 + 2 * (offsetLeft + getPaddingWidth()); auto y1 = +1.0 - 2 * (offsetTop + getPaddingHeight()); auto y2 = +1.0 - 2 * (offsetTop); auto& V0 = input.vertex[0]; auto& V1 = input.vertex[1]; auto& V2 = input.vertex[2]; auto& V3 = input.vertex[3]; V0.position[0] = V1.position[0] = x1; V2.position[0] = V3.position[0] = x2; V0.position[1] = V2.position[1] = y1; V1.position[1] = V3.position[1] = y2; V0.position[2] = V1.position[2] = V2.position[2] = V3.position[2] = 0.0; V0.position[3] = V1.position[3] = V2.position[3] = V3.position[3] = 1.0; V0.background = style.background; V1.background = style.background; V2.background = style.background; V3.background = style.background; manager->pushWidgetContainer(input); auto childOffsetTop = offsetTop + getCoordY(style.padding.top); auto childOffsetLeft = offsetLeft + getCoordX(style.padding.left); // Render children widgets vertically if (layout == LAYOUT_VERTICAL) { if (style.alignV == ALIGN_VERTICAL_CENTER) { childOffsetTop += (vertHeight - compHeight) / 2.0; } if (style.alignV == ALIGN_VERTICAL_BOTTOM) { childOffsetTop += (vertHeight - compHeight); } for (auto& child : children) { // Correct horizontal alignment switch (style.alignH) { case ALIGN_HORIZONTAL_LEFT: child->setOffsetLeft(childOffsetLeft); break; case ALIGN_HORIZONTAL_CENTER: child->setOffsetLeft(childOffsetLeft + (getContentWidth() - child->getBorderWidth()) / 2.0); break; case ALIGN_HORIZONTAL_RIGHT: child->setOffsetLeft(childOffsetLeft + (getContentWidth() - child->getBorderWidth())); break; } child->setOffsetTop(childOffsetTop); child->render(); childOffsetTop += child->getMarginHeight(); } } // Render children widgets horizontally if (layout == LAYOUT_HORIZONTAL) { if (style.alignH == ALIGN_HORIZONTAL_CENTER) { childOffsetLeft += (vertWidth - compWidth) / 2.0; } if (style.alignH == ALIGN_HORIZONTAL_RIGHT) { childOffsetLeft += (vertWidth - compWidth); } for (auto& child : children) { // Correct vertical alignment switch (style.alignV) { case ALIGN_VERTICAL_TOP: child->setOffsetTop(childOffsetTop); break; case ALIGN_VERTICAL_CENTER: child->setOffsetTop(childOffsetTop + (getContentHeight() - child->getBorderHeight()) / 2.0); break; case ALIGN_VERTICAL_BOTTOM: child->setOffsetTop(childOffsetTop + (getContentHeight() - child->getBorderHeight())); break; } child->setOffsetLeft(childOffsetLeft); child->render(); childOffsetLeft += child->getMarginWidth(); } } }
uint32 ConsoleWindow::getColumns() const { return floorf(getContentWidth() / _font.getFont().getWidth('m')); }
float Widget::getPaddingWidth() { auto paddingLeft = getCoordX(style.padding.left); auto paddingRight = getCoordX(style.padding.right); return getContentWidth() + paddingLeft + paddingRight; }