Merge branch 'master' into beta

This commit is contained in:
David Capello 2016-12-06 12:05:44 -03:00
commit f989dcd9e9
7 changed files with 53 additions and 52 deletions

View File

@ -263,8 +263,8 @@
</section>
<section id="symmetry">
<option id="mode" type="SymmetryMode" default="SymmetryMode::NONE" />
<option id="x_axis" type="int" default="0" />
<option id="y_axis" type="int" default="0" />
<option id="x_axis" type="double" default="0" />
<option id="y_axis" type="double" default="0" />
</section>
<section id="grid">
<option id="snap" type="bool" default="false" migrate="Grid.SnapTo" />

View File

@ -164,28 +164,25 @@
<separator horizontal="true" expansive="true" />
</hbox>
<grid columns="3">
<grid columns="5">
<label text="X:" />
<hbox cell_hspan="2">
<entry id="grid_x" text="" maxsize="4" />
<label text="Y:" />
<entry id="grid_y" text="" maxsize="4" />
</hbox>
<entry id="grid_x" text="" maxsize="4" />
<label text="Y:" />
<entry id="grid_y" text="" maxsize="4" />
<hbox />
<label text="Width:" />
<hbox cell_hspan="2">
<entry id="grid_w" text="" maxsize="4" />
<label text="Height:" />
<entry id="grid_h" text="" maxsize="4" />
</hbox>
<entry id="grid_w" text="" maxsize="4" />
<label text="Height:" />
<entry id="grid_h" text="" maxsize="4" />
<hbox />
<label text="Color:" />
<box id="grid_color_placeholder" /><!-- custom widget -->
<box id="grid_color_placeholder" cell_hspan="3" /><!-- custom widget -->
<hbox />
<label text="Opacity:" />
<slider id="grid_opacity" min="1" max="255" width="128" />
<slider id="grid_opacity" cell_hspan="3" min="1" max="255" width="128" />
<check id="grid_auto_opacity" text="Auto" />
</grid>

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2015 David Capello
// Copyright (C) 2015-2016 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -16,20 +16,20 @@ namespace tools {
class HorizontalSymmetry : public Symmetry {
public:
HorizontalSymmetry(int x) : m_x(x) { }
HorizontalSymmetry(double x) : m_x(x) { }
void generateStrokes(const Stroke& mainStroke, Strokes& strokes,
ToolLoop* loop) override;
private:
int m_x;
double m_x;
};
class VerticalSymmetry : public Symmetry {
public:
VerticalSymmetry(int y) : m_y(y) { }
VerticalSymmetry(double y) : m_y(y) { }
void generateStrokes(const Stroke& mainStroke, Strokes& strokes,
ToolLoop* loop) override;
private:
int m_y;
double m_y;
};
} // namespace tools

View File

@ -749,23 +749,23 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
// Do nothing
break;
case app::gen::SymmetryMode::HORIZONTAL: {
int x = m_docPref.symmetry.xAxis();
double x = m_docPref.symmetry.xAxis();
if (x > 0) {
gfx::Color color = color_utils::color_for_ui(m_docPref.grid.color());
g->drawVLine(color,
spriteRect.x + m_proj.applyX(x),
spriteRect.x + m_proj.applyX<double>(x),
enclosingRect.y,
enclosingRect.h);
}
break;
}
case app::gen::SymmetryMode::VERTICAL: {
int y = m_docPref.symmetry.yAxis();
double y = m_docPref.symmetry.yAxis();
if (y > 0) {
gfx::Color color = color_utils::color_for_ui(m_docPref.grid.color());
g->drawHLine(color,
enclosingRect.x,
spriteRect.y + m_proj.applyY(y),
spriteRect.y + m_proj.applyY<double>(y),
enclosingRect.w);
}
break;

View File

@ -14,18 +14,20 @@
#include "app/ui/status_bar.h"
#include "ui/message.h"
#include <cmath>
namespace app {
using namespace ui;
MovingSymmetryState::MovingSymmetryState(Editor* editor, MouseMessage* msg,
app::gen::SymmetryMode mode,
Option<int>& symmetryAxis)
Option<double>& symmetryAxis)
: m_symmetryMode(mode)
, m_symmetryAxis(symmetryAxis)
, m_symmetryAxisStart(symmetryAxis())
{
m_mouseStart = editor->screenToEditor(msg->position());
m_mouseStart = editor->screenToEditorF(msg->position());
editor->captureMouse();
}
@ -38,18 +40,20 @@ bool MovingSymmetryState::onMouseUp(Editor* editor, MouseMessage* msg)
bool MovingSymmetryState::onMouseMove(Editor* editor, MouseMessage* msg)
{
gfx::Point newCursorPos = editor->screenToEditor(msg->position());
gfx::Point delta = newCursorPos - m_mouseStart;
int pos = 0;
gfx::PointF newCursorPos = editor->screenToEditorF(msg->position());
gfx::PointF delta = newCursorPos - m_mouseStart;
double pos = 0.0;
switch (m_symmetryMode) {
case app::gen::SymmetryMode::HORIZONTAL:
pos = m_symmetryAxisStart + delta.x;
pos = MID(1, pos, editor->sprite()->width()-1);
pos = std::round(pos*2.0)/2.0;
pos = MID(1.0, pos, editor->sprite()->width()-1.0);
break;
case app::gen::SymmetryMode::VERTICAL:
pos = m_symmetryAxisStart + delta.y;
pos = MID(1, pos, editor->sprite()->height()-1);
pos = std::round(pos*2.0)/2.0;
pos = MID(1.0, pos, editor->sprite()->height()-1.0);
break;
}
m_symmetryAxis(pos);
@ -65,12 +69,12 @@ bool MovingSymmetryState::onUpdateStatusBar(Editor* editor)
{
if (m_symmetryMode == app::gen::SymmetryMode::HORIZONTAL)
StatusBar::instance()->setStatusText
(0, "Left %3d Right %3d", m_symmetryAxis(),
editor->sprite()->width() - m_symmetryAxis());
(0, "Left %3.1f Right %3.1f", m_symmetryAxis(),
double(editor->sprite()->width()) - m_symmetryAxis());
else
StatusBar::instance()->setStatusText
(0, "Top %3d Bottom %3d", m_symmetryAxis(),
editor->sprite()->height() - m_symmetryAxis());
(0, "Top %3.1f Bottom %3.1f", m_symmetryAxis(),
double(editor->sprite()->height()) - m_symmetryAxis());
return true;
}

View File

@ -18,7 +18,7 @@ namespace app {
public:
MovingSymmetryState(Editor* editor, ui::MouseMessage* msg,
app::gen::SymmetryMode mode,
Option<int>& symmetryAxis);
Option<double>& symmetryAxis);
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
@ -28,9 +28,9 @@ namespace app {
private:
app::gen::SymmetryMode m_symmetryMode;
Option<int>& m_symmetryAxis;
Option<double>& m_symmetryAxis;
int m_symmetryAxisStart;
gfx::Point m_mouseStart;
gfx::PointF m_mouseStart;
};
} // namespace app

View File

@ -811,29 +811,29 @@ bool StandbyState::Decorator::getSymmetryHandles(Editor* editor, gfx::Rect& box1
auto mode = symmetry.mode();
if (mode != app::gen::SymmetryMode::NONE) {
bool horz = (mode == app::gen::SymmetryMode::HORIZONTAL);
int pos = (horz ? symmetry.xAxis():
symmetry.yAxis());
gfx::Rect spriteBounds = editor->sprite()->bounds();
gfx::Rect editorViewport = View::getView(editor)->viewportBounds();
double pos = (horz ? symmetry.xAxis():
symmetry.yAxis());
gfx::RectF spriteBounds = gfx::RectF(editor->sprite()->bounds());
gfx::RectF editorViewport = gfx::RectF(View::getView(editor)->viewportBounds());
skin::SkinTheme* theme = static_cast<skin::SkinTheme*>(CurrentTheme::get());
she::Surface* part = theme->parts.transformationHandle()->bitmap(0);
gfx::Point pt1, pt2;
gfx::PointF pt1, pt2;
if (horz) {
pt1 = gfx::Point(spriteBounds.x+pos, spriteBounds.y);
pt1 = editor->editorToScreen(pt1);
pt2 = gfx::Point(spriteBounds.x+pos, spriteBounds.y+spriteBounds.h);
pt2 = editor->editorToScreen(pt2);
pt1 = gfx::PointF(spriteBounds.x+pos, spriteBounds.y);
pt1 = editor->editorToScreenF(pt1);
pt2 = gfx::PointF(spriteBounds.x+pos, spriteBounds.y+spriteBounds.h);
pt2 = editor->editorToScreenF(pt2);
pt1.y = std::max(pt1.y-part->height(), editorViewport.y);
pt2.y = std::min(pt2.y, editorViewport.point2().y-part->height());
pt1.x -= part->width()/2;
pt2.x -= part->width()/2;
}
else {
pt1 = gfx::Point(spriteBounds.x, spriteBounds.y+pos);
pt1 = editor->editorToScreen(pt1);
pt2 = gfx::Point(spriteBounds.x+spriteBounds.w, spriteBounds.y+pos);
pt2 = editor->editorToScreen(pt2);
pt1 = gfx::PointF(spriteBounds.x, spriteBounds.y+pos);
pt1 = editor->editorToScreenF(pt1);
pt2 = gfx::PointF(spriteBounds.x+spriteBounds.w, spriteBounds.y+pos);
pt2 = editor->editorToScreenF(pt2);
pt1.x = std::max(pt1.x-part->width(), editorViewport.x);
pt2.x = std::min(pt2.x, editorViewport.point2().x-part->width());
pt1.y -= part->height()/2;