Code/Editor
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -72,7 +72,7 @@ void CColorGradientCtrl::resizeEvent(QResizeEvent* event)
|
||||
m_grid.rect = m_rcGradient;
|
||||
if (m_bNoZoom)
|
||||
{
|
||||
m_grid.zoom.x = m_grid.rect.width();
|
||||
m_grid.zoom.x = static_cast<f32>(m_grid.rect.width());
|
||||
}
|
||||
|
||||
m_rcKeys = rc;
|
||||
@@ -106,11 +106,6 @@ QPoint CColorGradientCtrl::KeyToPoint(int nKey)
|
||||
QPoint CColorGradientCtrl::TimeToPoint(float time)
|
||||
{
|
||||
return QPoint(m_grid.WorldToClient(Vec2(time, 0)).x(), m_rcGradient.height() / 2);
|
||||
|
||||
QPoint point;
|
||||
point.rx() = (time - m_fMinTime) * (m_rcGradient.width() / (m_fMaxTime - m_fMinTime)) + m_rcGradient.left();
|
||||
point.ry() = m_rcGradient.height() / 2;
|
||||
return point;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -833,15 +833,15 @@ static void SetEditorRange(EditorType* editor, IVariable* var)
|
||||
// If this variable has custom limits set, then use that as the min/max
|
||||
// Otherwise, the min/max for the input box will be bounded by the type
|
||||
// limit, but the slider will be constricted to a smaller default range
|
||||
static const double defaultMin = -100.0f;
|
||||
static const double defaultMax = 100.0f;
|
||||
static const float defaultMin = -100.0f;
|
||||
static const float defaultMax = 100.0f;
|
||||
if (var->HasCustomLimits())
|
||||
{
|
||||
editor->setRange(min, max);
|
||||
editor->setRange(static_cast<EditorType::value_type>(min), static_cast<EditorType::value_type>(max));
|
||||
}
|
||||
else
|
||||
{
|
||||
editor->setSoftRange(defaultMin, defaultMax);
|
||||
editor->setSoftRange(static_cast<EditorType::value_type>(defaultMin), static_cast<EditorType::value_type>(defaultMax));
|
||||
}
|
||||
|
||||
// Set the step size. The default variable step is 0, so if it's
|
||||
@@ -850,7 +850,7 @@ static void SetEditorRange(EditorType* editor, IVariable* var)
|
||||
// use that for the int values
|
||||
if (step > 0)
|
||||
{
|
||||
editor->spinbox()->setSingleStep(step);
|
||||
editor->spinbox()->setSingleStep(static_cast<int>(step));
|
||||
}
|
||||
else if (auto doubleSpinBox = qobject_cast<AzQtComponents::DoubleSpinBox*>(editor->spinbox()))
|
||||
{
|
||||
|
||||
@@ -175,7 +175,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
penSpikes = penColor;
|
||||
painter.setPen(Qt::black);
|
||||
painter.setBrush(Qt::white);
|
||||
rcGraph = QRect(QPoint(m_graphMargin, m_graphMargin), QPoint(abs(rc.width() - m_graphMargin), abs(rc.height() * m_graphHeightPercent)));
|
||||
rcGraph = QRect(QPoint(m_graphMargin, m_graphMargin), QPoint(abs(rc.width() - m_graphMargin), static_cast<int>(abs(rc.height() * m_graphHeightPercent))));
|
||||
painter.drawRect(rcGraph);
|
||||
painter.setPen(penSpikes);
|
||||
|
||||
@@ -193,7 +193,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
{
|
||||
float scale = 0;
|
||||
|
||||
i = ((float)x / graphWidth) * (kNumColorLevels - 1);
|
||||
i = static_cast<int>(((float)x / graphWidth) * (kNumColorLevels - 1));
|
||||
i = CLAMP(i, 0, kNumColorLevels - 1);
|
||||
|
||||
switch (m_drawMode)
|
||||
@@ -245,7 +245,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
}
|
||||
|
||||
crtX = static_cast<int>(rcGraph.left() + x + 1);
|
||||
painter.drawLine(crtX, graphBottom, crtX, graphBottom - scale * graphHeight);
|
||||
painter.drawLine(crtX, graphBottom, crtX, static_cast<int>(graphBottom - scale * graphHeight));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -258,7 +258,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
|
||||
for (size_t x = 0, xCount = abs(rcGraph.width()); x < xCount; ++x)
|
||||
{
|
||||
i = ((float)x / graphWidth) * (kNumColorLevels - 1);
|
||||
i = static_cast<int>(((float)x / graphWidth) * (kNumColorLevels - 1));
|
||||
i = CLAMP(i, 0, kNumColorLevels - 1);
|
||||
crtX = static_cast<UINT>(rcGraph.left() + x + 1);
|
||||
scaleR = scaleG = scaleB = scaleA = 0;
|
||||
@@ -283,10 +283,10 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
scaleA = (float)m_count[3][i] / m_maxCount[3];
|
||||
}
|
||||
|
||||
heightR = graphBottom - scaleR * graphHeight;
|
||||
heightG = graphBottom - scaleG * graphHeight;
|
||||
heightB = graphBottom - scaleB * graphHeight;
|
||||
heightA = graphBottom - scaleA * graphHeight;
|
||||
heightR = static_cast<int>(graphBottom - scaleR * graphHeight);
|
||||
heightG = static_cast<int>(graphBottom - scaleG * graphHeight);
|
||||
heightB = static_cast<int>(graphBottom - scaleB * graphHeight);
|
||||
heightA = static_cast<int>(graphBottom - scaleA * graphHeight);
|
||||
|
||||
if (lastHeight[0] == INT_MAX)
|
||||
{
|
||||
@@ -350,7 +350,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
for (size_t x = 0, xCount = abs(rcGraph.width()); x < xCount; ++x)
|
||||
{
|
||||
pos = (float)x / graphWidth;
|
||||
i = (float)((int)(pos * kNumColorLevels) % aThirdOfNumColorLevels) / aThirdOfNumColorLevels * kNumColorLevels;
|
||||
i = static_cast<int>((float)((int)(pos * kNumColorLevels) % aThirdOfNumColorLevels) / aThirdOfNumColorLevels * kNumColorLevels);
|
||||
i = CLAMP(i, 0, kNumColorLevels - 1);
|
||||
scale = 0;
|
||||
|
||||
@@ -385,7 +385,7 @@ void CImageHistogramDisplay::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
}
|
||||
|
||||
painter.setPen(pPen);
|
||||
painter.drawLine(rcGraph.left() + static_cast<int>(x) + 1, graphBottom, rcGraph.left() + static_cast<int>(x) + 1, graphBottom - scale * graphHeight);
|
||||
painter.drawLine(rcGraph.left() + static_cast<int>(x) + 1, graphBottom, rcGraph.left() + static_cast<int>(x) + 1, static_cast<int>(graphBottom - scale * graphHeight));
|
||||
}
|
||||
|
||||
// then draw 3 lines so we separate the channels
|
||||
|
||||
@@ -422,7 +422,7 @@ void QBitmapPreviewDialogImp::paintEvent(QPaintEvent* e)
|
||||
|
||||
|
||||
curr_x = histogramRect.left() + x + 1;
|
||||
int i = ((float)x / (graphWidth - 1)) * (CImageHistogram::kNumColorLevels - 1);
|
||||
int i = static_cast<int>(((float)x / (graphWidth - 1)) * (CImageHistogram::kNumColorLevels - 1));
|
||||
if (m_histrogramMode == eHistogramMode_SplitRGB)
|
||||
{
|
||||
// Filter out to area which we are interested
|
||||
@@ -446,7 +446,7 @@ void QBitmapPreviewDialogImp::paintEvent(QPaintEvent* e)
|
||||
scale = (float)m_histogram.m_count[c][i] / m_histogram.m_maxCount[c];
|
||||
}
|
||||
|
||||
int height = graphBottom - graphHeight * scale;
|
||||
int height = static_cast<int>(graphBottom - graphHeight * scale);
|
||||
if (last_height == INT_MAX)
|
||||
{
|
||||
last_height = height;
|
||||
|
||||
@@ -308,7 +308,7 @@ void ReflectedPropertyControl::CreateItems(XmlNodeRef node, CVarBlockPtr& outBlo
|
||||
int nMin(0), nMax(0);
|
||||
if (child->getAttr("min", nMin) && child->getAttr("max", nMax))
|
||||
{
|
||||
intVar->SetLimits(nMin, nMax);
|
||||
intVar->SetLimits(static_cast<float>(nMin), static_cast<float>(nMax));
|
||||
}
|
||||
}
|
||||
else if (!azstricmp(type, "float"))
|
||||
|
||||
@@ -39,20 +39,20 @@ namespace {
|
||||
hardMin = desc.m_bHardMin;
|
||||
hardMax = desc.m_bHardMax;
|
||||
}
|
||||
reflectedVar->m_softMinVal = min;
|
||||
reflectedVar->m_softMaxVal = max;
|
||||
reflectedVar->m_softMinVal = static_cast<R>(min);
|
||||
reflectedVar->m_softMaxVal = static_cast<R>(max);
|
||||
|
||||
if (hardMin)
|
||||
{
|
||||
reflectedVar->m_minVal = min;
|
||||
reflectedVar->m_minVal = static_cast<R>(min);
|
||||
}
|
||||
else
|
||||
{
|
||||
reflectedVar->m_minVal = std::numeric_limits<int>::lowest();
|
||||
reflectedVar->m_minVal = std::numeric_limits<R>::lowest();
|
||||
}
|
||||
if (hardMax)
|
||||
{
|
||||
reflectedVar->m_maxVal = max;
|
||||
reflectedVar->m_maxVal = static_cast<R>(max);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -64,9 +64,9 @@ namespace {
|
||||
../Code/Editor/Controls/ReflectedPropertyControl/ReflectedVarWrapper.cpp:59:38: error: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Werror,-Wimplicit-int-float-conversion]
|
||||
reflectedVar->m_maxVal = std::numeric_limits<int>::max();
|
||||
*/
|
||||
reflectedVar->m_maxVal = static_cast<float>(std::numeric_limits<int>::max());
|
||||
reflectedVar->m_maxVal = static_cast<R>(std::numeric_limits<int>::max());
|
||||
}
|
||||
reflectedVar->m_stepSize = step;
|
||||
reflectedVar->m_stepSize = static_cast<R>(step);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ void ReflectedVarIntAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
|
||||
{
|
||||
int intValue;
|
||||
pVariable->Get(intValue);
|
||||
value = intValue;
|
||||
value = static_cast<float>(intValue);
|
||||
}
|
||||
m_reflectedVar->m_value = std::round(value * m_valueMultiplier);
|
||||
m_reflectedVar->m_value = static_cast<int>(std::round(value * m_valueMultiplier));
|
||||
}
|
||||
|
||||
void ReflectedVarIntAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
|
||||
@@ -362,14 +362,14 @@ void ReflectedVarColorAdapter::SyncReflectedVarToIVar(IVariable *pVariable)
|
||||
Vec3 v(0, 0, 0);
|
||||
pVariable->Get(v);
|
||||
const QColor col = ColorLinearToGamma(ColorF(v.x, v.y, v.z));
|
||||
m_reflectedVar->m_color.Set(col.redF(), col.greenF(), col.blueF());
|
||||
m_reflectedVar->m_color.Set(static_cast<float>(col.redF()), static_cast<float>(col.greenF()), static_cast<float>(col.blueF()));
|
||||
}
|
||||
else
|
||||
{
|
||||
int col(0);
|
||||
pVariable->Get(col);
|
||||
const QColor qcolor = ColorToQColor((uint32)col);
|
||||
m_reflectedVar->m_color.Set(qcolor.redF(), qcolor.greenF(), qcolor.blueF());
|
||||
m_reflectedVar->m_color.Set(static_cast<float>(qcolor.redF()), static_cast<float>(qcolor.greenF()), static_cast<float>(qcolor.blueF()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,9 +382,9 @@ void ReflectedVarColorAdapter::SyncIVarToReflectedVar(IVariable *pVariable)
|
||||
}
|
||||
else
|
||||
{
|
||||
int ir = m_reflectedVar->m_color.GetX() * 255.0f;
|
||||
int ig = m_reflectedVar->m_color.GetY() * 255.0f;
|
||||
int ib = m_reflectedVar->m_color.GetZ() * 255.0f;
|
||||
int ir = static_cast<int>(m_reflectedVar->m_color.GetX() * 255.0f);
|
||||
int ig = static_cast<int>(m_reflectedVar->m_color.GetY() * 255.0f);
|
||||
int ib = static_cast<int>(m_reflectedVar->m_color.GetZ() * 255.0f);
|
||||
|
||||
pVariable->Set(static_cast<int>(RGB(ir, ig, ib)));
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ QPoint CSplineCtrl::KeyToPoint(int nKey)
|
||||
QPoint CSplineCtrl::TimeToPoint(float time)
|
||||
{
|
||||
QPoint point;
|
||||
point.setX((time - m_fMinTime) * (m_rcSpline.width() / (m_fMaxTime - m_fMinTime)) + m_rcSpline.left());
|
||||
point.setX(static_cast<int>((time - m_fMinTime) * (m_rcSpline.width() / (m_fMaxTime - m_fMinTime)) + m_rcSpline.left()));
|
||||
float val = 0;
|
||||
if (m_pSpline)
|
||||
{
|
||||
m_pSpline->InterpolateFloat(time, val);
|
||||
}
|
||||
point.setY((floor((m_fMaxValue - val) * (m_rcSpline.height() / (m_fMaxValue - m_fMinValue)) + 0.5f) + m_rcSpline.top()));
|
||||
point.setY(static_cast<int>((floor((m_fMaxValue - val) * (m_rcSpline.height() / (m_fMaxValue - m_fMinValue)) + 0.5f) + m_rcSpline.top())));
|
||||
return point;
|
||||
}
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ QPoint AbstractSplineWidget::TimeToPoint(float time, ISplineInterpolator* pSplin
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float AbstractSplineWidget::TimeToXOfs(float x)
|
||||
{
|
||||
return WorldToClient(Vec2(float(x), 0.0f)).x();
|
||||
return static_cast<float>(WorldToClient(Vec2(float(x), 0.0f)).x());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -832,8 +832,8 @@ void SplineWidget::DrawSpline(QPainter* painter, SSplineInfo& splineInfo, float
|
||||
int nTotalNumberOfDimensions(0);
|
||||
int nCurrentDimension(0);
|
||||
|
||||
int left = TimeToXOfs(startTime);//rcClip.left;
|
||||
int right = TimeToXOfs(endTime);//rcClip.right;
|
||||
int left = static_cast<int>(TimeToXOfs(startTime));//rcClip.left;
|
||||
int right = static_cast<int>(TimeToXOfs(endTime));//rcClip.right;
|
||||
QPoint p0 = TimeToPoint(pSpline->GetKeyTime(0), pSpline);
|
||||
QPoint p1 = TimeToPoint(pSpline->GetKeyTime(pSpline->GetKeyCount() - 1), pSpline);
|
||||
|
||||
@@ -898,7 +898,7 @@ void SplineWidget::DrawSpline(QPainter* painter, SSplineInfo& splineInfo, float
|
||||
|
||||
if ((x == right && pointsInLine >= 0) || (pointsInLine > 0 && fabs(lineStart.y() + gradient * (pt.x() - lineStart.x()) - pt.y()) > 1.0f))
|
||||
{
|
||||
lineStart = QPoint(pt.x() - 1, lineStart.y() + gradient * (pt.x() - 1 - lineStart.x()));
|
||||
lineStart = QPoint(pt.x() - 1, static_cast<int>(lineStart.y() + gradient * (pt.x() - 1 - lineStart.x())));
|
||||
path.lineTo(lineStart);
|
||||
gradient = float(pt.y() - lineStart.y()) / (pt.x() - lineStart.x());
|
||||
pointsInLine = 1;
|
||||
@@ -1063,7 +1063,7 @@ void SplineWidget::DrawTimeMarker(QPainter* painter)
|
||||
float x = TimeToXOfs(m_fTimeMarker);
|
||||
if (x >= m_rcSpline.left() && x <= m_rcSpline.right() + 1)
|
||||
{
|
||||
painter->drawLine(x, m_rcSpline.top(), x, m_rcSpline.bottom() + 1);
|
||||
painter->drawLine(static_cast<int>(x), m_rcSpline.top(), static_cast<int>(x), m_rcSpline.bottom() + 1);
|
||||
}
|
||||
painter->setPen(pOldPen);
|
||||
}
|
||||
@@ -2145,8 +2145,8 @@ void AbstractSplineWidget::TimeScaleKeys(float time, float startTime, float endT
|
||||
}
|
||||
}
|
||||
|
||||
int rangeMin = TimeToXOfs(affectedRangeMin);
|
||||
int rangeMax = TimeToXOfs(affectedRangeMax);
|
||||
int rangeMin = static_cast<int>(TimeToXOfs(affectedRangeMin));
|
||||
int rangeMax = static_cast<int>(TimeToXOfs(affectedRangeMax));
|
||||
|
||||
if (m_timeRange.start == affectedRangeMin)
|
||||
{
|
||||
@@ -2377,8 +2377,8 @@ void AbstractSplineWidget::RedrawWindowAroundMarker()
|
||||
UpdateKeyTimes();
|
||||
std::vector<KeyTime>::iterator itKeyTime = std::lower_bound(m_keyTimes.begin(), m_keyTimes.end(), KeyTime(m_fTimeMarker, 0));
|
||||
size_t keyTimeIndex = (itKeyTime != m_keyTimes.end() ? itKeyTime - m_keyTimes.begin() : m_keyTimes.size());
|
||||
int redrawRangeStart = (keyTimeIndex >= 2 ? TimeToXOfs(m_keyTimes[keyTimeIndex - 2].time) : m_rcSpline.left());
|
||||
int redrawRangeEnd = (keyTimeIndex < m_keyTimes.size() - 2 ? TimeToXOfs(m_keyTimes[keyTimeIndex + 2].time) : m_rcSpline.right() + 1);
|
||||
int redrawRangeStart = (keyTimeIndex >= 2 ? static_cast<int>(TimeToXOfs(m_keyTimes[keyTimeIndex - 2].time)) : m_rcSpline.left());
|
||||
int redrawRangeEnd = (keyTimeIndex < m_keyTimes.size() - 2 ? static_cast<int>(TimeToXOfs(m_keyTimes[keyTimeIndex + 2].time)) : m_rcSpline.right() + 1);
|
||||
|
||||
QRect rc(QPoint(redrawRangeStart, m_rcSpline.top()), QPoint(redrawRangeEnd, m_rcSpline.bottom() + 1) - QPoint(1, 1));
|
||||
rc = rc.normalized().intersected(m_rcSpline);
|
||||
|
||||
@@ -25,9 +25,9 @@ static const QColor ltgrayCol = QColor(110, 110, 110);
|
||||
|
||||
QColor InterpolateColor(const QColor& c1, const QColor& c2, float fraction)
|
||||
{
|
||||
const int r = (c2.red() - c1.red()) * fraction + c1.red();
|
||||
const int g = (c2.green() - c1.green()) * fraction + c1.green();
|
||||
const int b = (c2.blue() - c1.blue()) * fraction + c1.blue();
|
||||
const int r = static_cast<int>(static_cast<float>(c2.red() - c1.red()) * fraction + c1.red());
|
||||
const int g = static_cast<int>(static_cast<float>(c2.green() - c1.green()) * fraction + c1.green());
|
||||
const int b = static_cast<int>(static_cast<float>(c2.blue() - c1.blue()) * fraction + c1.blue());
|
||||
return QColor(r, g, b);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ float TimelineWidget::SnapTime(float time)
|
||||
{
|
||||
double t = floor((double)time * m_ticksStep + 0.5);
|
||||
t = t / m_ticksStep;
|
||||
return t;
|
||||
return static_cast<float>(t);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -153,10 +153,10 @@ void TimelineWidget::DrawTicks(QPainter* painter)
|
||||
painter->setPen(redpen);
|
||||
int x = TimeToClient(m_fTimeMarker);
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(QRect(QPoint(x - 3, rc.top()), QPoint(x + 2, rc.bottom())));
|
||||
painter->drawRect(QRect(QPoint(x - 3, static_cast<int>(rc.top())), QPoint(x + 2, static_cast<int>(rc.bottom()))));
|
||||
|
||||
painter->setPen(redpen);
|
||||
painter->drawLine(x, rc.top(), x, rc.bottom());
|
||||
painter->drawLine(x, static_cast<int>(rc.top()), x, static_cast<int>(rc.bottom()));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
// Draw vertical line showing current time.
|
||||
@@ -190,7 +190,7 @@ void TimelineWidget::DrawTicks(QPainter* painter)
|
||||
float keyTime = (m_pKeyTimeSet ? m_pKeyTimeSet->GetKeyTime(keyTimeIndex) : 0.0f);
|
||||
|
||||
int x2 = TimeToClient(keyTime);
|
||||
painter->drawRect(QRect(QPoint(x2 - 1, rc.top()), QPoint(x2 + 2, rc.bottom())));
|
||||
painter->drawRect(QRect(QPoint(x2 - 1, static_cast<int>(rc.top())), QPoint(x2 + 2, static_cast<int>(rc.bottom()))));
|
||||
}
|
||||
|
||||
painter->setPen(pOldPen);
|
||||
|
||||
Reference in New Issue
Block a user