2009-06-01 02:59:15 +00:00
|
|
|
/* ASE - Allegro Sprite Editor
|
2011-01-18 23:49:53 +00:00
|
|
|
* Copyright (C) 2001-2011 David Capello
|
2009-06-01 02:59:15 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <allegro/file.h>
|
2010-12-30 02:19:45 +00:00
|
|
|
#include <allegro/system.h>
|
2009-06-01 02:59:15 +00:00
|
|
|
|
2009-12-11 14:53:05 +00:00
|
|
|
#include "app.h"
|
2010-12-30 02:19:45 +00:00
|
|
|
#include "base/path.h"
|
2009-06-01 02:59:15 +00:00
|
|
|
#include "modules/editors.h"
|
|
|
|
#include "raster/sprite.h"
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-07 19:47:45 +00:00
|
|
|
#include "settings/ui_settings_impl.h"
|
|
|
|
#include "ui_context.h"
|
2011-02-23 22:29:57 +00:00
|
|
|
#include "widgets/color_bar.h"
|
2009-06-01 02:59:15 +00:00
|
|
|
#include "widgets/tabs.h"
|
|
|
|
|
2009-10-09 01:34:06 +00:00
|
|
|
UIContext* UIContext::m_instance = NULL;
|
2009-06-01 02:59:15 +00:00
|
|
|
|
2009-10-09 01:34:06 +00:00
|
|
|
UIContext::UIContext()
|
- All tools stuff refactored in various files/components.
- Added classes: IToolLoop, Tool, ToolGroup, ToolInk, ToolController, ToolPointShape, ToolIntertwine, ToolBox, etc.
- Added ToolLoopManager.
- Removed old src/modules/tools.cpp.
- Added ISettings and UISettingsImpl, adding the tools settings (onion skinning, grid, tiled mode, etc.).
- Added App::PenSizeBeforeChange, PenSizeAfterChange, CurrentToolChange signals.
- Renamed Context::get_bg/fg_color to getBg/FgColor.
- Refactored Brush class to Pen and added PenType.
- Renamed tiled_t to TiledMode.
- get_config_rect now uses the new Rect class imported from Vaca instead of old jrect.
- Added default_skin.xml to load tool icons.
- Added pen preview in Editor::cursor stuff.
- Added Editor::decorators.
Note: This big patch is from some time ago. I did my best to pre-commit other small changes before this big one.
2010-03-07 19:47:45 +00:00
|
|
|
: Context(new UISettingsImpl)
|
2009-06-01 02:59:15 +00:00
|
|
|
{
|
2010-08-04 02:33:44 +00:00
|
|
|
ASSERT(m_instance == NULL);
|
2009-10-09 01:34:06 +00:00
|
|
|
m_instance = this;
|
2009-06-01 02:59:15 +00:00
|
|
|
}
|
|
|
|
|
2009-10-09 01:34:06 +00:00
|
|
|
UIContext::~UIContext()
|
2009-06-01 02:59:15 +00:00
|
|
|
{
|
2010-08-04 02:33:44 +00:00
|
|
|
ASSERT(m_instance == this);
|
2009-10-09 01:34:06 +00:00
|
|
|
m_instance = NULL;
|
2009-06-01 02:59:15 +00:00
|
|
|
}
|
|
|
|
|
2011-01-20 22:58:11 +00:00
|
|
|
void UIContext::onAddSprite(Sprite* sprite)
|
2009-06-01 02:59:15 +00:00
|
|
|
{
|
|
|
|
// base method
|
2011-01-20 22:58:11 +00:00
|
|
|
Context::onAddSprite(sprite);
|
2009-06-01 02:59:15 +00:00
|
|
|
|
|
|
|
// add the tab for this sprite
|
2010-06-13 20:51:22 +00:00
|
|
|
app_get_tabsbar()->addTab(get_filename(sprite->getFilename()), sprite);
|
2009-06-01 02:59:15 +00:00
|
|
|
|
|
|
|
// rebuild the menu list of sprites
|
|
|
|
app_realloc_sprite_list();
|
|
|
|
}
|
|
|
|
|
2011-01-20 22:58:11 +00:00
|
|
|
void UIContext::onRemoveSprite(Sprite* sprite)
|
2009-06-01 02:59:15 +00:00
|
|
|
{
|
|
|
|
// base method
|
2011-01-20 22:58:11 +00:00
|
|
|
Context::onRemoveSprite(sprite);
|
2009-06-01 02:59:15 +00:00
|
|
|
|
|
|
|
// remove this sprite from tabs
|
2010-06-13 20:51:22 +00:00
|
|
|
app_get_tabsbar()->removeTab(sprite);
|
2009-06-01 02:59:15 +00:00
|
|
|
|
|
|
|
// rebuild the menu list of sprites
|
|
|
|
app_realloc_sprite_list();
|
|
|
|
|
|
|
|
// select other sprites in the editors where are this sprite
|
|
|
|
editors_hide_sprite(sprite);
|
|
|
|
}
|
|
|
|
|
2011-01-20 22:58:11 +00:00
|
|
|
void UIContext::onSetCurrentSprite(Sprite* sprite)
|
2009-06-01 02:59:15 +00:00
|
|
|
{
|
2011-01-20 22:58:11 +00:00
|
|
|
Context::onSetCurrentSprite(sprite);
|
2009-06-01 02:59:15 +00:00
|
|
|
|
2010-12-30 02:19:45 +00:00
|
|
|
// Select the sprite in the tabs.
|
2010-06-13 20:51:22 +00:00
|
|
|
app_get_tabsbar()->selectTab(sprite);
|
2010-12-30 02:19:45 +00:00
|
|
|
|
2011-02-23 22:29:57 +00:00
|
|
|
// Change the image-type of color bar.
|
|
|
|
app_get_colorbar()->setImgType(app_get_current_image_type());
|
|
|
|
|
2010-12-30 02:19:45 +00:00
|
|
|
// Change the main frame title.
|
|
|
|
base::string defaultTitle = PACKAGE " v" VERSION;
|
|
|
|
base::string title;
|
|
|
|
if (sprite) {
|
|
|
|
// Prepend the sprite's filename.
|
|
|
|
title += base::get_file_name(sprite->getFilename());
|
|
|
|
title += " - ";
|
|
|
|
}
|
|
|
|
title += defaultTitle;
|
|
|
|
set_window_title(title.c_str());
|
2009-06-01 02:59:15 +00:00
|
|
|
}
|