* Implemented rotating path point indices.
* Improved menu items in Path list view. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31805 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -267,6 +267,7 @@ Application Icon-O-Matic :
|
|||||||
RemoveShapesCommand.cpp
|
RemoveShapesCommand.cpp
|
||||||
RemoveTransformersCommand.cpp
|
RemoveTransformersCommand.cpp
|
||||||
ReversePathCommand.cpp
|
ReversePathCommand.cpp
|
||||||
|
RotatePathIndicesCommand.cpp
|
||||||
SplitPointsCommand.cpp
|
SplitPointsCommand.cpp
|
||||||
TransformPointsCommand.cpp
|
TransformPointsCommand.cpp
|
||||||
UnassignPathCommand.cpp
|
UnassignPathCommand.cpp
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
#include "RemovePathsCommand.h"
|
#include "RemovePathsCommand.h"
|
||||||
#include "ReversePathCommand.h"
|
#include "ReversePathCommand.h"
|
||||||
|
#include "RotatePathIndicesCommand.h"
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
#include "ShapeContainer.h"
|
#include "ShapeContainer.h"
|
||||||
#include "Selection.h"
|
#include "Selection.h"
|
||||||
@@ -231,19 +232,20 @@ class ShapePathListener : public PathContainerListener,
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_ADD = 'addp',
|
MSG_ADD = 'addp',
|
||||||
|
|
||||||
MSG_ADD_RECT = 'addr',
|
MSG_ADD_RECT = 'addr',
|
||||||
MSG_ADD_CIRCLE = 'addc',
|
MSG_ADD_CIRCLE = 'addc',
|
||||||
MSG_ADD_ARC = 'adda',
|
MSG_ADD_ARC = 'adda',
|
||||||
|
|
||||||
MSG_DUPLICATE = 'dupp',
|
MSG_DUPLICATE = 'dupp',
|
||||||
|
|
||||||
MSG_REVERSE = 'rvrs',
|
MSG_REVERSE = 'rvrs',
|
||||||
MSG_CLEAN_UP = 'clup',
|
MSG_CLEAN_UP = 'clup',
|
||||||
MSG_ROTATE_INDICES = 'roti',
|
MSG_ROTATE_INDICES_CW = 'ricw',
|
||||||
|
MSG_ROTATE_INDICES_CCW = 'ricc',
|
||||||
|
|
||||||
MSG_REMOVE = 'remp',
|
MSG_REMOVE = 'remp',
|
||||||
};
|
};
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
@@ -347,7 +349,7 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_ADD:
|
case MSG_ADD:
|
||||||
if (fCommandStack) {
|
if (fCommandStack != NULL) {
|
||||||
VectorPath* path;
|
VectorPath* path;
|
||||||
AddPathsCommand* command;
|
AddPathsCommand* command;
|
||||||
new_path(fPathContainer, &path, &command);
|
new_path(fPathContainer, &path, &command);
|
||||||
@@ -356,11 +358,11 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_ADD_RECT:
|
case MSG_ADD_RECT:
|
||||||
if (fCommandStack) {
|
if (fCommandStack != NULL) {
|
||||||
VectorPath* path;
|
VectorPath* path;
|
||||||
AddPathsCommand* command;
|
AddPathsCommand* command;
|
||||||
new_path(fPathContainer, &path, &command);
|
new_path(fPathContainer, &path, &command);
|
||||||
if (path) {
|
if (path != NULL) {
|
||||||
path->AddPoint(BPoint(16, 16));
|
path->AddPoint(BPoint(16, 16));
|
||||||
path->AddPoint(BPoint(16, 48));
|
path->AddPoint(BPoint(16, 48));
|
||||||
path->AddPoint(BPoint(48, 48));
|
path->AddPoint(BPoint(48, 48));
|
||||||
@@ -373,11 +375,11 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case MSG_ADD_CIRCLE:
|
case MSG_ADD_CIRCLE:
|
||||||
// TODO: ask for number of secions
|
// TODO: ask for number of secions
|
||||||
if (fCommandStack) {
|
if (fCommandStack != NULL) {
|
||||||
VectorPath* path;
|
VectorPath* path;
|
||||||
AddPathsCommand* command;
|
AddPathsCommand* command;
|
||||||
new_path(fPathContainer, &path, &command);
|
new_path(fPathContainer, &path, &command);
|
||||||
if (path) {
|
if (path != NULL) {
|
||||||
// add four control points defining a circle:
|
// add four control points defining a circle:
|
||||||
// a
|
// a
|
||||||
// b d
|
// b d
|
||||||
@@ -409,10 +411,10 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_DUPLICATE:
|
case MSG_DUPLICATE:
|
||||||
if (fCommandStack) {
|
if (fCommandStack != NULL) {
|
||||||
PathListItem* item = dynamic_cast<PathListItem*>(
|
PathListItem* item = dynamic_cast<PathListItem*>(
|
||||||
ItemAt(CurrentSelection(0)));
|
ItemAt(CurrentSelection(0)));
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
VectorPath* path;
|
VectorPath* path;
|
||||||
@@ -423,10 +425,10 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_REVERSE:
|
case MSG_REVERSE:
|
||||||
if (fCommandStack) {
|
if (fCommandStack != NULL) {
|
||||||
PathListItem* item = dynamic_cast<PathListItem*>(
|
PathListItem* item = dynamic_cast<PathListItem*>(
|
||||||
ItemAt(CurrentSelection(0)));
|
ItemAt(CurrentSelection(0)));
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ReversePathCommand* command
|
ReversePathCommand* command
|
||||||
@@ -436,10 +438,10 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_CLEAN_UP:
|
case MSG_CLEAN_UP:
|
||||||
if (fCommandStack) {
|
if (fCommandStack != NULL) {
|
||||||
PathListItem* item = dynamic_cast<PathListItem*>(
|
PathListItem* item = dynamic_cast<PathListItem*>(
|
||||||
ItemAt(CurrentSelection(0)));
|
ItemAt(CurrentSelection(0)));
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CleanUpPathCommand* command
|
CleanUpPathCommand* command
|
||||||
@@ -448,6 +450,21 @@ PathListView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSG_ROTATE_INDICES_CW:
|
||||||
|
case MSG_ROTATE_INDICES_CCW:
|
||||||
|
if (fCommandStack != NULL) {
|
||||||
|
PathListItem* item = dynamic_cast<PathListItem*>(
|
||||||
|
ItemAt(CurrentSelection(0)));
|
||||||
|
if (item == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
RotatePathIndicesCommand* command
|
||||||
|
= new (nothrow) RotatePathIndicesCommand(item->path,
|
||||||
|
message->what == MSG_ROTATE_INDICES_CW);
|
||||||
|
fCommandStack->Perform(command);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case MSG_REMOVE:
|
case MSG_REMOVE:
|
||||||
RemoveSelected();
|
RemoveSelected();
|
||||||
break;
|
break;
|
||||||
@@ -708,34 +725,39 @@ void
|
|||||||
PathListView::SetMenu(BMenu* menu)
|
PathListView::SetMenu(BMenu* menu)
|
||||||
{
|
{
|
||||||
fMenu = menu;
|
fMenu = menu;
|
||||||
if (!fMenu)
|
if (fMenu == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fAddMI = new BMenuItem("Add", new BMessage(MSG_ADD));
|
fAddMI = new BMenuItem("Add", new BMessage(MSG_ADD));
|
||||||
fAddRectMI = new BMenuItem("Add Rect", new BMessage(MSG_ADD_RECT));
|
fAddRectMI = new BMenuItem("Add Rect", new BMessage(MSG_ADD_RECT));
|
||||||
fAddCircleMI = new BMenuItem("Add Circle"B_UTF8_ELLIPSIS,
|
fAddCircleMI = new BMenuItem("Add Circle"/*B_UTF8_ELLIPSIS*/,
|
||||||
new BMessage(MSG_ADD_CIRCLE));
|
new BMessage(MSG_ADD_CIRCLE));
|
||||||
fAddArcMI = new BMenuItem("Add Arc"B_UTF8_ELLIPSIS,
|
// fAddArcMI = new BMenuItem("Add Arc"B_UTF8_ELLIPSIS,
|
||||||
new BMessage(MSG_ADD_ARC));
|
// new BMessage(MSG_ADD_ARC));
|
||||||
fDuplicateMI = new BMenuItem("Duplicate", new BMessage(MSG_DUPLICATE));
|
fDuplicateMI = new BMenuItem("Duplicate", new BMessage(MSG_DUPLICATE));
|
||||||
fReverseMI = new BMenuItem("Reverse", new BMessage(MSG_REVERSE));
|
fReverseMI = new BMenuItem("Reverse", new BMessage(MSG_REVERSE));
|
||||||
fCleanUpMI = new BMenuItem("Clean Up", new BMessage(MSG_CLEAN_UP));
|
fCleanUpMI = new BMenuItem("Clean Up", new BMessage(MSG_CLEAN_UP));
|
||||||
fRotateIndicesMI = new BMenuItem("Rotate Indices",
|
fRotateIndicesLeftMI = new BMenuItem("Rotate Indices Left",
|
||||||
new BMessage(MSG_ROTATE_INDICES));
|
new BMessage(MSG_ROTATE_INDICES_CW), 'R');
|
||||||
|
fRotateIndicesRightMI = new BMenuItem("Rotate Indices Right",
|
||||||
|
new BMessage(MSG_ROTATE_INDICES_CCW), 'R', B_SHIFT_KEY);
|
||||||
fRemoveMI = new BMenuItem("Remove", new BMessage(MSG_REMOVE));
|
fRemoveMI = new BMenuItem("Remove", new BMessage(MSG_REMOVE));
|
||||||
|
|
||||||
fMenu->AddItem(fAddMI);
|
fMenu->AddItem(fAddMI);
|
||||||
fMenu->AddItem(fAddRectMI);
|
fMenu->AddItem(fAddRectMI);
|
||||||
fMenu->AddItem(fAddCircleMI);
|
fMenu->AddItem(fAddCircleMI);
|
||||||
fMenu->AddItem(fAddArcMI);
|
// fMenu->AddItem(fAddArcMI);
|
||||||
fAddArcMI->SetEnabled(false);
|
|
||||||
|
|
||||||
fMenu->AddSeparatorItem();
|
fMenu->AddSeparatorItem();
|
||||||
|
|
||||||
fMenu->AddItem(fDuplicateMI);
|
fMenu->AddItem(fDuplicateMI);
|
||||||
fMenu->AddItem(fReverseMI);
|
fMenu->AddItem(fReverseMI);
|
||||||
fMenu->AddItem(fCleanUpMI);
|
fMenu->AddItem(fCleanUpMI);
|
||||||
fMenu->AddItem(fRotateIndicesMI);
|
|
||||||
|
fMenu->AddSeparatorItem();
|
||||||
|
|
||||||
|
fMenu->AddItem(fRotateIndicesLeftMI);
|
||||||
|
fMenu->AddItem(fRotateIndicesRightMI);
|
||||||
|
|
||||||
fMenu->AddSeparatorItem();
|
fMenu->AddSeparatorItem();
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ class PathListView : public SimpleListView,
|
|||||||
BMenuItem* fDuplicateMI;
|
BMenuItem* fDuplicateMI;
|
||||||
BMenuItem* fReverseMI;
|
BMenuItem* fReverseMI;
|
||||||
BMenuItem* fCleanUpMI;
|
BMenuItem* fCleanUpMI;
|
||||||
BMenuItem* fRotateIndicesMI;
|
BMenuItem* fRotateIndicesLeftMI;
|
||||||
|
BMenuItem* fRotateIndicesRightMI;
|
||||||
BMenuItem* fRemoveMI;
|
BMenuItem* fRemoveMI;
|
||||||
|
|
||||||
PathContainer* fPathContainer;
|
PathContainer* fPathContainer;
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Stephan Aßmus <[email protected]>. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "RotatePathIndicesCommand.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "VectorPath.h"
|
||||||
|
|
||||||
|
|
||||||
|
RotatePathIndicesCommand::RotatePathIndicesCommand(VectorPath* path,
|
||||||
|
bool clockWise)
|
||||||
|
:
|
||||||
|
PathCommand(path),
|
||||||
|
fClockWise(clockWise)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RotatePathIndicesCommand::~RotatePathIndicesCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
RotatePathIndicesCommand::InitCheck()
|
||||||
|
{
|
||||||
|
status_t ret = PathCommand::InitCheck();
|
||||||
|
if (ret == B_OK && fPath->CountPoints() < 2)
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
RotatePathIndicesCommand::Perform()
|
||||||
|
{
|
||||||
|
return _Rotate(fClockWise);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
RotatePathIndicesCommand::Undo()
|
||||||
|
{
|
||||||
|
return _Rotate(!fClockWise);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
RotatePathIndicesCommand::GetName(BString& name)
|
||||||
|
{
|
||||||
|
name << "Rotate Path Indices";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
RotatePathIndicesCommand::_Rotate(bool clockWise)
|
||||||
|
{
|
||||||
|
BPoint point;
|
||||||
|
BPoint pointIn;
|
||||||
|
BPoint pointOut;
|
||||||
|
bool connected;
|
||||||
|
|
||||||
|
int32 removeIndex;
|
||||||
|
int32 addIndex;
|
||||||
|
if (!clockWise) {
|
||||||
|
removeIndex = fPath->CountPoints() - 1;
|
||||||
|
addIndex = 0;
|
||||||
|
} else {
|
||||||
|
removeIndex = 0;
|
||||||
|
addIndex = fPath->CountPoints() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fPath->GetPointsAt(removeIndex, point, pointIn, pointOut, &connected))
|
||||||
|
return B_ERROR;
|
||||||
|
|
||||||
|
fPath->RemovePoint(removeIndex);
|
||||||
|
fPath->AddPoint(point, addIndex);
|
||||||
|
fPath->SetPoint(addIndex, point, pointIn, pointOut, connected);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Stephan Aßmus <[email protected]>. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef ROTATE_PATH_INDICES_COMMAND_H
|
||||||
|
#define ROTATE_PATH_INDICES_COMMAND_H
|
||||||
|
|
||||||
|
#include "PathCommand.h"
|
||||||
|
|
||||||
|
class RotatePathIndicesCommand : public PathCommand {
|
||||||
|
public:
|
||||||
|
RotatePathIndicesCommand(VectorPath* path,
|
||||||
|
bool clockWise);
|
||||||
|
virtual ~RotatePathIndicesCommand();
|
||||||
|
|
||||||
|
virtual status_t InitCheck();
|
||||||
|
|
||||||
|
virtual status_t Perform();
|
||||||
|
virtual status_t Undo();
|
||||||
|
|
||||||
|
virtual void GetName(BString& name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
status_t _Rotate(bool clockWise);
|
||||||
|
|
||||||
|
bool fClockWise;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ROTATE_PATH_INDICES_COMMAND_H
|
||||||
Reference in New Issue
Block a user