View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0013211 | Scribus | Canvas | public | 2015-07-07 13:28 | 2019-12-08 21:24 |
Reporter | ale | Assigned To | ale | ||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Product Version | 1.5.1svn | ||||
Fixed in Version | 1.5.6.svn | ||||
Summary | 0013211: Snap to bleeds | ||||
Description | we can now get the items to snap to the page border, it would be wonderful if they would also snap to the bleed. | ||||
Tags | bleed, patch, snapping | ||||
Patch | Yes | ||||
|
since one should mostly not set the size to the page width/height, but always use the bleed if available we could rather have a switch in the preferences / document setting to use the one and the other only (that way we avoid the conflict in snapping when due to the zoom they are too close) but, mostly, we always want to snap to the bleeds if any are defined. |
|
i guess we should replace snapping to page to snapping to bleeds (and if bleeds are 0, it will snap to page) i don't see a reason someone would want to snap to the page, if she has set a bleed... |
|
the latest one is the good one: just snap to the bleed. |
|
yes, please, implement this! it is just terrible annoying to work with bleeds without snapping... IMO snap to page should be kept, because one might want to snap some text boxes to page border instead of bleed, if the page is going to be folded. E.g for folded flyers, CD-digipacks, Vinyl-covers, etc. |
|
i'm really not convinced that i would want the first letter of a text to start on the middle fold of a booklet... but if you really want it, you can always add a guide at 0... imo easier to do that rather than fighting with two snapping points (bleed and border) that are 3 mm from each other... and in your example, no, i'm not sure that the result will look right... the centered text will probably look off center. |
|
You are definitely right, I'll just add guides around page for my needs, so it's fine! In my example, the 3mm bleed will be cut out after printing, so the text will be centered (as far as I could experience in the past). Anyway, I definitely think it is more important to snap to bleed than to page borders. As a workaround for bleed snapping, I wrote a script to add guides around page (and around objects), with the possibility to adjust the distance to the page border (or object). With this script it is really easy to set guides at bleed, at page border, etc etc. Maybe it might be an idea to implement in scribus under "Manage guides" ? https://github.com/sonejostudios/ScribusGuides |
|
i didn't notice that you do not have margins in your screenshot. imo, the right way to do that would be to define 0 mm margins. since this seems to be what you want... then you will have a snapping to the page border and the bleeds. |
|
you are definitely right, that's the way to go! :) |
|
i have a working patch that replaces snapping to the page border by snapping to the bleeds. i'm cleaning it up and will post it later... |
|
hey ale, this is great, thanks you! |
|
Hi sonejostudios This script is fantastic. Thanks for you. |
|
here is my patch, with some refactoring... there is one thing i don't get: what are GxM and GyM? wouldn't it be better if the values assigned to those variables would be kept internal to the set functions and the function would return a boolean that tell if they have modified the x and y values? snap-to-bleed.diff (5,900 bytes)
diff --git a/scribus/scribusdoc.cpp b/scribus/scribusdoc.cpp index 1864f1152..f27c8c811 100644 --- a/scribus/scribusdoc.cpp +++ b/scribus/scribusdoc.cpp @@ -13775,8 +13775,6 @@ void ScribusDoc::createNewDocPages(int pageCount) void ScribusDoc::getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage) { - *GxM = -1; - *GyM = -1; ScPage* page = (refPage == nullptr) ? currentPage() : refPage; QMap<double, uint> tmpGuidesSel; Guides tmpGuides = page->guides.horizontals(GuideManagerCore::Standard); @@ -13836,8 +13834,6 @@ void ScribusDoc::getClosestGuides(double xin, double yin, double *xout, double * void ScribusDoc::getClosestElementBorder(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage) { - *GxM = -1; - *GyM = -1; ScPage* page = (refPage == nullptr) ? currentPage() : refPage; QMap<double, uint> tmpGuidesSel; double viewScale=m_View->scale(); @@ -13894,6 +13890,53 @@ void ScribusDoc::getClosestElementBorder(double xin, double yin, double *xout, d } } +void ScribusDoc::getClosestPageBoundaries(const double xin, const double yin, double &xout, double &yout, int &GxM, int &GyM, ScPage* refPage) +{ + ScPage* page = (refPage == nullptr) ? currentPage() : refPage; + + const double snapDistance = m_docPrefsData.guidesPrefs.guideRad * 1/m_View->scale(); + if (fabs(page->Margins.left() + page->xOffset() - xin) < snapDistance) + { + xout = page->Margins.left(); + GxM = 1; + } + if (fabs((page->width() - page->Margins.right()) + page->xOffset() - xin) < snapDistance) + { + xout = page->width() - page->Margins.right(); + GxM = 1; + } + if (fabs(page->width() + bleeds()->right() + page->xOffset() - xin) < snapDistance) + { + xout = page->width() + bleeds()->right(); + GxM = 1; + } + if (fabs(page->xOffset() - bleeds()->left() - xin) < snapDistance) + { + xout = - bleeds()->left(); + GxM = 1; + } + if (fabs(page->Margins.top() + page->yOffset() - yin) < snapDistance) + { + yout = page->Margins.top(); + GyM = 1; + } + if (fabs((page->height() - page->Margins.bottom())+page->yOffset() - yin) < snapDistance) + { + yout = page->height() - page->Margins.bottom(); + GyM = 1; + } + if (fabs(page->height() + bleeds()->bottom() + page->yOffset() - yin) < snapDistance) + { + yout = page->height() + bleeds()->bottom(); + GyM = 1; + } + if (fabs(page->yOffset() - bleeds()->top() - yin) < snapDistance) + { + yout = - bleeds()->top(); + GyM = 1; + } +} + void ScribusDoc::SnapToGuides(PageItem *currItem) { int pg = OnPage(currItem); @@ -13948,23 +13991,24 @@ void ScribusDoc::SnapToGuides(PageItem *currItem) bool ScribusDoc::ApplyGuides(double *x, double *y, bool elementSnap) { -// m_SnapCounter++; bool ret = false; double xout, yout; int pg = OnPage(*x, *y); if (pg == -1) return ret; ScPage* page = Pages->at(pg); - int GxM, GyM; + int GxM = -1, GyM = -1; // if ((SnapGuides) && (m_SnapCounter > 1)) if ((SnapGuides && !elementSnap) || (SnapElement && elementSnap)) { -// m_SnapCounter = 0; if (!elementSnap) getClosestGuides(*x, *y, &xout, &yout, &GxM, &GyM, page); else getClosestElementBorder(*x, *y, &xout, &yout, &GxM, &GyM, page); + + getClosestPageBoundaries(*x, *y, xout, yout, GxM, GyM, page); + if (GxM != -1) { *x = xout+page->xOffset(); @@ -13975,50 +14019,7 @@ bool ScribusDoc::ApplyGuides(double *x, double *y, bool elementSnap) *y = yout+page->yOffset(); ret = true; } - double invViewScale=1/m_View->scale(); - if (fabs(page->Margins.left() + page->xOffset() - *x) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *x = page->Margins.left()+page->xOffset(); - ret = true; - } - if (fabs((page->width() - page->Margins.right()) + page->xOffset() - *x) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *x = page->width() - page->Margins.right()+page->xOffset(); - ret = true; - } - if (fabs(page->width() + page->xOffset() - *x) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *x = page->width() + page->xOffset(); - ret = true; - } - if (fabs(page->xOffset() - *x) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *x = page->xOffset(); - ret = true; - } - if (fabs(page->Margins.top() + page->yOffset() - *y) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *y = page->Margins.top()+page->yOffset(); - ret = true; - } - if (fabs((page->height() - page->Margins.bottom())+page->yOffset() - *y) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *y = page->height() - page->Margins.bottom()+page->yOffset(); - ret = true; - } - if (fabs(page->height() + page->yOffset() - *y) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *y = page->height() + page->yOffset(); - ret = true; - } - if (fabs(page->yOffset() - *y) < (m_docPrefsData.guidesPrefs.guideRad * invViewScale)) - { - *y = page->yOffset(); - ret = true; - } } -// if (m_SnapCounter > 10) -// m_SnapCounter = 0; return ret; } diff --git a/scribus/scribusdoc.h b/scribus/scribusdoc.h index 27b7d7a82..9160bd356 100644 --- a/scribus/scribusdoc.h +++ b/scribus/scribusdoc.h @@ -1171,6 +1171,8 @@ public: void getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage = nullptr); //! \brief Get the closest border of another element to the given point void getClosestElementBorder(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage = nullptr); + //! \brief Get the closest page margin or bleed + void getClosestPageBoundaries(const double xin, const double yin, double &xout, double &yout, int &GxM, int &GyM, ScPage* refPage); //! \brief Snap an item to the guides void SnapToGuides(PageItem *currItem); bool ApplyGuides(double *x, double *y, bool elementSnap = false); |
|
and, of course a signature like std::optional<DoublePoint> ScribusDoc::getClosestElementBorder(const DoublePoint &pos) would even be better... on top of it, i wonder if it would not be better to detect all the possible snapping points on mouse down... |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-07-07 13:28 | ale | New Issue | |
2015-07-07 13:31 | ale | Note Added: 0035681 | |
2016-05-21 07:38 | Kunda | Tag Attached: snapping | |
2016-05-23 09:35 | ale | Note Added: 0041328 | |
2017-02-07 09:23 | ale | Relationship added | has duplicate 0014606 |
2017-02-07 09:24 | ale | Note Added: 0043454 | |
2019-08-13 06:21 | sonejostudios | File Added: Selection_031.png | |
2019-08-13 06:21 | sonejostudios | Note Added: 0046457 | |
2019-08-13 06:22 | sonejostudios | Tag Attached: bleeds | |
2019-08-13 06:22 | sonejostudios | Tag Detached: bleeds | |
2019-08-13 06:22 | sonejostudios | Tag Attached: bleed | |
2019-08-13 08:21 | ale | Note Added: 0046458 | |
2019-08-14 07:00 | sonejostudios | Note Added: 0046460 | |
2019-08-14 18:30 | ale | Note Added: 0046463 | |
2019-08-15 09:27 | sonejostudios | Note Added: 0046464 | |
2019-08-16 09:02 | ale | Note Added: 0046467 | |
2019-08-16 09:36 | sonejostudios | Note Added: 0046468 | |
2019-08-16 17:36 | PeterBenedek | Note Added: 0046469 | |
2019-08-17 08:15 | ale | File Added: snap-to-bleed.diff | |
2019-08-17 08:15 | ale | Note Added: 0046470 | |
2019-08-17 08:19 | ale | Note Added: 0046471 | |
2019-08-17 15:25 | ale | Summary | snap to bleeds => ]PATCH] snap to bleeds |
2019-08-17 15:25 | ale | Patch | No => Yes |
2019-08-17 15:25 | ale | Tag Attached: patch | |
2019-08-18 16:41 | ale | Summary | ]PATCH] snap to bleeds => [PATCH] snap to bleeds |
2019-08-24 05:20 | jghali | Summary | [PATCH] snap to bleeds => Snap to bleeds |
2019-08-24 06:21 | jghali | Assigned To | => ale |
2019-08-24 06:21 | jghali | Status | new => resolved |
2019-08-24 06:21 | jghali | Resolution | open => fixed |
2019-08-24 06:21 | jghali | Fixed in Version | => 1.5.6.svn |
2019-12-08 21:24 | cbradney | Status | resolved => closed |