diff --git a/src/apps/icon-o-matic/IconEditorApp.cpp b/src/apps/icon-o-matic/IconEditorApp.cpp index 502ab7a929..149a06e5b9 100644 --- a/src/apps/icon-o-matic/IconEditorApp.cpp +++ b/src/apps/icon-o-matic/IconEditorApp.cpp @@ -137,10 +137,16 @@ IconEditorApp::MessageReceived(BMessage* message) } _SyncPanels(fSavePanel, fOpenPanel); } else { + const char* saveText = NULL; + if (fDocument->Ref()) + saveText = fDocument->Ref()->name; + switch (message->what) { case MSG_EXPORT_AS: case MSG_EXPORT: exportMode = EXPORT_MODE_FLAT_ICON; + if (fDocument->ExportRef()) + saveText = fDocument->ExportRef()->name; break; case MSG_EXPORT_BITMAP: exportMode = EXPORT_MODE_BITMAP; @@ -171,6 +177,8 @@ IconEditorApp::MessageReceived(BMessage* message) fSavePanel->SetMessage(&fpMessage); // fSavePanel->Refresh(); + if (saveText) + fSavePanel->SetSaveText(saveText); fSavePanel->Show(); } break; @@ -325,13 +333,15 @@ IconEditorApp::_Open(const entry_ref& ref, bool append) fDocument->SetIcon(icon); - switch (refMode) { - case REF_MESSAGE: - fDocument->SetRef(ref); - break; - case REF_FLAT: - fDocument->SetExportRef(ref); - break; + if (!append) { + switch (refMode) { + case REF_MESSAGE: + fDocument->SetRef(ref); + break; + case REF_FLAT: + fDocument->SetExportRef(ref); + break; + } } locker.Unlock(); diff --git a/src/apps/icon-o-matic/import_export/svg/DocumentBuilder.cpp b/src/apps/icon-o-matic/import_export/svg/DocumentBuilder.cpp index b772b802fe..bec9eea3a6 100644 --- a/src/apps/icon-o-matic/import_export/svg/DocumentBuilder.cpp +++ b/src/apps/icon-o-matic/import_export/svg/DocumentBuilder.cpp @@ -454,6 +454,8 @@ DocumentBuilder::parse_path(PathTokenizer& tok) } } +// #pragma mark - + // GetIcon status_t DocumentBuilder::GetIcon(Icon* icon, SVGImporter* importer, @@ -519,6 +521,25 @@ printf("scale: %f\n", scale); _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; } @@ -528,7 +549,8 @@ DocumentBuilder::StartGradient(bool radial) { if (fCurrentGradient) { fprintf(stderr, "DocumentBuilder::StartGradient() - ERROR: " - "previous gradient (%s) not finished!\n", fCurrentGradient->ID()); + "previous gradient (%s) not finished!\n", + fCurrentGradient->ID()); } if (radial) @@ -546,7 +568,8 @@ DocumentBuilder::EndGradient() if (fCurrentGradient) { // fCurrentGradient->PrintToStream(); } else { - fprintf(stderr, "DocumentBuilder::EndGradient() - ERROR: no gradient started!\n"); + fprintf(stderr, "DocumentBuilder::EndGradient() - " + "ERROR: no gradient started!\n"); } fCurrentGradient = NULL; } diff --git a/src/apps/icon-o-matic/style/SetColorCommand.cpp b/src/apps/icon-o-matic/style/SetColorCommand.cpp index a9be92a79a..c7ed4619a7 100644 --- a/src/apps/icon-o-matic/style/SetColorCommand.cpp +++ b/src/apps/icon-o-matic/style/SetColorCommand.cpp @@ -34,11 +34,11 @@ SetColorCommand::~SetColorCommand() status_t 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 ? B_OK : B_NO_INIT; -#else - return fStyle && fStyle->Color() != fColor ? B_OK : B_NO_INIT; #endif } diff --git a/src/libs/icon/Icon.h b/src/libs/icon/Icon.h index 4a7c6cbc60..209f980d74 100644 --- a/src/libs/icon/Icon.h +++ b/src/libs/icon/Icon.h @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku. + * Copyright 2006, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: diff --git a/src/libs/icon/shape/VectorPath.cpp b/src/libs/icon/shape/VectorPath.cpp index c84b055b84..6d991db937 100644 --- a/src/libs/icon/shape/VectorPath.cpp +++ b/src/libs/icon/shape/VectorPath.cpp @@ -20,6 +20,7 @@ #ifdef ICON_O_MATIC #include +#include #include #include @@ -169,9 +170,14 @@ VectorPath::~VectorPath() obj_free(fPath); #ifdef ICON_O_MATIC - if (fListeners.CountItems() > 0) - debugger("VectorPath::~VectorPath() - " - "there are still listeners attached!"); + if (fListeners.CountItems() > 0) { + PathListener* listener = (PathListener*)fListeners.ItemAt(0); + char message[512]; + sprintf(message, "VectorPath::~VectorPath() - " + "there are still listeners attached! %p/%s", + listener, typeid(*listener).name()); + debugger(message); + } #endif } diff --git a/src/libs/icon/style/Style.cpp b/src/libs/icon/style/Style.cpp index cffd41f50c..7dd456db0e 100644 --- a/src/libs/icon/style/Style.cpp +++ b/src/libs/icon/style/Style.cpp @@ -142,13 +142,31 @@ Style::Archive(BMessage* into, bool deep) const 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 // SetColor void Style::SetColor(const rgb_color& color) { - if ((uint32&)fColor == (uint32&)color) + if (*(uint32*)&fColor == *(uint32*)&color) return; fColor = color; diff --git a/src/libs/icon/style/Style.h b/src/libs/icon/style/Style.h index 2584e7f19b..a116971607 100644 --- a/src/libs/icon/style/Style.h +++ b/src/libs/icon/style/Style.h @@ -45,6 +45,8 @@ class Style { // Style status_t Archive(BMessage* into, bool deep = true) const; + + bool operator==(const Style& other) const; #else inline void Notify() {} #endif // ICON_O_MATIC