|
| 1 | +/* Aseprite |
| 2 | + * Copyright (C) 2001-2014 David Capello |
| 3 | + * |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program; if not, write to the Free Software |
| 16 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | + */ |
| 18 | + |
| 19 | +#ifdef HAVE_CONFIG_H |
| 20 | +#include "config.h" |
| 21 | +#endif |
| 22 | + |
| 23 | +#include "app/app_render.h" |
| 24 | + |
| 25 | +#include "app/app.h" |
| 26 | +#include "app/color_utils.h" |
| 27 | +#include "app/pref/preferences.h" |
| 28 | +#include "render/render.h" |
| 29 | + |
| 30 | +namespace app { |
| 31 | + |
| 32 | +AppRender::AppRender() |
| 33 | +{ |
| 34 | +} |
| 35 | + |
| 36 | +AppRender::AppRender(app::Document* doc, doc::PixelFormat pixelFormat) |
| 37 | +{ |
| 38 | + setupBackground(doc, pixelFormat); |
| 39 | +} |
| 40 | + |
| 41 | +void AppRender::setupBackground(app::Document* doc, doc::PixelFormat pixelFormat) |
| 42 | +{ |
| 43 | + DocumentPreferences& docPref = App::instance()->preferences().document(doc); |
| 44 | + render::BgType bgType; |
| 45 | + |
| 46 | + gfx::Size tile; |
| 47 | + switch (docPref.bg.type()) { |
| 48 | + case app::gen::BgType::CHECKED_16x16: |
| 49 | + bgType = render::BgType::CHECKED; |
| 50 | + tile = gfx::Size(16, 16); |
| 51 | + break; |
| 52 | + case app::gen::BgType::CHECKED_8x8: |
| 53 | + bgType = render::BgType::CHECKED; |
| 54 | + tile = gfx::Size(8, 8); |
| 55 | + break; |
| 56 | + case app::gen::BgType::CHECKED_4x4: |
| 57 | + bgType = render::BgType::CHECKED; |
| 58 | + tile = gfx::Size(4, 4); |
| 59 | + break; |
| 60 | + case app::gen::BgType::CHECKED_2x2: |
| 61 | + bgType = render::BgType::CHECKED; |
| 62 | + tile = gfx::Size(2, 2); |
| 63 | + break; |
| 64 | + default: |
| 65 | + bgType = render::BgType::TRANSPARENT; |
| 66 | + break; |
| 67 | + } |
| 68 | + |
| 69 | + setBgType(bgType); |
| 70 | + setBgZoom(docPref.bg.zoom()); |
| 71 | + setBgColor1(color_utils::color_for_image(docPref.bg.color1(), pixelFormat)); |
| 72 | + setBgColor2(color_utils::color_for_image(docPref.bg.color2(), pixelFormat)); |
| 73 | + setBgCheckedSize(tile); |
| 74 | +} |
| 75 | + |
| 76 | +} |
0 commit comments