* improvements to saving/loading, biggest flaw was that appending an icon
changed the save entry_ref to the appended file, instead of keeping it * added cleaning up styles (removing duplicates) after importing from SVG * compile fixes for rgb_color ==/!= rgb_color * added Style::operator==(const Style& other) * improved debug output when listeners are still attached to a VectorPath upon destruction git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19188 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -137,10 +137,16 @@ IconEditorApp::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
_SyncPanels(fSavePanel, fOpenPanel);
|
_SyncPanels(fSavePanel, fOpenPanel);
|
||||||
} else {
|
} else {
|
||||||
|
const char* saveText = NULL;
|
||||||
|
if (fDocument->Ref())
|
||||||
|
saveText = fDocument->Ref()->name;
|
||||||
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case MSG_EXPORT_AS:
|
case MSG_EXPORT_AS:
|
||||||
case MSG_EXPORT:
|
case MSG_EXPORT:
|
||||||
exportMode = EXPORT_MODE_FLAT_ICON;
|
exportMode = EXPORT_MODE_FLAT_ICON;
|
||||||
|
if (fDocument->ExportRef())
|
||||||
|
saveText = fDocument->ExportRef()->name;
|
||||||
break;
|
break;
|
||||||
case MSG_EXPORT_BITMAP:
|
case MSG_EXPORT_BITMAP:
|
||||||
exportMode = EXPORT_MODE_BITMAP;
|
exportMode = EXPORT_MODE_BITMAP;
|
||||||
@@ -171,6 +177,8 @@ IconEditorApp::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
fSavePanel->SetMessage(&fpMessage);
|
fSavePanel->SetMessage(&fpMessage);
|
||||||
// fSavePanel->Refresh();
|
// fSavePanel->Refresh();
|
||||||
|
if (saveText)
|
||||||
|
fSavePanel->SetSaveText(saveText);
|
||||||
fSavePanel->Show();
|
fSavePanel->Show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -325,13 +333,15 @@ IconEditorApp::_Open(const entry_ref& ref, bool append)
|
|||||||
|
|
||||||
fDocument->SetIcon(icon);
|
fDocument->SetIcon(icon);
|
||||||
|
|
||||||
switch (refMode) {
|
if (!append) {
|
||||||
case REF_MESSAGE:
|
switch (refMode) {
|
||||||
fDocument->SetRef(ref);
|
case REF_MESSAGE:
|
||||||
break;
|
fDocument->SetRef(ref);
|
||||||
case REF_FLAT:
|
break;
|
||||||
fDocument->SetExportRef(ref);
|
case REF_FLAT:
|
||||||
break;
|
fDocument->SetExportRef(ref);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locker.Unlock();
|
locker.Unlock();
|
||||||
|
|||||||
@@ -454,6 +454,8 @@ DocumentBuilder::parse_path(PathTokenizer& tok)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
// GetIcon
|
// GetIcon
|
||||||
status_t
|
status_t
|
||||||
DocumentBuilder::GetIcon(Icon* icon, SVGImporter* importer,
|
DocumentBuilder::GetIcon(Icon* icon, SVGImporter* importer,
|
||||||
@@ -519,6 +521,25 @@ printf("scale: %f\n", scale);
|
|||||||
_AddShape(attributes, true, transform, icon);
|
_AddShape(attributes, true, transform, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean up styles and paths (remove duplicates)
|
||||||
|
int32 count = icon->Shapes()->CountShapes();
|
||||||
|
for (int32 i = 1; i < count; i++) {
|
||||||
|
Shape* shape = icon->Shapes()->ShapeAtFast(i);
|
||||||
|
Style* style = shape->Style();
|
||||||
|
if (!style)
|
||||||
|
continue;
|
||||||
|
int32 styleIndex = icon->Styles()->IndexOf(style);
|
||||||
|
for (int32 j = 0; j < styleIndex; j++) {
|
||||||
|
Style* earlierStyle = icon->Styles()->StyleAtFast(j);
|
||||||
|
if (*style == *earlierStyle) {
|
||||||
|
shape->SetStyle(earlierStyle);
|
||||||
|
icon->Styles()->RemoveStyle(style);
|
||||||
|
style->Release();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,7 +549,8 @@ DocumentBuilder::StartGradient(bool radial)
|
|||||||
{
|
{
|
||||||
if (fCurrentGradient) {
|
if (fCurrentGradient) {
|
||||||
fprintf(stderr, "DocumentBuilder::StartGradient() - ERROR: "
|
fprintf(stderr, "DocumentBuilder::StartGradient() - ERROR: "
|
||||||
"previous gradient (%s) not finished!\n", fCurrentGradient->ID());
|
"previous gradient (%s) not finished!\n",
|
||||||
|
fCurrentGradient->ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radial)
|
if (radial)
|
||||||
@@ -546,7 +568,8 @@ DocumentBuilder::EndGradient()
|
|||||||
if (fCurrentGradient) {
|
if (fCurrentGradient) {
|
||||||
// fCurrentGradient->PrintToStream();
|
// fCurrentGradient->PrintToStream();
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "DocumentBuilder::EndGradient() - ERROR: no gradient started!\n");
|
fprintf(stderr, "DocumentBuilder::EndGradient() - "
|
||||||
|
"ERROR: no gradient started!\n");
|
||||||
}
|
}
|
||||||
fCurrentGradient = NULL;
|
fCurrentGradient = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ SetColorCommand::~SetColorCommand()
|
|||||||
status_t
|
status_t
|
||||||
SetColorCommand::InitCheck()
|
SetColorCommand::InitCheck()
|
||||||
{
|
{
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_BEOS
|
#ifdef __HAIKU__
|
||||||
|
return fStyle && fStyle->Color() != fColor ? B_OK : B_NO_INIT;
|
||||||
|
#else
|
||||||
return fStyle && *(uint32*)&fStyle->Color() != *(uint32*)&fColor ?
|
return fStyle && *(uint32*)&fStyle->Color() != *(uint32*)&fColor ?
|
||||||
B_OK : B_NO_INIT;
|
B_OK : B_NO_INIT;
|
||||||
#else
|
|
||||||
return fStyle && fStyle->Color() != fColor ? B_OK : B_NO_INIT;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2006, Haiku.
|
* Copyright 2006, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#ifdef ICON_O_MATIC
|
#ifdef ICON_O_MATIC
|
||||||
#include <debugger.h>
|
#include <debugger.h>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
@@ -169,9 +170,14 @@ VectorPath::~VectorPath()
|
|||||||
obj_free(fPath);
|
obj_free(fPath);
|
||||||
|
|
||||||
#ifdef ICON_O_MATIC
|
#ifdef ICON_O_MATIC
|
||||||
if (fListeners.CountItems() > 0)
|
if (fListeners.CountItems() > 0) {
|
||||||
debugger("VectorPath::~VectorPath() - "
|
PathListener* listener = (PathListener*)fListeners.ItemAt(0);
|
||||||
"there are still listeners attached!");
|
char message[512];
|
||||||
|
sprintf(message, "VectorPath::~VectorPath() - "
|
||||||
|
"there are still listeners attached! %p/%s",
|
||||||
|
listener, typeid(*listener).name());
|
||||||
|
debugger(message);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,13 +142,31 @@ Style::Archive(BMessage* into, bool deep) const
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// operator ==
|
||||||
|
bool
|
||||||
|
Style::operator==(const Style& other) const
|
||||||
|
{
|
||||||
|
if (fGradient) {
|
||||||
|
if (other.fGradient)
|
||||||
|
return *fGradient == *other.fGradient;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (!other.fGradient)
|
||||||
|
return *(uint32*)&fColor == *(uint32*)&other.fColor;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ICON_O_MATIC
|
#endif // ICON_O_MATIC
|
||||||
|
|
||||||
// SetColor
|
// SetColor
|
||||||
void
|
void
|
||||||
Style::SetColor(const rgb_color& color)
|
Style::SetColor(const rgb_color& color)
|
||||||
{
|
{
|
||||||
if ((uint32&)fColor == (uint32&)color)
|
if (*(uint32*)&fColor == *(uint32*)&color)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fColor = color;
|
fColor = color;
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ class Style {
|
|||||||
// Style
|
// Style
|
||||||
status_t Archive(BMessage* into,
|
status_t Archive(BMessage* into,
|
||||||
bool deep = true) const;
|
bool deep = true) const;
|
||||||
|
|
||||||
|
bool operator==(const Style& other) const;
|
||||||
#else
|
#else
|
||||||
inline void Notify() {}
|
inline void Notify() {}
|
||||||
#endif // ICON_O_MATIC
|
#endif // ICON_O_MATIC
|
||||||
|
|||||||
Reference in New Issue
Block a user