mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Rename "checked" -> "checkered" (background, drawing routines, etc.)
Also rename setBgCheckedSize -> setBgStripeSize in case we add new background patterns (like horizontal/vertical/diagonal stripes, etc.)
This commit is contained in:
parent
2367c8526b
commit
4e12e427ef
@ -32,12 +32,12 @@
|
||||
<value id="FULLNEDGES" value="4" />
|
||||
</enum>
|
||||
<enum id="BgType">
|
||||
<value id="CHECKED_16x16" value="0" />
|
||||
<value id="CHECKED_8x8" value="1" />
|
||||
<value id="CHECKED_4x4" value="2" />
|
||||
<value id="CHECKED_2x2" value="3" />
|
||||
<value id="CHECKED_1x1" value="4" />
|
||||
<value id="CHECKED_CUSTOM" value="5" />
|
||||
<value id="CHECKERED_16x16" value="0" />
|
||||
<value id="CHECKERED_8x8" value="1" />
|
||||
<value id="CHECKERED_4x4" value="2" />
|
||||
<value id="CHECKERED_2x2" value="3" />
|
||||
<value id="CHECKERED_1x1" value="4" />
|
||||
<value id="CHECKERED_CUSTOM" value="5" />
|
||||
</enum>
|
||||
<enum id="StopAtGrid">
|
||||
<value id="NEVER" value="0" />
|
||||
@ -455,7 +455,7 @@
|
||||
<option id="auto_opacity" type="bool" default="true" />
|
||||
</section>
|
||||
<section id="bg" canforce="true">
|
||||
<option id="type" type="BgType" default="BgType::CHECKED_16x16" />
|
||||
<option id="type" type="BgType" default="BgType::CHECKERED_16x16" />
|
||||
<option id="size" type="gfx::Size" default="gfx::Size(16, 16)" />
|
||||
<option id="zoom" type="bool" default="true" />
|
||||
<option id="color1" type="app::Color" default="app::Color::fromRgb(128, 128, 128)" />
|
||||
|
@ -1218,7 +1218,7 @@ brush_preview_fullnedges = Full Preview and Edges
|
||||
cursor_color_type = Crosshair && Brush Edges Color:
|
||||
cursor_neg_bw = Negative Black and White
|
||||
cursor_specific_color = Specific Color
|
||||
bg_checked = Checked Background
|
||||
bg_checkered = Checkered Background
|
||||
bg_size = Size:
|
||||
bg_apply_zoom = Apply Zoom
|
||||
bg_colors = Colors:
|
||||
|
@ -317,20 +317,20 @@
|
||||
<vbox id="section_bg">
|
||||
<combobox id="bg_scope" />
|
||||
|
||||
<separator text="@.bg_checked" horizontal="true" />
|
||||
<separator text="@.bg_checkered" horizontal="true" />
|
||||
<grid columns="2">
|
||||
<label text="@.bg_size" />
|
||||
<hbox>
|
||||
<combobox id="checked_bg_size" />
|
||||
<expr id="checked_bg_custom_w" />
|
||||
<expr id="checked_bg_custom_h" />
|
||||
<check text="@.bg_apply_zoom" id="checked_bg_zoom" />
|
||||
<combobox id="checkered_bg_size" />
|
||||
<expr id="checkered_bg_custom_w" />
|
||||
<expr id="checkered_bg_custom_h" />
|
||||
<check text="@.bg_apply_zoom" id="checkered_bg_zoom" />
|
||||
</hbox>
|
||||
|
||||
<label text="@.bg_colors" />
|
||||
<hbox>
|
||||
<colorpicker id="checked_bg_color1" rgba="true" />
|
||||
<colorpicker id="checked_bg_color2" rgba="true" />
|
||||
<colorpicker id="checkered_bg_color1" rgba="true" />
|
||||
<colorpicker id="checkered_bg_color2" rgba="true" />
|
||||
</hbox>
|
||||
</grid>
|
||||
|
||||
|
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 0f6c63166d5cdf00137775f78a9bd2046360ebaa
|
||||
Subproject commit 858acb25f0fc645e52ff64d5a00378d2fdb81202
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -149,7 +149,7 @@ protected:
|
||||
else if (keyMsg->scancode() == kKeyMinusPad ||
|
||||
keyMsg->unicodeChar() == '-') {
|
||||
if (m_index_bg_color >= 0) {
|
||||
--m_index_bg_color; // can be -1 which is the checked background
|
||||
--m_index_bg_color; // can be -1 which is the checkered background
|
||||
|
||||
invalidate();
|
||||
}
|
||||
@ -199,7 +199,8 @@ protected:
|
||||
render.setProjection(m_proj);
|
||||
if (m_index_bg_color == -1) {
|
||||
render.setupBackground(m_doc, m_doublebuf->pixelFormat());
|
||||
render.renderCheckedBackground(m_doublebuf.get(),
|
||||
render.renderCheckeredBackground(
|
||||
m_doublebuf.get(),
|
||||
gfx::Clip(0, 0, -m_pos.x, -m_pos.y,
|
||||
m_doublebuf->width(), m_doublebuf->height()));
|
||||
}
|
||||
|
@ -486,17 +486,17 @@ public:
|
||||
slideZoom()->setVisible(false);
|
||||
#endif
|
||||
|
||||
// Checked background size
|
||||
static_assert(int(app::gen::BgType::CHECKED_16x16) == 0, "");
|
||||
static_assert(int(app::gen::BgType::CHECKED_1x1) == 4, "");
|
||||
static_assert(int(app::gen::BgType::CHECKED_CUSTOM) == 5, "");
|
||||
checkedBgSize()->addItem("16x16");
|
||||
checkedBgSize()->addItem("8x8");
|
||||
checkedBgSize()->addItem("4x4");
|
||||
checkedBgSize()->addItem("2x2");
|
||||
checkedBgSize()->addItem("1x1");
|
||||
checkedBgSize()->addItem("Custom");
|
||||
checkedBgSize()->Change.connect([this]{ onCheckedBgSizeChange(); });
|
||||
// Checkered background size
|
||||
static_assert(int(app::gen::BgType::CHECKERED_16x16) == 0, "");
|
||||
static_assert(int(app::gen::BgType::CHECKERED_1x1) == 4, "");
|
||||
static_assert(int(app::gen::BgType::CHECKERED_CUSTOM) == 5, "");
|
||||
checkeredBgSize()->addItem("16x16");
|
||||
checkeredBgSize()->addItem("8x8");
|
||||
checkeredBgSize()->addItem("4x4");
|
||||
checkeredBgSize()->addItem("2x2");
|
||||
checkeredBgSize()->addItem("1x1");
|
||||
checkeredBgSize()->addItem("Custom");
|
||||
checkeredBgSize()->Change.connect([this]{ onCheckeredBgSizeChange(); });
|
||||
|
||||
// Reset buttons
|
||||
resetBg()->Click.connect([this]{ onResetBg(); });
|
||||
@ -708,15 +708,15 @@ public:
|
||||
m_curPref->pixelGrid.opacity(pixelGridOpacity()->getValue());
|
||||
m_curPref->pixelGrid.autoOpacity(pixelGridAutoOpacity()->isSelected());
|
||||
|
||||
m_curPref->bg.type(app::gen::BgType(checkedBgSize()->getSelectedItemIndex()));
|
||||
if (m_curPref->bg.type() == app::gen::BgType::CHECKED_CUSTOM) {
|
||||
m_curPref->bg.type(app::gen::BgType(checkeredBgSize()->getSelectedItemIndex()));
|
||||
if (m_curPref->bg.type() == app::gen::BgType::CHECKERED_CUSTOM) {
|
||||
m_curPref->bg.size(gfx::Size(
|
||||
checkedBgCustomW()->textInt(),
|
||||
checkedBgCustomH()->textInt()));
|
||||
checkeredBgCustomW()->textInt(),
|
||||
checkeredBgCustomH()->textInt()));
|
||||
}
|
||||
m_curPref->bg.zoom(checkedBgZoom()->isSelected());
|
||||
m_curPref->bg.color1(checkedBgColor1()->getColor());
|
||||
m_curPref->bg.color2(checkedBgColor2()->getColor());
|
||||
m_curPref->bg.zoom(checkeredBgZoom()->isSelected());
|
||||
m_curPref->bg.color1(checkeredBgColor1()->getColor());
|
||||
m_curPref->bg.color2(checkeredBgColor2()->getColor());
|
||||
|
||||
// Alerts preferences
|
||||
m_pref.openFile.openSequence(gen::SequenceDecision(openSequence()->getSelectedItemIndex()));
|
||||
@ -1039,24 +1039,24 @@ private:
|
||||
case 1: m_curPref = &m_docPref; break;
|
||||
}
|
||||
|
||||
checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
|
||||
checkedBgZoom()->setSelected(m_curPref->bg.zoom());
|
||||
checkedBgColor1()->setColor(m_curPref->bg.color1());
|
||||
checkedBgColor2()->setColor(m_curPref->bg.color2());
|
||||
checkeredBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
|
||||
checkeredBgZoom()->setSelected(m_curPref->bg.zoom());
|
||||
checkeredBgColor1()->setColor(m_curPref->bg.color1());
|
||||
checkeredBgColor2()->setColor(m_curPref->bg.color2());
|
||||
|
||||
onCheckedBgSizeChange();
|
||||
onCheckeredBgSizeChange();
|
||||
}
|
||||
|
||||
void onCheckedBgSizeChange() {
|
||||
if (checkedBgSize()->getSelectedItemIndex() == int(app::gen::BgType::CHECKED_CUSTOM)) {
|
||||
checkedBgCustomW()->setTextf("%d", m_curPref->bg.size().w);
|
||||
checkedBgCustomH()->setTextf("%d", m_curPref->bg.size().h);
|
||||
checkedBgCustomW()->setVisible(true);
|
||||
checkedBgCustomH()->setVisible(true);
|
||||
void onCheckeredBgSizeChange() {
|
||||
if (checkeredBgSize()->getSelectedItemIndex() == int(app::gen::BgType::CHECKERED_CUSTOM)) {
|
||||
checkeredBgCustomW()->setTextf("%d", m_curPref->bg.size().w);
|
||||
checkeredBgCustomH()->setTextf("%d", m_curPref->bg.size().h);
|
||||
checkeredBgCustomW()->setVisible(true);
|
||||
checkeredBgCustomH()->setVisible(true);
|
||||
}
|
||||
else {
|
||||
checkedBgCustomW()->setVisible(false);
|
||||
checkedBgCustomH()->setVisible(false);
|
||||
checkeredBgCustomW()->setVisible(false);
|
||||
checkeredBgCustomH()->setVisible(false);
|
||||
}
|
||||
sectionBg()->layout();
|
||||
}
|
||||
@ -1090,19 +1090,19 @@ private:
|
||||
|
||||
// Reset global preferences (use default values specified in pref.xml)
|
||||
if (m_curPref == &m_globPref) {
|
||||
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
|
||||
checkedBgCustomW()->setVisible(false);
|
||||
checkedBgCustomH()->setVisible(false);
|
||||
checkedBgZoom()->setSelected(pref.bg.zoom.defaultValue());
|
||||
checkedBgColor1()->setColor(pref.bg.color1.defaultValue());
|
||||
checkedBgColor2()->setColor(pref.bg.color2.defaultValue());
|
||||
checkeredBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
|
||||
checkeredBgCustomW()->setVisible(false);
|
||||
checkeredBgCustomH()->setVisible(false);
|
||||
checkeredBgZoom()->setSelected(pref.bg.zoom.defaultValue());
|
||||
checkeredBgColor1()->setColor(pref.bg.color1.defaultValue());
|
||||
checkeredBgColor2()->setColor(pref.bg.color2.defaultValue());
|
||||
}
|
||||
// Reset document preferences with global settings
|
||||
else {
|
||||
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
|
||||
checkedBgZoom()->setSelected(pref.bg.zoom());
|
||||
checkedBgColor1()->setColor(pref.bg.color1());
|
||||
checkedBgColor2()->setColor(pref.bg.color2());
|
||||
checkeredBgSize()->setSelectedItemIndex(int(pref.bg.type()));
|
||||
checkeredBgZoom()->setSelected(pref.bg.zoom());
|
||||
checkeredBgColor1()->setColor(pref.bg.color1());
|
||||
checkeredBgColor2()->setColor(pref.bg.color2());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ using namespace gfx;
|
||||
|
||||
namespace {
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
void draw_checkered_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const gfx::Size& tile,
|
||||
const gfx::Color c1,
|
||||
@ -90,19 +90,19 @@ gfx::Color grid_color2()
|
||||
return gfx::rgba(192, 192, 192);
|
||||
}
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
void draw_checkered_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const gfx::Size& tile)
|
||||
{
|
||||
draw_checked_grid(g, rc, tile, grid_color1(), grid_color2());
|
||||
draw_checkered_grid(g, rc, tile, grid_color1(), grid_color2());
|
||||
}
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
void draw_checkered_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const gfx::Size& tile,
|
||||
DocumentPreferences& docPref)
|
||||
{
|
||||
draw_checked_grid(g, rc, tile, grid_color1(), grid_color2());
|
||||
draw_checkered_grid(g, rc, tile, grid_color1(), grid_color2());
|
||||
}
|
||||
|
||||
void draw_color(ui::Graphics* g,
|
||||
@ -121,9 +121,9 @@ void draw_color(ui::Graphics* g,
|
||||
|
||||
if (alpha < 255) {
|
||||
if (rc.w == rc.h)
|
||||
draw_checked_grid(g, rc, gfx::Size(rc.w/2, rc.h/2));
|
||||
draw_checkered_grid(g, rc, gfx::Size(rc.w/2, rc.h/2));
|
||||
else
|
||||
draw_checked_grid(g, rc, gfx::Size(rc.w/4, rc.h/2));
|
||||
draw_checkered_grid(g, rc, gfx::Size(rc.w/4, rc.h/2));
|
||||
}
|
||||
|
||||
if (alpha > 0) {
|
||||
|
@ -30,11 +30,11 @@ namespace app {
|
||||
gfx::Color grid_color1();
|
||||
gfx::Color grid_color2();
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
void draw_checkered_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const gfx::Size& tile);
|
||||
|
||||
void draw_checked_grid(ui::Graphics* g,
|
||||
void draw_checkered_grid(ui::Graphics* g,
|
||||
const gfx::Rect& rc,
|
||||
const gfx::Size& tile,
|
||||
DocumentPreferences& docPref);
|
||||
|
@ -680,7 +680,7 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
|
||||
|
||||
m_renderEngine->removeExtraImage();
|
||||
|
||||
// If the checked background is visible in this sprite, we save
|
||||
// If the checkered background is visible in this sprite, we save
|
||||
// all settings of the background for this document.
|
||||
if (!m_sprite->isOpaque())
|
||||
m_docPref.bg.forceSection();
|
||||
@ -981,7 +981,7 @@ void Editor::drawMask(Graphics* g)
|
||||
auto& segs = m_document->maskBoundaries();
|
||||
segs.createPathIfNeeeded();
|
||||
|
||||
CheckedDrawMode checked(g, m_antsOffset,
|
||||
CheckeredDrawMode checkered(g, m_antsOffset,
|
||||
gfx::rgba(0, 0, 0, 255),
|
||||
gfx::rgba(255, 255, 255, 255));
|
||||
os::Paint paint;
|
||||
@ -989,7 +989,7 @@ void Editor::drawMask(Graphics* g)
|
||||
paint.color(gfx::rgba(0, 0, 0));
|
||||
|
||||
// We translate the path instead of applying a matrix to the
|
||||
// ui::Graphics so the "checked" pattern is not scaled too.
|
||||
// ui::Graphics so the "checkered" pattern is not scaled too.
|
||||
gfx::Path path;
|
||||
segs.path().transform(m_proj.scaleMatrix(), &path);
|
||||
path.offset(pt.x, pt.y);
|
||||
@ -1247,7 +1247,7 @@ void Editor::drawCelHGuide(ui::Graphics* g,
|
||||
|
||||
// Vertical guide to touch the horizontal line
|
||||
{
|
||||
CheckedDrawMode checked(g, 0, color, gfx::ColorNone);
|
||||
CheckeredDrawMode checkered(g, 0, color, gfx::ColorNone);
|
||||
|
||||
if (scrY < scrCmpBounds.y)
|
||||
g->drawVLine(color, dottedX, scrCelBounds.y, scrCmpBounds.y - scrCelBounds.y);
|
||||
@ -1273,7 +1273,7 @@ void Editor::drawCelVGuide(ui::Graphics* g,
|
||||
|
||||
// Horizontal guide to touch the vertical line
|
||||
{
|
||||
CheckedDrawMode checked(g, 0, color, gfx::ColorNone);
|
||||
CheckeredDrawMode checkered(g, 0, color, gfx::ColorNone);
|
||||
|
||||
if (scrX < scrCmpBounds.x)
|
||||
g->drawHLine(color, scrCelBounds.x, dottedY, scrCmpBounds.x - scrCelBounds.x);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -57,28 +57,28 @@ void EditorRender::setupBackground(Doc* doc, doc::PixelFormat pixelFormat)
|
||||
|
||||
gfx::Size tile;
|
||||
switch (docPref.bg.type()) {
|
||||
case app::gen::BgType::CHECKED_16x16:
|
||||
bgType = render::BgType::CHECKED;
|
||||
case app::gen::BgType::CHECKERED_16x16:
|
||||
bgType = render::BgType::CHECKERED;
|
||||
tile = gfx::Size(16, 16);
|
||||
break;
|
||||
case app::gen::BgType::CHECKED_8x8:
|
||||
bgType = render::BgType::CHECKED;
|
||||
case app::gen::BgType::CHECKERED_8x8:
|
||||
bgType = render::BgType::CHECKERED;
|
||||
tile = gfx::Size(8, 8);
|
||||
break;
|
||||
case app::gen::BgType::CHECKED_4x4:
|
||||
bgType = render::BgType::CHECKED;
|
||||
case app::gen::BgType::CHECKERED_4x4:
|
||||
bgType = render::BgType::CHECKERED;
|
||||
tile = gfx::Size(4, 4);
|
||||
break;
|
||||
case app::gen::BgType::CHECKED_2x2:
|
||||
bgType = render::BgType::CHECKED;
|
||||
case app::gen::BgType::CHECKERED_2x2:
|
||||
bgType = render::BgType::CHECKERED;
|
||||
tile = gfx::Size(2, 2);
|
||||
break;
|
||||
case app::gen::BgType::CHECKED_1x1:
|
||||
bgType = render::BgType::CHECKED;
|
||||
case app::gen::BgType::CHECKERED_1x1:
|
||||
bgType = render::BgType::CHECKERED;
|
||||
tile = gfx::Size(1, 1);
|
||||
break;
|
||||
case app::gen::BgType::CHECKED_CUSTOM:
|
||||
bgType = render::BgType::CHECKED;
|
||||
case app::gen::BgType::CHECKERED_CUSTOM:
|
||||
bgType = render::BgType::CHECKERED;
|
||||
tile = docPref.bg.size();
|
||||
break;
|
||||
default:
|
||||
@ -90,7 +90,7 @@ void EditorRender::setupBackground(Doc* doc, doc::PixelFormat pixelFormat)
|
||||
m_render->setBgZoom(docPref.bg.zoom());
|
||||
m_render->setBgColor1(color_utils::color_for_image_without_alpha(docPref.bg.color1(), pixelFormat));
|
||||
m_render->setBgColor2(color_utils::color_for_image_without_alpha(docPref.bg.color2(), pixelFormat));
|
||||
m_render->setBgCheckedSize(tile);
|
||||
m_render->setBgStripeSize(tile);
|
||||
}
|
||||
|
||||
void EditorRender::setTransparentBackground()
|
||||
@ -161,11 +161,11 @@ void EditorRender::renderSprite(
|
||||
m_render->renderSprite(dstImage, sprite, frame, area);
|
||||
}
|
||||
|
||||
void EditorRender::renderCheckedBackground(
|
||||
void EditorRender::renderCheckeredBackground(
|
||||
doc::Image* image,
|
||||
const gfx::Clip& area)
|
||||
{
|
||||
m_render->renderCheckedBackground(image, area);
|
||||
m_render->renderCheckeredBackground(image, area);
|
||||
}
|
||||
|
||||
void EditorRender::renderImage(
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (C) 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -79,7 +79,7 @@ namespace app {
|
||||
const doc::Sprite* sprite,
|
||||
doc::frame_t frame,
|
||||
const gfx::ClipF& area);
|
||||
void renderCheckedBackground(
|
||||
void renderCheckeredBackground(
|
||||
doc::Image* image,
|
||||
const gfx::Clip& area);
|
||||
void renderImage(
|
||||
|
@ -627,7 +627,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev)
|
||||
|
||||
IntersectClip clip(g, clipR);
|
||||
if (clip) {
|
||||
CheckedDrawMode checked(g, getMarchingAntsOffset(),
|
||||
CheckeredDrawMode checkered(g, getMarchingAntsOffset(),
|
||||
gfx::rgba(0, 0, 0, 255),
|
||||
gfx::rgba(255, 255, 255, 255));
|
||||
g->drawRect(gfx::rgba(0, 0, 0), box);
|
||||
|
@ -1961,7 +1961,7 @@ void Timeline::drawClipboardRange(ui::Graphics* g)
|
||||
|
||||
IntersectClip clip(g, getRangeClipBounds(clipboard_range));
|
||||
if (clip) {
|
||||
CheckedDrawMode checked(g, m_offset_count,
|
||||
CheckeredDrawMode checkered(g, m_offset_count,
|
||||
gfx::rgba(0, 0, 0, 255),
|
||||
gfx::rgba(255, 255, 255, 255));
|
||||
g->drawRect(gfx::rgba(0, 0, 0),
|
||||
@ -2254,7 +2254,7 @@ void Timeline::drawCel(ui::Graphics* g, layer_t layerIndex, frame_t frame, Cel*
|
||||
if (!thumb_bounds.isEmpty()) {
|
||||
if (os::SurfaceRef surface = thumb::get_cel_thumbnail(cel, thumb_bounds.size())) {
|
||||
const int t = std::clamp(thumb_bounds.w/8, 4, 16);
|
||||
draw_checked_grid(g, thumb_bounds, gfx::Size(t, t), docPref());
|
||||
draw_checkered_grid(g, thumb_bounds, gfx::Size(t, t), docPref());
|
||||
|
||||
g->drawRgbaSurface(surface.get(),
|
||||
thumb_bounds.center().x-surface->width()/2,
|
||||
@ -2342,7 +2342,7 @@ void Timeline::drawCelOverlay(ui::Graphics* g)
|
||||
gfx::Rect rc = m_sprite->bounds().fitIn(
|
||||
gfx::Rect(m_thumbnailsOverlayBounds).shrink(1));
|
||||
if (os::SurfaceRef surface = thumb::get_cel_thumbnail(cel, rc.size())) {
|
||||
draw_checked_grid(g, rc, gfx::Size(8, 8)*ui::guiscale(), docPref());
|
||||
draw_checkered_grid(g, rc, gfx::Size(8, 8)*ui::guiscale(), docPref());
|
||||
|
||||
g->drawRgbaSurface(surface.get(),
|
||||
rc.center().x-surface->width()/2,
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (c) 2022 Igara Studio S.A.
|
||||
// Copyright (c) 2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -13,7 +14,7 @@ namespace render {
|
||||
enum class BgType {
|
||||
NONE,
|
||||
TRANSPARENT,
|
||||
CHECKED,
|
||||
CHECKERED,
|
||||
};
|
||||
|
||||
} // namespace render
|
||||
|
@ -543,7 +543,7 @@ Render::Render()
|
||||
, m_extraImage(NULL)
|
||||
, m_newBlendMethod(true)
|
||||
, m_bgType(BgType::TRANSPARENT)
|
||||
, m_bgCheckedSize(16, 16)
|
||||
, m_bgStripeSize(16, 16)
|
||||
, m_globalOpacity(255)
|
||||
, m_selectedLayerForOpacity(nullptr)
|
||||
, m_selectedLayer(nullptr)
|
||||
@ -597,9 +597,9 @@ void Render::setBgColor2(color_t color)
|
||||
m_bgColor2 = color;
|
||||
}
|
||||
|
||||
void Render::setBgCheckedSize(const gfx::Size& size)
|
||||
void Render::setBgStripeSize(const gfx::Size& size)
|
||||
{
|
||||
m_bgCheckedSize = size;
|
||||
m_bgStripeSize = size;
|
||||
}
|
||||
|
||||
void Render::setSelectedLayer(const Layer* layer)
|
||||
@ -730,15 +730,15 @@ void Render::renderSprite(
|
||||
// New Blending Method:
|
||||
if (m_newBlendMethod) {
|
||||
// Clear dstImage with the bg_color (if the background is not a
|
||||
// special background pattern like the checked background, this is
|
||||
// enough as a base color).
|
||||
// special background pattern like the checkered background, this
|
||||
// is enough as a base color).
|
||||
fill_rect(dstImage, area.dstBounds(), bg_color);
|
||||
|
||||
// Draw the Background layer - Onion skin behind the sprite - Transparent Layers
|
||||
renderSpriteLayers(dstImage, area, frame, compositeImage);
|
||||
|
||||
// In case that we need a special background (e.g. like the
|
||||
// checked pattern), we can draw the background in a temporal
|
||||
// checkered pattern), we can draw the background in a temporal
|
||||
// image and then merge this temporal image with the dstImage.
|
||||
if (!isSolidBackground(bgLayer, bg_color)) {
|
||||
if (!m_tmpBuf)
|
||||
@ -819,8 +819,8 @@ void Render::renderBackground(Image* image,
|
||||
}
|
||||
else {
|
||||
switch (m_bgType) {
|
||||
case BgType::CHECKED:
|
||||
renderCheckedBackground(image, area);
|
||||
case BgType::CHECKERED:
|
||||
renderCheckeredBackground(image, area);
|
||||
if (bgLayer && bgLayer->isVisible() &&
|
||||
// TODO Review this: bg_color can be an index (not an rgba())
|
||||
// when sprite and dstImage are indexed
|
||||
@ -846,7 +846,7 @@ bool Render::isSolidBackground(
|
||||
const color_t bg_color) const
|
||||
{
|
||||
return
|
||||
((m_bgType != BgType::CHECKED) ||
|
||||
((m_bgType != BgType::CHECKERED) ||
|
||||
(bgLayer && bgLayer->isVisible() &&
|
||||
// TODO Review this: bg_color can be an index (not an rgba())
|
||||
// when sprite and dstImage are indexed
|
||||
@ -915,13 +915,13 @@ void Render::renderOnionskin(
|
||||
}
|
||||
}
|
||||
|
||||
void Render::renderCheckedBackground(
|
||||
void Render::renderCheckeredBackground(
|
||||
Image* image,
|
||||
const gfx::Clip& area)
|
||||
{
|
||||
int x, y, u, v;
|
||||
int tile_w = m_bgCheckedSize.w;
|
||||
int tile_h = m_bgCheckedSize.h;
|
||||
int tile_w = m_bgStripeSize.w;
|
||||
int tile_h = m_bgStripeSize.h;
|
||||
|
||||
if (m_bgZoom) {
|
||||
tile_w = m_proj.zoom().apply(tile_w);
|
||||
@ -954,7 +954,7 @@ void Render::renderCheckedBackground(
|
||||
break;
|
||||
}
|
||||
|
||||
// Draw checked background (tile by tile)
|
||||
// Draw checkered background (tile by tile)
|
||||
int u_start = u;
|
||||
for (y=y_start-tile_h; y<image->height()+tile_h; y+=tile_h) {
|
||||
for (x=x_start-tile_w; x<image->width()+tile_w; x+=tile_w) {
|
||||
@ -1281,10 +1281,10 @@ CompositeImageFunc Render::getImageComposition(
|
||||
// image n-times (where n is the zoom scale).
|
||||
double intpart;
|
||||
const bool finegrain =
|
||||
(!m_bgZoom && (m_bgCheckedSize.w < m_proj.applyX(1) ||
|
||||
m_bgCheckedSize.h < m_proj.applyY(1) ||
|
||||
std::modf(double(m_bgCheckedSize.w) / m_proj.applyX(1.0), &intpart) != 0.0 ||
|
||||
std::modf(double(m_bgCheckedSize.h) / m_proj.applyY(1.0), &intpart) != 0.0)) ||
|
||||
(!m_bgZoom && (m_bgStripeSize.w < m_proj.applyX(1) ||
|
||||
m_bgStripeSize.h < m_proj.applyY(1) ||
|
||||
std::modf(double(m_bgStripeSize.w) / m_proj.applyX(1.0), &intpart) != 0.0 ||
|
||||
std::modf(double(m_bgStripeSize.h) / m_proj.applyY(1.0), &intpart) != 0.0)) ||
|
||||
(layer &&
|
||||
layer->isGroup() &&
|
||||
has_visible_reference_layers(static_cast<const LayerGroup*>(layer)));
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Render Library
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -65,7 +65,7 @@ namespace render {
|
||||
void setBgZoom(bool state);
|
||||
void setBgColor1(color_t color);
|
||||
void setBgColor2(color_t color);
|
||||
void setBgCheckedSize(const gfx::Size& size);
|
||||
void setBgStripeSize(const gfx::Size& size);
|
||||
|
||||
void setSelectedLayer(const Layer* layer);
|
||||
|
||||
@ -117,7 +117,7 @@ namespace render {
|
||||
const gfx::ClipF& area);
|
||||
|
||||
// Extra functions
|
||||
void renderCheckedBackground(
|
||||
void renderCheckeredBackground(
|
||||
Image* image,
|
||||
const gfx::Clip& area);
|
||||
|
||||
@ -215,7 +215,7 @@ namespace render {
|
||||
bool m_bgZoom;
|
||||
color_t m_bgColor1;
|
||||
color_t m_bgColor2;
|
||||
gfx::Size m_bgCheckedSize;
|
||||
gfx::Size m_bgStripeSize;
|
||||
int m_globalOpacity;
|
||||
const Layer* m_selectedLayerForOpacity;
|
||||
const Layer* m_selectedLayer;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2019 Igara Studio S.A.
|
||||
// Copyright (c) 2019-2022 Igara Studio S.A.
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -58,11 +58,11 @@ static void Bm_Render(benchmark::State& state)
|
||||
clear_image(dst.get(), 0);
|
||||
|
||||
Render render;
|
||||
render.setBgType(BgType::CHECKED);
|
||||
render.setBgType(BgType::CHECKERED);
|
||||
render.setBgZoom(true);
|
||||
render.setBgColor1(rgba(100, 100, 100, 255));
|
||||
render.setBgColor2(rgba(200, 200, 200, 255));
|
||||
render.setBgCheckedSize(gfx::Size(16, 16));
|
||||
render.setBgStripeSize(gfx::Size(16, 16));
|
||||
render.renderSprite(
|
||||
dst.get(), spr, frame_t(0),
|
||||
gfx::Clip(0, 0, 0, 0, w, h));
|
||||
|
@ -131,7 +131,7 @@ TEST(Render, DefaultBackgroundModeWithNonzeroTransparentIndex)
|
||||
EXPECT_2X2_PIXELS(dst.get(), 0, 0, 0, c1); // RGB transparent
|
||||
}
|
||||
|
||||
TEST(Render, CheckedBackground)
|
||||
TEST(Render, CheckeredBackground)
|
||||
{
|
||||
std::shared_ptr<Document> doc = std::make_shared<Document>();
|
||||
doc->sprites().add(Sprite::MakeStdSprite(ImageSpec(ColorMode::INDEXED, 4, 4)));
|
||||
@ -140,12 +140,12 @@ TEST(Render, CheckedBackground)
|
||||
clear_image(dst.get(), 0);
|
||||
|
||||
Render render;
|
||||
render.setBgType(BgType::CHECKED);
|
||||
render.setBgType(BgType::CHECKERED);
|
||||
render.setBgZoom(true);
|
||||
render.setBgColor1(1);
|
||||
render.setBgColor2(2);
|
||||
|
||||
render.setBgCheckedSize(gfx::Size(1, 1));
|
||||
render.setBgStripeSize(gfx::Size(1, 1));
|
||||
render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
|
||||
EXPECT_4X4_PIXELS(dst.get(),
|
||||
1, 2, 1, 2,
|
||||
@ -153,7 +153,7 @@ TEST(Render, CheckedBackground)
|
||||
1, 2, 1, 2,
|
||||
2, 1, 2, 1);
|
||||
|
||||
render.setBgCheckedSize(gfx::Size(2, 2));
|
||||
render.setBgStripeSize(gfx::Size(2, 2));
|
||||
render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
|
||||
EXPECT_4X4_PIXELS(dst.get(),
|
||||
1, 1, 2, 2,
|
||||
@ -161,7 +161,7 @@ TEST(Render, CheckedBackground)
|
||||
2, 2, 1, 1,
|
||||
2, 2, 1, 1);
|
||||
|
||||
render.setBgCheckedSize(gfx::Size(3, 3));
|
||||
render.setBgStripeSize(gfx::Size(3, 3));
|
||||
render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
|
||||
EXPECT_4X4_PIXELS(dst.get(),
|
||||
1, 1, 1, 2,
|
||||
@ -170,7 +170,7 @@ TEST(Render, CheckedBackground)
|
||||
2, 2, 2, 1);
|
||||
|
||||
render.setProjection(Projection(PixelRatio(1, 1), Zoom(2, 1)));
|
||||
render.setBgCheckedSize(gfx::Size(1, 1));
|
||||
render.setBgStripeSize(gfx::Size(1, 1));
|
||||
render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
|
||||
EXPECT_4X4_PIXELS(dst.get(),
|
||||
1, 1, 2, 2,
|
||||
@ -195,11 +195,11 @@ TEST(Render, ZoomAndDstBounds)
|
||||
clear_image(dst.get(), 0);
|
||||
|
||||
Render render;
|
||||
render.setBgType(BgType::CHECKED);
|
||||
render.setBgType(BgType::CHECKERED);
|
||||
render.setBgZoom(true);
|
||||
render.setBgColor1(1);
|
||||
render.setBgColor2(2);
|
||||
render.setBgCheckedSize(gfx::Size(1, 1));
|
||||
render.setBgStripeSize(gfx::Size(1, 1));
|
||||
|
||||
render.renderSprite(
|
||||
dst.get(), doc->sprite(), frame_t(0),
|
||||
@ -228,11 +228,11 @@ TEST(Render, BugWithMultiplesOf3ZoomFactors)
|
||||
clear_image(dst.get(), 0);
|
||||
|
||||
Render render;
|
||||
render.setBgType(BgType::CHECKED);
|
||||
render.setBgType(BgType::CHECKERED);
|
||||
render.setBgZoom(false);
|
||||
render.setBgColor1(rgba(128, 128, 128, 255));
|
||||
render.setBgColor2(rgba(64, 64, 64, 255));
|
||||
render.setBgCheckedSize(gfx::Size(2, 2));
|
||||
render.setBgStripeSize(gfx::Size(2, 2));
|
||||
render.setProjection(Projection(PixelRatio(1, 1), Zoom(zoom, 1)));
|
||||
render.renderSprite(
|
||||
dst.get(), doc->sprite(), frame_t(0),
|
||||
|
@ -126,8 +126,8 @@ void Graphics::setDrawMode(DrawMode mode, int param,
|
||||
case DrawMode::Xor:
|
||||
m_surface->setDrawMode(os::DrawMode::Xor);
|
||||
break;
|
||||
case DrawMode::Checked:
|
||||
m_surface->setDrawMode(os::DrawMode::Checked, param, a, b);
|
||||
case DrawMode::Checkered:
|
||||
m_surface->setDrawMode(os::DrawMode::Checkered, param, a, b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace ui {
|
||||
enum class DrawMode {
|
||||
Solid,
|
||||
Xor,
|
||||
Checked,
|
||||
Checkered,
|
||||
};
|
||||
|
||||
Graphics(const os::SurfaceRef& surface, int dx, int dy);
|
||||
@ -191,22 +191,22 @@ namespace ui {
|
||||
DISABLE_COPYING(IntersectClip);
|
||||
};
|
||||
|
||||
class CheckedDrawMode {
|
||||
class CheckeredDrawMode {
|
||||
public:
|
||||
CheckedDrawMode(Graphics* g, int param,
|
||||
CheckeredDrawMode(Graphics* g, int param,
|
||||
const gfx::Color a,
|
||||
const gfx::Color b) : m_graphics(g) {
|
||||
m_graphics->setDrawMode(Graphics::DrawMode::Checked, param, a, b);
|
||||
m_graphics->setDrawMode(Graphics::DrawMode::Checkered, param, a, b);
|
||||
}
|
||||
|
||||
~CheckedDrawMode() {
|
||||
~CheckeredDrawMode() {
|
||||
m_graphics->setDrawMode(Graphics::DrawMode::Solid);
|
||||
}
|
||||
|
||||
private:
|
||||
Graphics* m_graphics;
|
||||
|
||||
DISABLE_COPYING(CheckedDrawMode);
|
||||
DISABLE_COPYING(CheckeredDrawMode);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<Graphics> GraphicsPtr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user