Remove IDocumentSettings and DocumentSettingsObserver

Document user options are completely replaced with DocumentPreferences.
This commit is contained in:
David Capello 2015-02-15 09:48:38 -03:00
parent 869b6606b2
commit 69ac11eea2
47 changed files with 398 additions and 1061 deletions

View File

@ -14,12 +14,6 @@
<value id="PICK_FGCOLOR" value="1" />
<value id="ERASE" value="2" />
</enum>
<enum id="TiledMode">
<value id="NONE" value="0" />
<value id="X_AXIS" value="1" />
<value id="Y_AXIS" value="2" />
<value id="BOTH" value="3" />
</enum>
<enum id="OnionskinType">
<value id="MERGE" value="0" />
<value id="RED_BLUE_TINT" value="1" />
@ -109,21 +103,21 @@
<document>
<section id="tiled">
<option id="tiled_mode" type="TiledMode" default="TiledMode::NONE" />
<option id="mode" type="filters::TiledMode" default="filters::TiledMode::NONE" migrate="Tools.Tiled" />
</section>
<section id="grid">
<option id="snap" type="bool" default="false" />
<option id="visible" type="bool" default="false" />
<option id="bounds" type="gfx::Rect" default="gfx::Rect(0, 0, 16, 16)" />
<option id="color" type="app::Color" default="app::Color::fromRgb(0, 0, 255)" />
<option id="opacity" type="int" default="160" />
<option id="auto_opacity" type="bool" default="true" />
<option id="snap" type="bool" default="false" migrate="Grid.SnapTo" />
<option id="visible" type="bool" default="false" migrate="Grid.Visible" />
<option id="bounds" type="gfx::Rect" default="gfx::Rect(0, 0, 16, 16)" migrate="Grid.Bounds" />
<option id="color" type="app::Color" default="app::Color::fromRgb(0, 0, 255)" migrate="Grid.Color" />
<option id="opacity" type="int" default="160" migrate="Grid.Opacity" />
<option id="auto_opacity" type="bool" default="true" migrate="Grid.AutoOpacity" />
</section>
<section id="pixel_grid">
<option id="visible" type="bool" default="false" />
<option id="color" type="app::Color" default="app::Color::fromRgb(200, 200, 200)" />
<option id="opacity" type="int" default="160" />
<option id="auto_opacity" type="bool" default="true" />
<option id="visible" type="bool" default="false" migrate="PixelGrid.Visible" />
<option id="color" type="app::Color" default="app::Color::fromRgb(200, 200, 200)" migrate="PixelGrid.Color" />
<option id="opacity" type="int" default="160" migrate="PixelGrid.Opacity" />
<option id="auto_opacity" type="bool" default="true" migrate="PixelGrid.AutoOpacity" />
</section>
<section id="bg">
<option id="type" type="BgType" default="BgType::CHECKED_16x16" migrate="Option.CheckedBgType" />
@ -132,12 +126,12 @@
<option id="color2" type="app::Color" default="app::Color::fromRgb(192, 192, 192)" migrate="Option.CheckedBgColor2" />
</section>
<section id="onionskin">
<option id="active" type="bool" default="false" />
<option id="prev_frames" type="int" default="1" />
<option id="next_frames" type="int" default="1" />
<option id="opacity_base" type="int" default="68" />
<option id="opacity_step" type="int" default="28" />
<option id="type" type="OnionskinType" default="OnionskinType::MERGE" />
<option id="active" type="bool" default="false" migrate="Onionskin.Enabled" />
<option id="prev_frames" type="int" default="1" migrate="Onionskin.PrevFrames" />
<option id="next_frames" type="int" default="1" migrate="Onionskin.NextFrames" />
<option id="opacity_base" type="int" default="68" migrate="Onionskin.OpacityBase" />
<option id="opacity_step" type="int" default="28" migrate="Onionskin.OpacityStep" />
<option id="type" type="OnionskinType" default="OnionskinType::MERGE" migrate="Onionskin.Type" />
</section>
<section id="loop">
<option id="visible" type="bool" default="false" />

View File

@ -253,6 +253,7 @@ add_library(app-lib
send_crash.cpp
settings/ui_settings_impl.cpp
shell.cpp
snap_to_grid.cpp
thumbnail_generator.cpp
tools/intertwine.cpp
tools/pick_ink.cpp

View File

@ -18,7 +18,7 @@
#include "app/load_widget.h"
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/settings/document_settings.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/ui/color_button.h"
#include "app/ui/editor/editor.h"
@ -26,8 +26,8 @@
#include "app/ui_context.h"
#include "base/bind.h"
#include "doc/context_observer.h"
#include "gfx/size.h"
#include "doc/mask.h"
#include "gfx/size.h"
#include "ui/ui.h"
#include "generated_tools_configuration.h"
@ -47,8 +47,8 @@ public:
// Slots
this->Close.connect(Bind<void>(&ToolsConfigurationWindow::onWindowClose, this));
tiled()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledClick, this));
tiledX()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledXYClick, this, filters::TILED_X_AXIS, tiledX()));
tiledY()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledXYClick, this, filters::TILED_Y_AXIS, tiledY()));
tiledX()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledXYClick, this, filters::TiledMode::X_AXIS, tiledX()));
tiledY()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onTiledXYClick, this, filters::TiledMode::Y_AXIS, tiledY()));
viewGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onViewGridClick, this));
pixelGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onPixelGridClick, this));
setGrid()->Click.connect(Bind<void>(&ToolsConfigurationWindow::onSetGridClick, this));
@ -71,20 +71,23 @@ private:
return m_ctx->settings();
}
IDocumentSettings* docSettings() {
ASSERT(settings());
return settings()->getDocumentSettings(m_ctx->activeDocument());
Preferences& preferences() {
return App::instance()->preferences();
}
DocumentPreferences& docPref() {
return preferences().document(m_ctx->activeDocument());
}
void onSetActiveDocument(doc::Document* document) override {
IDocumentSettings* docSettings = this->docSettings();
DocumentPreferences& docPref = this->docPref();
tiled()->setSelected(docSettings->getTiledMode() != filters::TILED_NONE);
tiledX()->setSelected(docSettings->getTiledMode() & filters::TILED_X_AXIS ? true: false);
tiledY()->setSelected(docSettings->getTiledMode() & filters::TILED_Y_AXIS ? true: false);
snapToGrid()->setSelected(docSettings->getSnapToGrid());
viewGrid()->setSelected(docSettings->getGridVisible());
pixelGrid()->setSelected(docSettings->getPixelGridVisible());
tiled()->setSelected(docPref.tiled.mode() != filters::TiledMode::NONE);
tiledX()->setSelected(int(docPref.tiled.mode()) & int(filters::TiledMode::X_AXIS) ? true: false);
tiledY()->setSelected(int(docPref.tiled.mode()) & int(filters::TiledMode::Y_AXIS) ? true: false);
snapToGrid()->setSelected(docPref.grid.snap());
viewGrid()->setSelected(docPref.grid.visible());
pixelGrid()->setSelected(docPref.pixelGrid.visible());
}
void onWindowClose() {
@ -94,33 +97,34 @@ private:
void onTiledClick() {
bool flag = tiled()->isSelected();
docSettings()->setTiledMode(
flag ? filters::TILED_BOTH:
filters::TILED_NONE);
docPref().tiled.mode(
flag ? filters::TiledMode::BOTH:
filters::TiledMode::NONE);
tiledX()->setSelected(flag);
tiledY()->setSelected(flag);
}
void onTiledXYClick(int tiled_axis, CheckBox* checkbox) {
int tiled_mode = docSettings()->getTiledMode();
void onTiledXYClick(filters::TiledMode tiled_axis, CheckBox* checkbox) {
int tiled_mode = int(docPref().tiled.mode());
if (checkbox->isSelected())
tiled_mode |= tiled_axis;
tiled_mode |= int(tiled_axis);
else
tiled_mode &= ~tiled_axis;
tiled_mode &= ~int(tiled_axis);
checkbox->findSibling("tiled")->setSelected(tiled_mode != filters::TILED_NONE);
checkbox->findSibling("tiled")->setSelected(
tiled_mode != int(filters::TiledMode::NONE));
docSettings()->setTiledMode((filters::TiledMode)tiled_mode);
docPref().tiled.mode(filters::TiledMode(tiled_mode));
}
void onViewGridClick() {
docSettings()->setGridVisible(viewGrid()->isSelected());
docPref().grid.visible(viewGrid()->isSelected());
}
void onPixelGridClick() {
docSettings()->setPixelGridVisible(pixelGrid()->isSelected());
docPref().pixelGrid.visible(pixelGrid()->isSelected());
}
void onSetGridClick() {
@ -132,7 +136,7 @@ private:
if (document && document->isMaskVisible()) {
const Mask* mask(document->mask());
docSettings()->setGridBounds(mask->bounds());
docPref().grid.bounds(mask->bounds());
}
else {
Command* grid_settings_cmd =
@ -147,7 +151,7 @@ private:
}
void onSnapToGridClick() {
docSettings()->setSnapToGrid(snapToGrid()->isSelected());
docPref().grid.snap(snapToGrid()->isSelected());
}
Context* m_ctx;

View File

@ -18,8 +18,7 @@
#include "app/context.h"
#include "app/modules/editors.h"
#include "app/modules/gfx.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "app/ui/editor/editor.h"
#include "app/ui/keyboard_shortcuts.h"
#include "app/ui/status_bar.h"
@ -58,8 +57,8 @@ public:
// will call other sub-commands (e.g. previous frame, next frame,
// etc.).
View* view = View::getView(editor);
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(m_doc);
m_tiled = docSettings->getTiledMode();
DocumentPreferences& docPref = App::instance()->preferences().document(m_doc);
m_tiled = (filters::TiledMode)docPref.tiled.mode();
// Free mouse
editor->getManager()->freeMouse();
@ -191,8 +190,8 @@ protected:
w = m_zoom.apply(m_sprite->width());
h = m_zoom.apply(m_sprite->height());
if (m_tiled & TILED_X_AXIS) x = SGN(x) * (ABS(x)%w);
if (m_tiled & TILED_Y_AXIS) y = SGN(y) * (ABS(y)%h);
if (int(m_tiled) & int(TiledMode::X_AXIS)) x = SGN(x) * (ABS(x)%w);
if (int(m_tiled) & int(TiledMode::Y_AXIS)) y = SGN(y) * (ABS(y)%h);
if (m_index_bg_color == -1) {
render.setupBackground(m_doc, m_doublebuf->pixelFormat());
@ -205,21 +204,21 @@ protected:
}
switch (m_tiled) {
case TILED_NONE:
case TiledMode::NONE:
render.renderImage(m_doublebuf, m_render, m_pal, x, y,
m_zoom, 255, BLEND_MODE_NORMAL);
break;
case TILED_X_AXIS:
case TiledMode::X_AXIS:
for (u=x-w; u<ui::display_w()+w; u+=w)
render.renderImage(m_doublebuf, m_render, m_pal, u, y,
m_zoom, 255, BLEND_MODE_NORMAL);
break;
case TILED_Y_AXIS:
case TiledMode::Y_AXIS:
for (v=y-h; v<ui::display_h()+h; v+=h)
render.renderImage(m_doublebuf, m_render, m_pal, x, v,
m_zoom, 255, BLEND_MODE_NORMAL);
break;
case TILED_BOTH:
case TiledMode::BOTH:
for (v=y-h; v<ui::display_h()+h; v+=h)
for (u=x-w; u<ui::display_w()+w; u+=w)
render.renderImage(m_doublebuf, m_render, m_pal, u, v,

View File

@ -16,8 +16,7 @@
#include "app/find_widget.h"
#include "app/load_widget.h"
#include "app/modules/editors.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "app/ui/status_bar.h"
#include "app/ui_context.h"
#include "ui/window.h"
@ -32,25 +31,20 @@ public:
ShowGridCommand()
: Command("ShowGrid",
"Show Grid",
CmdUIOnlyFlag)
{
CmdUIOnlyFlag) {
}
Command* clone() const override { return new ShowGridCommand(*this); }
protected:
bool onChecked(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
return docSettings->getGridVisible();
bool onChecked(Context* ctx) {
DocumentPreferences& docPref = App::instance()->preferences().document(ctx->activeDocument());
return docPref.grid.visible();
}
void onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
docSettings->setGridVisible(docSettings->getGridVisible() ? false: true);
void onExecute(Context* ctx) {
DocumentPreferences& docPref = App::instance()->preferences().document(ctx->activeDocument());
docPref.grid.visible(!docPref.grid.visible());
}
};
@ -59,25 +53,20 @@ public:
ShowPixelGridCommand()
: Command("ShowPixelGrid",
"Show Pixel Grid",
CmdUIOnlyFlag)
{
CmdUIOnlyFlag) {
}
Command* clone() const override { return new ShowPixelGridCommand(*this); }
protected:
bool onChecked(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
return docSettings->getPixelGridVisible();
bool onChecked(Context* ctx) {
DocumentPreferences& docPref = App::instance()->preferences().document(ctx->activeDocument());
return docPref.pixelGrid.visible();
}
void onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
docSettings->setPixelGridVisible(docSettings->getPixelGridVisible() ? false: true);
void onExecute(Context* ctx) {
DocumentPreferences& docPref = App::instance()->preferences().document(ctx->activeDocument());
docPref.pixelGrid.visible(!docPref.pixelGrid.visible());
}
};
@ -86,28 +75,24 @@ public:
SnapToGridCommand()
: Command("SnapToGrid",
"Snap to Grid",
CmdUIOnlyFlag)
{
CmdUIOnlyFlag) {
}
Command* clone() const override { return new SnapToGridCommand(*this); }
protected:
bool onChecked(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
return docSettings->getSnapToGrid();
bool onChecked(Context* ctx) {
DocumentPreferences& docPref = App::instance()->preferences().document(ctx->activeDocument());
return docPref.grid.snap();
}
void onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
docSettings->setSnapToGrid(docSettings->getSnapToGrid() ? false: true);
void onExecute(Context* ctx) {
DocumentPreferences& docPref = App::instance()->preferences().document(ctx->activeDocument());
docPref.grid.snap(!docPref.grid.snap());
char buf[512];
sprintf(buf, "Snap to grid: %s",
(docSettings->getSnapToGrid() ? "On": "Off"));
(docPref.grid.snap() ? "On": "Off"));
StatusBar::instance()->setStatusText(250, buf);
}
@ -144,8 +129,8 @@ void GridSettingsCommand::onExecute(Context* context)
Widget* grid_w = app::find_widget<Widget>(window, "grid_w");
Widget* grid_h = app::find_widget<Widget>(window, "grid_h");
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
Rect bounds = docSettings->getGridBounds();
DocumentPreferences& docPref = App::instance()->preferences().document(context->activeDocument());
Rect bounds = docPref.grid.bounds();
grid_x->setTextf("%d", bounds.x);
grid_y->setTextf("%d", bounds.y);
@ -162,7 +147,7 @@ void GridSettingsCommand::onExecute(Context* context)
bounds.w = MAX(bounds.w, 1);
bounds.h = MAX(bounds.h, 1);
docSettings->setGridBounds(bounds);
docPref.grid.bounds(bounds);
}
}

View File

@ -9,6 +9,7 @@
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/cmd_move_mask.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
@ -16,10 +17,9 @@
#include "app/document_api.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/ui/editor/editor.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/ui/editor/editor.h"
#include "base/convert_to.h"
#include "doc/mask.h"
#include "doc/sprite.h"
@ -68,10 +68,10 @@ bool MoveMaskCommand::onEnabled(Context* context)
void MoveMaskCommand::onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
DocumentPreferences& docPref = App::instance()->preferences().document(context->activeDocument());
ui::View* view = ui::View::getView(current_editor);
gfx::Rect vp = view->getViewportBounds();
gfx::Rect gridBounds = docSettings->getGridBounds();
gfx::Rect gridBounds = docPref.grid.bounds();
int dx = 0;
int dy = 0;
int pixels = 0;

View File

@ -13,8 +13,7 @@
#include "app/commands/command.h"
#include "app/context.h"
#include "app/document.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
namespace app {
@ -34,16 +33,14 @@ public:
protected:
bool onChecked(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
return docSettings->getUseOnionskin();
DocumentPreferences& docPref = App::instance()->preferences().document(context->activeDocument());
return docPref.onionskin.active();
}
void onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
docSettings->setUseOnionskin(docSettings->getUseOnionskin() ? false: true);
DocumentPreferences& docPref = App::instance()->preferences().document(context->activeDocument());
docPref.onionskin.active(!docPref.onionskin.active());
}
};

View File

@ -21,7 +21,6 @@
#include "app/pref/preferences.h"
#include "app/resource_finder.h"
#include "app/send_crash.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/ui/color_button.h"
#include "app/ui/editor/editor.h"
@ -43,9 +42,6 @@ public:
OptionsWindow(Context* context, int& curSection)
: m_settings(context->settings())
, m_preferences(App::instance()->preferences())
, m_globSettings(m_settings->getDocumentSettings(nullptr))
, m_docSettings(m_settings->getDocumentSettings(context->activeDocument()))
, m_curSettings(m_docSettings)
, m_globPref(m_preferences.document(nullptr))
, m_docPref(m_preferences.document(context->activeDocument()))
, m_curPref(&m_docPref)
@ -146,13 +142,6 @@ public:
void saveConfig() {
Editor::set_cursor_color(m_cursorColor->getColor());
m_curSettings->setGridColor(m_gridColor->getColor());
m_curSettings->setGridOpacity(gridOpacity()->getValue());
m_curSettings->setGridAutoOpacity(gridAutoOpacity()->isSelected());
m_curSettings->setPixelGridColor(m_pixelGridColor->getColor());
m_curSettings->setPixelGridOpacity(pixelGridOpacity()->getValue());
m_curSettings->setPixelGridAutoOpacity(pixelGridAutoOpacity()->isSelected());
m_preferences.general.autoshowTimeline(autotimeline()->isSelected());
bool expandOnMouseover = expandMenubarOnMouseover()->isSelected();
@ -165,6 +154,12 @@ public:
m_settings->setZoomWithScrollWheel(wheelZoom()->isSelected());
m_settings->setRightClickMode(static_cast<RightClickMode>(rightClickBehavior()->getSelectedItemIndex()));
m_curPref->grid.color(m_gridColor->getColor());
m_curPref->grid.opacity(gridOpacity()->getValue());
m_curPref->grid.autoOpacity(gridAutoOpacity()->isSelected());
m_curPref->pixelGrid.color(m_pixelGridColor->getColor());
m_curPref->pixelGrid.opacity(pixelGridOpacity()->getValue());
m_curPref->pixelGrid.autoOpacity(pixelGridAutoOpacity()->isSelected());
m_curPref->bg.type(app::gen::BgType(checkedBgSize()->getSelectedItemIndex()));
m_curPref->bg.zoom(checkedBgZoom()->isSelected());
m_curPref->bg.color1(m_checked_bg_color1->getColor());
@ -209,23 +204,17 @@ private:
int item = gridScope()->getSelectedItemIndex();
switch (item) {
case 0:
m_curSettings = m_globSettings;
m_curPref = &m_globPref;
break;
case 1:
m_curSettings = m_docSettings;
m_curPref = &m_docPref;
break;
case 0: m_curPref = &m_globPref; break;
case 1: m_curPref = &m_docPref; break;
}
m_gridColor->setColor(m_curSettings->getGridColor());
gridOpacity()->setValue(m_curSettings->getGridOpacity());
gridAutoOpacity()->setSelected(m_curSettings->getGridAutoOpacity());
m_gridColor->setColor(m_curPref->grid.color());
gridOpacity()->setValue(m_curPref->grid.opacity());
gridAutoOpacity()->setSelected(m_curPref->grid.autoOpacity());
m_pixelGridColor->setColor(m_curSettings->getPixelGridColor());
pixelGridOpacity()->setValue(m_curSettings->getPixelGridOpacity());
pixelGridAutoOpacity()->setSelected(m_curSettings->getPixelGridAutoOpacity());
m_pixelGridColor->setColor(m_curPref->pixelGrid.color());
pixelGridOpacity()->setValue(m_curPref->pixelGrid.opacity());
pixelGridAutoOpacity()->setSelected(m_curPref->pixelGrid.autoOpacity());
checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
checkedBgZoom()->setSelected(m_curPref->bg.zoom());
@ -261,9 +250,6 @@ private:
}
ISettings* m_settings;
IDocumentSettings* m_globSettings;
IDocumentSettings* m_docSettings;
IDocumentSettings* m_curSettings;
Preferences& m_preferences;
DocumentPreferences& m_globPref;
DocumentPreferences& m_docPref;

View File

@ -19,7 +19,7 @@
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
#include "app/settings/document_settings.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/ui/editor/editor.h"
#include "app/ui/main_window.h"
@ -42,14 +42,14 @@ public:
, m_oldFrame(editor->frame())
, m_oldFlags(m_editor->editorFlags())
, m_doc(editor->document())
, m_docSettings(context->settings()->getDocumentSettings(m_doc))
, m_oldOnionskinState(m_docSettings->getUseOnionskin())
, m_docPref(App::instance()->preferences().document(m_doc))
, m_oldOnionskinState(m_docPref.onionskin.active())
, m_playTimer(10)
{
m_editor->setEditorFlags(Editor::kNoneFlag);
// Desactivate the onionskin
m_docSettings->setUseOnionskin(false);
m_docPref.onionskin.active(false);
// Clear extras (e.g. pen preview)
m_doc->destroyExtraCel();
@ -73,7 +73,7 @@ protected:
frame_t frame = calculate_next_frame(
m_editor->sprite(),
m_editor->frame(),
m_docSettings,
m_docPref,
m_pingPongForward);
m_editor->setFrame(frame);
@ -94,7 +94,7 @@ protected:
case kCloseMessage:
// Restore onionskin flag
m_docSettings->setUseOnionskin(m_oldOnionskinState);
m_docPref.onionskin.active(m_oldOnionskinState);
// Restore editor
m_editor->setFrame(m_oldFrame);
@ -138,7 +138,7 @@ private:
frame_t m_oldFrame;
Editor::EditorFlags m_oldFlags;
Document* m_doc;
IDocumentSettings* m_docSettings;
DocumentPreferences& m_docPref;
bool m_oldOnionskinState;
bool m_pingPongForward;

View File

@ -9,12 +9,12 @@
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/modules/editors.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "app/ui/editor/editor.h"
#include "base/convert_to.h"
#include "ui/view.h"
@ -87,11 +87,11 @@ bool ScrollCommand::onEnabled(Context* context)
void ScrollCommand::onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
DocumentPreferences& docPref = App::instance()->preferences().document(context->activeDocument());
ui::View* view = ui::View::getView(current_editor);
gfx::Rect vp = view->getViewportBounds();
gfx::Point scroll = view->getViewScroll();
gfx::Rect gridBounds = docSettings->getGridBounds();
gfx::Rect gridBounds = docPref.grid.bounds();
gfx::Point delta(0, 0);
int pixels = 0;

View File

@ -13,8 +13,7 @@
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "app/ui/main_window.h"
#include "app/ui/timeline.h"
@ -71,10 +70,7 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
if (!doc)
return;
IDocumentSettings* docSets = ctx->settings()->getDocumentSettings(doc);
if (!docSets)
return;
DocumentPreferences& docPref = App::instance()->preferences().document(doc);
frame_t begin = m_begin;
frame_t end = m_end;
bool on = false;
@ -105,11 +101,12 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
}
if (on) {
docSets->setLoopAnimation(true);
docSets->setLoopRange(begin, end);
docPref.loop.visible(true);
docPref.loop.from(begin);
docPref.loop.to(end);
}
else
docSets->setLoopAnimation(false);
docPref.loop.visible(false);
}
Command* CommandFactory::createSetLoopSectionCommand()

View File

@ -9,6 +9,7 @@
#include "config.h"
#endif
#include "app/app.h"
#include "app/color.h"
#include "app/commands/command.h"
#include "app/commands/filters/convolution_matrix_stock.h"
@ -19,13 +20,12 @@
#include "app/find_widget.h"
#include "app/ini_file.h"
#include "app/load_widget.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "base/bind.h"
#include "filters/convolution_matrix.h"
#include "filters/convolution_matrix_filter.h"
#include "doc/mask.h"
#include "doc/sprite.h"
#include "filters/convolution_matrix.h"
#include "filters/convolution_matrix_filter.h"
#include "ui/button.h"
#include "ui/label.h"
#include "ui/listbox.h"
@ -176,9 +176,11 @@ void ConvolutionMatrixCommand::onExecute(Context* context)
m_stock.getByName(get_config_string(ConfigSection, "Selected", ""));
// Create the filter and setup initial settings
DocumentPreferences& docPref = App::instance()
->preferences().document(context->activeDocument());
ConvolutionMatrixFilter filter;
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
filter.setTiledMode(docSettings->getTiledMode());
filter.setTiledMode(docPref.tiled.mode());
if (matrix != 0)
filter.setMatrix(matrix);

View File

@ -9,6 +9,7 @@
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/commands/filters/filter_manager_impl.h"
#include "app/commands/filters/filter_window.h"
@ -17,12 +18,11 @@
#include "app/find_widget.h"
#include "app/ini_file.h"
#include "app/load_widget.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "base/bind.h"
#include "filters/median_filter.h"
#include "doc/mask.h"
#include "doc/sprite.h"
#include "filters/median_filter.h"
#include "ui/button.h"
#include "ui/entry.h"
#include "ui/grid.h"
@ -106,10 +106,10 @@ bool DespeckleCommand::onEnabled(Context* context)
void DespeckleCommand::onExecute(Context* context)
{
IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument());
DocumentPreferences& docPref = App::instance()->preferences().document(context->activeDocument());
MedianFilter filter;
filter.setTiledMode(docSettings->getTiledMode());
filter.setTiledMode((filters::TiledMode)docPref.tiled.mode());
filter.setSize(get_config_int(ConfigSection, "Width", 3),
get_config_int(ConfigSection, "Height", 3));

View File

@ -60,7 +60,7 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection,
addChild(&m_hbox);
if (m_tiledCheck) {
m_tiledCheck->setSelected(tiledMode != TILED_NONE);
m_tiledCheck->setSelected(tiledMode != TiledMode::NONE);
m_tiledCheck->Click.connect(Bind<void>(&FilterWindow::onTiledChange, this));
m_vbox.addChild(m_tiledCheck);
@ -155,7 +155,9 @@ void FilterWindow::onTiledChange()
// Call derived class implementation of setupTiledMode() so the
// filter is modified.
setupTiledMode(m_tiledCheck->isSelected() ? TILED_BOTH: TILED_NONE);
setupTiledMode(m_tiledCheck->isSelected() ?
TiledMode::BOTH:
TiledMode::NONE);
// Restart the preview.
restartPreview();

View File

@ -29,10 +29,10 @@ namespace app {
enum WithTiled { WithTiledCheckBox, WithoutTiledCheckBox };
FilterWindow(const char* title, const char* cfgSection,
FilterManagerImpl* filterMgr,
WithChannels withChannels,
WithTiled withTiled,
TiledMode tiledMode = TILED_NONE);
FilterManagerImpl* filterMgr,
WithChannels withChannels,
WithTiled withTiled,
TiledMode tiledMode = TiledMode::NONE);
~FilterWindow();
// Shows the window as modal (blocking interface), and returns true

View File

@ -11,7 +11,6 @@
#include "app/handle_anidir.h"
#include "app/settings/document_settings.h"
#include "doc/sprite.h"
namespace app {
@ -19,15 +18,16 @@ namespace app {
doc::frame_t calculate_next_frame(
doc::Sprite* sprite,
doc::frame_t frame,
IDocumentSettings* docSettings,
DocumentPreferences& docPref,
bool& pingPongForward)
{
frame_t first = frame_t(0);
frame_t last = sprite->lastFrame();
if (docSettings->getLoopAnimation()) {
if (docPref.loop.visible()) {
frame_t loopBegin, loopEnd;
docSettings->getLoopRange(&loopBegin, &loopEnd);
loopBegin = docPref.loop.from();
loopEnd = docPref.loop.to();
loopBegin = MID(first, loopBegin, last);
loopEnd = MID(first, loopEnd, last);
@ -35,21 +35,21 @@ doc::frame_t calculate_next_frame(
last = loopEnd;
}
switch (docSettings->getAnimationDirection()) {
switch (docPref.loop.aniDir()) {
case IDocumentSettings::AniDir_Normal:
case app::gen::AniDir::FORWARD:
++frame;
if (frame > last)
frame = first;
break;
case IDocumentSettings::AniDir_Reverse:
case app::gen::AniDir::REVERSE:
--frame;
if (frame < first)
frame = last;
break;
case IDocumentSettings::AniDir_PingPong:
case app::gen::AniDir::PING_PONG:
if (pingPongForward) {
++frame;
if (frame > last) {

View File

@ -9,6 +9,7 @@
#define APP_HANDLE_ANIDIR_H_INCLUDED
#pragma once
#include "app/pref/preferences.h"
#include "doc/frame.h"
namespace doc {
@ -17,12 +18,10 @@ namespace doc {
namespace app {
class IDocumentSettings;
doc::frame_t calculate_next_frame(
doc::Sprite* sprite,
doc::frame_t frame,
IDocumentSettings* docSettings,
DocumentPreferences& docPref,
bool& pingPongForward);
} // namespace app

View File

@ -12,6 +12,10 @@
#include "app/pref/option.h"
#include "doc/documents_observer.h"
namespace filters {
enum class TiledMode;
}
#include "generated_pref_types.h"
#include <map>

View File

@ -1,107 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
#ifndef APP_SETTINGS_DOCUMENT_SETTINGS_H_INCLUDED
#define APP_SETTINGS_DOCUMENT_SETTINGS_H_INCLUDED
#pragma once
#include "app/color.h"
#include "filters/tiled_mode.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "doc/frame.h"
namespace app {
class DocumentSettingsObserver;
class IDocumentSettings {
public:
virtual ~IDocumentSettings() { }
// Tiled mode
virtual filters::TiledMode getTiledMode() = 0;
virtual void setTiledMode(filters::TiledMode mode) = 0;
// Grid settings
virtual bool getSnapToGrid() = 0;
virtual bool getGridVisible() = 0;
virtual gfx::Rect getGridBounds() = 0;
virtual app::Color getGridColor() = 0;
virtual int getGridOpacity() = 0;
virtual bool getGridAutoOpacity() = 0;
virtual void setSnapToGrid(bool state) = 0;
virtual void setGridVisible(bool state) = 0;
virtual void setGridBounds(const gfx::Rect& rect) = 0;
virtual void setGridColor(const app::Color& color) = 0;
virtual void setGridOpacity(int opacity) = 0;
virtual void setGridAutoOpacity(bool state) = 0;
virtual void snapToGrid(gfx::Point& point) const = 0;
// Pixel grid
virtual bool getPixelGridVisible() = 0;
virtual app::Color getPixelGridColor() = 0;
virtual int getPixelGridOpacity() = 0;
virtual bool getPixelGridAutoOpacity() = 0;
virtual void setPixelGridVisible(bool state) = 0;
virtual void setPixelGridColor(const app::Color& color) = 0;
virtual void setPixelGridOpacity(int opacity) = 0;
virtual void setPixelGridAutoOpacity(bool state) = 0;
// Onionskin settings
enum OnionskinType {
Onionskin_Merge,
Onionskin_RedBlueTint,
Onionskin_Last = Onionskin_RedBlueTint
};
virtual bool getUseOnionskin() = 0;
virtual int getOnionskinPrevFrames() = 0;
virtual int getOnionskinNextFrames() = 0;
virtual int getOnionskinOpacityBase() = 0;
virtual int getOnionskinOpacityStep() = 0;
virtual OnionskinType getOnionskinType() = 0;
virtual void setUseOnionskin(bool state) = 0;
virtual void setOnionskinPrevFrames(int frames) = 0;
virtual void setOnionskinNextFrames(int frames) = 0;
virtual void setOnionskinOpacityBase(int base) = 0;
virtual void setOnionskinOpacityStep(int step) = 0;
virtual void setOnionskinType(OnionskinType type) = 0;
virtual void setDefaultOnionskinSettings() = 0;
// Animation
enum AniDir {
AniDir_Normal,
AniDir_Reverse,
AniDir_PingPong
};
virtual bool getLoopAnimation() = 0;
virtual void getLoopRange(doc::frame_t* begin, doc::frame_t* end) = 0;
virtual AniDir getAnimationDirection() = 0;
virtual void setLoopAnimation(bool state) = 0;
virtual void setLoopRange(doc::frame_t begin, doc::frame_t end) = 0;
virtual void setAnimationDirection(AniDir dir) = 0;
// Observable
virtual void addObserver(DocumentSettingsObserver* observer) = 0;
virtual void removeObserver(DocumentSettingsObserver* observer) = 0;
};
} // namespace app
#endif

View File

@ -27,7 +27,6 @@ namespace app {
class ColorSwatches;
class IColorSwatchesStore;
class IDocumentSettings;
class IBrushSettings;
class BrushSettingsObserver;
class IToolSettings;
@ -68,11 +67,6 @@ namespace app {
virtual void setCurrentTool(tools::Tool* tool) = 0;
virtual void setColorSwatches(app::ColorSwatches* colorSwatches) = 0;
// Returns the specific settings for the given document. If the
// document is null, it should return an interface for
// global/default settings.
virtual IDocumentSettings* getDocumentSettings(const doc::Document* document) = 0;
// Specific configuration for the given tool.
virtual IToolSettings* getToolSettings(tools::Tool* tool) = 0;

View File

@ -71,17 +71,6 @@ namespace app {
virtual void onSetColorSwatches(ColorSwatches* swaches) {}
};
class DocumentSettingsObserver {
public:
virtual ~DocumentSettingsObserver() { }
virtual void onSetTiledMode(filters::TiledMode mode) { }
virtual void onSetSnapToGrid(bool state) { }
virtual void onSetGridVisible(bool state) { }
virtual void onSetGridBounds(const gfx::Rect& rect) { }
virtual void onSetGridColor(const app::Color& color) { }
};
} // namespace app
#endif // APP_SETTINGS_SETTINGS_OBSERVERS_H_INCLUDED

View File

@ -16,7 +16,6 @@
#include "app/document.h"
#include "app/ini_file.h"
#include "app/resource_finder.h"
#include "app/settings/document_settings.h"
#include "app/tools/controller.h"
#include "app/tools/ink.h"
#include "app/tools/point_shape.h"
@ -46,224 +45,6 @@ using namespace filters;
namespace {
class UIDocumentSettingsImpl : public IDocumentSettings,
public base::Observable<DocumentSettingsObserver> {
public:
UIDocumentSettingsImpl(const doc::Document* doc)
: m_doc(doc)
, m_tiledMode(TILED_NONE)
, m_use_onionskin(false)
, m_prev_frames_onionskin(1)
, m_next_frames_onionskin(1)
, m_onionskin_opacity_base(DEFAULT_ONIONSKIN_OPACITY_BASE)
, m_onionskin_opacity_step(DEFAULT_ONIONSKIN_OPACITY_STEP)
, m_onionskinType(DEFAULT_ONIONSKIN_TYPE)
, m_snapToGrid(false)
, m_gridVisible(false)
, m_gridBounds(0, 0, 16, 16)
, m_gridColor(app::Color::fromRgb(0, 0, 255))
, m_gridOpacity(200)
, m_gridAutoOpacity(true)
, m_pixelGridVisible(false)
, m_pixelGridColor(app::Color::fromRgb(200, 200, 200))
, m_pixelGridOpacity(200)
, m_pixelGridAutoOpacity(true)
, m_isLoop(false)
, m_loopBegin(0)
, m_loopEnd(1)
, m_aniDir(AniDir_Normal)
{
bool specific_file = false;
if (m_doc && static_cast<const app::Document*>(m_doc)->isAssociatedToFile()) {
push_config_state();
set_config_file(configFileName().c_str());
specific_file = true;
m_tiledMode = (TiledMode)get_config_int("Tools", "Tiled", (int)m_tiledMode);
m_use_onionskin = get_config_bool("Onionskin", "Enabled", m_use_onionskin);
m_prev_frames_onionskin = get_config_int("Onionskin", "PrevFrames", m_prev_frames_onionskin);
m_next_frames_onionskin = get_config_int("Onionskin", "NextFrames", m_next_frames_onionskin);
m_onionskin_opacity_base = get_config_int("Onionskin", "OpacityBase", m_onionskin_opacity_base);
m_onionskin_opacity_step = get_config_int("Onionskin", "OpacityStep", m_onionskin_opacity_step);
m_onionskinType = (OnionskinType)get_config_int("Onionskin", "Type", m_onionskinType);
m_snapToGrid = get_config_bool("Grid", "SnapTo", m_snapToGrid);
m_gridVisible = get_config_bool("Grid", "Visible", m_gridVisible);
m_gridBounds = get_config_rect("Grid", "Bounds", m_gridBounds);
m_pixelGridVisible = get_config_bool("PixelGrid", "Visible", m_pixelGridVisible);
// Limit values
m_tiledMode = (TiledMode)MID(0, (int)m_tiledMode, (int)TILED_BOTH);
m_onionskinType = (OnionskinType)MID(0, (int)m_onionskinType, (int)Onionskin_Last);
}
m_gridColor = get_config_color("Grid", "Color", m_gridColor);
m_gridOpacity = get_config_int("Grid", "Opacity", m_gridOpacity);
m_gridAutoOpacity = get_config_bool("Grid", "AutoOpacity", m_gridAutoOpacity);
m_pixelGridColor = get_config_color("PixelGrid", "Color", m_pixelGridColor);
m_pixelGridOpacity = get_config_int("PixelGrid", "Opacity", m_pixelGridOpacity);
m_pixelGridAutoOpacity = get_config_bool("PixelGrid", "AutoOpacity", m_pixelGridAutoOpacity);
if (specific_file)
pop_config_state();
}
~UIDocumentSettingsImpl()
{
bool specific_file = false;
if (m_doc) {
// We don't save the document configuration if it isn't associated with a file.
if (!static_cast<const app::Document*>(m_doc)->isAssociatedToFile())
return;
push_config_state();
set_config_file(configFileName().c_str());
specific_file = true;
set_config_int("Tools", "Tiled", m_tiledMode);
set_config_bool("Grid", "SnapTo", m_snapToGrid);
set_config_bool("Grid", "Visible", m_gridVisible);
set_config_rect("Grid", "Bounds", m_gridBounds);
set_config_bool("PixelGrid", "Visible", m_pixelGridVisible);
set_config_bool("Onionskin", "Enabled", m_use_onionskin);
set_config_int("Onionskin", "PrevFrames", m_prev_frames_onionskin);
set_config_int("Onionskin", "NextFrames", m_next_frames_onionskin);
set_config_int("Onionskin", "OpacityBase", m_onionskin_opacity_base);
set_config_int("Onionskin", "OpacityStep", m_onionskin_opacity_step);
set_config_int("Onionskin", "Type", m_onionskinType);
}
saveSharedSettings();
if (specific_file) {
flush_config_file();
pop_config_state();
}
}
// Tiled mode
virtual TiledMode getTiledMode() override;
virtual void setTiledMode(TiledMode mode) override;
// Grid settings
virtual bool getSnapToGrid() override;
virtual bool getGridVisible() override;
virtual gfx::Rect getGridBounds() override;
virtual app::Color getGridColor() override;
virtual int getGridOpacity() override;
virtual bool getGridAutoOpacity() override;
virtual void setSnapToGrid(bool state) override;
virtual void setGridVisible(bool state) override;
virtual void setGridBounds(const gfx::Rect& rect) override;
virtual void setGridColor(const app::Color& color) override;
virtual void setGridOpacity(int opacity) override;
virtual void setGridAutoOpacity(bool state) override;
virtual void snapToGrid(gfx::Point& point) const override;
// Pixel grid
virtual bool getPixelGridVisible() override;
virtual app::Color getPixelGridColor() override;
virtual int getPixelGridOpacity() override;
virtual bool getPixelGridAutoOpacity() override;
virtual void setPixelGridVisible(bool state) override;
virtual void setPixelGridColor(const app::Color& color) override;
virtual void setPixelGridOpacity(int opacity) override;
virtual void setPixelGridAutoOpacity(bool state) override;
// Onionskin settings
virtual bool getUseOnionskin() override;
virtual int getOnionskinPrevFrames() override;
virtual int getOnionskinNextFrames() override;
virtual int getOnionskinOpacityBase() override;
virtual int getOnionskinOpacityStep() override;
virtual OnionskinType getOnionskinType() override;
virtual void setUseOnionskin(bool state) override;
virtual void setOnionskinPrevFrames(int frames) override;
virtual void setOnionskinNextFrames(int frames) override;
virtual void setOnionskinOpacityBase(int base) override;
virtual void setOnionskinOpacityStep(int step) override;
virtual void setOnionskinType(OnionskinType type) override;
virtual void setDefaultOnionskinSettings() override;
// Animation
virtual bool getLoopAnimation() override;
virtual void getLoopRange(doc::frame_t* begin, doc::frame_t* end) override;
virtual AniDir getAnimationDirection() override;
virtual void setLoopAnimation(bool state) override;
virtual void setLoopRange(doc::frame_t begin, doc::frame_t end) override;
virtual void setAnimationDirection(AniDir dir) override;
virtual void addObserver(DocumentSettingsObserver* observer) override;
virtual void removeObserver(DocumentSettingsObserver* observer) override;
private:
void saveSharedSettings() {
set_config_color("Grid", "Color", m_gridColor);
set_config_int("Grid", "Opacity", m_gridOpacity);
set_config_bool("Grid", "AutoOpacity", m_gridAutoOpacity);
set_config_color("PixelGrid", "Color", m_pixelGridColor);
set_config_int("PixelGrid", "Opacity", m_pixelGridOpacity);
set_config_bool("PixelGrid", "AutoOpacity", m_pixelGridAutoOpacity);
}
std::string configFileName() {
if (!m_doc)
return "";
if (m_cfgName.empty()) {
ResourceFinder rf;
std::string fn = m_doc->filename();
for (size_t i=0; i<fn.size(); ++i) {
if (fn[i] == ' ' || fn[i] == '/' || fn[i] == '\\' || fn[i] == ':' || fn[i] == '.') {
fn[i] = '-';
}
}
rf.includeUserDir(("files/" + fn + ".ini").c_str());
m_cfgName = rf.getFirstOrCreateDefault();
}
return m_cfgName;
}
void redrawDocumentViews() {
// TODO Redraw only document's views
ui::Manager::getDefault()->invalidate();
}
const doc::Document* m_doc;
std::string m_cfgName;
TiledMode m_tiledMode;
bool m_use_onionskin;
int m_prev_frames_onionskin;
int m_next_frames_onionskin;
int m_onionskin_opacity_base;
int m_onionskin_opacity_step;
OnionskinType m_onionskinType;
bool m_snapToGrid;
bool m_gridVisible;
gfx::Rect m_gridBounds;
app::Color m_gridColor;
int m_gridOpacity;
bool m_gridAutoOpacity;
bool m_pixelGridVisible;
app::Color m_pixelGridColor;
int m_pixelGridOpacity;
bool m_pixelGridAutoOpacity;
bool m_isLoop;
doc::frame_t m_loopBegin;
doc::frame_t m_loopEnd;
AniDir m_aniDir;
};
class UISelectionSettingsImpl
: public ISelectionSettings
, public base::Observable<SelectionSettingsObserver> {
@ -321,9 +102,6 @@ UISettingsImpl::~UISettingsImpl()
set_config_bool("Options", "AutoSelectLayer", m_autoSelectLayer);
set_config_int("Options", "RightClickMode", static_cast<int>(m_rightClickMode));
for (auto it : m_docSettings)
delete it.second;
for (auto it : m_toolSettings)
delete it.second;
@ -331,15 +109,6 @@ UISettingsImpl::~UISettingsImpl()
delete it;
}
void UISettingsImpl::onRemoveDocument(doc::Document* doc)
{
auto it = m_docSettings.find(doc->id());
if (it != m_docSettings.end()) {
delete it->second;
m_docSettings.erase(it);
}
}
//////////////////////////////////////////////////////////////////////
// General settings
@ -466,22 +235,6 @@ void UISettingsImpl::setColorSwatches(app::ColorSwatches* colorSwatches)
notifyObservers<app::ColorSwatches*>(&GlobalSettingsObserver::onSetColorSwatches, colorSwatches);
}
IDocumentSettings* UISettingsImpl::getDocumentSettings(const doc::Document* document)
{
doc::ObjectId id;
if (!document)
id = doc::NullId;
else
id = document->id();
auto it = m_docSettings.find(id);
if (it != m_docSettings.end())
return it->second;
return m_docSettings[id] = new UIDocumentSettingsImpl(document);
}
IColorSwatchesStore* UISettingsImpl::getColorSwatchesStore()
{
return this;
@ -544,272 +297,6 @@ void UISettingsImpl::setFlashLayer(bool state)
set_config_bool("Options", "FlashLayer", state);
}
//////////////////////////////////////////////////////////////////////
// IDocumentSettings implementation
TiledMode UIDocumentSettingsImpl::getTiledMode()
{
return m_tiledMode;
}
void UIDocumentSettingsImpl::setTiledMode(TiledMode mode)
{
m_tiledMode = mode;
notifyObservers<TiledMode>(&DocumentSettingsObserver::onSetTiledMode, mode);
}
bool UIDocumentSettingsImpl::getSnapToGrid()
{
return m_snapToGrid;
}
bool UIDocumentSettingsImpl::getGridVisible()
{
return m_gridVisible;
}
Rect UIDocumentSettingsImpl::getGridBounds()
{
return m_gridBounds;
}
app::Color UIDocumentSettingsImpl::getGridColor()
{
return m_gridColor;
}
int UIDocumentSettingsImpl::getGridOpacity()
{
return m_gridOpacity;
}
bool UIDocumentSettingsImpl::getGridAutoOpacity()
{
return m_gridAutoOpacity;
}
void UIDocumentSettingsImpl::setSnapToGrid(bool state)
{
m_snapToGrid = state;
notifyObservers<bool>(&DocumentSettingsObserver::onSetSnapToGrid, state);
}
void UIDocumentSettingsImpl::setGridVisible(bool state)
{
m_gridVisible = state;
notifyObservers<bool>(&DocumentSettingsObserver::onSetGridVisible, state);
}
void UIDocumentSettingsImpl::setGridBounds(const Rect& rect)
{
m_gridBounds = rect;
notifyObservers<const Rect&>(&DocumentSettingsObserver::onSetGridBounds, rect);
}
void UIDocumentSettingsImpl::setGridColor(const app::Color& color)
{
m_gridColor = color;
notifyObservers<const app::Color&>(&DocumentSettingsObserver::onSetGridColor, color);
saveSharedSettings();
}
void UIDocumentSettingsImpl::setGridOpacity(int opacity)
{
m_gridOpacity = opacity;
notifyObservers<const app::Color&>(&DocumentSettingsObserver::onSetGridColor, m_gridColor);
saveSharedSettings();
}
void UIDocumentSettingsImpl::setGridAutoOpacity(bool state)
{
m_gridAutoOpacity = state;
notifyObservers<const app::Color&>(&DocumentSettingsObserver::onSetGridColor, m_gridColor);
saveSharedSettings();
}
void UIDocumentSettingsImpl::snapToGrid(gfx::Point& point) const
{
int w = m_gridBounds.w;
int h = m_gridBounds.h;
div_t d, dx, dy;
dx = div(m_gridBounds.x, w);
dy = div(m_gridBounds.y, h);
d = div(point.x-dx.rem, w);
point.x = dx.rem + d.quot*w + ((d.rem > w/2)? w: 0);
d = div(point.y-dy.rem, h);
point.y = dy.rem + d.quot*h + ((d.rem > h/2)? h: 0);
}
bool UIDocumentSettingsImpl::getPixelGridVisible()
{
return m_pixelGridVisible;
}
app::Color UIDocumentSettingsImpl::getPixelGridColor()
{
return m_pixelGridColor;
}
int UIDocumentSettingsImpl::getPixelGridOpacity()
{
return m_pixelGridOpacity;
}
bool UIDocumentSettingsImpl::getPixelGridAutoOpacity()
{
return m_pixelGridAutoOpacity;
}
void UIDocumentSettingsImpl::setPixelGridVisible(bool state)
{
m_pixelGridVisible = state;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setPixelGridColor(const app::Color& color)
{
m_pixelGridColor = color;
redrawDocumentViews();
saveSharedSettings();
}
void UIDocumentSettingsImpl::setPixelGridOpacity(int opacity)
{
m_pixelGridOpacity = opacity;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setPixelGridAutoOpacity(bool state)
{
m_pixelGridAutoOpacity = state;
redrawDocumentViews();
}
bool UIDocumentSettingsImpl::getUseOnionskin()
{
return m_use_onionskin;
}
int UIDocumentSettingsImpl::getOnionskinPrevFrames()
{
return m_prev_frames_onionskin;
}
int UIDocumentSettingsImpl::getOnionskinNextFrames()
{
return m_next_frames_onionskin;
}
int UIDocumentSettingsImpl::getOnionskinOpacityBase()
{
return m_onionskin_opacity_base;
}
int UIDocumentSettingsImpl::getOnionskinOpacityStep()
{
return m_onionskin_opacity_step;
}
IDocumentSettings::OnionskinType UIDocumentSettingsImpl::getOnionskinType()
{
return m_onionskinType;
}
void UIDocumentSettingsImpl::setUseOnionskin(bool state)
{
m_use_onionskin = state;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setOnionskinPrevFrames(int frames)
{
m_prev_frames_onionskin = frames;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setOnionskinNextFrames(int frames)
{
m_next_frames_onionskin = frames;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setOnionskinOpacityBase(int base)
{
m_onionskin_opacity_base = base;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setOnionskinOpacityStep(int step)
{
m_onionskin_opacity_step = step;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setOnionskinType(OnionskinType type)
{
m_onionskinType = type;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setDefaultOnionskinSettings()
{
m_onionskinType = DEFAULT_ONIONSKIN_TYPE;
m_onionskin_opacity_base = DEFAULT_ONIONSKIN_OPACITY_BASE;
m_onionskin_opacity_step = DEFAULT_ONIONSKIN_OPACITY_STEP;
redrawDocumentViews();
}
bool UIDocumentSettingsImpl::getLoopAnimation()
{
return m_isLoop;
}
void UIDocumentSettingsImpl::getLoopRange(doc::frame_t* begin, doc::frame_t* end)
{
*begin = m_loopBegin;
*end = m_loopEnd;
}
IDocumentSettings::AniDir UIDocumentSettingsImpl::getAnimationDirection()
{
return m_aniDir;
}
void UIDocumentSettingsImpl::setLoopAnimation(bool state)
{
m_isLoop = state;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setLoopRange(doc::frame_t begin, doc::frame_t end)
{
m_loopBegin = begin;
m_loopEnd = end;
redrawDocumentViews();
}
void UIDocumentSettingsImpl::setAnimationDirection(AniDir dir)
{
m_aniDir = dir;
}
void UIDocumentSettingsImpl::addObserver(DocumentSettingsObserver* observer)
{
base::Observable<DocumentSettingsObserver>::addObserver(observer);
}
void UIDocumentSettingsImpl::removeObserver(DocumentSettingsObserver* observer)
{
base::Observable<DocumentSettingsObserver>::removeObserver(observer);
}
//////////////////////////////////////////////////////////////////////
// Tools & brush settings

View File

@ -17,7 +17,6 @@
#include "app/settings/settings_observers.h"
#include "base/observable.h"
#include "base/unique_ptr.h"
#include "doc/documents_observer.h"
#include "doc/object_id.h"
namespace app {
@ -26,15 +25,11 @@ namespace app {
: public ISettings
, public IExperimentalSettings
, public IColorSwatchesStore
, public doc::DocumentsObserver
, base::Observable<GlobalSettingsObserver> {
public:
UISettingsImpl();
~UISettingsImpl();
// doc::DocumentsObserver
void onRemoveDocument(doc::Document* doc) override;
// ISettings implementation
bool getZoomWithScrollWheel() override;
bool getCenterOnZoom() override;
@ -58,7 +53,6 @@ namespace app {
void setCurrentTool(tools::Tool* tool) override;
void setColorSwatches(app::ColorSwatches* colorSwatches) override;
IDocumentSettings* getDocumentSettings(const doc::Document* document) override;
IToolSettings* getToolSettings(tools::Tool* tool) override;
IColorSwatchesStore* getColorSwatchesStore() override;
@ -93,7 +87,6 @@ namespace app {
bool m_grabAlpha;
bool m_autoSelectLayer;
RightClickMode m_rightClickMode;
std::map<doc::ObjectId, IDocumentSettings*> m_docSettings;
};
} // namespace app

38
src/app/snap_to_grid.cpp Normal file
View File

@ -0,0 +1,38 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/snap_to_grid.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include <cstdlib>
namespace app {
gfx::Point snap_to_grid(const gfx::Rect& grid, const gfx::Point& point)
{
gfx::Point newPoint;
div_t d, dx, dy;
dx = std::div(grid.x, grid.w);
dy = std::div(grid.y, grid.h);
d = std::div(point.x-dx.rem, grid.w);
newPoint.x = dx.rem + d.quot*grid.w + ((d.rem > grid.w/2)? grid.w: 0);
d = std::div(point.y-dy.rem, grid.h);
newPoint.y = dy.rem + d.quot*grid.h + ((d.rem > grid.h/2)? grid.h: 0);
return newPoint;
}
} // namespace app

20
src/app/snap_to_grid.h Normal file
View File

@ -0,0 +1,20 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
#ifndef APP_SNAP_TO_GRID_H_INCLUDED
#define APP_SNAP_TO_GRID_H_INCLUDED
#pragma once
#include "gfx/fwd.h"
namespace app {
gfx::Point snap_to_grid(const gfx::Rect& grid, const gfx::Point& point);
} // namespace app
#endif

View File

@ -7,7 +7,6 @@
#include <cmath>
#include "app/settings/document_settings.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
@ -152,7 +151,7 @@ public:
// Adjust points for selection like tools (so we can select tiles)
if (loop->getController()->canSnapToGrid() &&
loop->getDocumentSettings()->getSnapToGrid() &&
loop->getSnapToGrid() &&
loop->getInk()->isSelection()) {
if (points[0].x < points[1].x)
points[1].x--;

View File

@ -6,7 +6,6 @@
// published by the Free Software Foundation.
#include "app/modules/palettes.h"
#include "app/settings/document_settings.h"
#include "app/tools/shade_table.h"
#include "app/tools/shading_options.h"
#include "doc/palette.h"
@ -276,7 +275,7 @@ class BlurInkProcessing<RgbTraits> : public DoubleInkProcessing<BlurInkProcessin
public:
BlurInkProcessing(ToolLoop* loop) :
m_opacity(loop->getOpacity()),
m_tiledMode(loop->getDocumentSettings()->getTiledMode()),
m_tiledMode(loop->getTiledMode()),
m_srcImage(loop->getSrcImage()) {
}
@ -332,7 +331,7 @@ class BlurInkProcessing<GrayscaleTraits> : public DoubleInkProcessing<BlurInkPro
public:
BlurInkProcessing(ToolLoop* loop) :
m_opacity(loop->getOpacity()),
m_tiledMode(loop->getDocumentSettings()->getTiledMode()),
m_tiledMode(loop->getTiledMode()),
m_srcImage(loop->getSrcImage()) {
}
@ -384,7 +383,7 @@ public:
m_palette(get_current_palette()),
m_rgbmap(loop->getRgbMap()),
m_opacity(loop->getOpacity()),
m_tiledMode(loop->getDocumentSettings()->getTiledMode()),
m_tiledMode(loop->getTiledMode()),
m_srcImage(loop->getSrcImage()),
m_area(get_current_palette()) {
}
@ -534,7 +533,7 @@ public:
m_rgbmap(loop->getRgbMap()),
m_speed(loop->getSpeed() / 4),
m_opacity(loop->getOpacity()),
m_tiledMode(loop->getDocumentSettings()->getTiledMode()),
m_tiledMode(loop->getTiledMode()),
m_srcImage(loop->getSrcImage()),
m_srcImageWidth(m_srcImage->width()),
m_srcImageHeight(m_srcImage->height()) {
@ -549,7 +548,7 @@ private:
int u = x + (rand() % 3)-1 - m_speed.x;
int v = y + (rand() % 3)-1 - m_speed.y;
if (m_tiledMode & TILED_X_AXIS) {
if (int(m_tiledMode) & int(TiledMode::X_AXIS)) {
if (u < 0)
u = m_srcImageWidth - (-(u+1) % m_srcImageWidth) - 1;
else if (u >= m_srcImageWidth)
@ -559,7 +558,7 @@ private:
u = MID(0, u, m_srcImageWidth-1);
}
if (m_tiledMode & TILED_Y_AXIS) {
if (int(m_tiledMode) & int(TiledMode::Y_AXIS)) {
if (v < 0)
v = m_srcImageHeight - (-(v+1) % m_srcImageHeight) - 1;
else if (v >= m_srcImageHeight)

View File

@ -11,7 +11,6 @@
#include "app/tools/point_shape.h"
#include "app/settings/document_settings.h"
#include "app/tools/ink.h"
#include "app/tools/tool_loop.h"
#include "doc/image.h"
@ -24,11 +23,11 @@ using namespace filters;
void PointShape::doInkHline(int x1, int y, int x2, ToolLoop* loop)
{
TiledMode tiledMode = loop->getDocumentSettings()->getTiledMode();
TiledMode tiledMode = loop->getTiledMode();
int x, w, size; // width or height
// Tiled in Y axis
if (tiledMode & TILED_Y_AXIS) {
if (int(tiledMode) & int(TiledMode::Y_AXIS)) {
size = loop->getDstImage()->height(); // size = image height
if (y < 0)
y = size - (-(y+1) % size) - 1;
@ -39,7 +38,7 @@ void PointShape::doInkHline(int x1, int y, int x2, ToolLoop* loop)
return;
// Tiled in X axis
if (tiledMode & TILED_X_AXIS) {
if (int(tiledMode) & int(TiledMode::X_AXIS)) {
if (x1 > x2)
return;

View File

@ -87,8 +87,8 @@ private:
bounds = bounds.createIntersect(loop->getSrcImage()->bounds());
// Limit the flood-fill to the current tile if the grid is visible.
if (loop->getDocumentSettings()->getGridVisible()) {
gfx::Rect grid = loop->getDocumentSettings()->getGridBounds();
if (loop->getGridVisible()) {
gfx::Rect grid = loop->getGridBounds();
div_t d, dx, dy;
dx = div(grid.x+loop->getOffset().x, grid.w);

View File

@ -35,7 +35,6 @@ namespace render {
namespace app {
class Context;
class Document;
class IDocumentSettings;
class ISettings;
namespace tools {
@ -161,15 +160,16 @@ namespace app {
// primary/secondary).
virtual ISettings* settings() = 0;
// Returns the document settings (tiled mode, grid bounds, etc.).
// It's used to know the preferred "tiled" mode of the document.
// Returns the preferred "tiled" mode of the document.
// See the method PointShape::doInkHline to check how this member is
// used. When tiled mode is activated, each scanline can be divided
// in various sub-lines if they pass the image bounds. For each of
// these scanlines a Ink::inkHline is called
// Also it's used to know the grid/snap-to-grid settings/behavior
// (see ToolLoopManager::snapToGrid).
virtual IDocumentSettings* getDocumentSettings() = 0;
virtual filters::TiledMode getTiledMode() = 0;
virtual bool getGridVisible() = 0;
virtual bool getSnapToGrid() = 0;
virtual gfx::Rect getGridBounds() = 0;
// Returns true if the figure must be filled when we release the
// mouse (e.g. a filled rectangle, etc.)

View File

@ -12,7 +12,7 @@
#include "app/tools/tool_loop_manager.h"
#include "app/context.h"
#include "app/settings/document_settings.h"
#include "app/snap_to_grid.h"
#include "app/tools/controller.h"
#include "app/tools/ink.h"
#include "app/tools/intertwine.h"
@ -220,10 +220,10 @@ void ToolLoopManager::doLoopStep(bool last_step)
void ToolLoopManager::snapToGrid(Point& point)
{
if (!m_toolLoop->getController()->canSnapToGrid() ||
!m_toolLoop->getDocumentSettings()->getSnapToGrid())
!m_toolLoop->getSnapToGrid())
return;
m_toolLoop->getDocumentSettings()->snapToGrid(point);
point = snap_to_grid(m_toolLoop->getGridBounds(), point);
}
void ToolLoopManager::calculateDirtyArea(const Points& points)
@ -259,8 +259,8 @@ void ToolLoopManager::calculateDirtyArea(const Points& points)
m_dirtyArea.createUnion(m_dirtyArea, prevDirtyArea);
// Apply tiled mode
TiledMode tiledMode = m_toolLoop->getDocumentSettings()->getTiledMode();
if (tiledMode != TILED_NONE) {
TiledMode tiledMode = m_toolLoop->getTiledMode();
if (tiledMode != TiledMode::NONE) {
int w = m_toolLoop->sprite()->width();
int h = m_toolLoop->sprite()->height();
Region sprite_area(Rect(0, 0, w, h));
@ -268,10 +268,10 @@ void ToolLoopManager::calculateDirtyArea(const Points& points)
outside.createSubtraction(m_dirtyArea, sprite_area);
switch (tiledMode) {
case TILED_X_AXIS:
case TiledMode::X_AXIS:
outside.createIntersection(outside, Region(Rect(-w*10000, 0, w*20000, h)));
break;
case TILED_Y_AXIS:
case TiledMode::Y_AXIS:
outside.createIntersection(outside, Region(Rect(0, -h*10000, w, h*20000)));
break;
}

View File

@ -16,7 +16,6 @@
#include "app/document.h"
#include "app/find_widget.h"
#include "app/load_widget.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/commands/commands.h"
#include "app/ui/main_window.h"
@ -62,57 +61,50 @@ ConfigureTimelinePopup::ConfigureTimelinePopup()
m_resetOnionskin->Click.connect(Bind<void>(&ConfigureTimelinePopup::onResetOnionskin, this));
m_setLoopSection->Click.connect(Bind<void>(&ConfigureTimelinePopup::onSetLoopSection, this));
m_resetLoopSection->Click.connect(Bind<void>(&ConfigureTimelinePopup::onResetLoopSection, this));
m_normalDir->Click.connect(Bind<void>(&ConfigureTimelinePopup::onAniDir, this, IDocumentSettings::AniDir_Normal));
m_reverseDir->Click.connect(Bind<void>(&ConfigureTimelinePopup::onAniDir, this, IDocumentSettings::AniDir_Reverse));
m_pingPongDir->Click.connect(Bind<void>(&ConfigureTimelinePopup::onAniDir, this, IDocumentSettings::AniDir_PingPong));
m_normalDir->Click.connect(Bind<void>(&ConfigureTimelinePopup::onAniDir, this, app::gen::AniDir::FORWARD));
m_reverseDir->Click.connect(Bind<void>(&ConfigureTimelinePopup::onAniDir, this, app::gen::AniDir::REVERSE));
m_pingPongDir->Click.connect(Bind<void>(&ConfigureTimelinePopup::onAniDir, this, app::gen::AniDir::PING_PONG));
}
IDocumentSettings* ConfigureTimelinePopup::docSettings()
DocumentPreferences& ConfigureTimelinePopup::docPref()
{
Context* context = UIContext::instance();
Document* document = context->activeDocument();
if (!document)
return NULL;
return context->settings()->getDocumentSettings(document);
return App::instance()->preferences().document(
UIContext::instance()->activeDocument());
}
void ConfigureTimelinePopup::updateWidgetsFromCurrentSettings()
{
IDocumentSettings* docSet = docSettings();
if (!docSet)
return;
DocumentPreferences& docPref = this->docPref();
base::ScopedValue<bool> lockUpdates(m_lockUpdates, true, false);
switch (docSet->getOnionskinType()) {
case IDocumentSettings::Onionskin_Merge:
switch (docPref.onionskin.type()) {
case app::gen::OnionskinType::MERGE:
m_merge->setSelected(true);
break;
case IDocumentSettings::Onionskin_RedBlueTint:
case app::gen::OnionskinType::RED_BLUE_TINT:
m_tint->setSelected(true);
break;
}
m_opacity->setValue(docSet->getOnionskinOpacityBase());
m_opacityStep->setValue(docSet->getOnionskinOpacityStep());
m_opacity->setValue(docPref.onionskin.opacityBase());
m_opacityStep->setValue(docPref.onionskin.opacityStep());
switch (docSet->getOnionskinType()) {
case IDocumentSettings::Onionskin_Merge:
switch (docPref.onionskin.type()) {
case app::gen::OnionskinType::MERGE:
m_merge->setSelected(true);
break;
case IDocumentSettings::Onionskin_RedBlueTint:
case app::gen::OnionskinType::RED_BLUE_TINT:
m_tint->setSelected(true);
break;
}
switch (docSet->getAnimationDirection()) {
case IDocumentSettings::AniDir_Normal:
switch (docPref.loop.aniDir()) {
case app::gen::AniDir::FORWARD:
m_normalDir->setSelected(true);
break;
case IDocumentSettings::AniDir_Reverse:
case app::gen::AniDir::REVERSE:
m_reverseDir->setSelected(true);
break;
case IDocumentSettings::AniDir_PingPong:
case app::gen::AniDir::PING_PONG:
m_pingPongDir->setSelected(true);
break;
}
@ -136,11 +128,9 @@ void ConfigureTimelinePopup::onChangeType()
if (m_lockUpdates)
return;
IDocumentSettings* docSet = docSettings();
if (docSet)
docSet->setOnionskinType(m_merge->isSelected() ?
IDocumentSettings::Onionskin_Merge:
IDocumentSettings::Onionskin_RedBlueTint);
docPref().onionskin.type(m_merge->isSelected() ?
app::gen::OnionskinType::MERGE:
app::gen::OnionskinType::RED_BLUE_TINT);
}
void ConfigureTimelinePopup::onOpacity()
@ -148,9 +138,7 @@ void ConfigureTimelinePopup::onOpacity()
if (m_lockUpdates)
return;
IDocumentSettings* docSet = docSettings();
if (docSet)
docSet->setOnionskinOpacityBase(m_opacity->getValue());
docPref().onionskin.opacityBase(m_opacity->getValue());
}
void ConfigureTimelinePopup::onOpacityStep()
@ -158,18 +146,18 @@ void ConfigureTimelinePopup::onOpacityStep()
if (m_lockUpdates)
return;
IDocumentSettings* docSet = docSettings();
if (docSet)
docSet->setOnionskinOpacityStep(m_opacityStep->getValue());
docPref().onionskin.opacityStep(m_opacityStep->getValue());
}
void ConfigureTimelinePopup::onResetOnionskin()
{
IDocumentSettings* docSet = docSettings();
if (docSet) {
docSet->setDefaultOnionskinSettings();
updateWidgetsFromCurrentSettings();
}
DocumentPreferences& docPref = this->docPref();
docPref.onionskin.type(docPref.onionskin.type.defaultValue());
docPref.onionskin.opacityBase(docPref.onionskin.opacityBase.defaultValue());
docPref.onionskin.opacityStep(docPref.onionskin.opacityStep.defaultValue());
updateWidgetsFromCurrentSettings();
}
void ConfigureTimelinePopup::onSetLoopSection()
@ -179,16 +167,12 @@ void ConfigureTimelinePopup::onSetLoopSection()
void ConfigureTimelinePopup::onResetLoopSection()
{
IDocumentSettings* docSet = docSettings();
if (docSet)
docSet->setLoopAnimation(false);
docPref().loop.visible(false);
}
void ConfigureTimelinePopup::onAniDir(IDocumentSettings::AniDir aniDir)
void ConfigureTimelinePopup::onAniDir(app::gen::AniDir aniDir)
{
IDocumentSettings* docSet = docSettings();
if (docSet)
docSet->setAnimationDirection(aniDir);
docPref().loop.aniDir(aniDir);
}
} // namespace app

View File

@ -9,7 +9,7 @@
#define APP_UI_CONFIGURE_TIMELINE_POPUP_H_INCLUDED
#pragma once
#include "app/settings/document_settings.h"
#include "app/pref/preferences.h"
#include "ui/popup_window.h"
namespace ui {
@ -33,11 +33,11 @@ namespace app {
void onResetOnionskin();
void onSetLoopSection();
void onResetLoopSection();
void onAniDir(IDocumentSettings::AniDir aniDir);
void onAniDir(app::gen::AniDir aniDir);
private:
void updateWidgetsFromCurrentSettings();
IDocumentSettings* docSettings();
DocumentPreferences& docPref();
ui::RadioButton* m_merge;
ui::RadioButton* m_tint;

View File

@ -22,7 +22,7 @@
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
#include "app/settings/document_settings.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/tools/ink.h"
#include "app/tools/tool.h"
@ -168,9 +168,14 @@ Editor::Editor(Document* document, EditorFlags flags)
m_fgColorChangeConn =
ColorBar::instance()->FgColorChange.connect(Bind<void>(&Editor::onFgColorChange, this));
UIContext::instance()->settings()
->getDocumentSettings(m_document)
->addObserver(this);
DocumentPreferences& docPref = App::instance()
->preferences().document(m_document);
m_tiledModeConn = docPref.tiled.mode.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
m_gridVisibleConn = docPref.grid.visible.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
m_gridBoundsConn = docPref.grid.bounds.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
m_gridColorConn = docPref.grid.color.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
m_pixelGridVisibleConn = docPref.pixelGrid.visible.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
m_pixelGridColorConn = docPref.pixelGrid.visible.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
m_document->addObserver(this);
@ -181,10 +186,6 @@ Editor::~Editor()
{
m_document->removeObserver(this);
UIContext::instance()->settings()
->getDocumentSettings(m_document)
->removeObserver(this);
setCustomizationDelegate(NULL);
m_mask_timer.stop();
@ -390,20 +391,20 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
m_renderEngine.setOnionskin(render::OnionskinType::NONE, 0, 0, 0, 0);
if ((m_flags & kShowOnionskin) == kShowOnionskin) {
IDocumentSettings* docSettings = UIContext::instance()
->settings()->getDocumentSettings(m_document);
DocumentPreferences& docPref = App::instance()
->preferences().document(m_document);
if (docSettings->getUseOnionskin()) {
if (docPref.onionskin.active()) {
m_renderEngine.setOnionskin(
(docSettings->getOnionskinType() == IDocumentSettings::Onionskin_Merge ?
(docPref.onionskin.type() == app::gen::OnionskinType::MERGE ?
render::OnionskinType::MERGE:
(docSettings->getOnionskinType() == IDocumentSettings::Onionskin_RedBlueTint ?
(docPref.onionskin.type() == app::gen::OnionskinType::RED_BLUE_TINT ?
render::OnionskinType::RED_BLUE_TINT:
render::OnionskinType::NONE)),
docSettings->getOnionskinPrevFrames(),
docSettings->getOnionskinNextFrames(),
docSettings->getOnionskinOpacityBase(),
docSettings->getOnionskinOpacityStep());
docPref.onionskin.prevFrames(),
docPref.onionskin.nextFrames(),
docPref.onionskin.opacityBase(),
docPref.onionskin.opacityStep());
}
}
@ -464,10 +465,10 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
outside.createSubtraction(outside, gfx::Region(spriteRect));
// Document settings
IDocumentSettings* docSettings =
UIContext::instance()->settings()->getDocumentSettings(m_document);
DocumentPreferences& docPref =
App::instance()->preferences().document(m_document);
if (docSettings->getTiledMode() & filters::TILED_X_AXIS) {
if (int(docPref.tiled.mode()) & int(filters::TiledMode::X_AXIS)) {
drawOneSpriteUnclippedRect(g, rc, -spriteRect.w, 0);
drawOneSpriteUnclippedRect(g, rc, +spriteRect.w, 0);
@ -475,7 +476,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
outside.createSubtraction(outside, gfx::Region(enclosingRect));
}
if (docSettings->getTiledMode() & filters::TILED_Y_AXIS) {
if (int(docPref.tiled.mode()) & int(filters::TiledMode::Y_AXIS)) {
drawOneSpriteUnclippedRect(g, rc, 0, -spriteRect.h);
drawOneSpriteUnclippedRect(g, rc, 0, +spriteRect.h);
@ -483,7 +484,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
outside.createSubtraction(outside, gfx::Region(enclosingRect));
}
if (docSettings->getTiledMode() == filters::TILED_BOTH) {
if (docPref.tiled.mode() == filters::TiledMode::BOTH) {
drawOneSpriteUnclippedRect(g, rc, -spriteRect.w, -spriteRect.h);
drawOneSpriteUnclippedRect(g, rc, +spriteRect.w, -spriteRect.h);
drawOneSpriteUnclippedRect(g, rc, -spriteRect.w, +spriteRect.h);
@ -511,34 +512,34 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
IntersectClip clip(g, cliprc);
// Draw the pixel grid
if ((m_zoom.scale() > 2.0) && docSettings->getPixelGridVisible()) {
int alpha = docSettings->getPixelGridOpacity();
if ((m_zoom.scale() > 2.0) && docPref.pixelGrid.visible()) {
int alpha = docPref.pixelGrid.opacity();
if (docSettings->getPixelGridAutoOpacity()) {
if (docPref.pixelGrid.autoOpacity()) {
alpha = int(alpha * (m_zoom.scale()-2.) / (16.-2.));
alpha = MID(0, alpha, 255);
}
drawGrid(g, enclosingRect, Rect(0, 0, 1, 1),
docSettings->getPixelGridColor(), alpha);
docPref.pixelGrid.color(), alpha);
}
// Draw the grid
if (docSettings->getGridVisible()) {
gfx::Rect gridrc = docSettings->getGridBounds();
if (docPref.grid.visible()) {
gfx::Rect gridrc = docPref.grid.bounds();
if (m_zoom.apply(gridrc.w) > 2 &&
m_zoom.apply(gridrc.h) > 2) {
int alpha = docSettings->getGridOpacity();
int alpha = docPref.grid.opacity();
if (docSettings->getGridAutoOpacity()) {
if (docPref.grid.autoOpacity()) {
double len = (m_zoom.apply(gridrc.w) + m_zoom.apply(gridrc.h)) / 2.;
alpha = int(alpha * len / 32.);
alpha = MID(0, alpha, 255);
}
if (alpha > 8)
drawGrid(g, enclosingRect, docSettings->getGridBounds(),
docSettings->getGridColor(), alpha);
drawGrid(g, enclosingRect, docPref.grid.bounds(),
docPref.grid.color(), alpha);
}
}
}
@ -1494,24 +1495,4 @@ ImageBufferPtr Editor::getRenderImageBuffer()
return m_renderBuffer;
}
void Editor::onSetTiledMode(filters::TiledMode mode)
{
invalidate();
}
void Editor::onSetGridVisible(bool state)
{
invalidate();
}
void Editor::onSetGridBounds(const gfx::Rect& rect)
{
invalidate();
}
void Editor::onSetGridColor(const app::Color& color)
{
invalidate();
}
} // namespace app

View File

@ -13,7 +13,6 @@
#include "app/color.h"
#include "app/document.h"
#include "app/settings/selection_mode.h"
#include "app/settings/settings_observers.h"
#include "app/ui/editor/editor_observers.h"
#include "app/ui/editor/editor_state.h"
#include "app/ui/editor/editor_states_history.h"
@ -21,6 +20,7 @@
#include "doc/document_observer.h"
#include "doc/frame.h"
#include "doc/image_buffer.h"
#include "filters/tiled_mode.h"
#include "gfx/fwd.h"
#include "render/zoom.h"
#include "ui/base.h"
@ -57,8 +57,7 @@ namespace app {
};
class Editor : public ui::Widget,
public doc::DocumentObserver,
public DocumentSettingsObserver {
public doc::DocumentObserver {
public:
typedef void (*PixelDelegate)(ui::Graphics*, const gfx::Point&, gfx::Color);
@ -212,11 +211,6 @@ namespace app {
void onExposeSpritePixels(doc::DocumentEvent& ev);
void onSetTiledMode(filters::TiledMode mode);
void onSetGridVisible(bool state);
void onSetGridBounds(const gfx::Rect& rect);
void onSetGridColor(const app::Color& color);
private:
void setStateInternal(const EditorStatePtr& newState);
void updateQuicktool();
@ -289,6 +283,14 @@ namespace app {
ScopedConnection m_currentToolChangeConn;
ScopedConnection m_fgColorChangeConn;
// Slots listeing document preferences.
ScopedConnection m_tiledModeConn;
ScopedConnection m_gridVisibleConn;
ScopedConnection m_gridBoundsConn;
ScopedConnection m_gridColorConn;
ScopedConnection m_pixelGridVisibleConn;
ScopedConnection m_pixelGridColorConn;
EditorObservers m_observers;
EditorCustomizationDelegate* m_customizationDelegate;

View File

@ -11,14 +11,16 @@
#include "app/ui/editor/pixels_movement.h"
#include "app/app.h"
#include "app/cmd/clear_mask.h"
#include "app/cmd/deselect_mask.h"
#include "app/cmd/set_mask.h"
#include "app/document.h"
#include "app/document_api.h"
#include "app/modules/gui.h"
#include "app/settings/document_settings.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/snap_to_grid.h"
#include "app/ui_context.h"
#include "app/util/expand_cel_canvas.h"
#include "base/vector2d.h"
@ -197,9 +199,10 @@ void PixelsMovement::moveImage(const gfx::Point& pos, MoveModifier moveModifier)
if ((moveModifier & SnapToGridMovement) == SnapToGridMovement) {
// Snap the x1,y1 point to the grid.
gfx::Rect gridBounds = App::instance()
->preferences().document(m_document).grid.bounds();
gfx::Point gridOffset(x1, y1);
UIContext::instance()->settings()
->getDocumentSettings(m_document)->snapToGrid(gridOffset);
gridOffset = snap_to_grid(gridBounds, gridOffset);
// Now we calculate the difference from x1,y1 point and we can
// use it to adjust all coordinates (x1, y1, x2, y2).
@ -437,7 +440,7 @@ void PixelsMovement::stampImage()
// Expand the canvas to paste the image in the fully visible
// portion of sprite.
ExpandCelCanvas expand(writer.context(),
TILED_NONE, m_transaction,
TiledMode::NONE, m_transaction,
ExpandCelCanvas::None);
// TODO can we reduce this region?

View File

@ -19,7 +19,7 @@
#include "app/context_access.h"
#include "app/document_undo.h"
#include "app/modules/gui.h"
#include "app/settings/document_settings.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/tools/controller.h"
#include "app/tools/ink.h"
@ -59,7 +59,7 @@ class ToolLoopImpl : public tools::ToolLoop,
int m_sprayWidth;
int m_spraySpeed;
ISettings* m_settings;
IDocumentSettings* m_docSettings;
DocumentPreferences& m_docPref;
IToolSettings* m_toolSettings;
bool m_useMask;
Mask* m_mask;
@ -96,7 +96,7 @@ public:
, m_layer(editor->layer())
, m_frame(editor->frame())
, m_settings(m_context->settings())
, m_docSettings(m_settings->getDocumentSettings(m_document))
, m_docPref(App::instance()->preferences().document(m_document))
, m_toolSettings(m_settings->getToolSettings(m_tool))
, m_canceled(false)
, m_button(button)
@ -112,7 +112,7 @@ public:
getInk()->isZoom()) ? DoesntModifyDocument:
ModifyDocument))
, m_expandCelCanvas(m_context,
m_docSettings->getTiledMode(),
m_docPref.tiled.mode(),
m_transaction,
ExpandCelCanvas::Flags(
ExpandCelCanvas::NeedsSource |
@ -259,7 +259,10 @@ public:
bool getContiguous() override { return m_contiguous; }
SelectionMode getSelectionMode() override { return m_editor->getSelectionMode(); }
ISettings* settings() override { return m_settings; }
IDocumentSettings* getDocumentSettings() override { return m_docSettings; }
filters::TiledMode getTiledMode() override { return m_docPref.tiled.mode(); }
bool getGridVisible() override { return m_docPref.grid.visible(); }
bool getSnapToGrid() override { return m_docPref.grid.snap(); }
gfx::Rect getGridBounds() override { return m_docPref.grid.bounds(); }
bool getFilled() override { return m_filled; }
bool getPreviewFilled() override { return m_previewFilled; }
int getSprayWidth() override { return m_sprayWidth; }

View File

@ -11,13 +11,13 @@
#include "app/ui/preview_editor.h"
#include "app/app.h"
#include "app/document.h"
#include "app/handle_anidir.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/pref/preferences.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/editor_view.h"
#include "app/ui/editor/navigate_state.h"
@ -334,10 +334,8 @@ void PreviewEditorWindow::onPlaybackTick()
if (!document || !sprite)
return;
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(document);
if (!docSettings)
return;
DocumentPreferences& docPref =
App::instance()->preferences().document(document);
if (m_nextFrameTime >= 0) {
m_nextFrameTime -= (ui::clock() - m_curFrameTick);
@ -346,7 +344,7 @@ void PreviewEditorWindow::onPlaybackTick()
frame_t frame = calculate_next_frame(
sprite,
miniEditor->frame(),
docSettings,
docPref,
m_pingPongForward);
miniEditor->setFrame(frame);

View File

@ -25,8 +25,6 @@
#include "app/modules/editors.h"
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/settings/document_settings.h"
#include "app/settings/settings.h"
#include "app/ui/configure_timeline_popup.h"
#include "app/ui/document_view.h"
#include "app/ui/editor/editor.h"
@ -339,17 +337,13 @@ bool Timeline::onProcessMessage(Message* msg)
m_state = STATE_MOVING_SEPARATOR;
break;
case A_PART_HEADER_ONIONSKIN_RANGE_LEFT: {
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
m_state = STATE_MOVING_ONIONSKIN_RANGE_LEFT;
m_origFrames = docSettings->getOnionskinPrevFrames();
m_origFrames = docPref().onionskin.prevFrames();
break;
}
case A_PART_HEADER_ONIONSKIN_RANGE_RIGHT: {
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
m_state = STATE_MOVING_ONIONSKIN_RANGE_RIGHT;
m_origFrames = docSettings->getOnionskinNextFrames();
m_origFrames = docPref().onionskin.nextFrames();
break;
}
case A_PART_HEADER_FRAME: {
@ -451,19 +445,15 @@ bool Timeline::onProcessMessage(Message* msg)
}
case STATE_MOVING_ONIONSKIN_RANGE_LEFT: {
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
int newValue = m_origFrames + (m_clk_frame - hot_frame);
docSettings->setOnionskinPrevFrames(MAX(0, newValue));
docPref().onionskin.prevFrames(MAX(0, newValue));
invalidate();
return true;
}
case STATE_MOVING_ONIONSKIN_RANGE_RIGHT:
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
int newValue = m_origFrames - (m_clk_frame - hot_frame);
docSettings->setOnionskinNextFrames(MAX(0, newValue));
docPref().onionskin.nextFrames(MAX(0, newValue));
invalidate();
return true;
}
@ -583,10 +573,7 @@ bool Timeline::onProcessMessage(Message* msg)
}
case A_PART_HEADER_ONIONSKIN: {
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
if (docSettings)
docSettings->setUseOnionskin(!docSettings->getUseOnionskin());
docPref().onionskin.active(!docPref().onionskin.active());
break;
}
@ -1109,8 +1096,6 @@ void Timeline::drawClipboardRange(ui::Graphics* g)
void Timeline::drawHeader(ui::Graphics* g)
{
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
bool allInvisible = allLayersInvisible();
bool allLocked = allLayersLocked();
bool allContinuous = allLayersContinuous();
@ -1144,7 +1129,7 @@ void Timeline::drawHeader(ui::Graphics* g)
drawPart(g, getPartBounds(A_PART_HEADER_ONIONSKIN),
NULL, m_timelineOnionskinStyle,
docSettings->getUseOnionskin(),
docPref().onionskin.active(),
m_hot_part == A_PART_HEADER_ONIONSKIN,
m_clk_part == A_PART_HEADER_ONIONSKIN);
@ -1322,13 +1307,12 @@ void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& bounds,
void Timeline::drawLoopRange(ui::Graphics* g)
{
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
if (!docSettings->getLoopAnimation())
DocumentPreferences& docPref = this->docPref();
if (!docPref.loop.visible())
return;
frame_t begin, end;
docSettings->getLoopRange(&begin, &end);
frame_t begin = docPref.loop.from();
frame_t end = docPref.loop.to();
if (begin > end)
return;
@ -1460,22 +1444,21 @@ gfx::Rect Timeline::getFrameHeadersBounds() const
gfx::Rect Timeline::getOnionskinFramesBounds() const
{
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
if (docSettings->getUseOnionskin()) {
frame_t firstFrame = m_frame - docSettings->getOnionskinPrevFrames();
frame_t lastFrame = m_frame + docSettings->getOnionskinNextFrames();
DocumentPreferences& docPref = this->docPref();
if (!docPref.onionskin.active())
return gfx::Rect();
if (firstFrame < this->firstFrame())
firstFrame = this->firstFrame();
frame_t firstFrame = m_frame - docPref.onionskin.prevFrames();
frame_t lastFrame = m_frame + docPref.onionskin.nextFrames();
if (lastFrame > this->lastFrame())
lastFrame = this->lastFrame();
if (firstFrame < this->firstFrame())
firstFrame = this->firstFrame();
return getPartBounds(A_PART_HEADER_FRAME, firstLayer(), firstFrame)
.createUnion(getPartBounds(A_PART_HEADER_FRAME, firstLayer(), lastFrame));
}
return gfx::Rect();
if (lastFrame > this->lastFrame())
lastFrame = this->lastFrame();
return getPartBounds(A_PART_HEADER_FRAME, firstLayer(), firstFrame)
.createUnion(getPartBounds(A_PART_HEADER_FRAME, firstLayer(), lastFrame));
}
gfx::Rect Timeline::getCelsBounds() const
@ -1831,14 +1814,9 @@ void Timeline::updateStatusBar(ui::Message* msg)
switch (m_hot_part) {
case A_PART_HEADER_ONIONSKIN: {
ISettings* settings = UIContext::instance()->settings();
IDocumentSettings* docSettings = settings->getDocumentSettings(m_document);
if (docSettings) {
sb->setStatusText(0, "Onionskin is %s",
docSettings->getUseOnionskin() ? "enabled": "disabled");
return;
}
break;
sb->setStatusText(0, "Onionskin is %s",
docPref().onionskin.active() ? "enabled": "disabled");
return;
}
case A_PART_LAYER_TEXT:
@ -2211,4 +2189,9 @@ bool Timeline::isCopyKeyPressed(ui::Message* msg)
msg->altPressed(); // Alt is common on Mac OS X
}
DocumentPreferences& Timeline::docPref() const
{
return App::instance()->preferences().document(m_document);
}
} // namespace app

View File

@ -10,6 +10,7 @@
#pragma once
#include "app/document_range.h"
#include "app/pref/preferences.h"
#include "app/ui/editor/editor_observer.h"
#include "app/ui/skin/style.h"
#include "base/connection.h"
@ -188,6 +189,8 @@ namespace app {
bool validLayer(LayerIndex layer) const { return layer >= firstLayer() && layer <= lastLayer(); }
bool validFrame(frame_t frame) const { return frame >= firstFrame() && frame <= lastFrame(); }
DocumentPreferences& docPref() const;
skin::Style* m_timelineStyle;
skin::Style* m_timelineBoxStyle;
skin::Style* m_timelineOpenEyeStyle;

View File

@ -35,7 +35,6 @@ UIContext::UIContext()
: Context(new UISettingsImpl)
, m_lastSelectedView(NULL)
{
documents().addObserver(static_cast<UISettingsImpl*>(settings()));
documents().addObserver(&App::instance()->preferences());
ASSERT(m_instance == NULL);
@ -47,7 +46,6 @@ UIContext::~UIContext()
ASSERT(m_instance == this);
m_instance = NULL;
documents().removeObserver(static_cast<UISettingsImpl*>(settings()));
documents().removeObserver(&App::instance()->preferences());
// The context must be empty at this point. (It's to check if the UI

View File

@ -98,7 +98,7 @@ ExpandCelCanvas::ExpandCelCanvas(Context* context, TiledMode tiledMode, Transact
m_sprite->width(),
m_sprite->height());
if (tiledMode == TILED_NONE) { // Non-tiled
if (tiledMode == TiledMode::NONE) { // Non-tiled
m_bounds = celBounds.createUnion(spriteBounds);
}
else { // Tiled

View File

@ -114,7 +114,7 @@ namespace {
ConvolutionMatrixFilter::ConvolutionMatrixFilter()
: m_matrix(NULL)
, m_tiledMode(TILED_NONE)
, m_tiledMode(TiledMode::NONE)
{
}

View File

@ -89,7 +89,7 @@ namespace {
};
MedianFilter::MedianFilter()
: m_tiledMode(TILED_NONE)
: m_tiledMode(TiledMode::NONE)
, m_width(0)
, m_height(0)
, m_ncolors(0)

View File

@ -34,7 +34,7 @@ namespace filters {
int getx, gety = y - centerY;
int addx, addy = 0;
if (gety < 0) {
if (tiledMode & TILED_Y_AXIS)
if (int(tiledMode) & int(TiledMode::Y_AXIS))
gety = sourceImage->height() - (-(gety+1) % sourceImage->height()) - 1;
else {
addy = -gety;
@ -42,7 +42,7 @@ namespace filters {
}
}
else if (gety >= sourceImage->height()) {
if (tiledMode & TILED_Y_AXIS)
if (int(tiledMode) & int(TiledMode::Y_AXIS))
gety = gety % sourceImage->height();
else
gety = sourceImage->height()-1;
@ -53,7 +53,7 @@ namespace filters {
getx = x - centerX;
addx = 0;
if (getx < 0) {
if (tiledMode & TILED_X_AXIS)
if (int(tiledMode) & int(TiledMode::X_AXIS))
getx = sourceImage->width() - (-(getx+1) % sourceImage->width()) - 1;
else {
addx = -getx;
@ -61,7 +61,7 @@ namespace filters {
}
}
else if (getx >= sourceImage->width()) {
if (tiledMode & TILED_X_AXIS)
if (int(tiledMode) & int(TiledMode::X_AXIS))
getx = getx % sourceImage->width();
else
getx = sourceImage->width()-1;
@ -82,7 +82,7 @@ namespace filters {
else
--addx;
}
else if (tiledMode & TILED_X_AXIS) {
else if (int(tiledMode) & int(TiledMode::X_AXIS)) {
getx = 0;
srcAddress =
reinterpret_cast<typename Traits::const_address_t>(sourceImage->getPixelAddress(getx, gety));
@ -96,7 +96,7 @@ namespace filters {
else
--addy;
}
else if (tiledMode & TILED_Y_AXIS)
else if (int(tiledMode) & int(TiledMode::Y_AXIS))
gety = 0;
}
}

View File

@ -11,11 +11,11 @@
namespace filters {
enum TiledMode {
TILED_NONE = 0,
TILED_X_AXIS = 1,
TILED_Y_AXIS = 2,
TILED_BOTH = 3,
enum class TiledMode {
NONE = 0,
X_AXIS = 1,
Y_AXIS = 2,
BOTH = 3,
};
} // namespace filters

View File

@ -1,5 +1,5 @@
// Aseprite Code Generator
// Copyright (c) 2014 David Capello
// Copyright (c) 2014, 2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -21,7 +21,7 @@ typedef std::vector<TiXmlElement*> XmlElements;
static void print_pref_class_def(TiXmlElement* elem, const std::string& className, const char* section, int indentSpaces)
{
std::string indent(indentSpaces, ' ');
std::cout
std::cout
<< "\n"
<< indent << "class " << className << " {\n"
<< indent << " std::string m_section;\n"
@ -97,11 +97,11 @@ static void print_pref_class_impl(TiXmlElement* elem, const std::string& prefix,
child = child->NextSiblingElement();
}
std::cout
std::cout
<< "{\n"
<< "}\n";
std::cout
std::cout
<< "\n"
<< "void " << prefix << className << "::load()\n"
<< "{\n";
@ -135,7 +135,7 @@ static void print_pref_class_impl(TiXmlElement* elem, const std::string& prefix,
child = child->NextSiblingElement();
}
std::cout
std::cout
<< "}\n"
<< "\n"
<< "void " << prefix << className << "::save()\n"
@ -157,7 +157,7 @@ static void print_pref_class_impl(TiXmlElement* elem, const std::string& prefix,
child = child->NextSiblingElement();
}
std::cout
std::cout
<< "}\n";
child = (elem->FirstChild() ? elem->FirstChild()->ToElement(): NULL);
@ -178,7 +178,7 @@ void gen_pref_header(TiXmlDocument* doc, const std::string& inputFn)
std::cout
<< "// Don't modify, generated file from " << inputFn << "\n"
<< "\n";
std::cout
<< "#ifndef GENERATED_PREF_TYPES_H_INCLUDED\n"
<< "#define GENERATED_PREF_TYPES_H_INCLUDED\n"
@ -188,6 +188,7 @@ void gen_pref_header(TiXmlDocument* doc, const std::string& inputFn)
<< "#include \"app/pref/option.h\"\n"
<< "#include \"doc/frame.h\"\n"
<< "#include \"gfx/rect.h\"\n"
<< "#include \"filters/tiled_mode.h\"\n"
<< "\n"
<< "#include <string>\n"
<< "\n"