/* Aseprite * Copyright (C) 2001-2013 David Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "app/color_utils.h" #include "app/commands/command.h" #include "app/context_access.h" #include "app/document_api.h" #include "app/find_widget.h" #include "app/load_widget.h" #include "app/modules/editors.h" #include "app/modules/gui.h" #include "app/settings/settings.h" #include "app/ui/color_bar.h" #include "app/ui/editor/editor.h" #include "app/ui/editor/select_box_state.h" #include "app/undo_transaction.h" #include "base/bind.h" #include "base/unique_ptr.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/ui.h" #include namespace app { using namespace ui; // Disable warning about usage of "this" in initializer list. #pragma warning(disable:4355) // Window used to show canvas parameters. class CanvasSizeWindow : public Window , public SelectBoxDelegate { public: CanvasSizeWindow(int left, int top, int right, int bottom) : Window(WithTitleBar, "Canvas Size") , m_editor(current_editor) , m_rect(-left, -top, current_editor->getSprite()->getWidth() + left + right, current_editor->getSprite()->getHeight() + top + bottom) , m_selectBoxState(new SelectBoxState(this, m_rect, SelectBoxState::PaintRulers | SelectBoxState::PaintDarkOutside)) , m_mainBox(app::load_widget("canvas_size.xml", "main_box")) , m_left(app::find_widget(m_mainBox, "left")) , m_top(app::find_widget(m_mainBox, "top")) , m_right(app::find_widget(m_mainBox, "right")) , m_bottom(app::find_widget(m_mainBox, "bottom")) , m_ok(app::find_widget