void MultiLineText::Layout() { const Point newSize(m_layout->ComputeSize(GetSize())); if (m_preferredSize != newSize) GetContext()->RequestLayout(); m_preferredSize = newSize; SetActiveArea(m_preferredSize); }
void ModelSpinner::Layout() { Point size(GetSize()); Point activeArea(std::min(size.x, size.y)); Point activeOffset(std::max(0, (size.x-activeArea.x)/2), std::max(0, (size.y-activeArea.y)/2)); SetActiveArea(activeArea, activeOffset); }
void Label::Layout() { if (m_preferredSize == Point()) PreferredSize(); const Point &size = GetSize(); SetActiveArea(Point(std::min(m_preferredSize.x,size.x), std::min(m_preferredSize.y,size.y))); }
void Button::Layout() { Widget *innerWidget = GetInnerWidget(); if (!innerWidget) { SetActiveArea(Point(GetContext()->GetSkin().ButtonMinInnerSize()) + Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2)); return; } const Point innerSize = GetSize() - Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2); SetWidgetDimensions(innerWidget, Point(GetContext()->GetSkin().ButtonNormal().borderWidth), CalcSize(innerWidget, innerSize)); innerWidget->Layout(); Point innerActiveArea(innerWidget->GetActiveArea()); growToMinimum(innerActiveArea, GetContext()->GetSkin().ButtonMinInnerSize()); SetActiveArea(innerActiveArea + Point(GetContext()->GetSkin().ButtonNormal().borderWidth*2)); }
void Button::Layout() { Widget *innerWidget = GetInnerWidget(); const Skin::BorderedRectElement &elem(GetContext()->GetSkin().ButtonNormal()); if (!innerWidget) { SetActiveArea(PreferredSize()); return; } const Point innerSize = GetSize() - Point(elem.paddingX*2, elem.paddingY*2); SetWidgetDimensions(innerWidget, Point(elem.paddingX, elem.paddingY), innerWidget->CalcSize(innerSize)); innerWidget->Layout(); Point innerActiveArea(innerWidget->GetActiveArea()); growToMinimum(innerActiveArea, GetContext()->GetSkin().ButtonMinInnerSize()); SetActiveArea(innerActiveArea + Point(elem.paddingX*2, elem.paddingY*2)); }
void Face::Layout() { Point size(GetSize()); Point activeArea(std::min(size.x, size.y)); Point activeOffset(std::max(0, (size.x-activeArea.x)/2), std::max(0, (size.y-activeArea.y)/2)); SetActiveArea(activeArea, activeOffset); Widget *innerWidget = GetInnerWidget(); if (!innerWidget) return; SetWidgetDimensions(innerWidget, activeOffset, activeArea); innerWidget->Layout(); }
void Image::Layout() { Point size = GetSize(); Point activeArea; switch (m_stretchMode) { case STRETCH_MAX: activeArea = size; break; case STRETCH_PRESERVE_ASPECT: { float originalRatio = float(m_initialSize.x) / float(m_initialSize.y); float wantRatio = float(size.x) / float(size.y); // more room on X than Y, use full X, scale Y if (wantRatio < originalRatio) { activeArea.x = size.x; activeArea.y = float(size.x) / originalRatio; } // more room on Y than X, use full Y, scale X else { activeArea.x = float(size.y) * originalRatio; activeArea.y = size.y; } break; } default: assert(0); } Point activeOffset(std::max(0, (size.x-activeArea.x)/2), std::max(0, (size.y-activeArea.y)/2)); SetActiveArea(activeArea, activeOffset); }
void Widget::SetDimensions(const Point &position, const Point &size) { m_position = position; SetSize(size); SetActiveArea(size); }
void Gauge::Layout() { SetActiveArea(Point(GetSize().x, GetContext()->GetSkin().GaugeBackground().size.y)); }
void SmallButton::Layout() { SetActiveArea(PreferredSize()); }
void MultiLineText::Layout() { m_preferredSize = m_layout->ComputeSize(GetSize()); SetActiveArea(m_preferredSize); }
void CheckBox::Layout() { SetActiveArea(PreferredSize()); }