Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FillStyle): Add controls for fill color and opacity for shapes #693

Merged
merged 30 commits into from
Aug 23, 2019

Conversation

kwilson-bits
Copy link
Collaborator

@kwilson-bits kwilson-bits commented Jul 19, 2019

Add controls for fill color and opacity for shapes, vector layers, and feature actions.
re #531

Testing link: http://os-fill-controls.surge.sh/

@welchyd
Copy link
Collaborator

welchyd commented Jul 23, 2019

I made a live link to help expedite testing: http://late-garden.surge.sh [outdated]
Test steps:

  1. Draw a polygon (square, circle, or polygon) on the map and save it as a place
  2. In the style accordion try out various Fill Style combinations for color and opacity
  3. Verify that the polygon fill changes in the preview as different options are selected
  4. Save the polygon and verify that it remembers the fill style when you edit it
  5. In the layers menu expand the Saved Places layer and click on a place
  6. Verify that the style accordion in the layers menu correctly shows the fill style
  7. Verify that you can change the fill style
  8. Verify that the style changes are toggleable with the command stack (ctrl + z and ctrl + y)
  9. Verify that exporting Saved Places as a place preserves the fill style
  10. Export saved places as a kml, verify that it imports with the fill style
  11. Import and select the kml layer in the layers window and in the style accordion check 'replace feature style'
  12. Verify that all shapes reflect the selected fill style
  13. Export Saved Places as a csv, verity that it does not import with the fill style
  14. Select the csv layer in the layers window and from the style accordion verify that all shapes reflect the selected fill style
  15. In the layers window, right click on the csv file and from the menu select feature actions
  16. Create a feature action that sets the style to have a fill
  17. Verify that the fill changes as expected
  18. Verify that exporting/importing the feature action with fill style works
  19. Refresh Open Sphere and verify that the fill styles are persisted

I found a few small things:

  • Pre-existing, handle separately - When changing the fill color from the nodeui, the node doesn't update to match the new color

Copy link
Collaborator

@welchyd welchyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

featurestyleaction.js needs to be updated to include fill color and opacity for export/import of feature actions

src/os/ui/featureedit.js Show resolved Hide resolved
src/os/command/feature/featurefillcolorcmd.js Outdated Show resolved Hide resolved
src/os/command/feature/featurefillopacitycmd.js Outdated Show resolved Hide resolved
src/os/command/feature/featureopacitycmd.js Outdated Show resolved Hide resolved
src/os/command/feature/featurestrokecolorcmd.js Outdated Show resolved Hide resolved
src/os/command/feature/featurestrokeopacitycmd.js Outdated Show resolved Hide resolved
src/os/ui/featureedit.js Outdated Show resolved Hide resolved
@kwilson-bits kwilson-bits force-pushed the 531-shape-fill-controls branch from 056714f to 325ad9b Compare July 26, 2019 15:27
@jsalankey
Copy link
Contributor

jsalankey commented Jul 26, 2019

Testing feedback:

  • Places are not visible while editing them due to the fact that the fill opacity slider is set to 0.
  • The fill style on points is overriding the stroke style. Changing the original stroke color picker has no effect if there's a fill color set.
  • Having a fill style slider at all with a point is confusing. This is part of a larger issue that also applies to the border style picker, so we may not be able to fix it here. However, they shouldn't conflict with each other.
  • The fill color is not reflected in the node icon in the layers window. This is a difficult problem also, to which the best solution is to have those icons show sort of both a stroke color on themselves and a fill color. We should write a followon to address this issue.
  • The fill color on a point place is applying and changing properly, but on refresh, it is not applying. The color is still set in the feature style UI on refresh, but it's not being applied.
  • Undoing a fill opacity change is always resetting the fill opacity to 100%.
  • The overall opacity slider now synchronizes both sliders. These two things should be able to be adjusted totally independently.

@kwilson-bits
Copy link
Collaborator Author

Testing feedback:

  • Places are not visible while editing them due to the fact that the fill opacity slider is set to 0.
  • The fill style on points is overriding the stroke style. Changing the original stroke color picker has no effect if there's a fill color set.
  • Having a fill style slider at all with a point is confusing. This is part of a larger issue that also applies to the border style picker, so we may not be able to fix it here. However, they shouldn't conflict with each other.
  • The fill color is not reflected in the node icon in the layers window. This is a difficult problem also, to which the best solution is to have those icons show sort of both a stroke color on themselves and a fill color. We should write a followon to address this issue.
  • The fill color on a point place is applying and changing properly, but on refresh, it is not applying. The color is still set in the feature style UI on refresh, but it's not being applied.
  • Undoing a fill opacity change is always resetting the fill opacity to 100%.
  • The overall opacity slider now synchronizes both sliders. These two things should be able to be adjusted totally independently.

The opacity slider behavior should be as follows:

  • When the stroke opacity and the fill opacity have the same value and the stroke slider is moved, the fill slider should move to match it. The idea being that if you have set the stroke and fill to be the same value, you want to keep them the same value.
  • As part of this, if you slide the stroke opacity to be the same as the fill opacity's value, and then keep sliding the stroke opacity, it will pick up the fill opacity and change them both to be the same.
  • Regardless of the stroke opacity value, when moving the fill slider you should only change the fill opacity. This way you can always change one without changing the other.

This should now behave the same for both commands and Feature Edit.

When undoing a fill opacity change, it should now properly reset to the previous value.

Copy link
Contributor

@schmidtk schmidtk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see the large volume of code duplication in this PR reduced.

src/os/command/feature/featurefillcolorcmd.js Outdated Show resolved Hide resolved
src/os/command/vectorlayerfillcolorcmd.js Outdated Show resolved Hide resolved
src/plugin/file/kml/kmlnodelayerui.js Outdated Show resolved Hide resolved
src/os/ui/featureedit.js Outdated Show resolved Hide resolved
@kwilson-bits kwilson-bits requested a review from welchyd August 12, 2019 16:56
Copy link
Contributor

@schmidtk schmidtk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layers:

  • Layers that were loaded in the application prior to this change have a default fill opacity of 1 instead of 0. The layer should probably correct this in restore if os.style.StyleField.FILL_COLOR is not defined on the config.
  • Point geometries are using the fill color. That should only change config.fill, not config.image.fill. Points should be using the "Color" UI value.
  • If I undo the color, fill color, or fill opacity commands, the fill opacity is always set to 1.
  • The color Reset buttons (color and fill color) throw an error. More details in the code review.

Places:

  • The fill color command resets fill opacity to 1 on undo.
  • When the fill color matches the base color, changing the base color puts two commands on the stack. It should add a single command (likely multiple commands wrapped in a sequence command), and undo/redo should work for that command.
  • The fill color Reset button throws an error. More details in the code review.

Feature Actions:

  • Point geometries are using the fill color. That should only change config.fill, not config.image.fill. Points should be using the "Color" UI value.

src/os/ui/layer/vectorlayerui.js Outdated Show resolved Hide resolved
src/plugin/file/kml/kmlnodelayerui.js Show resolved Hide resolved
src/plugin/file/kml/kmlnodelayerui.js Show resolved Hide resolved
src/os/ui/layer/vectorlayerui.js Show resolved Hide resolved
src/os/ui/layer/vectorlayerui.js Outdated Show resolved Hide resolved
src/plugin/file/kml/kmlnodelayerui.js Show resolved Hide resolved
src/os/command/feature/featurecolorcmd.js Outdated Show resolved Hide resolved
src/os/command/vectorlayercolorcmd.js Show resolved Hide resolved
src/os/ui/layer/vectorlayerui.js Outdated Show resolved Hide resolved
src/plugin/featureaction/featurestyleaction.js Outdated Show resolved Hide resolved
src/plugin/featureaction/ui/featurestyleactionconfig.js Outdated Show resolved Hide resolved
src/plugin/file/kml/kmlnodelayerui.js Outdated Show resolved Hide resolved
kwilson-bits and others added 10 commits August 15, 2019 12:22
BREAKING CHANGE: Adds required argument to os.ui.file.kml.AbstractKMLExporter#createStyle
Fix an issue when undoing fill opacity. Fix when sliding stroke opacity when using Feature Edit
dialog.
BREAKING CHANGE: This changes the behavior of `os.style.getConfigColor` when using a field hint.
- If `config.<hint> === null`, return `null`. This allows disabling stroke/fill.
- If `config.<hint>.color` is defined, return the value.
- Return `undefined` otherwise, indicating the field/color could not be found.
@schmidtk
Copy link
Contributor

I cleaned up remaining issues I've come across in testing, as well as a few bugs from master:

  • Undo feature color change will update the label color if it's the same as the feature.
  • Quick added places were not persisting their label columns, so labels would disappear after refresh.

@schmidtk schmidtk self-requested a review August 19, 2019 12:44
@schmidtk schmidtk dismissed stale reviews from welchyd and jsalankey August 19, 2019 12:44

Feedback resolved.

schmidtk
schmidtk previously approved these changes Aug 19, 2019
@schmidtk
Copy link
Contributor

I deployed this to Surge at http://os-fill-controls.surge.sh/, updated in the issue description.

Copy link
Collaborator

@welchyd welchyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When creating or editing a Place - the border dash options drop down doesn't show the initial selection

In the layers window, when the opacity and fill opacity sliders get set to the same value, changing the opacity slider also causes the fill opacity to change. This is not consistent with the behavior when creating/editing a Place

@schmidtk
Copy link
Contributor

@welchyd

When creating or editing a Place - the border dash options drop down doesn't show the initial selection

This is broken on master, unrelated.

In the layers window, when the opacity and fill opacity sliders get set to the same value, changing the opacity slider also causes the fill opacity to change. This is not consistent with the behavior when creating/editing a Place

Ah thanks, missed that one when I was removing the opacity/fill opacity linkage. Fixed/deployed.

welchyd
welchyd previously approved these changes Aug 19, 2019
@justin-bits
Copy link
Collaborator

justin-bits commented Aug 19, 2019

  1. Opacity and Fill Style are not retained in saved states
  2. Saved Places with default styling exported as KML, then imported as features are not visible on the map. Only the label is visible. Regression. If non default styling was applied before save, the places are visible. The features are also visible on mouseover, changing size or checking Replace Feature Style. The position for the Size slider definitely affects visibility. The features are not visible in the default position of 22.22%, but visible at any other position. On sliding left or right (visible), then returning to the default position, the features are again not visible.
  3. Opacity is no longer respected on imported KML features unless Replace Feature Style is checked. Regression.

Follow-on issues here: #737

jsalankey
jsalankey previously approved these changes Aug 20, 2019
Changing layer opacity at the config level has significant performance
implications, in that it creates new style objects for each opacity
value. It also prevents the layer opacity control from affecting KML
layers because the layer config is ignored.
Kevin Schmidt added 2 commits August 20, 2019 09:40
@schmidtk
Copy link
Contributor

@justin-bits I believe all of those are resolved, though I didn't see the second bullet prior to my latest changes.

This PR was making a fundamental change to how the layer-level opacity slider was working. Instead of using OL's get/setOpacity API's, it was changing the opacity in the layer style config by changing the color alpha values. This presents a few problems:

  • A new OL style will be created/cached for each opacity value.
  • Layer opacity no longer multiplied by feature opacity. This broke the layer opacity control for any layer with feature-specific styling (KML, layers with feature actions applied, etc). Fixing this would require computing the combined layer/feature opacity internally, which would incur a performance penalty.
  • Layer persist/restore behavior changed, impacting how state files are imported/exported.

To resolve these issues, the original layer opacity behavior was restored. This does mean the layer opacity will be multiplied by fill opacity, so if they're both at 50% the fill will be rendered at 25%. This seemed to be a reasonable compromise to avoid the above problems.

@justin-bits
Copy link
Collaborator

Looks good

@schmidtk schmidtk requested a review from jsalankey August 20, 2019 20:00
@schmidtk schmidtk merged commit 3e75cd0 into ngageoint:master Aug 23, 2019
@schmidtk schmidtk deleted the 531-shape-fill-controls branch August 23, 2019 13:48
@bradh bradh mentioned this pull request Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants