* various UI improvements and fixes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19347 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
#include "AddPathsCommand.h"
|
||||
#include "AddShapesCommand.h"
|
||||
#include "AddStylesCommand.h"
|
||||
#include "AddTransformersCommand.h"
|
||||
#include "CanvasView.h"
|
||||
#include "CommandStack.h"
|
||||
#include "CompoundCommand.h"
|
||||
@@ -45,7 +44,6 @@
|
||||
#include "StyleListView.h"
|
||||
#include "StyleView.h"
|
||||
#include "SwatchGroup.h"
|
||||
#include "TransformerFactory.h"
|
||||
#include "TransformerListView.h"
|
||||
#include "TransformGradientBox.h"
|
||||
#include "TransformShapesBox.h"
|
||||
@@ -78,8 +76,6 @@ enum {
|
||||
MSG_SHAPE_RESET_TRANSFORMATION = 'rtsh',
|
||||
MSG_STYLE_RESET_TRANSFORMATION = 'rtst',
|
||||
|
||||
MSG_ADD_TRANSFORMER = 'adtr',
|
||||
|
||||
MSG_MOUSE_FILTER_MODE = 'mfmd',
|
||||
};
|
||||
|
||||
@@ -268,7 +264,6 @@ case MSG_SHAPE_SELECTED: {
|
||||
|
||||
fState->DeleteManipulators();
|
||||
if (selectedShapes.CountItems() > 0) {
|
||||
printf("selected shapes: %ld\n", selectedShapes.CountItems());
|
||||
TransformShapesBox* transformBox = new (nothrow) TransformShapesBox(
|
||||
fCanvasView,
|
||||
(const Shape**)selectedShapes.Items(),
|
||||
@@ -277,33 +272,6 @@ printf("selected shapes: %ld\n", selectedShapes.CountItems());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MSG_ADD_TRANSFORMER: {
|
||||
Shape* shape = fPathListView->CurrentShape();
|
||||
if (!shape)
|
||||
break;
|
||||
|
||||
uint32 type;
|
||||
if (message->FindInt32("type", (int32*)&type) < B_OK)
|
||||
break;
|
||||
|
||||
Transformer* transformer
|
||||
= TransformerFactory::TransformerFor(type,
|
||||
shape->VertexSource());
|
||||
if (!transformer)
|
||||
break;
|
||||
|
||||
Transformer* transformers[1];
|
||||
transformers[0] = transformer;
|
||||
::Command* command = new (nothrow) AddTransformersCommand(
|
||||
shape, transformers, 1, shape->CountTransformers());
|
||||
|
||||
if (!command)
|
||||
delete transformer;
|
||||
|
||||
fDocument->CommandStack()->Perform(command);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
}
|
||||
@@ -499,6 +467,7 @@ MainWindow::_Init()
|
||||
fShapeListView->SetCommandStack(fDocument->CommandStack());
|
||||
fShapeListView->SetSelection(fDocument->Selection());
|
||||
|
||||
fTransformerListView->SetMenu(fTransformerMenu);
|
||||
fTransformerListView->SetCommandStack(fDocument->CommandStack());
|
||||
fTransformerListView->SetSelection(fDocument->Selection());
|
||||
|
||||
@@ -1019,19 +988,6 @@ MainWindow::_CreateMenuBar(BRect frame)
|
||||
|
||||
settingsMenu->AddItem(filterModeMenu);
|
||||
|
||||
// Transformer
|
||||
BMenu* addMenu = new BMenu("Add");
|
||||
int32 cookie = 0;
|
||||
uint32 type;
|
||||
BString name;
|
||||
while (TransformerFactory::NextType(&cookie, &type, &name)) {
|
||||
message = new BMessage(MSG_ADD_TRANSFORMER);
|
||||
message->AddInt32("type", type);
|
||||
addMenu->AddItem(new BMenuItem(name.String(), message));
|
||||
}
|
||||
addMenu->SetTargetForItems(this);
|
||||
fTransformerMenu->AddItem(addMenu);
|
||||
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ void
|
||||
PropertyListView::FrameResized(float width, float height)
|
||||
{
|
||||
SetVisibleSize(width, height);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
// Draw
|
||||
@@ -422,6 +423,7 @@ PropertyListView::SetTo(PropertyObject* object)
|
||||
|
||||
_UpdateSavedProperties();
|
||||
_CheckMenuStatus();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
// PropertyChanged
|
||||
@@ -666,9 +668,15 @@ PropertyListView::_LayoutItems()
|
||||
void
|
||||
PropertyListView::_CheckMenuStatus()
|
||||
{
|
||||
if (!fPropertyM || !fSuspendUpdates)
|
||||
if (!fPropertyM || fSuspendUpdates)
|
||||
return;
|
||||
|
||||
if (!fPropertyObject) {
|
||||
fPropertyM->SetEnabled(false);
|
||||
return;
|
||||
} else
|
||||
fPropertyM->SetEnabled(false);
|
||||
|
||||
bool gotSelection = false;
|
||||
for (int32 i = 0; PropertyItemView* item = _ItemAt(i); i++) {
|
||||
if (item->IsSelected()) {
|
||||
|
||||
@@ -39,6 +39,40 @@ IconObjectListView::~IconObjectListView()
|
||||
_SetObject(NULL);
|
||||
}
|
||||
|
||||
// Draw
|
||||
void
|
||||
IconObjectListView::Draw(BRect updateRect)
|
||||
{
|
||||
PropertyListView::Draw(updateRect);
|
||||
|
||||
if (fObject)
|
||||
return;
|
||||
|
||||
// display helpful messages
|
||||
const char* message1 = "Click on an object in";
|
||||
const char* message2 = "any of the other lists to";
|
||||
const char* message3 = "edit it's properties here.";
|
||||
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
BRect b(Bounds());
|
||||
|
||||
BPoint middle;
|
||||
float textHeight = (fh.ascent + fh.descent) * 1.5;
|
||||
middle.y = (b.top + b.bottom) / 2.0 - textHeight;
|
||||
middle.x = (b.left + b.right - StringWidth(message1)) / 2.0;
|
||||
DrawString(message1, middle);
|
||||
|
||||
middle.y += textHeight;
|
||||
middle.x = (b.left + b.right - StringWidth(message2)) / 2.0;
|
||||
DrawString(message2, middle);
|
||||
|
||||
middle.y += textHeight;
|
||||
middle.x = (b.left + b.right - StringWidth(message3)) / 2.0;
|
||||
DrawString(message3, middle);
|
||||
}
|
||||
|
||||
// PropertyChanged
|
||||
void
|
||||
IconObjectListView::PropertyChanged(const Property* previous,
|
||||
|
||||
@@ -23,6 +23,8 @@ class IconObjectListView : public PropertyListView,
|
||||
virtual ~IconObjectListView();
|
||||
|
||||
// PropertyListView interface
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
virtual void PropertyChanged(const Property* previous,
|
||||
const Property* current);
|
||||
virtual void PasteProperties(const PropertyObject* object);
|
||||
|
||||
@@ -153,6 +153,8 @@ StyleView::StyleView(BRect frame)
|
||||
AddChild(fGradientControl);
|
||||
#endif // __HAIKU__
|
||||
|
||||
fStyleType->SetEnabled(false);
|
||||
fGradientType->SetEnabled(false);
|
||||
fGradientControl->SetEnabled(false);
|
||||
fGradientControl->Gradient()->AddObserver(this);
|
||||
}
|
||||
@@ -295,9 +297,12 @@ StyleView::SetStyle(Style* style)
|
||||
|
||||
if (fCurrentColor && !gradient)
|
||||
fCurrentColor->SetColor(fStyle->Color());
|
||||
}
|
||||
|
||||
_SetGradient(gradient);
|
||||
fStyleType->SetEnabled(true);
|
||||
} else
|
||||
fStyleType->SetEnabled(false);
|
||||
|
||||
_SetGradient(gradient, true);
|
||||
}
|
||||
|
||||
// SetCommandStack
|
||||
@@ -327,9 +332,9 @@ StyleView::SetCurrentColor(CurrentColor* color)
|
||||
|
||||
// _SetGradient
|
||||
void
|
||||
StyleView::_SetGradient(Gradient* gradient)
|
||||
StyleView::_SetGradient(Gradient* gradient, bool forceControlUpdate)
|
||||
{
|
||||
if (fGradient == gradient)
|
||||
if (!forceControlUpdate && fGradient == gradient)
|
||||
return;
|
||||
|
||||
if (fGradient)
|
||||
|
||||
@@ -50,7 +50,8 @@ class StyleView : public BView,
|
||||
void SetCurrentColor(CurrentColor* color);
|
||||
|
||||
private:
|
||||
void _SetGradient(Gradient* gradient);
|
||||
void _SetGradient(Gradient* gradient,
|
||||
bool forceControlUpdate = false);
|
||||
void _MarkType(BMenu* menu,
|
||||
int32 type) const;
|
||||
void _SetStyleType(int32 type);
|
||||
|
||||
@@ -13,14 +13,18 @@
|
||||
|
||||
#include <Application.h>
|
||||
#include <ListItem.h>
|
||||
#include <Message.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Mime.h>
|
||||
#include <Message.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include "AddTransformersCommand.h"
|
||||
#include "CommandStack.h"
|
||||
#include "MoveTransformersCommand.h"
|
||||
#include "RemoveTransformersCommand.h"
|
||||
#include "Transformer.h"
|
||||
#include "TransformerFactory.h"
|
||||
#include "Observer.h"
|
||||
#include "Selection.h"
|
||||
|
||||
@@ -87,7 +91,8 @@ class TransformerItem : public SimpleItem,
|
||||
// #pragma mark -
|
||||
|
||||
enum {
|
||||
MSG_DRAG_TRANSFORMER = 'drgt',
|
||||
MSG_DRAG_TRANSFORMER = 'drgt',
|
||||
MSG_ADD_TRANSFORMER = 'adtr',
|
||||
};
|
||||
|
||||
// constructor
|
||||
@@ -113,6 +118,35 @@ TransformerListView::~TransformerListView()
|
||||
fShape->RemoveListener(this);
|
||||
}
|
||||
|
||||
// Draw
|
||||
void
|
||||
TransformerListView::Draw(BRect updateRect)
|
||||
{
|
||||
SimpleListView::Draw(updateRect);
|
||||
|
||||
if (fShape)
|
||||
return;
|
||||
|
||||
// display helpful messages
|
||||
const char* message1 = "Click on a shape above";
|
||||
const char* message2 = "to attach Transformers.";
|
||||
|
||||
SetHighColor(tint_color(LowColor(), B_DARKEN_2_TINT));
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
BRect b(Bounds());
|
||||
|
||||
BPoint middle;
|
||||
float textHeight = (fh.ascent + fh.descent) * 1.5;
|
||||
middle.y = (b.top + b.bottom - textHeight) / 2.0;
|
||||
middle.x = (b.left + b.right - StringWidth(message1)) / 2.0;
|
||||
DrawString(message1, middle);
|
||||
|
||||
middle.y += textHeight;
|
||||
middle.x = (b.left + b.right - StringWidth(message2)) / 2.0;
|
||||
DrawString(message2, middle);
|
||||
}
|
||||
|
||||
// SelectionChanged
|
||||
void
|
||||
TransformerListView::SelectionChanged()
|
||||
@@ -134,6 +168,42 @@ TransformerListView::SelectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// MessageReceived
|
||||
void
|
||||
TransformerListView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case MSG_ADD_TRANSFORMER: {
|
||||
if (!fShape || !fCommandStack)
|
||||
break;
|
||||
|
||||
uint32 type;
|
||||
if (message->FindInt32("type", (int32*)&type) < B_OK)
|
||||
break;
|
||||
|
||||
Transformer* transformer
|
||||
= TransformerFactory::TransformerFor(type,
|
||||
fShape->VertexSource());
|
||||
if (!transformer)
|
||||
break;
|
||||
|
||||
Transformer* transformers[1];
|
||||
transformers[0] = transformer;
|
||||
::Command* command = new (nothrow) AddTransformersCommand(
|
||||
fShape, transformers, 1, fShape->CountTransformers());
|
||||
|
||||
if (!command)
|
||||
delete transformer;
|
||||
|
||||
fCommandStack->Perform(command);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
SimpleListView::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// MakeDragMessage
|
||||
void
|
||||
TransformerListView::MakeDragMessage(BMessage* message) const
|
||||
@@ -289,6 +359,32 @@ TransformerListView::StyleChanged(Style* oldStyle, Style* newStyle)
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
// SetMenu
|
||||
void
|
||||
TransformerListView::SetMenu(BMenu* menu)
|
||||
{
|
||||
if (fMenu == menu)
|
||||
return;
|
||||
|
||||
fMenu = menu;
|
||||
if (fMenu == NULL)
|
||||
return;
|
||||
|
||||
BMenu* addMenu = new BMenu("Add");
|
||||
int32 cookie = 0;
|
||||
uint32 type;
|
||||
BString name;
|
||||
while (TransformerFactory::NextType(&cookie, &type, &name)) {
|
||||
BMessage* message = new BMessage(MSG_ADD_TRANSFORMER);
|
||||
message->AddInt32("type", type);
|
||||
addMenu->AddItem(new BMenuItem(name.String(), message));
|
||||
}
|
||||
addMenu->SetTargetForItems(this);
|
||||
fMenu->AddItem(addMenu);
|
||||
|
||||
_UpdateMenu();
|
||||
}
|
||||
|
||||
// SetShape
|
||||
void
|
||||
TransformerListView::SetShape(Shape* shape)
|
||||
@@ -312,6 +408,8 @@ TransformerListView::SetShape(Shape* shape)
|
||||
int32 count = fShape->CountTransformers();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
_AddTransformer(fShape->TransformerAtFast(i), i);
|
||||
|
||||
_UpdateMenu();
|
||||
}
|
||||
|
||||
// SetCommandStack
|
||||
@@ -357,4 +455,9 @@ TransformerListView::_ItemForTransformer(Transformer* transformer) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// _UpdateMenu
|
||||
void
|
||||
TransformerListView::_UpdateMenu()
|
||||
{
|
||||
fMenu->SetEnabled(fShape != NULL);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "ListViews.h"
|
||||
#include "Shape.h"
|
||||
|
||||
class BMenu;
|
||||
class CommandStack;
|
||||
class Transformer;
|
||||
class TransformerItem;
|
||||
@@ -27,8 +28,12 @@ class TransformerListView : public SimpleListView,
|
||||
virtual ~TransformerListView();
|
||||
|
||||
// SimpleListView interface
|
||||
virtual void Draw(BRect updateRect);
|
||||
|
||||
virtual void SelectionChanged();
|
||||
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
virtual void MakeDragMessage(BMessage* message) const;
|
||||
|
||||
virtual void MoveItems(BList& items, int32 toIndex);
|
||||
@@ -48,6 +53,7 @@ class TransformerListView : public SimpleListView,
|
||||
virtual void StyleChanged(Style* oldStyle, Style* newStyle);
|
||||
|
||||
// TransformerListView
|
||||
void SetMenu(BMenu* menu);
|
||||
void SetShape(Shape* shape);
|
||||
void SetCommandStack(CommandStack* stack);
|
||||
|
||||
@@ -60,10 +66,14 @@ class TransformerListView : public SimpleListView,
|
||||
TransformerItem* _ItemForTransformer(
|
||||
Transformer* transformer) const;
|
||||
|
||||
void _UpdateMenu();
|
||||
|
||||
BMessage* fMessage;
|
||||
|
||||
Shape* fShape;
|
||||
CommandStack* fCommandStack;
|
||||
|
||||
BMenu* fMenu;
|
||||
};
|
||||
|
||||
#endif // TRANSFORMER_LIST_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user