mirror of https://github.com/aseprite/aseprite.git
Merge branch 'beta' into tilemap-editor
This commit is contained in:
commit
0bae04f40b
2
laf
2
laf
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2ecf7a9827f6d187d4e1b9a25b354d6a6b636096
|
Subproject commit c8e6b958fdcca7809ab2b50f9cfed7d9387a2c86
|
||||||
|
|
@ -55,10 +55,10 @@
|
||||||
#include "app/util/layer_utils.h"
|
#include "app/util/layer_utils.h"
|
||||||
#include "base/chrono.h"
|
#include "base/chrono.h"
|
||||||
#include "base/clamp.h"
|
#include "base/clamp.h"
|
||||||
#include "base/convert_to.h"
|
|
||||||
#include "doc/doc.h"
|
#include "doc/doc.h"
|
||||||
#include "doc/mask_boundaries.h"
|
#include "doc/mask_boundaries.h"
|
||||||
#include "doc/slice.h"
|
#include "doc/slice.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
#include "os/color_space.h"
|
#include "os/color_space.h"
|
||||||
#include "os/display.h"
|
#include "os/display.h"
|
||||||
#include "os/surface.h"
|
#include "os/surface.h"
|
||||||
|
|
@ -94,6 +94,10 @@ public:
|
||||||
return m_editor;
|
return m_editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Graphics* getGraphics() override {
|
||||||
|
return m_g;
|
||||||
|
}
|
||||||
|
|
||||||
void drawLine(gfx::Color color, int x1, int y1, int x2, int y2) override {
|
void drawLine(gfx::Color color, int x1, int y1, int x2, int y2) override {
|
||||||
gfx::Point a(x1, y1);
|
gfx::Point a(x1, y1);
|
||||||
gfx::Point b(x2, y2);
|
gfx::Point b(x2, y2);
|
||||||
|
|
@ -1232,7 +1236,7 @@ void Editor::drawCelHGuide(ui::Graphics* g,
|
||||||
const int dottedX)
|
const int dottedX)
|
||||||
{
|
{
|
||||||
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
|
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
|
||||||
g->drawHLine(color, scrX1, scrY, scrX2 - scrX1);
|
g->drawHLine(color, std::min(scrX1, scrX2), scrY, std::abs(scrX2 - scrX1));
|
||||||
|
|
||||||
// Vertical guide to touch the horizontal line
|
// Vertical guide to touch the horizontal line
|
||||||
{
|
{
|
||||||
|
|
@ -1244,7 +1248,7 @@ void Editor::drawCelHGuide(ui::Graphics* g,
|
||||||
g->drawVLine(color, dottedX, scrCmpBounds.y2(), scrCelBounds.y2() - scrCmpBounds.y2());
|
g->drawVLine(color, dottedX, scrCmpBounds.y2(), scrCelBounds.y2() - scrCmpBounds.y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto text = base::convert_to<std::string>(ABS(sprX2 - sprX1)) + "px";
|
auto text = fmt::format("{}px", ABS(sprX2 - sprX1));
|
||||||
const int textW = Graphics::measureUITextLength(text, font());
|
const int textW = Graphics::measureUITextLength(text, font());
|
||||||
g->drawText(text,
|
g->drawText(text,
|
||||||
color_utils::blackandwhite_neg(color), color,
|
color_utils::blackandwhite_neg(color), color,
|
||||||
|
|
@ -1258,7 +1262,7 @@ void Editor::drawCelVGuide(ui::Graphics* g,
|
||||||
const int dottedY)
|
const int dottedY)
|
||||||
{
|
{
|
||||||
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
|
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
|
||||||
g->drawVLine(color, scrX, scrY1, scrY2 - scrY1);
|
g->drawVLine(color, scrX, std::min(scrY1, scrY2), std::abs(scrY2 - scrY1));
|
||||||
|
|
||||||
// Horizontal guide to touch the vertical line
|
// Horizontal guide to touch the vertical line
|
||||||
{
|
{
|
||||||
|
|
@ -1270,7 +1274,7 @@ void Editor::drawCelVGuide(ui::Graphics* g,
|
||||||
g->drawHLine(color, scrCmpBounds.x2(), dottedY, scrCelBounds.x2() - scrCmpBounds.x2());
|
g->drawHLine(color, scrCmpBounds.x2(), dottedY, scrCelBounds.x2() - scrCmpBounds.x2());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto text = base::convert_to<std::string>(ABS(sprY2 - sprY1)) + "px";
|
auto text = fmt::format("{}px", ABS(sprY2 - sprY1));
|
||||||
g->drawText(text,
|
g->drawText(text,
|
||||||
color_utils::blackandwhite_neg(color), color,
|
color_utils::blackandwhite_neg(color), color,
|
||||||
gfx::Point(scrX, (scrY1+scrY2)/2-textHeight()/2));
|
gfx::Point(scrX, (scrY1+scrY2)/2-textHeight()/2));
|
||||||
|
|
@ -2610,7 +2614,7 @@ void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
|
||||||
Menu menu;
|
Menu menu;
|
||||||
|
|
||||||
for (double option : options) {
|
for (double option : options) {
|
||||||
MenuItem* item = new MenuItem("Speed x" + base::convert_to<std::string>(option));
|
MenuItem* item = new MenuItem(fmt::format("Speed x{}", option));
|
||||||
item->Click.connect([this, option]{ setAnimationSpeedMultiplier(option); });
|
item->Click.connect([this, option]{ setAnimationSpeedMultiplier(option); });
|
||||||
item->setSelected(m_aniSpeed == option);
|
item->setSelected(m_aniSpeed == option);
|
||||||
menu.addChild(item);
|
menu.addChild(item);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
|
@ -36,6 +37,7 @@ namespace app {
|
||||||
public:
|
public:
|
||||||
virtual ~EditorPostRender() { }
|
virtual ~EditorPostRender() { }
|
||||||
virtual Editor* getEditor() = 0;
|
virtual Editor* getEditor() = 0;
|
||||||
|
virtual ui::Graphics* getGraphics() = 0;
|
||||||
virtual void drawLine(gfx::Color color, int x1, int y1, int x2, int y2) = 0;
|
virtual void drawLine(gfx::Color color, int x1, int y1, int x2, int y2) = 0;
|
||||||
virtual void drawRectXor(const gfx::Rect& rc) = 0;
|
virtual void drawRectXor(const gfx::Rect& rc) = 0;
|
||||||
virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0;
|
virtual void fillRect(gfx::Color color, const gfx::Rect& rc) = 0;
|
||||||
|
|
|
||||||
|
|
@ -1002,7 +1002,8 @@ void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render)
|
||||||
tools::Ink* ink = editor->getCurrentEditorInk();
|
tools::Ink* ink = editor->getCurrentEditorInk();
|
||||||
|
|
||||||
if (ink->isSelection()) {
|
if (ink->isSelection()) {
|
||||||
getTransformHandles(editor)->drawHandles(editor,
|
getTransformHandles(editor)
|
||||||
|
->drawHandles(editor, render->getGraphics(),
|
||||||
m_standbyState->getTransformation(editor));
|
m_standbyState->getTransformation(editor));
|
||||||
|
|
||||||
m_standbyState->m_transformSelectionHandlesAreVisible = true;
|
m_standbyState->m_transformSelectionHandlesAreVisible = true;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
|
@ -84,9 +85,9 @@ HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point&
|
||||||
return NoHandle;
|
return NoHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformHandles::drawHandles(Editor* editor, const Transformation& transform)
|
void TransformHandles::drawHandles(Editor* editor, ui::Graphics* g,
|
||||||
|
const Transformation& transform)
|
||||||
{
|
{
|
||||||
ScreenGraphics g;
|
|
||||||
fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI);
|
fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI);
|
||||||
|
|
||||||
Transformation::Corners corners;
|
Transformation::Corners corners;
|
||||||
|
|
@ -95,29 +96,31 @@ void TransformHandles::drawHandles(Editor* editor, const Transformation& transfo
|
||||||
std::vector<gfx::Point> screenPoints;
|
std::vector<gfx::Point> screenPoints;
|
||||||
getScreenPoints(editor, corners, screenPoints);
|
getScreenPoints(editor, corners, screenPoints);
|
||||||
|
|
||||||
// TODO DO NOT COMMIT
|
const gfx::Point origin = editor->bounds().origin();
|
||||||
|
|
||||||
#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)
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
{
|
{
|
||||||
gfx::Point
|
gfx::Point
|
||||||
a(transform.bounds().origin()),
|
a(transform.bounds().origin()),
|
||||||
b(transform.bounds().point2());
|
b(transform.bounds().point2());
|
||||||
a = editor->editorToScreen(a);
|
a = editor->editorToScreen(a) - origin;
|
||||||
b = editor->editorToScreen(b);
|
b = editor->editorToScreen(b) - origin;
|
||||||
g.drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a, b));
|
g->drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a, b));
|
||||||
|
|
||||||
a = transform.pivot();
|
a = transform.pivot();
|
||||||
a = editor->editorToScreen(a);
|
a = editor->editorToScreen(a) - origin;
|
||||||
g.drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a.x-2, a.y-2, 5, 5));
|
g->drawRect(gfx::rgba(255, 0, 0), gfx::Rect(a.x-2, a.y-2, 5, 5));
|
||||||
}
|
}
|
||||||
// -----------------------------------------------
|
// -----------------------------------------------
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Draw corner handle
|
// Draw corner handle
|
||||||
for (size_t c=0; c<HANDLES; ++c) {
|
for (size_t c=0; c<HANDLES; ++c) {
|
||||||
drawHandle(&g,
|
drawHandle(
|
||||||
(screenPoints[handles_info[c].i1].x+screenPoints[handles_info[c].i2].x)/2,
|
g,
|
||||||
(screenPoints[handles_info[c].i1].y+screenPoints[handles_info[c].i2].y)/2,
|
(screenPoints[handles_info[c].i1].x+screenPoints[handles_info[c].i2].x)/2 - origin.x,
|
||||||
|
(screenPoints[handles_info[c].i1].y+screenPoints[handles_info[c].i2].y)/2 - origin.y,
|
||||||
angle + handles_info[c].angle);
|
angle + handles_info[c].angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,7 +130,9 @@ void TransformHandles::drawHandles(Editor* editor, const Transformation& transfo
|
||||||
SkinTheme* theme = SkinTheme::instance();
|
SkinTheme* theme = SkinTheme::instance();
|
||||||
os::Surface* part = theme->parts.pivotHandle()->bitmap(0);
|
os::Surface* part = theme->parts.pivotHandle()->bitmap(0);
|
||||||
|
|
||||||
g.drawRgbaSurface(part, pivotBounds.x, pivotBounds.y);
|
g->drawRgbaSurface(part,
|
||||||
|
pivotBounds.x - origin.x,
|
||||||
|
pivotBounds.y - origin.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
|
|
@ -30,7 +31,8 @@ namespace app {
|
||||||
// has applied the given transformation to the selection.
|
// has applied the given transformation to the selection.
|
||||||
HandleType getHandleAtPoint(Editor* editor, const gfx::Point& pt, const Transformation& transform);
|
HandleType getHandleAtPoint(Editor* editor, const gfx::Point& pt, const Transformation& transform);
|
||||||
|
|
||||||
void drawHandles(Editor* editor, const Transformation& transform);
|
void drawHandles(Editor* editor, ui::Graphics* g,
|
||||||
|
const Transformation& transform);
|
||||||
void invalidateHandles(Editor* editor, const Transformation& transform);
|
void invalidateHandles(Editor* editor, const Transformation& transform);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue