From d495c46ba1269459d7202356a12702c5e3e11738 Mon Sep 17 00:00:00 2001 From: Paul Manias Date: Wed, 15 May 2024 11:27:26 +0100 Subject: [PATCH] [Document] Removed ScrollToPoint method. --- docs/xml/modules/classes/document.xml | 16 ------------ include/parasol/modules/document.h | 7 ----- src/document/class/document_class.cpp | 37 --------------------------- src/document/class/document_def.c | 2 -- src/document/defs/document.fdl | 1 - src/document/functions.cpp | 12 ++++++++- src/document/ui.cpp | 4 ++- 7 files changed, 14 insertions(+), 65 deletions(-) diff --git a/docs/xml/modules/classes/document.xml b/docs/xml/modules/classes/document.xml index 81cc9bd1e..363faa451 100644 --- a/docs/xml/modules/classes/document.xml +++ b/docs/xml/modules/classes/document.xml @@ -316,22 +316,6 @@ - - ScrollToPoint - Scrolls a document's page to a new position. - ERR docScrollToPoint(OBJECTPTR Object, DOUBLE X, DOUBLE Y) - - New horizontal position. - New vertical position. - - -

Moves the document's Page to the new position indicated by (X, Y).

-
- - Operation successful. - -
- SelectLink Selects links in the document. diff --git a/include/parasol/modules/document.h b/include/parasol/modules/document.h index 2023977d0..a3b9633ed 100644 --- a/include/parasol/modules/document.h +++ b/include/parasol/modules/document.h @@ -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 @@ -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; }; @@ -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); diff --git a/src/document/class/document_class.cpp b/src/document/class/document_class.cpp index 94829bddf..e0246d462 100644 --- a/src/document/class/document_class.cpp +++ b/src/document/class/document_class.cpp @@ -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- diff --git a/src/document/class/document_def.c b/src/document/class/document_def.c index 35102a510..2638243f5 100644 --- a/src/document/class/document_def.c +++ b/src/document/class/document_def.c @@ -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 } }; @@ -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) }, diff --git a/src/document/defs/document.fdl b/src/document/defs/document.fdl index 9278296f7..b72837e16 100644 --- a/src/document/defs/document.fdl +++ b/src/document/defs/document.fdl @@ -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" }, diff --git a/src/document/functions.cpp b/src/document/functions.cpp index c5da5b046..cd0509e9e 100644 --- a/src/document/functions.cpp +++ b/src/document/functions.cpp @@ -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(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()); } diff --git a/src/document/ui.cpp b/src/document/ui.cpp index 1ec42f275..223fcad52 100644 --- a/src/document/ui.cpp +++ b/src/document/ui.cpp @@ -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;