Skip to content

Commit f70885e

Browse files
Merge pull request #2 from jposada202020/reviewing
Initial_commit
2 parents 7c78e7a + a8cebdf commit f70885e

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040

4141
intersphinx_mapping = {
4242
"python": ("https://docs.python.org/3.4", None),
43+
"adafruit_displayio_layout": (
44+
"https://circuitpython.readthedocs.io/projects/displayio-layout/en/latest/",
45+
None,
46+
),
4347
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
4448
}
4549

slider.py

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,30 @@ class Slider(Widget, Control):
5252
:param int x: pixel position, defaults to 0
5353
:param int y: pixel position, defaults to 0
5454
:param int width: width of the slider in pixels. It is recommended to use 100
55-
the height will auto-size relative to the width, defaults to 100
55+
the height will auto-size relative to the width. Defaults to :const:`100`
5656
:param int height: height of the slider in pixels, defaults to 40 pixels
5757
:param int touch_padding: the width of an additional border surrounding the switch
5858
that extends the touch response boundary, defaults to 0
5959
6060
:param anchor_point: starting point for the annotation line, where ``anchor_point`` is
6161
an (A,B) tuple in relative units of the size of the widget, for example (0.0, 0.0) is
62-
the upper left corner, and (1.0, 1.0) is the lower right corner of the widget.
63-
If ``anchor_point`` is `None`, then ``anchored_position`` is used to set the
64-
annotation line starting point, in widget size relative units (default is (0.0, 0.0)).
62+
the upper left corner, and (1.0, 1.0) is the lower right corner of the widget.
63+
If :attr:`anchor_point` is `None`, then :attr:`anchored_position` is used to set the
64+
annotation line starting point, in widget size relative units.
65+
Defaults to :const:`(0.0, 0.0)`
6566
:type anchor_point: Tuple[float, float]
6667
6768
:param anchored_position: pixel position starting point for the annotation line
68-
where ``anchored_position`` is an (x,y) tuple in pixel units relative to the
69+
where :attr:`anchored_position` is an (x,y) tuple in pixel units relative to the
6970
upper left corner of the widget, in pixel units (default is None).
7071
:type anchored_position: Tuple[int, int]
7172
7273
:param fill_color: (*RGB tuple or 24-bit hex value*) slider fill color, default
73-
is ``(66, 44, 66)`` gray.
74+
is :const:`(66, 44, 66)` gray.
7475
:param outline_color: (*RGB tuple or 24-bit hex value*) slider outline color,
75-
default is ``(30, 30, 30)`` dark gray.
76+
default is :const:`(30, 30, 30)` dark gray.
7677
:param background_color: (*RGB tuple or 24-bit hex value*) background color,
77-
default is ``(255, 255, 255)`` white
78+
default is :const:`(255, 255, 255)` white
7879
7980
:param int switch_stroke: outline stroke width for the switch and background, in pixels,
8081
default is 2
@@ -83,7 +84,7 @@ class Slider(Widget, Control):
8384
8485
**Quickstart: Importing and using Slider**
8586
86-
Here is one way of importing the ``Slider`` class so you can use it as
87+
Here is one way of importing the `Slider` class so you can use it as
8788
the name ``Slider``:
8889
8990
.. code-block:: python
@@ -124,20 +125,20 @@ class Slider(Widget, Control):
124125
The ``Slider`` widget has some options for controlling its position, visible appearance,
125126
and value through a collection of input variables:
126127
127-
- **position**: ``x``, ``y`` or ``anchor_point`` and ``anchored_position``
128+
- **position**: :const:`x`, ``y`` or ``anchor_point`` and ``anchored_position``
128129
129-
- **size**: ``width`` and ``height`` (recommend to leave ``height`` = None to use
130+
- **size**: :const:`width` and ``height`` (recommend to leave ``height`` = None to use
130131
preferred aspect ratio)
131132
132-
- **switch color**: ``fill_color``, ``outline_color``
133+
- **switch color**: :const:`fill_color`, :const:`outline_color`
133134
134-
- **background color**: ``background_color``
135+
- **background color**: :const:`background_color`
135136
136-
- **linewidths**: ``switch_stroke``
137+
- **linewidths**: :const:`switch_stroke`
137138
138139
- **value**: Set ``value`` to the initial value (True or False)
139140
140-
- **touch boundaries**: ``touch_padding`` defines the number of additional pixels
141+
- **touch boundaries**: :attr:`touch_padding` defines the number of additional pixels
141142
surrounding the switch that should respond to a touch. (Note: The ``touch_padding``
142143
variable updates the ``touch_boundary`` Control class variable. The definition of
143144
the ``touch_boundary`` is used to determine the region on the Widget that returns
@@ -156,6 +157,15 @@ class Slider(Widget, Control):
156157
157158
"""
158159

160+
# TODO: [ ] graphics: The slider can go outside the backgroundbox’s [BUG]
161+
# [ ] range, if slid all the way to the right side.touch behavior:
162+
# The slider does not “center” on the touch point [IMPROVEMENT]
163+
# [ ] Touch_Down vs Touch_Move [LONG-THERM]
164+
# Not designed as drag and move. Is desired like
165+
# this to point and select. Maybe could be a parameter
166+
# [ ] Touch MOVE outside box [IMPROVEMENT]
167+
# [ ] Slow Down With movement. No design to act as drag and move [LONG-THERM]
168+
159169
# pylint: disable=too-many-instance-attributes, too-many-arguments, too-many-locals
160170
# pylint: disable=too-many-branches, too-many-statements
161171
def __init__(
@@ -190,8 +200,9 @@ def __init__(
190200
self._height = self.height
191201

192202
# pylint: disable=access-member-before-definition)
203+
193204
if self._width is None:
194-
self._width = 50
205+
self._width = 100
195206
else:
196207
self._width = self.width
197208

@@ -288,7 +299,7 @@ def _draw_position(self, position):
288299
# Get the position offset from the motion function
289300
x_offset, y_offset = self._get_offset_position(position)
290301

291-
# Update the switch and text x- and y-positions
302+
# Update the switch x- and y-positions
292303
self._switch_handle.x = self._switch_initial_x + x_offset
293304
self._switch_handle.y = self._switch_initial_y + y_offset
294305

@@ -297,10 +308,14 @@ def when_selected(self, touch_point):
297308
Manages internal logic when widget is selected
298309
"""
299310

300-
touch_x = touch_point[0] - self.x
301-
touch_y = touch_point[1] - self.y
311+
if touch_point[0] <= self.x + self._knob_width:
312+
print("maayor", touch_point[0])
313+
touch_x = touch_point[0] - self.x
314+
else:
315+
print("menor", touch_point[0])
316+
touch_x = touch_point[0] - self.x - self._knob_width
302317

303-
self._switch_handle.x = touch_x
318+
touch_y = touch_point[1] - self.y
304319

305320
super().selected((touch_x, touch_y, 0))
306321
return self._switch_handle.x

0 commit comments

Comments
 (0)