Repository: napari/napari

Issue:
Newly added point in `Add` mode is selected but not editable
## 🐛 Bug

Hi,
Once a point has been drawn I would like to resize it immediately. Currently if I move the point size slider right after adding a new point, point size remains unchanged. I need to use the selection too, and select it and afterwards I can edit its size. So apparently right after creating a new point, the point is not selected, although it is highlighted as if it was selected. Would it be possible to make the point directly size-editable, without having first to select it?
Thanks
Benoit

## To Reproduce

Steps to reproduce the behavior:

1. Add a point in the graphical user interface.
2. Slide the point size slider --> the point does not get resized
3. Select the newly added point.
4. Slide the point size slider --> the point gets resized


## Expected behavior

The point should get resized at step 2 (in "To reproduce")

## Environment

 - Please copy and paste the information at napari info option in help menubar here:

napari: 0.4.3
Platform: macOS-11.2-x86_64-i386-64bit
Python: 3.9.1 | packaged by conda-forge | (default, Jan 26 2021, 01:32:59) [Clang 11.0.1 ]
Qt: 5.9.7
PyQt5: 5.9.2
NumPy: 1.19.5
SciPy: 1.6.0
Dask: 2021.01.1
VisPy: 0.6.6

OpenGL:
- GL version: 2.1 INTEL-16.1.10
- MAX_TEXTURE_SIZE: 16384

Screens:
- screen #1: resolution 2560x1440, scale 2.0
- screen #2: resolution 1440x900, scale 2.0

Plugins:
- napari_plugin_engine: 0.1.9
- svg: 0.1.4





Discussion:
This issue has been mentioned on **Image.sc Forum**. There might be relevant details there:

https://forum.image.sc/t/immediately-resizing-an-existing-point/48604/4

> the point is not selected, although it is highlighted as if it was selected.

This in particular sounds like a bug - if it is highlighted it should be selected. It seems reasonable too that the last added point should be selected by default. Maybe there was a regression somewhere. We should look into it
This is indeed a bug, and it does not just affect point size, but also other properties. The point is correctly selected, and I think we all agree that its selection is desired behavior. This means we need to explicitly update the `current_*` setters to remove the check that we are in `add` mode. 

Tagging this for SciPy sprint this weekend!
I will be working on this today at the napari sprint :)

Resolving patch:
diff --git a/napari/layers/points/points.py b/napari/layers/points/points.py
--- a/napari/layers/points/points.py
+++ b/napari/layers/points/points.py
@@ -623,11 +623,7 @@ def current_properties(self) -> Dict[str, np.ndarray]:
     @current_properties.setter
     def current_properties(self, current_properties):
         update_indices = None
-        if (
-            self._update_properties
-            and len(self.selected_data) > 0
-            and self._mode != Mode.ADD
-        ):
+        if self._update_properties and len(self.selected_data) > 0:
             update_indices = list(self.selected_data)
         self._feature_table.set_currents(
             current_properties, update_indices=update_indices
@@ -751,11 +747,7 @@ def current_size(self) -> Union[int, float]:
     @current_size.setter
     def current_size(self, size: Union[None, float]) -> None:
         self._current_size = size
-        if (
-            self._update_properties
-            and len(self.selected_data) > 0
-            and self._mode != Mode.ADD
-        ):
+        if self._update_properties and len(self.selected_data) > 0:
             for i in self.selected_data:
                 self.size[i, :] = (self.size[i, :] > 0) * size
             self.refresh()
@@ -856,11 +848,7 @@ def current_edge_width(self) -> Union[int, float]:
     @current_edge_width.setter
     def current_edge_width(self, edge_width: Union[None, float]) -> None:
         self._current_edge_width = edge_width
-        if (
-            self._update_properties
-            and len(self.selected_data) > 0
-            and self._mode != Mode.ADD
-        ):
+        if self._update_properties and len(self.selected_data) > 0:
             for i in self.selected_data:
                 self.edge_width[i] = (self.edge_width[i] > 0) * edge_width
             self.refresh()
@@ -928,11 +916,7 @@ def current_edge_color(self) -> str:
 
     @current_edge_color.setter
     def current_edge_color(self, edge_color: ColorType) -> None:
-        if (
-            self._update_properties
-            and len(self.selected_data) > 0
-            and self._mode != Mode.ADD
-        ):
+        if self._update_properties and len(self.selected_data) > 0:
             update_indices = list(self.selected_data)
         else:
             update_indices = []
@@ -1020,11 +1004,7 @@ def current_face_color(self) -> str:
     @current_face_color.setter
     def current_face_color(self, face_color: ColorType) -> None:
 
-        if (
-            self._update_properties
-            and len(self.selected_data) > 0
-            and self._mode != Mode.ADD
-        ):
+        if self._update_properties and len(self.selected_data) > 0:
             update_indices = list(self.selected_data)
         else:
             update_indices = []


Test patch:
diff --git a/napari/layers/points/_tests/test_points.py b/napari/layers/points/_tests/test_points.py
--- a/napari/layers/points/_tests/test_points.py
+++ b/napari/layers/points/_tests/test_points.py
@@ -12,6 +12,7 @@
     check_layer_world_data_extent,
 )
 from napari.layers import Points
+from napari.layers.points._points_constants import Mode
 from napari.layers.points._points_utils import points_to_squares
 from napari.layers.utils._text_constants import Anchor
 from napari.layers.utils.color_encoding import ConstantColorEncoding
@@ -2418,3 +2419,22 @@ def test_empty_data_from_tuple():
     layer = Points(name="points")
     layer2 = Points.create(*layer.as_layer_data_tuple())
     assert layer2.data.size == 0
+
+
+@pytest.mark.parametrize(
+    'attribute, new_value',
+    [
+        ("size", [20, 20]),
+        ("face_color", np.asarray([0.0, 0.0, 1.0, 1.0])),
+        ("edge_color", np.asarray([0.0, 0.0, 1.0, 1.0])),
+        ("edge_width", np.asarray([0.2])),
+    ],
+)
+def test_new_point_size_editable(attribute, new_value):
+    """tests the newly placed points may be edited without re-selecting"""
+    layer = Points()
+    layer.mode = Mode.ADD
+    layer.add((0, 0))
+
+    setattr(layer, f"current_{attribute}", new_value)
+    np.testing.assert_allclose(getattr(layer, attribute)[0], new_value)