Open new sprites in the center of the current sprite.

This commit is contained in:
David Capello 2011-01-23 21:15:00 -03:00
parent 73d7c608a1
commit 18db7513a8
4 changed files with 16 additions and 1 deletions

View File

@ -1,7 +1,6 @@
For next release
----------------
+ After creating or opening a sprite, it should be shown centered in the editor.
+ Mini-look for sliders in palette editor (add ISliderBackground to draw RGB/HSV sliders
with a customized background).
+ Fix palette editor to avoid generating a lot of consecutive Undo actions.

View File

@ -425,6 +425,7 @@ SpriteImpl::SpriteImpl(Sprite* sprite, int imgtype, int width, int height, int n
m_preferred.scroll_x = 0;
m_preferred.scroll_y = 0;
m_preferred.zoom = 0;
m_preferred.virgin = true;
// Generate palette
Palette pal(0, ncolors);

View File

@ -41,6 +41,7 @@ struct PreferredEditorSettings
int scroll_x;
int scroll_y;
int zoom;
bool virgin;
};
typedef std::vector<Palette*> PalettesList;

View File

@ -159,6 +159,20 @@ void Editor::editor_set_sprite(Sprite* sprite)
m_zoom = preferred.zoom;
editor_update();
if (preferred.virgin) {
JWidget view = jwidget_get_view(this);
JRect vp = jview_get_viewport_position(view);
preferred.virgin = false;
preferred.scroll_x = -jrect_w(vp)/2 + (sprite->getWidth()/2);
preferred.scroll_y = -jrect_h(vp)/2 + (sprite->getHeight()/2);
m_sprite->setPreferredEditorSettings(preferred);
jrect_free(vp);
}
editor_set_scroll(m_offset_x + preferred.scroll_x,
m_offset_y + preferred.scroll_y,
false);