Skip to content

Commit

Permalink
Merge pull request #191 from isteinbrecher/develop
Browse files Browse the repository at this point in the history
Release v1.0.2
  • Loading branch information
isteinbrecher authored Dec 27, 2024
2 parents 1933e3e + 8b63fed commit 16f07dd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
3 changes: 3 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

- **v1.0.2**
- Bug fixes:
- Fix bug that caused Illustrator to crash when deselecting all active LaTeX2AI elements [#189](https://github.com/isteinbrecher/latex2ai/issues/189).
- **v1.0.1**
- Bug fixes:
- Fix bug that caused problems when using items that were created using a deprecated hash algorithm.
Expand Down
8 changes: 3 additions & 5 deletions src/l2a_annotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ void L2A::Annotator::Draw(AIAnnotatorMessage* message) const
/**
*
*/
void L2A::Annotator::InvalAnnotation(AIAnnotatorMessage* message) const
void L2A::Annotator::InvalAnnotation(const AIRealRect& artwork_bounds) const
{
// Get the rectangle to invalidate.
AIRect inval_rect = L2A::AI::ArtworkBoundsToViewBounds(*message->invalidationRects);
AIRect inval_rect = L2A::AI::ArtworkBoundsToViewBounds(artwork_bounds);

// Invalidate the rect bounds so it is redrawn.
AIErr result = sAIAnnotator->InvalAnnotationRect(nullptr, &inval_rect);
Expand All @@ -211,7 +211,5 @@ void L2A::Annotator::InvalAnnotation() const
l2a_check_ai_error(result);

// Invalidate the rect bounds so it is redrawn.
AIRect inval_rect = L2A::AI::ArtworkBoundsToViewBounds(view_bounds);
result = sAIAnnotator->InvalAnnotationRect(nullptr, &inval_rect);
l2a_check_ai_error(result);
InvalAnnotation(view_bounds);
}
2 changes: 1 addition & 1 deletion src/l2a_annotator.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace L2A
/**
* \brief Invalidate the annotation.
*/
void InvalAnnotation(AIAnnotatorMessage* message) const;
void InvalAnnotation(const AIRealRect& artwork_bounds) const;

/**
* \brief Invalidate the entire document view bounds.
Expand Down
2 changes: 1 addition & 1 deletion src/l2a_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define L2A_PLUGIN_NAME "LaTeX2AI"

//! Version of the plugin.
#define L2A_VERSION_STRING_ "1.0.1"
#define L2A_VERSION_STRING_ "1.0.2"

//! Icon IDs.
#define TOOL_ICON_CREATE_DARK_ID 19000 // icon for create mode in dark mode
Expand Down
37 changes: 29 additions & 8 deletions src/l2a_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,35 @@ ASErr L2APlugin::Message(char* caller, char* selector, void* message)
{
if (strcmp(caller, kCallerAIAnnotation) == 0)
{
if (strcmp(selector, kSelectorAIDrawAnnotation) == 0)
// Draw the l2a annotator.
annotator_->Draw((AIAnnotatorMessage*)message);
else if (strcmp(selector, kSelectorAIInvalAnnotation) == 0)
// Invalidate the annotator.
// TODO: maybe this function call can be removed. Check if it is called at all / what the given
// invalidate box actually is.
annotator_->InvalAnnotation((AIAnnotatorMessage*)message);
auto* annotator_message = (AIAnnotatorMessage*)message;
if (annotator_message == nullptr)
{
// In case the annotator message pointer is null, we don't do anything here.
}
else
{
if (strcmp(selector, kSelectorAIDrawAnnotation) == 0)
// Draw the l2a annotator.
annotator_->Draw(annotator_message);
else if (strcmp(selector, kSelectorAIInvalAnnotation) == 0)
{
// Invalidate the annotator.
// TODO: maybe this function call can be removed. Check if it is called at all / what the given
// invalidate box actually is.

// In some calls, the pointer to the invalidation rectangle is null, in these cases we
// invalidate the whole document view.
auto* artwork_bounds = annotator_message->invalidationRects;
if (artwork_bounds == nullptr)
{
annotator_->InvalAnnotation();
}
else
{
annotator_->InvalAnnotation(*artwork_bounds);
}
}
}
}
}
else
Expand Down

0 comments on commit 16f07dd

Please sign in to comment.