mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Fix int <-> double <-> float casts
It looks like allegro includes several implicit conversions between float and double.
This commit is contained in:
parent
35be72833b
commit
f3974002d5
@ -36,7 +36,7 @@ namespace cmd {
|
|||||||
void onRedo() override;
|
void onRedo() override;
|
||||||
size_t onMemSize() const override {
|
size_t onMemSize() const override {
|
||||||
return sizeof(*this) +
|
return sizeof(*this) +
|
||||||
const_cast<std::stringstream*>(&m_stream)->tellp();
|
(size_t)const_cast<std::stringstream*>(&m_stream)->tellp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -32,7 +32,7 @@ namespace cmd {
|
|||||||
void onRedo() override;
|
void onRedo() override;
|
||||||
size_t onMemSize() const override {
|
size_t onMemSize() const override {
|
||||||
return sizeof(*this) +
|
return sizeof(*this) +
|
||||||
const_cast<std::stringstream*>(&m_stream)->tellp();
|
(size_t)const_cast<std::stringstream*>(&m_stream)->tellp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -36,7 +36,7 @@ namespace cmd {
|
|||||||
void onRedo() override;
|
void onRedo() override;
|
||||||
size_t onMemSize() const override {
|
size_t onMemSize() const override {
|
||||||
return sizeof(*this) +
|
return sizeof(*this) +
|
||||||
const_cast<std::stringstream*>(&m_stream)->tellp();
|
(size_t)const_cast<std::stringstream*>(&m_stream)->tellp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -31,7 +31,7 @@ namespace cmd {
|
|||||||
void onRedo() override;
|
void onRedo() override;
|
||||||
size_t onMemSize() const override {
|
size_t onMemSize() const override {
|
||||||
return sizeof(*this) +
|
return sizeof(*this) +
|
||||||
const_cast<std::stringstream*>(&m_stream)->tellp();
|
(size_t)const_cast<std::stringstream*>(&m_stream)->tellp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -202,8 +202,8 @@ void SpriteSizeCommand::onExecute(Context* context)
|
|||||||
{
|
{
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
const Sprite* sprite(reader.sprite());
|
const Sprite* sprite(reader.sprite());
|
||||||
int new_width = (m_width ? m_width: sprite->width()*m_scaleX);
|
int new_width = (m_width ? m_width: int(sprite->width()*m_scaleX));
|
||||||
int new_height = (m_height ? m_height: sprite->height()*m_scaleY);
|
int new_height = (m_height ? m_height: int(sprite->height()*m_scaleY));
|
||||||
ResizeMethod resize_method = m_resizeMethod;
|
ResizeMethod resize_method = m_resizeMethod;
|
||||||
|
|
||||||
if (context->isUiAvailable()) {
|
if (context->isUiAvailable()) {
|
||||||
|
@ -259,8 +259,8 @@ bool ColorCurveEditor::editNodeManually(gfx::Point& viewPt)
|
|||||||
window->openWindowInForeground();
|
window->openWindowInForeground();
|
||||||
|
|
||||||
if (window->getKiller() == button_ok) {
|
if (window->getKiller() == button_ok) {
|
||||||
viewPt.x = entry_x->getTextDouble();
|
viewPt.x = int(entry_x->getTextDouble());
|
||||||
viewPt.y = entry_y->getTextDouble();
|
viewPt.y = int(entry_y->getTextDouble());
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -113,7 +113,7 @@ void ConvolutionMatrixStock::reloadStock()
|
|||||||
for (y=0; y<h; ++y) {
|
for (y=0; y<h; ++y) {
|
||||||
for (x=0; x<w; ++x) {
|
for (x=0; x<w; ++x) {
|
||||||
READ_TOK();
|
READ_TOK();
|
||||||
int value = strtod(buf, NULL) * ConvolutionMatrix::Precision;
|
int value = int(strtod(buf, NULL) * ConvolutionMatrix::Precision);
|
||||||
div += value;
|
div += value;
|
||||||
|
|
||||||
matrix->value(x, y) = value;
|
matrix->value(x, y) = value;
|
||||||
@ -138,14 +138,14 @@ void ConvolutionMatrixStock::reloadStock()
|
|||||||
// Div
|
// Div
|
||||||
READ_TOK();
|
READ_TOK();
|
||||||
if (strcmp(buf, "auto") != 0)
|
if (strcmp(buf, "auto") != 0)
|
||||||
div = strtod(buf, NULL) * ConvolutionMatrix::Precision;
|
div = int(strtod(buf, NULL) * ConvolutionMatrix::Precision);
|
||||||
|
|
||||||
matrix->setDiv(div);
|
matrix->setDiv(div);
|
||||||
|
|
||||||
// Bias
|
// Bias
|
||||||
READ_TOK();
|
READ_TOK();
|
||||||
if (strcmp(buf, "auto") != 0)
|
if (strcmp(buf, "auto") != 0)
|
||||||
bias = strtod(buf, NULL);
|
bias = int(strtod(buf, NULL));
|
||||||
|
|
||||||
matrix->setBias(bias);
|
matrix->setBias(bias);
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
|
|||||||
ui::Slider* slider_quality = app::find_widget<ui::Slider>(window, "quality");
|
ui::Slider* slider_quality = app::find_widget<ui::Slider>(window, "quality");
|
||||||
ui::Widget* ok = app::find_widget<ui::Widget>(window, "ok");
|
ui::Widget* ok = app::find_widget<ui::Widget>(window, "ok");
|
||||||
|
|
||||||
slider_quality->setValue(jpeg_options->quality * 10.0f);
|
slider_quality->setValue(int(jpeg_options->quality * 10.0f));
|
||||||
|
|
||||||
window->openWindowInForeground();
|
window->openWindowInForeground();
|
||||||
|
|
||||||
|
@ -116,10 +116,20 @@ void set_config_int(const char* section, const char* name, int value)
|
|||||||
|
|
||||||
float get_config_float(const char* section, const char* name, float value)
|
float get_config_float(const char* section, const char* name, float value)
|
||||||
{
|
{
|
||||||
return g_configs.back()->getDoubleValue(section, name, value);
|
return (float)g_configs.back()->getDoubleValue(section, name, (float)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_config_float(const char* section, const char* name, float value)
|
void set_config_float(const char* section, const char* name, float value)
|
||||||
|
{
|
||||||
|
g_configs.back()->setDoubleValue(section, name, (float)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
double get_config_double(const char* section, const char* name, double value)
|
||||||
|
{
|
||||||
|
return g_configs.back()->getDoubleValue(section, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_config_double(const char* section, const char* name, double value)
|
||||||
{
|
{
|
||||||
g_configs.back()->setDoubleValue(section, name, value);
|
g_configs.back()->setDoubleValue(section, name, value);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,9 @@ namespace app {
|
|||||||
float get_config_float(const char* section, const char* name, float value);
|
float get_config_float(const char* section, const char* name, float value);
|
||||||
void set_config_float(const char* section, const char* name, float value);
|
void set_config_float(const char* section, const char* name, float value);
|
||||||
|
|
||||||
|
double get_config_double(const char* section, const char* name, double value);
|
||||||
|
void set_config_double(const char* section, const char* name, double value);
|
||||||
|
|
||||||
bool get_config_bool(const char* section, const char* name, bool value);
|
bool get_config_bool(const char* section, const char* name, bool value);
|
||||||
void set_config_bool(const char* section, const char* name, bool value);
|
void set_config_bool(const char* section, const char* name, bool value);
|
||||||
|
|
||||||
@ -71,7 +74,7 @@ namespace app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline double get_config_value(const char* section, const char* name, double value) {
|
inline double get_config_value(const char* section, const char* name, double value) {
|
||||||
return get_config_float(section, name, value);
|
return get_config_double(section, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline gfx::Rect get_config_value(const char* section, const char* name, const gfx::Rect& value) {
|
inline gfx::Rect get_config_value(const char* section, const char* name, const gfx::Rect& value) {
|
||||||
@ -104,7 +107,7 @@ namespace app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void set_config_value(const char* section, const char* name, double value) {
|
inline void set_config_value(const char* section, const char* name, double value) {
|
||||||
set_config_float(section, name, value);
|
set_config_double(section, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_config_value(const char* section, const char* name, const gfx::Rect& value) {
|
inline void set_config_value(const char* section, const char* name, const gfx::Rect& value) {
|
||||||
|
@ -380,7 +380,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
|
|||||||
// rendering process depending on each cel position.
|
// rendering process depending on each cel position.
|
||||||
// E.g. when we are drawing in a cel with position < (0,0)
|
// E.g. when we are drawing in a cel with position < (0,0)
|
||||||
if (m_zoom.scale() < 1.0)
|
if (m_zoom.scale() < 1.0)
|
||||||
expose.enlarge(1./m_zoom.scale());
|
expose.enlarge(int(1./m_zoom.scale()));
|
||||||
m_document->notifyExposeSpritePixels(m_sprite, gfx::Region(expose));
|
m_document->notifyExposeSpritePixels(m_sprite, gfx::Region(expose));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
|
|||||||
// For odd zoom scales minor than 100% we have to add an extra window
|
// For odd zoom scales minor than 100% we have to add an extra window
|
||||||
// just to make sure the whole rectangle is drawn.
|
// just to make sure the whole rectangle is drawn.
|
||||||
if (m_zoom.scale() < 1.0)
|
if (m_zoom.scale() < 1.0)
|
||||||
rc.inflate(1./m_zoom.scale(), 1./m_zoom.scale());
|
rc.inflate(int(1./m_zoom.scale()), int(1./m_zoom.scale()));
|
||||||
|
|
||||||
gfx::Rect client = getClientBounds();
|
gfx::Rect client = getClientBounds();
|
||||||
gfx::Rect spriteRect(
|
gfx::Rect spriteRect(
|
||||||
|
@ -181,10 +181,10 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier)
|
|||||||
bool updateBounds = false;
|
bool updateBounds = false;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
dx = ((pos.x - m_catchPos.x) * cos(m_currentData.angle()) +
|
dx = int((pos.x - m_catchPos.x) * cos(m_currentData.angle()) +
|
||||||
(pos.y - m_catchPos.y) * -sin(m_currentData.angle()));
|
(pos.y - m_catchPos.y) * -sin(m_currentData.angle()));
|
||||||
dy = ((pos.x - m_catchPos.x) * sin(m_currentData.angle()) +
|
dy = int((pos.x - m_catchPos.x) * sin(m_currentData.angle()) +
|
||||||
(pos.y - m_catchPos.y) * cos(m_currentData.angle()));
|
(pos.y - m_catchPos.y) * cos(m_currentData.angle()));
|
||||||
|
|
||||||
switch (m_handle) {
|
switch (m_handle) {
|
||||||
|
|
||||||
@ -388,8 +388,8 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier)
|
|||||||
// redraw of the sprite.
|
// redraw of the sprite.
|
||||||
gfx::Rect fullBounds;
|
gfx::Rect fullBounds;
|
||||||
for (int i=0; i<gfx::Transformation::Corners::NUM_OF_CORNERS; ++i) {
|
for (int i=0; i<gfx::Transformation::Corners::NUM_OF_CORNERS; ++i) {
|
||||||
fullBounds = fullBounds.createUnion(gfx::Rect(oldCorners[i].x, oldCorners[i].y, 1, 1));
|
fullBounds = fullBounds.createUnion(gfx::Rect((int)oldCorners[i].x, (int)oldCorners[i].y, 1, 1));
|
||||||
fullBounds = fullBounds.createUnion(gfx::Rect(newCorners[i].x, newCorners[i].y, 1, 1));
|
fullBounds = fullBounds.createUnion(gfx::Rect((int)newCorners[i].x, (int)newCorners[i].y, 1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If "fullBounds" is empty is because the cel was not moved
|
// If "fullBounds" is empty is because the cel was not moved
|
||||||
@ -407,10 +407,10 @@ Image* PixelsMovement::getDraggedImageCopy(gfx::Point& origin)
|
|||||||
gfx::Point leftTop(corners[0]);
|
gfx::Point leftTop(corners[0]);
|
||||||
gfx::Point rightBottom(corners[0]);
|
gfx::Point rightBottom(corners[0]);
|
||||||
for (size_t i=1; i<corners.size(); ++i) {
|
for (size_t i=1; i<corners.size(); ++i) {
|
||||||
if (leftTop.x > corners[i].x) leftTop.x = corners[i].x;
|
if (leftTop.x > corners[i].x) leftTop.x = (int)corners[i].x;
|
||||||
if (leftTop.y > corners[i].y) leftTop.y = corners[i].y;
|
if (leftTop.y > corners[i].y) leftTop.y = (int)corners[i].y;
|
||||||
if (rightBottom.x < corners[i].x) rightBottom.x = corners[i].x;
|
if (rightBottom.x < corners[i].x) rightBottom.x = (int)corners[i].x;
|
||||||
if (rightBottom.y < corners[i].y) rightBottom.y = corners[i].y;
|
if (rightBottom.y < corners[i].y) rightBottom.y = (int)corners[i].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int width = rightBottom.x - leftTop.x;
|
int width = rightBottom.x - leftTop.x;
|
||||||
@ -489,7 +489,7 @@ void PixelsMovement::dropImageTemporarily()
|
|||||||
newPivot += pivotPosFactor.x * point2Vector(corners.rightTop() - corners.leftTop());
|
newPivot += pivotPosFactor.x * point2Vector(corners.rightTop() - corners.leftTop());
|
||||||
newPivot += pivotPosFactor.y * point2Vector(corners.leftBottom() - corners.leftTop());
|
newPivot += pivotPosFactor.y * point2Vector(corners.leftBottom() - corners.leftTop());
|
||||||
|
|
||||||
m_currentData.displacePivotTo(gfx::Point(newPivot.x, newPivot.y));
|
m_currentData.displacePivotTo(gfx::Point((int)newPivot.x, (int)newPivot.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
redrawCurrentMask();
|
redrawCurrentMask();
|
||||||
@ -616,18 +616,26 @@ void PixelsMovement::drawParallelogram(doc::Image* dst, doc::Image* src,
|
|||||||
|
|
||||||
case kFastRotationAlgorithm:
|
case kFastRotationAlgorithm:
|
||||||
doc::algorithm::parallelogram(dst, src,
|
doc::algorithm::parallelogram(dst, src,
|
||||||
corners.leftTop().x-leftTop.x, corners.leftTop().y-leftTop.y,
|
int(corners.leftTop().x-leftTop.x),
|
||||||
corners.rightTop().x-leftTop.x, corners.rightTop().y-leftTop.y,
|
int(corners.leftTop().y-leftTop.y),
|
||||||
corners.rightBottom().x-leftTop.x, corners.rightBottom().y-leftTop.y,
|
int(corners.rightTop().x-leftTop.x),
|
||||||
corners.leftBottom().x-leftTop.x, corners.leftBottom().y-leftTop.y);
|
int(corners.rightTop().y-leftTop.y),
|
||||||
|
int(corners.rightBottom().x-leftTop.x),
|
||||||
|
int(corners.rightBottom().y-leftTop.y),
|
||||||
|
int(corners.leftBottom().x-leftTop.x),
|
||||||
|
int(corners.leftBottom().y-leftTop.y));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kRotSpriteRotationAlgorithm:
|
case kRotSpriteRotationAlgorithm:
|
||||||
doc::algorithm::rotsprite_image(dst, src,
|
doc::algorithm::rotsprite_image(dst, src,
|
||||||
corners.leftTop().x-leftTop.x, corners.leftTop().y-leftTop.y,
|
int(corners.leftTop().x-leftTop.x),
|
||||||
corners.rightTop().x-leftTop.x, corners.rightTop().y-leftTop.y,
|
int(corners.leftTop().y-leftTop.y),
|
||||||
corners.rightBottom().x-leftTop.x, corners.rightBottom().y-leftTop.y,
|
int(corners.rightTop().x-leftTop.x),
|
||||||
corners.leftBottom().x-leftTop.x, corners.leftBottom().y-leftTop.y);
|
int(corners.rightTop().y-leftTop.y),
|
||||||
|
int(corners.rightBottom().x-leftTop.x),
|
||||||
|
int(corners.rightBottom().y-leftTop.y),
|
||||||
|
int(corners.leftBottom().x-leftTop.x),
|
||||||
|
int(corners.leftBottom().y-leftTop.y));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,8 @@ HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point&
|
|||||||
|
|
||||||
std::vector<gfx::Point> screenPoints(corners.size());
|
std::vector<gfx::Point> screenPoints(corners.size());
|
||||||
for (size_t c=0; c<corners.size(); ++c)
|
for (size_t c=0; c<corners.size(); ++c)
|
||||||
screenPoints[c] = editor->editorToScreen(gfx::Point(corners[c].x, corners[c].y));
|
screenPoints[c] = editor->editorToScreen(
|
||||||
|
gfx::Point((int)corners[c].x, (int)corners[c].y));
|
||||||
|
|
||||||
int handle_rs[2] = { gfx->width()*2, gfx->width()*3 };
|
int handle_rs[2] = { gfx->width()*2, gfx->width()*3 };
|
||||||
for (int i=0; i<2; ++i) {
|
for (int i=0; i<2; ++i) {
|
||||||
@ -102,7 +103,8 @@ void TransformHandles::drawHandles(Editor* editor, const gfx::Transformation& tr
|
|||||||
|
|
||||||
std::vector<gfx::Point> screenPoints(corners.size());
|
std::vector<gfx::Point> screenPoints(corners.size());
|
||||||
for (size_t c=0; c<corners.size(); ++c)
|
for (size_t c=0; c<corners.size(); ++c)
|
||||||
screenPoints[c] = editor->editorToScreen(gfx::Point(corners[c].x, corners[c].y));
|
screenPoints[c] = editor->editorToScreen(
|
||||||
|
gfx::Point((int)corners[c].x, (int)corners[c].y));
|
||||||
|
|
||||||
// TODO DO NOT COMMIT
|
// TODO DO NOT COMMIT
|
||||||
#if 0 // Uncomment this if you want to see the bounds in red (only for debugging purposes)
|
#if 0 // Uncomment this if you want to see the bounds in red (only for debugging purposes)
|
||||||
@ -153,7 +155,8 @@ void TransformHandles::invalidateHandles(Editor* editor, const gfx::Transformati
|
|||||||
|
|
||||||
std::vector<gfx::Point> screenPoints(corners.size());
|
std::vector<gfx::Point> screenPoints(corners.size());
|
||||||
for (size_t c=0; c<corners.size(); ++c)
|
for (size_t c=0; c<corners.size(); ++c)
|
||||||
screenPoints[c] = editor->editorToScreen(gfx::Point(corners[c].x, corners[c].y));
|
screenPoints[c] = editor->editorToScreen(
|
||||||
|
gfx::Point((int)corners[c].x, (int)corners[c].y));
|
||||||
|
|
||||||
// Invalidate each corner handle.
|
// Invalidate each corner handle.
|
||||||
for (size_t c=0; c<HANDLES; ++c) {
|
for (size_t c=0; c<HANDLES; ++c) {
|
||||||
|
@ -2140,14 +2140,14 @@ void SkinTheme::draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int par
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinTheme::paintProgressBar(ui::Graphics* g, const gfx::Rect& rc0, float progress)
|
void SkinTheme::paintProgressBar(ui::Graphics* g, const gfx::Rect& rc0, double progress)
|
||||||
{
|
{
|
||||||
g->drawRect(getColor(ThemeColor::Text), rc0);
|
g->drawRect(getColor(ThemeColor::Text), rc0);
|
||||||
|
|
||||||
gfx::Rect rc = rc0;
|
gfx::Rect rc = rc0;
|
||||||
rc.shrink(1);
|
rc.shrink(1);
|
||||||
|
|
||||||
int u = (int)((float)rc.w*progress);
|
int u = (int)((double)rc.w*progress);
|
||||||
u = MID(0, u, rc.w);
|
u = MID(0, u, rc.w);
|
||||||
|
|
||||||
if (u > 0)
|
if (u > 0)
|
||||||
|
@ -160,7 +160,7 @@ namespace app {
|
|||||||
void draw_bounds_nw2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, int nw1, int nw2, gfx::Color bg1, gfx::Color bg2);
|
void draw_bounds_nw2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, int nw1, int nw2, gfx::Color bg1, gfx::Color bg2);
|
||||||
void draw_part_as_hline(ui::Graphics* g, const gfx::Rect& rc, int part);
|
void draw_part_as_hline(ui::Graphics* g, const gfx::Rect& rc, int part);
|
||||||
void draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int part);
|
void draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int part);
|
||||||
void paintProgressBar(ui::Graphics* g, const gfx::Rect& rc, float progress);
|
void paintProgressBar(ui::Graphics* g, const gfx::Rect& rc, double progress);
|
||||||
|
|
||||||
Style* getStyle(const std::string& id) {
|
Style* getStyle(const std::string& id) {
|
||||||
return m_stylesheet.getStyle(id);
|
return m_stylesheet.getStyle(id);
|
||||||
|
@ -132,8 +132,10 @@ Rules::Rules(const css::Query& query) :
|
|||||||
m_text->setAlign((int)textAlign.number());
|
m_text->setAlign((int)textAlign.number());
|
||||||
m_text->setColor(StyleSheet::convertColor(textColor));
|
m_text->setColor(StyleSheet::convertColor(textColor));
|
||||||
m_text->setPadding(gfx::Border(
|
m_text->setPadding(gfx::Border(
|
||||||
paddingLeft.number(), paddingTop.number(),
|
int(paddingLeft.number()),
|
||||||
paddingRight.number(), paddingBottom.number())*ui::guiscale());
|
int(paddingTop.number()),
|
||||||
|
int(paddingRight.number()),
|
||||||
|
int(paddingBottom.number()*ui::guiscale())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ bool Tabs::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
// Exponential
|
// Exponential
|
||||||
setScrollX(m_begScrollX +
|
setScrollX(m_begScrollX +
|
||||||
(m_endScrollX - m_begScrollX) * (1.0-std::exp(-10.0 * m_ani_t / (double)ANI_SMOOTH_SCROLL_TICKS)));
|
int((m_endScrollX - m_begScrollX) * (1.0-std::exp(-10.0 * m_ani_t / (double)ANI_SMOOTH_SCROLL_TICKS))));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -382,7 +382,8 @@ void Tabs::onPaint(PaintEvent& ev)
|
|||||||
y_delta = box.h * (ANI_ADDING_TAB_TICKS - m_ani_t) / ANI_ADDING_TAB_TICKS;
|
y_delta = box.h * (ANI_ADDING_TAB_TICKS - m_ani_t) / ANI_ADDING_TAB_TICKS;
|
||||||
}
|
}
|
||||||
else if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == tab) {
|
else if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == tab) {
|
||||||
x_delta += m_removedTab->width - m_removedTab->width*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS));
|
x_delta += m_removedTab->width
|
||||||
|
- int(double(m_removedTab->width)*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS)));
|
||||||
x_delta = MID(0, x_delta, m_removedTab->width);
|
x_delta = MID(0, x_delta, m_removedTab->width);
|
||||||
|
|
||||||
// Draw deleted tab
|
// Draw deleted tab
|
||||||
@ -401,7 +402,8 @@ void Tabs::onPaint(PaintEvent& ev)
|
|||||||
if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == NULL) {
|
if (m_ani == ANI_REMOVING_TAB && m_nextTabOfTheRemovedOne == NULL) {
|
||||||
// Draw deleted tab
|
// Draw deleted tab
|
||||||
if (m_removedTab) {
|
if (m_removedTab) {
|
||||||
int x_delta = m_removedTab->width - m_removedTab->width*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS));
|
int x_delta = m_removedTab->width
|
||||||
|
- int(double(m_removedTab->width)*(1.0-std::exp(-10.0 * m_ani_t / (double)ANI_REMOVING_TAB_TICKS)));
|
||||||
x_delta = MID(0, x_delta, m_removedTab->width);
|
x_delta = MID(0, x_delta, m_removedTab->width);
|
||||||
|
|
||||||
gfx::Rect box2(box.x, box.y, x_delta, box.h);
|
gfx::Rect box2(box.x, box.y, x_delta, box.h);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Base Library
|
// Aseprite Base Library
|
||||||
// Copyright (c) 2001-2013 David Capello
|
// Copyright (c) 2001-2013, 2015 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -42,7 +42,7 @@ Sha1 Sha1::calculateFromFile(const std::string& fileName)
|
|||||||
unsigned char buf[1024];
|
unsigned char buf[1024];
|
||||||
while (file.good()) {
|
while (file.good()) {
|
||||||
file.read((char*)buf, 1024);
|
file.read((char*)buf, 1024);
|
||||||
streamsize len = file.gcount();
|
size_t len = (size_t)file.gcount();
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
SHA1Input(&sha, buf, len);
|
SHA1Input(&sha, buf, len);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ void base::this_thread::sleep_for(double seconds)
|
|||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
::Sleep(seconds * 1000.0);
|
::Sleep(DWORD(seconds * 1000.0));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -418,8 +418,8 @@ void algo_spline(double x0, double y0, double x1, double y1,
|
|||||||
x = x0;
|
x = x0;
|
||||||
y = y0;
|
y = y0;
|
||||||
|
|
||||||
out_x1 = x0;
|
out_x1 = (int)x0;
|
||||||
out_y1 = y0;
|
out_y1 = (int)y0;
|
||||||
|
|
||||||
x += .5;
|
x += .5;
|
||||||
y += .5;
|
y += .5;
|
||||||
@ -431,8 +431,8 @@ void algo_spline(double x0, double y0, double x1, double y1,
|
|||||||
x += dx;
|
x += dx;
|
||||||
y += dy;
|
y += dy;
|
||||||
|
|
||||||
out_x2 = x;
|
out_x2 = (int)x;
|
||||||
out_y2 = y;
|
out_y2 = (int)y;
|
||||||
|
|
||||||
proc(out_x1, out_y1, out_x2, out_y2, data);
|
proc(out_x1, out_y1, out_x2, out_y2, data);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (c) 2001-2014 David Capello
|
// Copyright (c) 2001-2015 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -24,7 +24,7 @@ void resize_image(const Image* src, Image* dst, ResizeMethod method, const Palet
|
|||||||
switch (method) {
|
switch (method) {
|
||||||
|
|
||||||
// TODO optimize this
|
// TODO optimize this
|
||||||
case RESIZE_METHOD_NEAREST_NEIGHBOR:
|
case RESIZE_METHOD_NEAREST_NEIGHBOR:
|
||||||
{
|
{
|
||||||
int o_width = src->width(), o_height = src->height();
|
int o_width = src->width(), o_height = src->height();
|
||||||
int n_width = dst->width(), n_height = dst->height();
|
int n_width = dst->width(), n_height = dst->height();
|
||||||
@ -57,8 +57,8 @@ void resize_image(const Image* src, Image* dst, ResizeMethod method, const Palet
|
|||||||
dv = (src->height()-1) * 1.0 / (dst->height()-1);
|
dv = (src->height()-1) * 1.0 / (dst->height()-1);
|
||||||
for (y=0; y<dst->height(); ++y) {
|
for (y=0; y<dst->height(); ++y) {
|
||||||
for (x=0; x<dst->width(); ++x) {
|
for (x=0; x<dst->width(); ++x) {
|
||||||
u_floor = floor(u);
|
u_floor = (int)floor(u);
|
||||||
v_floor = floor(v);
|
v_floor = (int)floor(v);
|
||||||
|
|
||||||
if (u_floor > src->width()-1) {
|
if (u_floor > src->width()-1) {
|
||||||
u_floor = src->width()-1;
|
u_floor = src->width()-1;
|
||||||
@ -92,34 +92,34 @@ void resize_image(const Image* src, Image* dst, ResizeMethod method, const Palet
|
|||||||
|
|
||||||
switch (dst->pixelFormat()) {
|
switch (dst->pixelFormat()) {
|
||||||
case IMAGE_RGB: {
|
case IMAGE_RGB: {
|
||||||
int r = ((rgba_getr(color[0])*u2 + rgba_getr(color[1])*u1)*v2 +
|
int r = int((rgba_getr(color[0])*u2 + rgba_getr(color[1])*u1)*v2 +
|
||||||
(rgba_getr(color[2])*u2 + rgba_getr(color[3])*u1)*v1);
|
(rgba_getr(color[2])*u2 + rgba_getr(color[3])*u1)*v1);
|
||||||
int g = ((rgba_getg(color[0])*u2 + rgba_getg(color[1])*u1)*v2 +
|
int g = int((rgba_getg(color[0])*u2 + rgba_getg(color[1])*u1)*v2 +
|
||||||
(rgba_getg(color[2])*u2 + rgba_getg(color[3])*u1)*v1);
|
(rgba_getg(color[2])*u2 + rgba_getg(color[3])*u1)*v1);
|
||||||
int b = ((rgba_getb(color[0])*u2 + rgba_getb(color[1])*u1)*v2 +
|
int b = int((rgba_getb(color[0])*u2 + rgba_getb(color[1])*u1)*v2 +
|
||||||
(rgba_getb(color[2])*u2 + rgba_getb(color[3])*u1)*v1);
|
(rgba_getb(color[2])*u2 + rgba_getb(color[3])*u1)*v1);
|
||||||
int a = ((rgba_geta(color[0])*u2 + rgba_geta(color[1])*u1)*v2 +
|
int a = int((rgba_geta(color[0])*u2 + rgba_geta(color[1])*u1)*v2 +
|
||||||
(rgba_geta(color[2])*u2 + rgba_geta(color[3])*u1)*v1);
|
(rgba_geta(color[2])*u2 + rgba_geta(color[3])*u1)*v1);
|
||||||
dst_color = rgba(r, g, b, a);
|
dst_color = rgba(r, g, b, a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAGE_GRAYSCALE: {
|
case IMAGE_GRAYSCALE: {
|
||||||
int v = ((graya_getv(color[0])*u2 + graya_getv(color[1])*u1)*v2 +
|
int v = int((graya_getv(color[0])*u2 + graya_getv(color[1])*u1)*v2 +
|
||||||
(graya_getv(color[2])*u2 + graya_getv(color[3])*u1)*v1);
|
(graya_getv(color[2])*u2 + graya_getv(color[3])*u1)*v1);
|
||||||
int a = ((graya_geta(color[0])*u2 + graya_geta(color[1])*u1)*v2 +
|
int a = int((graya_geta(color[0])*u2 + graya_geta(color[1])*u1)*v2 +
|
||||||
(graya_geta(color[2])*u2 + graya_geta(color[3])*u1)*v1);
|
(graya_geta(color[2])*u2 + graya_geta(color[3])*u1)*v1);
|
||||||
dst_color = graya(v, a);
|
dst_color = graya(v, a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAGE_INDEXED: {
|
case IMAGE_INDEXED: {
|
||||||
int r = ((rgba_getr(pal->getEntry(color[0]))*u2 + rgba_getr(pal->getEntry(color[1]))*u1)*v2 +
|
int r = int((rgba_getr(pal->getEntry(color[0]))*u2 + rgba_getr(pal->getEntry(color[1]))*u1)*v2 +
|
||||||
(rgba_getr(pal->getEntry(color[2]))*u2 + rgba_getr(pal->getEntry(color[3]))*u1)*v1);
|
(rgba_getr(pal->getEntry(color[2]))*u2 + rgba_getr(pal->getEntry(color[3]))*u1)*v1);
|
||||||
int g = ((rgba_getg(pal->getEntry(color[0]))*u2 + rgba_getg(pal->getEntry(color[1]))*u1)*v2 +
|
int g = int((rgba_getg(pal->getEntry(color[0]))*u2 + rgba_getg(pal->getEntry(color[1]))*u1)*v2 +
|
||||||
(rgba_getg(pal->getEntry(color[2]))*u2 + rgba_getg(pal->getEntry(color[3]))*u1)*v1);
|
(rgba_getg(pal->getEntry(color[2]))*u2 + rgba_getg(pal->getEntry(color[3]))*u1)*v1);
|
||||||
int b = ((rgba_getb(pal->getEntry(color[0]))*u2 + rgba_getb(pal->getEntry(color[1]))*u1)*v2 +
|
int b = int((rgba_getb(pal->getEntry(color[0]))*u2 + rgba_getb(pal->getEntry(color[1]))*u1)*v2 +
|
||||||
(rgba_getb(pal->getEntry(color[2]))*u2 + rgba_getb(pal->getEntry(color[3]))*u1)*v1);
|
(rgba_getb(pal->getEntry(color[2]))*u2 + rgba_getb(pal->getEntry(color[3]))*u1)*v1);
|
||||||
int a = (((color[0] == 0 ? 0: 255)*u2 + (color[1] == 0 ? 0: 255)*u1)*v2 +
|
int a = int(((color[0] == 0 ? 0: 255)*u2 + (color[1] == 0 ? 0: 255)*u1)*v2 +
|
||||||
((color[2] == 0 ? 0: 255)*u2 + (color[3] == 0 ? 0: 255)*u1)*v1);
|
((color[2] == 0 ? 0: 255)*u2 + (color[3] == 0 ? 0: 255)*u1)*v1);
|
||||||
dst_color = a > 127 ? rgbmap->mapColor(r, g, b): 0;
|
dst_color = a > 127 ? rgbmap->mapColor(r, g, b): 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (c) 2001-2014 David Capello
|
// Copyright (c) 2001-2015 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -96,7 +96,7 @@ void Brush::regenerate()
|
|||||||
|
|
||||||
int size = m_size;
|
int size = m_size;
|
||||||
if (m_type == kSquareBrushType && m_angle != 0 && m_size > 2)
|
if (m_type == kSquareBrushType && m_angle != 0 && m_size > 2)
|
||||||
size = std::sqrt((double)2*m_size*m_size)+2;
|
size = (int)std::sqrt((double)2*m_size*m_size)+2;
|
||||||
|
|
||||||
m_image = Image::create(IMAGE_BITMAP, size, size);
|
m_image = Image::create(IMAGE_BITMAP, size, size);
|
||||||
|
|
||||||
@ -121,14 +121,14 @@ void Brush::regenerate()
|
|||||||
int c = size/2;
|
int c = size/2;
|
||||||
int r = m_size/2;
|
int r = m_size/2;
|
||||||
int d = m_size;
|
int d = m_size;
|
||||||
int x1 = c + r*cos(a-PI/2) + r*cos(a-PI);
|
int x1 = int(c + r*cos(a-PI/2) + r*cos(a-PI));
|
||||||
int y1 = c - r*sin(a-PI/2) - r*sin(a-PI);
|
int y1 = int(c - r*sin(a-PI/2) - r*sin(a-PI));
|
||||||
int x2 = x1 + d*cos(a);
|
int x2 = int(x1 + d*cos(a));
|
||||||
int y2 = y1 - d*sin(a);
|
int y2 = int(y1 - d*sin(a));
|
||||||
int x3 = x2 + d*cos(a+PI/2);
|
int x3 = int(x2 + d*cos(a+PI/2));
|
||||||
int y3 = y2 - d*sin(a+PI/2);
|
int y3 = int(y2 - d*sin(a+PI/2));
|
||||||
int x4 = x3 + d*cos(a+PI);
|
int x4 = int(x3 + d*cos(a+PI));
|
||||||
int y4 = y3 - d*sin(a+PI);
|
int y4 = int(y3 - d*sin(a+PI));
|
||||||
int points[8] = { x1, y1, x2, y2, x3, y3, x4, y4 };
|
int points[8] = { x1, y1, x2, y2, x3, y3, x4, y4 };
|
||||||
|
|
||||||
doc::algorithm::polygon(4, points, m_image, algo_hline);
|
doc::algorithm::polygon(4, points, m_image, algo_hline);
|
||||||
@ -137,12 +137,12 @@ void Brush::regenerate()
|
|||||||
|
|
||||||
case kLineBrushType: {
|
case kLineBrushType: {
|
||||||
double a = PI * m_angle / 180;
|
double a = PI * m_angle / 180;
|
||||||
float r = m_size/2;
|
double r = m_size/2;
|
||||||
float d = m_size;
|
double d = m_size;
|
||||||
int x1 = r + r*cos(a+PI);
|
int x1 = int(r + r*cos(a+PI));
|
||||||
int y1 = r - r*sin(a+PI);
|
int y1 = int(r - r*sin(a+PI));
|
||||||
int x2 = x1 + d*cos(a);
|
int x2 = int(x1 + d*cos(a));
|
||||||
int y2 = y1 - d*sin(a);
|
int y2 = int(y1 - d*sin(a));
|
||||||
|
|
||||||
draw_line(m_image, x1, y1, x2, y2, BitmapTraits::max_value);
|
draw_line(m_image, x1, y1, x2, y2, BitmapTraits::max_value);
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2001-2013 David Capello
|
// Copyright (C) 2001-2013, 2015 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -26,7 +26,7 @@ namespace ui {
|
|||||||
using namespace gfx;
|
using namespace gfx;
|
||||||
|
|
||||||
IntEntry::IntEntry(int min, int max)
|
IntEntry::IntEntry(int min, int max)
|
||||||
: Entry(std::ceil(std::log10((double)max))+1, "")
|
: Entry(int(std::ceil(std::log10((double)max)))+1, "")
|
||||||
, m_min(min)
|
, m_min(min)
|
||||||
, m_max(max)
|
, m_max(max)
|
||||||
, m_popupWindow(NULL)
|
, m_popupWindow(NULL)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
// Copyright (C) 2001-2013 David Capello
|
// Copyright (C) 2001-2013, 2015 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
@ -189,10 +189,10 @@ void Splitter::onResize(ResizeEvent& ev)
|
|||||||
pos.y = rect.y; \
|
pos.y = rect.y; \
|
||||||
switch (m_type) { \
|
switch (m_type) { \
|
||||||
case ByPercentage: \
|
case ByPercentage: \
|
||||||
pos.w = avail*m_pos/100; \
|
pos.w = int(avail*m_pos/100); \
|
||||||
break; \
|
break; \
|
||||||
case ByPixel: \
|
case ByPixel: \
|
||||||
pos.w = m_pos; \
|
pos.w = int(m_pos); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user