Rename SelectTileState to SelectBoxState.

This commit is contained in:
David Capello 2011-04-21 18:30:29 -03:00
parent ef4ce8a7f2
commit fc2fd9fdfd
5 changed files with 30 additions and 30 deletions

View File

@ -289,7 +289,7 @@ add_library(aseprite-library
widgets/editor/moving_pixels_state.cpp
widgets/editor/pixels_movement.cpp
widgets/editor/scrolling_state.cpp
widgets/editor/select_tile_state.cpp
widgets/editor/select_box_state.cpp
widgets/editor/standby_state.cpp
widgets/editor/tool_loop_impl.cpp
widgets/fileview.cpp

View File

@ -32,7 +32,7 @@
#include "undo_transaction.h"
#include "widgets/color_bar.h"
#include "widgets/editor/editor.h"
#include "widgets/editor/select_tile_state.h"
#include "widgets/editor/select_box_state.h"
#include <allegro/unicode.h>
@ -41,7 +41,7 @@
// Frame used to show canvas parameters.
class CanvasSizeFrame : public Frame
, public SelectTileDelegate
, public SelectBoxDelegate
{
public:
CanvasSizeFrame(int left, int top, int right, int bottom)
@ -50,7 +50,7 @@ public:
, m_rect(-left, -top,
current_editor->getSprite()->getWidth() + left + right,
current_editor->getSprite()->getHeight() + top + bottom)
, m_selectTileState(new SelectTileState(this, m_rect))
, m_selectBoxState(new SelectBoxState(this, m_rect))
{
m_mainBox = load_widget("canvas_size.xml", "main_box");
get_widgets(m_mainBox,
@ -72,7 +72,7 @@ public:
m_top ->EntryChange.connect(Bind<void>(&CanvasSizeFrame::onEntriesChange, this));
m_bottom->EntryChange.connect(Bind<void>(&CanvasSizeFrame::onEntriesChange, this));
m_editor->setDefaultState(m_selectTileState);
m_editor->setDefaultState(m_selectBoxState);
}
~CanvasSizeFrame()
@ -88,7 +88,7 @@ public:
int getBottom() const { return m_bottom->getTextInt(); }
protected:
// SelectTileDelegate impleentation
// SelectBoxDelegate impleentation
virtual void onChangeRectangle(const gfx::Rect& rect) OVERRIDE
{
m_rect = rect;
@ -108,7 +108,7 @@ protected:
m_editor->getSprite()->getWidth() + left + getRight(),
m_editor->getSprite()->getHeight() + top + getBottom());
static_cast<SelectTileState*>(m_selectTileState.get())->setBoxBounds(m_rect);
static_cast<SelectBoxState*>(m_selectBoxState.get())->setBoxBounds(m_rect);
// Redraw new rulers position
m_editor->invalidate();
@ -131,7 +131,7 @@ private:
Entry* m_bottom;
Widget* m_ok;
gfx::Rect m_rect;
EditorStatePtr m_selectTileState;
EditorStatePtr m_selectBoxState;
};
//////////////////////////////////////////////////////////////////////

View File

@ -19,7 +19,7 @@
#ifndef WIDGETS_EDITOR_RULER_H_INCLUDED
#define WIDGETS_EDITOR_RULER_H_INCLUDED
// A ruler inside the editor. It is used by SelectTileState to show
// A ruler inside the editor. It is used by SelectBoxState to show
// rulers that can be dragged by the user.
class Ruler
{

View File

@ -18,7 +18,7 @@
#include "config.h"
#include "widgets/editor/select_tile_state.h"
#include "widgets/editor/select_box_state.h"
#include "gfx/rect.h"
#include "gui/message.h"
@ -30,7 +30,7 @@
#include <allegro/color.h>
SelectTileState::SelectTileState(SelectTileDelegate* delegate, const gfx::Rect& rc)
SelectBoxState::SelectBoxState(SelectBoxDelegate* delegate, const gfx::Rect& rc)
: m_delegate(delegate)
, m_rulers(4)
, m_movingRuler(-1)
@ -38,7 +38,7 @@ SelectTileState::SelectTileState(SelectTileDelegate* delegate, const gfx::Rect&
setBoxBounds(rc);
}
gfx::Rect SelectTileState::getBoxBounds() const
gfx::Rect SelectBoxState::getBoxBounds() const
{
int x1 = std::min(m_rulers[V1].getPosition(), m_rulers[V2].getPosition());
int y1 = std::min(m_rulers[H1].getPosition(), m_rulers[H2].getPosition());
@ -47,7 +47,7 @@ gfx::Rect SelectTileState::getBoxBounds() const
return gfx::Rect(x1, y1, x2 - x1, y2 - y1);
}
void SelectTileState::setBoxBounds(const gfx::Rect& box)
void SelectBoxState::setBoxBounds(const gfx::Rect& box)
{
m_rulers[H1] = Ruler(Ruler::Horizontal, box.y);
m_rulers[H2] = Ruler(Ruler::Horizontal, box.y+box.h);
@ -55,7 +55,7 @@ void SelectTileState::setBoxBounds(const gfx::Rect& box)
m_rulers[V2] = Ruler(Ruler::Vertical, box.x+box.w);
}
bool SelectTileState::onMouseDown(Editor* editor, Message* msg)
bool SelectBoxState::onMouseDown(Editor* editor, Message* msg)
{
if (msg->mouse.left || msg->mouse.right) {
m_movingRuler = -1;
@ -74,13 +74,13 @@ bool SelectTileState::onMouseDown(Editor* editor, Message* msg)
return StandbyState::onMouseDown(editor, msg);
}
bool SelectTileState::onMouseUp(Editor* editor, Message* msg)
bool SelectBoxState::onMouseUp(Editor* editor, Message* msg)
{
m_movingRuler = -1;
return StandbyState::onMouseUp(editor, msg);
}
bool SelectTileState::onMouseMove(Editor* editor, Message* msg)
bool SelectBoxState::onMouseMove(Editor* editor, Message* msg)
{
if (m_movingRuler >= 0) {
int u, v;
@ -106,7 +106,7 @@ bool SelectTileState::onMouseMove(Editor* editor, Message* msg)
return StandbyState::onMouseMove(editor, msg);
}
bool SelectTileState::onSetCursor(Editor* editor)
bool SelectBoxState::onSetCursor(Editor* editor)
{
int x = jmouse_x(0);
int y = jmouse_y(0);
@ -127,12 +127,12 @@ bool SelectTileState::onSetCursor(Editor* editor)
return false;
}
EditorDecorator* SelectTileState::getDecorator()
EditorDecorator* SelectBoxState::getDecorator()
{
return this;
}
void SelectTileState::preRenderDecorator(EditorPreRender* render)
void SelectBoxState::preRenderDecorator(EditorPreRender* render)
{
gfx::Rect rc = getBoxBounds();
Image* image = render->getImage();
@ -157,7 +157,7 @@ void SelectTileState::preRenderDecorator(EditorPreRender* render)
render->fillRect(gfx::Rect(rc.x+rc.w, rc.y, sprite_w-(rc.x+rc.w), rc.h), _rgba(0, 0, 0, 255), 128);
}
void SelectTileState::postRenderDecorator(EditorPostRender* render)
void SelectBoxState::postRenderDecorator(EditorPostRender* render)
{
Editor* editor = render->getEditor();
int zoom = editor->getZoom();
@ -180,7 +180,7 @@ void SelectTileState::postRenderDecorator(EditorPostRender* render)
}
}
bool SelectTileState::touchRuler(Editor* editor, Ruler& ruler, int x, int y)
bool SelectBoxState::touchRuler(Editor* editor, Ruler& ruler, int x, int y)
{
int u, v;
editor->editorToScreen(ruler.getPosition(), ruler.getPosition(), &u, &v);

View File

@ -16,8 +16,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef WIDGETS_EDITOR_SELECT_TILE_STATE_H_INCLUDED
#define WIDGETS_EDITOR_SELECT_TILE_STATE_H_INCLUDED
#ifndef WIDGETS_EDITOR_SELECT_BOX_STATE_H_INCLUDED
#define WIDGETS_EDITOR_SELECT_BOX_STATE_H_INCLUDED
#include "base/compiler_specific.h"
#include "widgets/editor/editor_decorator.h"
@ -26,20 +26,20 @@
#include <vector>
class SelectTileDelegate
class SelectBoxDelegate
{
public:
virtual ~SelectTileDelegate() { }
virtual ~SelectBoxDelegate() { }
virtual void onChangeRectangle(const gfx::Rect& rect) = 0;
};
class SelectTileState : public StandbyState
, public EditorDecorator
class SelectBoxState : public StandbyState
, public EditorDecorator
{
enum { H1, H2, V1, V2 };
public:
SelectTileState(SelectTileDelegate* delegate, const gfx::Rect& rc);
SelectBoxState(SelectBoxDelegate* delegate, const gfx::Rect& rc);
// Returns the bounding box arranged by the rulers.
gfx::Rect getBoxBounds() const;
@ -67,9 +67,9 @@ private:
// the given ruler.
bool touchRuler(Editor* editor, Ruler& ruler, int x, int y);
SelectTileDelegate* m_delegate;
SelectBoxDelegate* m_delegate;
Rulers m_rulers;
int m_movingRuler;
};
#endif // WIDGETS_EDITOR_STANDBY_STATE_H_INCLUDED
#endif // WIDGETS_EDITOR_SELECT_BOX_STATE_H_INCLUDED