Skip to content

Commit

Permalink
[Document] Removed ScrollToPoint method.
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-manias committed May 15, 2024
1 parent 9b7b987 commit d495c46
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 65 deletions.
16 changes: 0 additions & 16 deletions docs/xml/modules/classes/document.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,6 @@
</result>
</method>

<method>
<name>ScrollToPoint</name>
<comment>Scrolls a document's page to a new position.</comment>
<prototype>ERR docScrollToPoint(OBJECTPTR Object, DOUBLE X, DOUBLE Y)</prototype>
<input>
<param type="DOUBLE" name="X">New horizontal position.</param>
<param type="DOUBLE" name="Y">New vertical position.</param>
</input>
<description>
<p>Moves the document's <field>Page</field> to the new position indicated by <code>(X, Y)</code>.</p>
</description>
<result>
<error code="Okay">Operation successful.</error>
</result>
</method>

<method>
<name>SelectLink</name>
<comment>Selects links in the document.</comment>
Expand Down
7 changes: 0 additions & 7 deletions include/parasol/modules/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ DEFINE_ENUM_FLAG_OPERATORS(FSO)

#define MT_docFeedParser -1
#define MT_docSelectLink -2
#define MT_docScrollToPoint -3
#define MT_docFindIndex -4
#define MT_docInsertXML -5
#define MT_docRemoveContent -6
Expand All @@ -111,7 +110,6 @@ DEFINE_ENUM_FLAG_OPERATORS(FSO)

struct docFeedParser { CSTRING String; };
struct docSelectLink { LONG Index; CSTRING Name; };
struct docScrollToPoint { DOUBLE X; DOUBLE Y; };
struct docFindIndex { CSTRING Name; LONG Start; LONG End; };
struct docInsertXML { CSTRING XML; LONG Index; };
struct docRemoveContent { LONG Start; LONG End; };
Expand All @@ -134,11 +132,6 @@ inline ERR docSelectLink(APTR Ob, LONG Index, CSTRING Name) noexcept {
return(Action(MT_docSelectLink, (OBJECTPTR)Ob, &args));
}

inline ERR docScrollToPoint(APTR Ob, DOUBLE X, DOUBLE Y) noexcept {
struct docScrollToPoint args = { X, Y };
return(Action(MT_docScrollToPoint, (OBJECTPTR)Ob, &args));
}

inline ERR docFindIndex(APTR Ob, CSTRING Name, LONG * Start, LONG * End) noexcept {
struct docFindIndex args = { Name, (LONG)0, (LONG)0 };
ERR error = Action(MT_docFindIndex, (OBJECTPTR)Ob, &args);
Expand Down
37 changes: 0 additions & 37 deletions src/document/class/document_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,43 +1154,6 @@ static ERR DOCUMENT_SaveToObject(extDocument *Self, struct acSaveToObject *Args)
return ERR::Okay;
}

/*********************************************************************************************************************
-METHOD-
ScrollToPoint: Scrolls a document's page to a new position.
Moves the document's #Page to the new position indicated by `(X, Y)`.
-INPUT-
double X: New horizontal position.
double Y: New vertical position.
-ERRORS-
Okay
*********************************************************************************************************************/

static ERR DOCUMENT_ScrollToPoint(extDocument *Self, struct docScrollToPoint *Args)
{
if (!Args) return ERR::NullArgs;

Self->XPosition = -Args->X;
Self->YPosition = -Args->Y;

// Validation: coordinates must be negative offsets

if (-Self->YPosition > Self->PageHeight - Self->VPHeight) {
Self->YPosition = -(Self->PageHeight - Self->VPHeight);
}

if (Self->YPosition > 0) Self->YPosition = 0;
if (Self->XPosition > 0) Self->XPosition = 0;

//log.msg("%d, %d / %d, %d", (LONG)Args->X, (LONG)Args->Y, Self->XPosition, Self->YPosition);

acMoveToPoint(Self->Page, Self->XPosition, Self->YPosition, 0, MTF::X|MTF::Y);
return ERR::Okay;
}

/*********************************************************************************************************************
-METHOD-
Expand Down
2 changes: 0 additions & 2 deletions src/document/class/document_def.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ static const struct FieldDef clDocumentFlags[] = {

FDEF maFeedParser[] = { { "String", FD_STR }, { 0, 0 } };
FDEF maSelectLink[] = { { "Index", FD_LONG }, { "Name", FD_STR }, { 0, 0 } };
FDEF maScrollToPoint[] = { { "X", FD_DOUBLE }, { "Y", FD_DOUBLE }, { 0, 0 } };
FDEF maFindIndex[] = { { "Name", FD_STR }, { "Start", FD_LONG|FD_RESULT }, { "End", FD_LONG|FD_RESULT }, { 0, 0 } };
FDEF maInsertXML[] = { { "XML", FD_STR }, { "Index", FD_LONG }, { 0, 0 } };
FDEF maRemoveContent[] = { { "Start", FD_LONG }, { "End", FD_LONG }, { 0, 0 } };
Expand All @@ -39,7 +38,6 @@ FDEF maReadContent[] = { { "Format", FD_LONG }, { "Start", FD_LONG }, { "End", F
static const struct MethodEntry clDocumentMethods[] = {
{ -1, (APTR)DOCUMENT_FeedParser, "FeedParser", maFeedParser, sizeof(struct docFeedParser) },
{ -2, (APTR)DOCUMENT_SelectLink, "SelectLink", maSelectLink, sizeof(struct docSelectLink) },
{ -3, (APTR)DOCUMENT_ScrollToPoint, "ScrollToPoint", maScrollToPoint, sizeof(struct docScrollToPoint) },
{ -4, (APTR)DOCUMENT_FindIndex, "FindIndex", maFindIndex, sizeof(struct docFindIndex) },
{ -5, (APTR)DOCUMENT_InsertXML, "InsertXML", maInsertXML, sizeof(struct docInsertXML) },
{ -6, (APTR)DOCUMENT_RemoveContent, "RemoveContent", maRemoveContent, sizeof(struct docRemoveContent) },
Expand Down
1 change: 0 additions & 1 deletion src/document/defs/document.fdl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ module({ name="Document", copyright="Paul Manias © 2005-2024", version=1.0 }, f
methods("Document", "doc", {
{ id=1, name="FeedParser" },
{ id=2, name="SelectLink" },
{ id=3, name="ScrollToPoint" },
{ id=4, name="FindIndex" },
{ id=5, name="InsertXML" },
{ id=6, name="RemoveContent" },
Expand Down
12 changes: 11 additions & 1 deletion src/document/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,17 @@ static void show_bookmark(extDocument *Self, const std::string &Bookmark)
// Get the vertical position of the index and scroll to it

auto &esc_index = Self->Stream.lookup<bc_index>(start);
docScrollToPoint(Self, 0, esc_index.y - 4);

Self->XPosition = 0;
Self->YPosition = -(esc_index.y - 4);

if (-Self->YPosition > Self->PageHeight - Self->VPHeight) {
Self->YPosition = -(Self->PageHeight - Self->VPHeight);
}

if (Self->YPosition > 0) Self->YPosition = 0;

acMoveToPoint(Self->Page, 0, Self->YPosition, 0, MTF::X|MTF::Y);
}
else log.warning("Failed to find bookmark '%s'", Bookmark.c_str());
}
Expand Down
4 changes: 3 additions & 1 deletion src/document/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,9 @@ static bool view_area(extDocument *Self, DOUBLE Left, DOUBLE Top, DOUBLE Right,
else view_x = 0;

if ((-view_x != Self->XPosition) or (-view_y != Self->YPosition)) {
docScrollToPoint(Self, view_x, view_y);
Self->XPosition = -view_x;
Self->YPosition = -view_y;
acMoveToPoint(Self->Page, -view_x, -view_y, 0, MTF::X|MTF::Y);
return true;
}
else return false;
Expand Down

0 comments on commit d495c46

Please sign in to comment.