Skip to content

Add Widget, Control and WidgetLabel class definitions, along with sliding switch and PyPortal example #4

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

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4dfdce6
Initial commit with Widget, Control and WidgetLabel class definitions…
kmatch98 Feb 2, 2021
a7eced3
Ran black, somehow failed for widget_label.py
kmatch98 Feb 2, 2021
ff05592
Add orientation and flip to switch, simplify animation functions with…
kmatch98 Feb 3, 2021
634f91c
Ran black and pylint, some cleanup
kmatch98 Feb 3, 2021
14303c8
Update widget name to SwitchRound
kmatch98 Feb 3, 2021
7272941
Change filename of example to remove _horizontal_
kmatch98 Feb 3, 2021
adb2dc0
Use .hidden property of TileGrid to handle text 0/1 display control
kmatch98 Feb 7, 2021
57eb704
Arrange folders to match library standard organization
kmatch98 Feb 7, 2021
bdc1f34
Update example to conform to correct directory structure
kmatch98 Feb 7, 2021
3158d43
Added resize function for compatibility with grid_layout
kmatch98 Feb 9, 2021
8072bb4
Some pylint fixes, delete debug print statements
kmatch98 Feb 9, 2021
bc24846
Initial commit of WidgetAnnotation
kmatch98 Feb 12, 2021
14b2543
Add Dial widget, add example for Switch, Dial and WidgetAnnotation an…
kmatch98 Feb 13, 2021
90c443e
Initial commit with Widget, Control and WidgetLabel class definitions…
kmatch98 Feb 2, 2021
3d6d443
Ran black, somehow failed for widget_label.py
kmatch98 Feb 2, 2021
4e2cfec
Merge branch 'main' of https://github.com/kmatch98/Adafruit_CircuitPy…
kmatch98 Feb 13, 2021
7582f2e
Initial commit with Widget, Control and WidgetLabel class definitions…
kmatch98 Feb 2, 2021
4daff4d
Merge branch 'main' of https://github.com/kmatch98/Adafruit_CircuitPy…
kmatch98 Feb 13, 2021
b8de020
Bring up to date with latest main upstream branch
kmatch98 Feb 13, 2021
4245291
Update to include merged changes from upstream
kmatch98 Feb 13, 2021
57fa93b
Ran black on widgets
kmatch98 Feb 13, 2021
7e4e3a4
Add comments to switch_round, add simpletest switch examples
kmatch98 Feb 14, 2021
e3cd623
Add font option for switch_round WidgetLabel
kmatch98 Feb 14, 2021
7aa9902
Add flip_input widget
kmatch98 Feb 15, 2021
759248d
Add flip_input example
kmatch98 Feb 15, 2021
8c5c397
add font file
kmatch98 Feb 15, 2021
4f62512
Streamline animation for flip_input, adapt to script fonts
kmatch98 Feb 16, 2021
c050b9a
Add easing animations for flip_input
kmatch98 Feb 18, 2021
dac960d
Updated animation redraws to allow springy animations
kmatch98 Feb 19, 2021
a0649d6
Add sphinx docs
kmatch98 Feb 19, 2021
fc9820d
Ran black
kmatch98 Feb 22, 2021
9275175
Update switch_round for new Widget and Control definitions
kmatch98 Feb 22, 2021
4550e20
Added extensive documentation
kmatch98 Feb 23, 2021
1b134ee
ran black
kmatch98 Feb 23, 2021
7184a13
More documentation updates
kmatch98 Feb 23, 2021
7a93cad
Repair bug in setting width
kmatch98 Feb 23, 2021
5f6117f
Add default values to Widget x,y
kmatch98 Feb 23, 2021
fd74f5d
Fix bug in time limit for switch_round animation
kmatch98 Feb 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added adafruit_displayio_layout/widgets/.DS_Store
Binary file not shown.
80 changes: 80 additions & 0 deletions adafruit_displayio_layout/widgets/control.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# The MIT License (MIT)
#
# Copyright (c) 2021 Kevin Matocha (kmatch98)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
# CircuitPython GUI Control Class for touch-related elements
#
# Defines the key response functions for touch controls:
# - contains: evaluates if touch_point is within the Control's self.touch_boundary
# - selected
# - still_touched
# - released
# - gesture_response


class Control:
"""A Control class for responsive elements, including several response functions,
including for touch response."""

def __init__(
self,
):

self.touch_boundary = None # should be overridden by subclass

def contains(self, touch_point):
"""Checks if the Control was touched. Returns True if the touch_point
is within the Control's touch_boundary."""

# The touch_point should be in local coordinates for this item.

if (self.touch_boundary is not None) and (
(
self.touch_boundary[0]
<= touch_point[0]
<= (self.touch_boundary[0] + self.touch_boundary[2])
)
and (
self.touch_boundary[1]
<= touch_point[1]
<= (self.touch_boundary[1] + self.touch_boundary[3])
)
):
return True
return False

# place holder touch_handler response functions
def selected(self, touch_point):
"""Response function when Control is selected."""
pass

def still_touched(self, touch_point): # *** this needs a clearer name
"""Response function when Control remains touched."""
pass

def released(self, touch_point):
"""Response function when Control is released."""
pass

def gesture_response(self, gesture):
"""Response function to handle gestures (future expansion)."""
pass
Loading