void EnergyMeter::setMaximumValue(const float &newMaximumValue) { if(newMaximumValue > 0.0f) { maximumValue = newMaximumValue; updateFill(); } // TODO: Throw exception? Something needs to happen. }
void EnergyMeter::setValue(const float &newValue) { if(newValue >= 0.0f) { value = newValue; value = std::min(value, getMaximumValue()); value = std::max(value, 0.0f); updateFill(); } // TODO: Notify caller? Exception? }
AnchorsBase::AnchorsBase(QWidget *w, bool): QObject(w), d_ptr(new AnchorsBasePrivate(this)) { Q_D(AnchorsBase); d->extendWidget = new ExtendWidget(w, this); connect(d->extendWidget, SIGNAL(enabledChanged(bool)), SIGNAL(enabledChanged(bool))); connect(d->fill, SIGNAL(sizeChanged(QSize)), SLOT(updateFill())); connect(d->centerIn, SIGNAL(sizeChanged(QSize)), SLOT(updateCenterIn())); d->setWidgetAnchorsBase(w, this); }
void AnchorsBase::setLeftMargin(int leftMargin) { Q_D(AnchorsBase); if (d->leftMargin == leftMargin) { return; } d->leftMargin = leftMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->left)) { updateHorizontal(); } emit leftMarginChanged(leftMargin); }
void AnchorsBase::setBottomMargin(int bottomMargin) { Q_D(AnchorsBase); if (d->bottomMargin == bottomMargin) { return; } d->bottomMargin = bottomMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->bottom)) { updateVertical(); } emit bottomMarginChanged(bottomMargin); }
void AnchorsBase::setTopMargin(int topMargin) { Q_D(AnchorsBase); if (d->topMargin == topMargin) { return; } d->topMargin = topMargin; if (d->fill->target()) { updateFill(); } else if (isBinding(d->top)) { updateVertical(); } emit topMarginChanged(topMargin); }
void AnchorsBase::setRightMargin(int rightMargin) { Q_D(AnchorsBase); if (d->rightMargin == rightMargin) { return; } d->rightMargin = rightMargin; if (isBinding(d->right)) { updateHorizontal(); } if (d->fill->target()) { updateFill(); } emit rightMarginChanged(rightMargin); }
EnergyMeter::EnergyMeter(const sf::Sprite &overlay, const float &maximumValue) : value(maximumValue) , maximumValue(maximumValue) , orientation(-1) , overlay(overlay) , primaryColor(DEFAULT_PRIMARY_COLOR) , secondaryColor(DEFAULT_SECONDARY_COLOR) , fillColor(DEFAULT_FILL_COLOR) { setVisible(true); foreground.setSize( sf::Vector2f( overlay.getLocalBounds().width, overlay.getLocalBounds().height ) ); primaryBackground.setSize(foreground.getSize()); secondaryBackground.setSize( sf::Vector2f( 2.0f, foreground.getSize().y ) ); setFillColor(fillColor); setPrimaryColor(primaryColor); setSecondaryColor(secondaryColor); setPosition( sf::Vector2i( static_cast<int>(overlay.getPosition().x), static_cast<int>(overlay.getPosition().y) ) ); setOrientation(VERTICAL_ORIENTATION); updateFill(); }
void AnchorsBase::setMargins(int margins) { Q_D(AnchorsBase); if (d->margins == margins) { return; } d->margins = margins; if (margins != 0) { if (d->fill->target()) { updateFill(); } else { updateVertical(); updateHorizontal(); } } emit marginsChanged(margins); }