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