View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0016996 | Scribus | Usability | public | 2023-08-12 18:48 | 2024-01-12 18:54 |
Reporter | pmjdebruijn | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 1.6.0.svn | ||||
Summary | 0016996: New (Linear) Gradients are Black-to-Black (effectively solid) | ||||
Description | When adding a new shape, and switching to a Linear gradient (via Properties/Colors), I get a solid black background. The newly added gradient, is a black-to-black gradient, while technically a gradient, effectively solid, which may confuse users. Recommended behavior: When a user switches from a default solid fill to a gradient, generate the previously selected color to white gradient. Example: So if the solid fill was previously set to red, then generate a red (or if unable to determine, fall through to black) to white gradient. Also, new linear gradients are by default graduated across the horizontal axis, which to me seems like the least common use-case, I have a suspicion gradients across the vertical axis are more commonly used, therefore I think this probably be the default direction for newly created linear gradients. I've tried digging into the code, but wasn't successful so far. | ||||
Tags | No tags attached. | ||||
Patch | No | ||||
|
If someone could point me to where a new Linear Gradient's parameter are initialized, I might be able to work out a patch... |
|
Ah found it: https://github.com/scribusproject/scribus/blob/master/scribus/pageitem.cpp#L558 Attached is a concept patch, which probably shouldn't be applied as-is: 1) it only affects fill gradients, but is easily extended to line gradients 2) the right stop is hardcoded to white, which results in a white-to-white gradient if the default fill/line color is set to white, so in that case it should probably be flipped to black But it shows what I'd like to change and roughly how... And I'd love some feedback. On a sidenote, two questions: 1) https://github.com/scribusproject/scribus/blob/master/scribus/pageitem.cpp#L595 why is the 'm_Doc->PageColors.contains("Black")' there if Black can't be deleted from the Document? 2) https://github.com/scribusproject/scribus/blob/master/scribus/pageitem.cpp#L1678 what's a GrType == Gradient_4Colors, presumably it's more than just a gradient with 4 stops? gradient.patch (3,432 bytes)
diff -Nurpd a/scribus/pageitem.cpp b/scribus/pageitem.cpp --- a/scribus/pageitem.cpp 2024-01-07 18:07:06.000000000 +0100 +++ b/scribus/pageitem.cpp 2024-01-12 10:15:21.074106187 +0100 @@ -506,6 +506,7 @@ PageItem::PageItem(ScribusDoc *doc, Item ImageIntent = Intent_Relative_Colorimetric; m_layerID = m_Doc->activeLayer(); + stroke_gradient = VGradient(VGradient::linear); stroke_gradient.clearStops(); if (m_lineColor != CommonStrings::None) @@ -543,6 +544,7 @@ PageItem::PageItem(ScribusDoc *doc, Item stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); } + fill_gradient = VGradient(VGradient::linear); fill_gradient.clearStops(); if (m_fillColor != CommonStrings::None) @@ -550,7 +552,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_fillColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); GrColorP1 = m_fillColor; GrColorP2 = m_fillColor; GrColorP3 = m_fillColor; @@ -563,7 +564,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); GrColorP1 = m_Doc->itemToolPrefs().shapeFillColor; GrColorP2 = m_Doc->itemToolPrefs().shapeFillColor; GrColorP3 = m_Doc->itemToolPrefs().shapeFillColor; @@ -576,7 +576,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_lineColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_lineColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_lineColor, 100); GrColorP1 = m_lineColor; GrColorP2 = m_lineColor; GrColorP3 = m_lineColor; @@ -589,7 +588,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); GrColorP1 = m_Doc->itemToolPrefs().shapeLineColor; GrColorP2 = m_Doc->itemToolPrefs().shapeLineColor; GrColorP3 = m_Doc->itemToolPrefs().shapeLineColor; @@ -600,7 +598,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors["Black"]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); GrColorP1 = "Black"; GrColorP2 = "Black"; GrColorP3 = "Black"; @@ -609,6 +606,10 @@ PageItem::PageItem(ScribusDoc *doc, Item } } } + const ScColor& col_right = m_Doc->PageColors["White"]; + QColor qcol_right = ScColorEngine::getRGBColor(col_right, m_Doc); + fill_gradient.addStop(qcol_right, 1.0, 0.5, 1.0, "White", 100); + GrMaskEndX = w; mask_gradient = VGradient(VGradient::linear); mask_gradient.clearStops(); |
|
Revision with stroke gradients as well gradient-2.patch (5,215 bytes)
diff -Nurpd a/scribus/pageitem.cpp b/scribus/pageitem.cpp --- a/scribus/pageitem.cpp 2024-01-07 18:07:06.000000000 +0100 +++ b/scribus/pageitem.cpp 2024-01-12 14:57:05.142550453 +0100 @@ -506,6 +506,7 @@ PageItem::PageItem(ScribusDoc *doc, Item ImageIntent = Intent_Relative_Colorimetric; m_layerID = m_Doc->activeLayer(); + stroke_gradient = VGradient(VGradient::linear); stroke_gradient.clearStops(); if (m_lineColor != CommonStrings::None) @@ -513,36 +514,35 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_lineColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_lineColor, 100); - stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_lineColor, 100); } else if (m_Doc->itemToolPrefs().shapeLineColor != CommonStrings::None) { const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); - stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); } else if (m_fillColor != CommonStrings::None) { const ScColor& col = m_Doc->PageColors[m_fillColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); - stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); } else if (m_Doc->itemToolPrefs().shapeFillColor != CommonStrings::None) { const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); - stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); } else if (m_Doc->PageColors.contains("Black")) { const ScColor& col = m_Doc->PageColors["Black"]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); stroke_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); - stroke_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); } + const ScColor& col_stroke_right = m_Doc->PageColors["White"]; + QColor qcol_stroke_right = ScColorEngine::getRGBColor(col_stroke_right, m_Doc); + stroke_gradient.addStop(qcol_stroke_right, 1.0, 0.5, 1.0, "White", 100); + fill_gradient = VGradient(VGradient::linear); fill_gradient.clearStops(); if (m_fillColor != CommonStrings::None) @@ -550,7 +550,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_fillColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_fillColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_fillColor, 100); GrColorP1 = m_fillColor; GrColorP2 = m_fillColor; GrColorP3 = m_fillColor; @@ -563,7 +562,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeFillColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeFillColor, 100); GrColorP1 = m_Doc->itemToolPrefs().shapeFillColor; GrColorP2 = m_Doc->itemToolPrefs().shapeFillColor; GrColorP3 = m_Doc->itemToolPrefs().shapeFillColor; @@ -576,7 +574,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_lineColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_lineColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_lineColor, 100); GrColorP1 = m_lineColor; GrColorP2 = m_lineColor; GrColorP3 = m_lineColor; @@ -589,7 +586,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors[m_Doc->itemToolPrefs().shapeLineColor]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, m_Doc->itemToolPrefs().shapeLineColor, 100); GrColorP1 = m_Doc->itemToolPrefs().shapeLineColor; GrColorP2 = m_Doc->itemToolPrefs().shapeLineColor; GrColorP3 = m_Doc->itemToolPrefs().shapeLineColor; @@ -600,7 +596,6 @@ PageItem::PageItem(ScribusDoc *doc, Item const ScColor& col = m_Doc->PageColors["Black"]; QColor qcol = ScColorEngine::getRGBColor(col, m_Doc); fill_gradient.addStop(qcol, 0.0, 0.5, 1.0, "Black", 100); - fill_gradient.addStop(qcol, 1.0, 0.5, 1.0, "Black", 100); GrColorP1 = "Black"; GrColorP2 = "Black"; GrColorP3 = "Black"; @@ -609,6 +604,10 @@ PageItem::PageItem(ScribusDoc *doc, Item } } } + const ScColor& col_fill_right = m_Doc->PageColors["White"]; + QColor qcol_fill_right = ScColorEngine::getRGBColor(col_fill_right, m_Doc); + fill_gradient.addStop(qcol_fill_right, 1.0, 0.5, 1.0, "White", 100); + GrMaskEndX = w; mask_gradient = VGradient(VGradient::linear); mask_gradient.clearStops(); |
|
I just realized the default horizontal gradient orientation is probably very intentional, as it matches the gradient in the properties dock. |
Date Modified | Username | Field | Change |
---|---|---|---|
2023-08-12 18:48 | pmjdebruijn | New Issue | |
2023-08-14 16:45 | pmjdebruijn | Note Added: 0050310 | |
2024-01-12 09:28 | pmjdebruijn | Note Added: 0050884 | |
2024-01-12 09:28 | pmjdebruijn | File Added: gradient.patch | |
2024-01-12 14:14 | pmjdebruijn | Note Added: 0050885 | |
2024-01-12 14:14 | pmjdebruijn | File Added: gradient-2.patch | |
2024-01-12 18:54 | pmjdebruijn | Note Added: 0050886 |