* Transformable::Reset() + Invert() didn't notify
* Path and StyleContainer take an index in Add...() * FlatIconImporter works when "appending" another icon git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18448 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -35,6 +35,9 @@ using std::nothrow;
|
|||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
FlatIconImporter::FlatIconImporter()
|
FlatIconImporter::FlatIconImporter()
|
||||||
|
#ifdef ICON_O_MATIC
|
||||||
|
: Importer()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +50,14 @@ FlatIconImporter::~FlatIconImporter()
|
|||||||
status_t
|
status_t
|
||||||
FlatIconImporter::Import(Icon* icon, BPositionIO* stream)
|
FlatIconImporter::Import(Icon* icon, BPositionIO* stream)
|
||||||
{
|
{
|
||||||
|
#ifdef ICON_O_MATIC
|
||||||
|
status_t ret = Init(icon);
|
||||||
|
if (ret < B_OK)
|
||||||
|
return ret;
|
||||||
|
#else
|
||||||
|
status_t ret;
|
||||||
|
#endif
|
||||||
|
|
||||||
// seek around in the stream to figure out the size
|
// seek around in the stream to figure out the size
|
||||||
off_t size = stream->Seek(0, SEEK_END);
|
off_t size = stream->Seek(0, SEEK_END);
|
||||||
if (stream->Seek(0, SEEK_SET) != 0)
|
if (stream->Seek(0, SEEK_SET) != 0)
|
||||||
@@ -64,7 +75,7 @@ FlatIconImporter::Import(Icon* icon, BPositionIO* stream)
|
|||||||
if (stream->Read(buffer.Buffer(), size) != size)
|
if (stream->Read(buffer.Buffer(), size) != size)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
status_t ret = _ParseSections(buffer, icon);
|
ret = _ParseSections(buffer, icon);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -73,6 +84,12 @@ FlatIconImporter::Import(Icon* icon, BPositionIO* stream)
|
|||||||
status_t
|
status_t
|
||||||
FlatIconImporter::Import(Icon* icon, uint8* _buffer, size_t size)
|
FlatIconImporter::Import(Icon* icon, uint8* _buffer, size_t size)
|
||||||
{
|
{
|
||||||
|
#ifdef ICON_O_MATIC
|
||||||
|
status_t ret = Init(icon);
|
||||||
|
if (ret < B_OK)
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!_buffer)
|
if (!_buffer)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
@@ -465,9 +482,10 @@ _ReadTransformer(LittleEndianBuffer& buffer, VertexSource& source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// _ReadPathSourceShape
|
// _ReadPathSourceShape
|
||||||
static Shape*
|
Shape*
|
||||||
_ReadPathSourceShape(LittleEndianBuffer& buffer,
|
FlatIconImporter::_ReadPathSourceShape(LittleEndianBuffer& buffer,
|
||||||
StyleContainer* styles, PathContainer* paths)
|
StyleContainer* styles,
|
||||||
|
PathContainer* paths)
|
||||||
{
|
{
|
||||||
// find out which style this shape uses
|
// find out which style this shape uses
|
||||||
uint8 styleIndex;
|
uint8 styleIndex;
|
||||||
@@ -475,7 +493,12 @@ _ReadPathSourceShape(LittleEndianBuffer& buffer,
|
|||||||
if (!buffer.Read(styleIndex) || !buffer.Read(pathCount))
|
if (!buffer.Read(styleIndex) || !buffer.Read(pathCount))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
#ifdef ICON_O_MATIC
|
||||||
|
Style* style = styles->StyleAt(StyleIndexFor(styleIndex));
|
||||||
|
#else
|
||||||
Style* style = styles->StyleAt(styleIndex);
|
Style* style = styles->StyleAt(styleIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!style) {
|
if (!style) {
|
||||||
printf("_ReadPathSourceShape() - "
|
printf("_ReadPathSourceShape() - "
|
||||||
"shape references non-existing style %d\n", styleIndex);
|
"shape references non-existing style %d\n", styleIndex);
|
||||||
@@ -495,7 +518,11 @@ _ReadPathSourceShape(LittleEndianBuffer& buffer,
|
|||||||
if (!buffer.Read(pathIndex))
|
if (!buffer.Read(pathIndex))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
#ifdef ICON_O_MATIC
|
||||||
|
VectorPath* path = paths->PathAt(PathIndexFor(pathIndex));
|
||||||
|
#else
|
||||||
VectorPath* path = paths->PathAt(pathIndex);
|
VectorPath* path = paths->PathAt(pathIndex);
|
||||||
|
#endif
|
||||||
if (!path) {
|
if (!path) {
|
||||||
printf("_ReadPathSourceShape() - "
|
printf("_ReadPathSourceShape() - "
|
||||||
"shape references non-existing path %d\n", pathIndex);
|
"shape references non-existing path %d\n", pathIndex);
|
||||||
|
|||||||
@@ -9,17 +9,26 @@
|
|||||||
#ifndef FLAT_ICON_IMPORTER_H
|
#ifndef FLAT_ICON_IMPORTER_H
|
||||||
#define FLAT_ICON_IMPORTER_H
|
#define FLAT_ICON_IMPORTER_H
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#ifdef ICON_O_MATIC
|
||||||
|
# include "Importer.h"
|
||||||
|
#else
|
||||||
|
# include <SupportDefs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BPositionIO;
|
class BPositionIO;
|
||||||
class Icon;
|
class Icon;
|
||||||
class LittleEndianBuffer;
|
class LittleEndianBuffer;
|
||||||
class PathContainer;
|
class PathContainer;
|
||||||
|
class Shape;
|
||||||
class ShapeContainer;
|
class ShapeContainer;
|
||||||
class StyleContainer;
|
class StyleContainer;
|
||||||
|
|
||||||
|
#ifdef ICON_O_MATIC
|
||||||
|
class FlatIconImporter : public Importer {
|
||||||
|
#else
|
||||||
class FlatIconImporter {
|
class FlatIconImporter {
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
FlatIconImporter();
|
FlatIconImporter();
|
||||||
virtual ~FlatIconImporter();
|
virtual ~FlatIconImporter();
|
||||||
@@ -40,6 +49,10 @@ class FlatIconImporter {
|
|||||||
StyleContainer* styles);
|
StyleContainer* styles);
|
||||||
status_t _ParsePaths(LittleEndianBuffer& buffer,
|
status_t _ParsePaths(LittleEndianBuffer& buffer,
|
||||||
PathContainer* paths);
|
PathContainer* paths);
|
||||||
|
Shape* _ReadPathSourceShape(
|
||||||
|
LittleEndianBuffer& buffer,
|
||||||
|
StyleContainer* styles,
|
||||||
|
PathContainer* paths);
|
||||||
status_t _ParseShapes(LittleEndianBuffer& buffer,
|
status_t _ParseShapes(LittleEndianBuffer& buffer,
|
||||||
StyleContainer* styles,
|
StyleContainer* styles,
|
||||||
PathContainer* paths,
|
PathContainer* paths,
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ PathContainer::~PathContainer()
|
|||||||
// AddPath
|
// AddPath
|
||||||
bool
|
bool
|
||||||
PathContainer::AddPath(VectorPath* path)
|
PathContainer::AddPath(VectorPath* path)
|
||||||
|
{
|
||||||
|
return AddPath(path, CountPaths());
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPath
|
||||||
|
bool
|
||||||
|
PathContainer::AddPath(VectorPath* path, int32 index)
|
||||||
{
|
{
|
||||||
if (!path)
|
if (!path)
|
||||||
return false;
|
return false;
|
||||||
@@ -57,9 +64,9 @@ PathContainer::AddPath(VectorPath* path)
|
|||||||
if (HasPath(path))
|
if (HasPath(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (fPaths.AddItem((void*)path)) {
|
if (fPaths.AddItem((void*)path, index)) {
|
||||||
#ifdef ICON_O_MATIC
|
#ifdef ICON_O_MATIC
|
||||||
_NotifyPathAdded(path);
|
_NotifyPathAdded(path, index);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -186,14 +193,14 @@ PathContainer::_MakeEmpty()
|
|||||||
#ifdef ICON_O_MATIC
|
#ifdef ICON_O_MATIC
|
||||||
// _NotifyPathAdded
|
// _NotifyPathAdded
|
||||||
void
|
void
|
||||||
PathContainer::_NotifyPathAdded(VectorPath* path) const
|
PathContainer::_NotifyPathAdded(VectorPath* path, int32 index) const
|
||||||
{
|
{
|
||||||
BList listeners(fListeners);
|
BList listeners(fListeners);
|
||||||
int32 count = listeners.CountItems();
|
int32 count = listeners.CountItems();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
PathContainerListener* listener
|
PathContainerListener* listener
|
||||||
= (PathContainerListener*)listeners.ItemAtFast(i);
|
= (PathContainerListener*)listeners.ItemAtFast(i);
|
||||||
listener->PathAdded(path);
|
listener->PathAdded(path, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class PathContainerListener {
|
|||||||
PathContainerListener();
|
PathContainerListener();
|
||||||
virtual ~PathContainerListener();
|
virtual ~PathContainerListener();
|
||||||
|
|
||||||
virtual void PathAdded(VectorPath* path) = 0;
|
virtual void PathAdded(VectorPath* path, int32 index) = 0;
|
||||||
virtual void PathRemoved(VectorPath* path) = 0;
|
virtual void PathRemoved(VectorPath* path) = 0;
|
||||||
};
|
};
|
||||||
#endif // ICON_O_MATIC
|
#endif // ICON_O_MATIC
|
||||||
@@ -30,6 +30,7 @@ class PathContainer {
|
|||||||
virtual ~PathContainer();
|
virtual ~PathContainer();
|
||||||
|
|
||||||
bool AddPath(VectorPath* path);
|
bool AddPath(VectorPath* path);
|
||||||
|
bool AddPath(VectorPath* path, int32 index);
|
||||||
bool RemovePath(VectorPath* path);
|
bool RemovePath(VectorPath* path);
|
||||||
VectorPath* RemovePath(int32 index);
|
VectorPath* RemovePath(int32 index);
|
||||||
|
|
||||||
@@ -54,7 +55,8 @@ class PathContainer {
|
|||||||
bool RemoveListener(PathContainerListener* listener);
|
bool RemoveListener(PathContainerListener* listener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _NotifyPathAdded(VectorPath* path) const;
|
void _NotifyPathAdded(VectorPath* path,
|
||||||
|
int32 index) const;
|
||||||
void _NotifyPathRemoved(VectorPath* path) const;
|
void _NotifyPathRemoved(VectorPath* path) const;
|
||||||
|
|
||||||
BList fListeners;
|
BList fListeners;
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ Shape::ObjectChanged(const Observable* object)
|
|||||||
|
|
||||||
// PathAdded
|
// PathAdded
|
||||||
void
|
void
|
||||||
Shape::PathAdded(VectorPath* path)
|
Shape::PathAdded(VectorPath* path, int32 index)
|
||||||
{
|
{
|
||||||
path->Acquire();
|
path->Acquire();
|
||||||
path->AddListener(this);
|
path->AddListener(this);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Shape : public Transformable {
|
|||||||
virtual void ObjectChanged(const Observable* object);
|
virtual void ObjectChanged(const Observable* object);
|
||||||
|
|
||||||
// PathContainerListener interface
|
// PathContainerListener interface
|
||||||
virtual void PathAdded(VectorPath* path);
|
virtual void PathAdded(VectorPath* path, int32 index);
|
||||||
virtual void PathRemoved(VectorPath* path);
|
virtual void PathRemoved(VectorPath* path);
|
||||||
|
|
||||||
// PathListener interface
|
// PathListener interface
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ StyleContainer::~StyleContainer()
|
|||||||
// AddStyle
|
// AddStyle
|
||||||
bool
|
bool
|
||||||
StyleContainer::AddStyle(Style* style)
|
StyleContainer::AddStyle(Style* style)
|
||||||
|
{
|
||||||
|
return AddStyle(style, CountStyles());
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddStyle
|
||||||
|
bool
|
||||||
|
StyleContainer::AddStyle(Style* style, int32 index)
|
||||||
{
|
{
|
||||||
if (!style)
|
if (!style)
|
||||||
return false;
|
return false;
|
||||||
@@ -57,9 +64,9 @@ StyleContainer::AddStyle(Style* style)
|
|||||||
if (HasStyle(style))
|
if (HasStyle(style))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (fStyles.AddItem((void*)style)) {
|
if (fStyles.AddItem((void*)style, index)) {
|
||||||
#ifdef ICON_O_MATIC
|
#ifdef ICON_O_MATIC
|
||||||
_NotifyStyleAdded(style);
|
_NotifyStyleAdded(style, index);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -187,14 +194,14 @@ StyleContainer::_MakeEmpty()
|
|||||||
|
|
||||||
// _NotifyStyleAdded
|
// _NotifyStyleAdded
|
||||||
void
|
void
|
||||||
StyleContainer::_NotifyStyleAdded(Style* style) const
|
StyleContainer::_NotifyStyleAdded(Style* style, int32 index) const
|
||||||
{
|
{
|
||||||
BList listeners(fListeners);
|
BList listeners(fListeners);
|
||||||
int32 count = listeners.CountItems();
|
int32 count = listeners.CountItems();
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
StyleContainerListener* listener
|
StyleContainerListener* listener
|
||||||
= (StyleContainerListener*)listeners.ItemAtFast(i);
|
= (StyleContainerListener*)listeners.ItemAtFast(i);
|
||||||
listener->StyleAdded(style);
|
listener->StyleAdded(style, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class StyleContainerListener {
|
|||||||
StyleContainerListener();
|
StyleContainerListener();
|
||||||
virtual ~StyleContainerListener();
|
virtual ~StyleContainerListener();
|
||||||
|
|
||||||
virtual void StyleAdded(Style* style) = 0;
|
virtual void StyleAdded(Style* style, int32 index) = 0;
|
||||||
virtual void StyleRemoved(Style* style) = 0;
|
virtual void StyleRemoved(Style* style) = 0;
|
||||||
};
|
};
|
||||||
#endif // ICON_O_MATIC
|
#endif // ICON_O_MATIC
|
||||||
@@ -30,6 +30,7 @@ class StyleContainer {
|
|||||||
virtual ~StyleContainer();
|
virtual ~StyleContainer();
|
||||||
|
|
||||||
bool AddStyle(Style* style);
|
bool AddStyle(Style* style);
|
||||||
|
bool AddStyle(Style* style, int32 index);
|
||||||
bool RemoveStyle(Style* style);
|
bool RemoveStyle(Style* style);
|
||||||
Style* RemoveStyle(int32 index);
|
Style* RemoveStyle(int32 index);
|
||||||
|
|
||||||
@@ -53,7 +54,8 @@ class StyleContainer {
|
|||||||
bool RemoveListener(StyleContainerListener* listener);
|
bool RemoveListener(StyleContainerListener* listener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _NotifyStyleAdded(Style* style) const;
|
void _NotifyStyleAdded(Style* style,
|
||||||
|
int32 index) const;
|
||||||
void _NotifyStyleRemoved(Style* style) const;
|
void _NotifyStyleRemoved(Style* style) const;
|
||||||
|
|
||||||
BList fListeners;
|
BList fListeners;
|
||||||
|
|||||||
@@ -87,14 +87,20 @@ Transformable::Multiply(const Transformable& other)
|
|||||||
void
|
void
|
||||||
Transformable::Reset()
|
Transformable::Reset()
|
||||||
{
|
{
|
||||||
reset();
|
if (!IsIdentity()) {
|
||||||
|
reset();
|
||||||
|
TransformationChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invert
|
// Invert
|
||||||
void
|
void
|
||||||
Transformable::Invert()
|
Transformable::Invert()
|
||||||
{
|
{
|
||||||
invert();
|
if (!IsIdentity()) {
|
||||||
|
invert();
|
||||||
|
TransformationChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsIdentity
|
// IsIdentity
|
||||||
|
|||||||
Reference in New Issue
Block a user