|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursormanager.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/cursors.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qwidget></qwidget>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpixmap></qpixmap>
|
|
Toshihiro Shimizu |
890ddd |
#include <assert.h></assert.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <map></map>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdebug></qdebug>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const struct {
|
|
Toshihiro Shimizu |
890ddd |
int cursorType;
|
|
Toshihiro Shimizu |
890ddd |
const char *pixmapFilename;
|
|
Toshihiro Shimizu |
890ddd |
int x, y;
|
|
Toshihiro Shimizu |
890ddd |
} cursorInfo[] = {
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PenCursor, "brush", 16, 16},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::BenderCursor, "bender", 10, 7},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::CutterCursor, "cutter", 6, 24}, //12,20},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::EraserCursor, "eraser", 7, 21}, //15,16},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::DistortCursor, "selection_distort", 11, 6},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursor, "fill", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::MoveCursor, "move", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::MoveEWCursor, "move_ew", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::MoveNSCursor, "move_ns", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::DisableCursor, "disable", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::MoveZCursor, "move_z", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FxGadgetCursor, "edit_FX", 7, 7},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FlipHCursor, "flip_h", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FlipVCursor, "flip_v", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::IronCursor, "iron", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::LevelSelectCursor, "level_select", 7, 4},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::MagnetCursor, "magnet", 18, 18},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PanCursor, "pan", 18, 19},
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerCursorLine, "picker_style_line", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerCursorArea, "picker_style_area", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerCursor, "picker_style", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PumpCursor, "pump", 16, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RotCursor, "rot", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RotTopLeft, "rot_top_left", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RotBottomRight, "rot_bottom_right", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RotBottomLeft, "rot_bottom_left", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RotateCursor, "rotate", 15, 19},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ScaleCursor, "scale", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ScaleInvCursor, "scale_inv", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ScaleHCursor, "scale_h", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ScaleVCursor, "scale_v", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::EditFxCursor, "edit_FX", 11, 6},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ScaleGlobalCursor, "scale_global", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ScaleHVCursor, "scale_hv", 15, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::StrokeSelectCursor, "stroke_select", 11, 6},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::TapeCursor, "tape", 9, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::TrackerCursor, "tracker", 12, 15},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::TypeInCursor, "type_in", 16, 19},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::TypeOutCursor, "type_out", 16, 19},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::ZoomCursor, "zoom", 14, 14},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PinchCursor, "pinch_curve", 10, 18},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PinchAngleCursor, "pinch_angle", 6, 16},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PinchWaveCursor, "pinch_wave", 6, 16},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::SplineEditorCursor, "stroke_select", 11, 6},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::SplineEditorCursorAdd, "selection_add", 11, 6},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::SplineEditorCursorSelect, "selection_convert", 11, 6},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::NormalEraserCursor, "normaleraser", 10, 21},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RectEraserCursor, "recteraser", 10, 21},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RectEraserCursorWhite, "recteraser_white", 10, 21},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorWhite, "fill_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::TapeCursorWhite, "tape_white", 9, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerCursorWhiteLine, "picker_style_white_line", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerCursorWhiteArea, "picker_style_white_area", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerCursorWhite, "picker_style_white", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerRGB, "picker_rgb", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::PickerRGBWhite, "picker_rgb_white", 7, 22},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorF, "fill_f", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorFWhite, "fill_f_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorP, "fill_p", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorPWhite, "fill_p_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorR, "fill_r", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorRWhite, "fill_r_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorA, "fill_a", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorAWhite, "fill_a_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorAF, "fill_a_f", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorAFWhite, "fill_a_f_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorAP, "fill_a_p", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorAPWhite, "fill_a_p_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorAR, "fill_a_r", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorARWhite, "fill_a_r_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorL, "karasu", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLWhite, "karasu_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLF, "karasu_f", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLFWhite, "karasu_f_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLP, "karasu_p", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLPWhite, "karasu_p_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLR, "karasu_r", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::FillCursorLRWhite, "karasu_r_white", 6, 23},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RulerModifyCursor, "ruler_modify", 7, 7},
|
|
Toshihiro Shimizu |
890ddd |
{ToolCursor::RulerNewCursor, "ruler_new", 7, 7},
|
|
Toshihiro Shimizu |
890ddd |
{0, 0, 0, 0}};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct CursorData {
|
|
Toshihiro Shimizu |
890ddd |
QPixmap pixmap;
|
|
Toshihiro Shimizu |
890ddd |
int x, y;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// CursorManager
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class CursorManager
|
|
Toshihiro Shimizu |
890ddd |
{ // singleton
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::map<int, cursordata=""> m_cursors;</int,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
CursorManager() {}
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
static CursorManager *instance()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static CursorManager _instance;
|
|
Toshihiro Shimizu |
890ddd |
return &_instance;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const CursorData &getCursorData(int cursorType)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// se e' gia' in tabella lo restituisco
|
|
Toshihiro Shimizu |
890ddd |
std::map<int, cursordata="">::iterator it;</int,>
|
|
Toshihiro Shimizu |
890ddd |
it = m_cursors.find(cursorType);
|
|
Toshihiro Shimizu |
890ddd |
if (it != m_cursors.end())
|
|
Toshihiro Shimizu |
890ddd |
return it->second;
|
|
Toshihiro Shimizu |
890ddd |
// provo a cercarlo in cursorInfo[]
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; cursorInfo[i].pixmapFilename; i++)
|
|
Toshihiro Shimizu |
890ddd |
if (cursorType == cursorInfo[i].cursorType) {
|
|
Toshihiro Shimizu |
890ddd |
QString path = QString(":Resources/") + cursorInfo[i].pixmapFilename + ".png";
|
|
Toshihiro Shimizu |
890ddd |
CursorData data;
|
|
Toshihiro Shimizu |
890ddd |
data.pixmap = QPixmap(path);
|
|
Toshihiro Shimizu |
890ddd |
data.x = cursorInfo[i].x;
|
|
Toshihiro Shimizu |
890ddd |
data.y = cursorInfo[i].y;
|
|
Toshihiro Shimizu |
890ddd |
it = m_cursors.insert(std::make_pair(cursorType, data)).first;
|
|
Toshihiro Shimizu |
890ddd |
return it->second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
// niente da fare. uso un default
|
|
Toshihiro Shimizu |
890ddd |
CursorData data;
|
|
Toshihiro Shimizu |
890ddd |
static const QPixmap standardCursorPixmap("cursors/hook.png");
|
|
Toshihiro Shimizu |
890ddd |
data.pixmap = standardCursorPixmap;
|
|
Toshihiro Shimizu |
890ddd |
data.x = data.y = 0;
|
|
Toshihiro Shimizu |
890ddd |
it = m_cursors.insert(std::make_pair(cursorType, data)).first;
|
|
Toshihiro Shimizu |
890ddd |
return it->second;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QCursor getCursor(int cursorType)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//assert(cursorType!=0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QCursor cursor;
|
|
Toshihiro Shimizu |
890ddd |
if (cursorType == ToolCursor::CURSOR_ARROW)
|
|
Toshihiro Shimizu |
890ddd |
cursor = Qt::ArrowCursor;
|
|
Toshihiro Shimizu |
890ddd |
else if (cursorType == ToolCursor::ForbiddenCursor)
|
|
Toshihiro Shimizu |
890ddd |
cursor = Qt::ForbiddenCursor;
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
const CursorData &data = getCursorData(cursorType);
|
|
Toshihiro Shimizu |
890ddd |
cursor = QCursor(data.pixmap, data.x, data.y);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return cursor;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setToolCursor(QWidget *viewer, int cursorType)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
viewer->setCursor(CursorManager::instance()->getCursor(cursorType));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QCursor getToolCursor(int cursorType)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return CursorManager::instance()->getCursor(cursorType);
|
|
Toshihiro Shimizu |
890ddd |
}
|