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
Re-implements the Bubble widget. #7882
Conversation
The old Bubble widget design was complicated and used a GridLayout with multiple dummy widgets solely to get an arrow placed as desired. Multiple magic numbers like 99 columns or 99 rows were undocumented and unintuitive. Probably some of these numbers even add unnecessary limitations to the Bubble widget. The Bubble widget was fused with the 'BubbleContent' which by design makes the Bubble widget feel very unflexible. Sizing the Bubble according to the content was unintuitive if not even impossible for some cases and the arrow positioning was relying on magic numbers as well. Lastly, the old implementation lacked test coverage with very few tests that did not even cover the core logic of the widget. The new implementation reduces the core logic (formerly "on_arrow_pos", ~100 lines of code) to ~30 lines plus a well documented lookup structure without magic but intuitive values. Furthermore, it adds proper inline documentation for maintainers. Furthermore, completely flexible arrow positioning was implemented and allows free positioning of the arrow to all sides of the content by selecting a (relative) position on the Bubble widget border. The BubbleContent widget is a seperate styled BoxLayout and the code and documentation makes clear that any other Widet or Layout can be placed as content. The background_color, border and border_auto_scale properties have been attached to the BubbleContent instead of the Bubble itself which removes the unnecessary connections between the Bubble itself and it's BubbleContent. Properties, that refer to multiple dimensions are cleanly integrated through ReferenceListProperties. The rework of the Bubble widget fixes the issue kivy#4348 which had been opened in 2016 and remained unsolved. Minimal changes are necessary for existing applications using the Bubble widget: - A BubbleContent (can be any Layout or a single Widget) is added as only child to the Bubble (similarly to the ActionBar/ActionView widgets). - The background_color, border and border_auto_scale properties have been removed from the Bubble as they belong to the BubbleContent Signed-off-by: AnthonyZimmermann <anthony.zimmermann@protonmail.com>
Core functionality tests: - Rendering - Add/remove content - Error handling if two child widgets are added to the Bubble - Test BubbleContent, BubbleButton Arrow positioning and Bubble sizing: - parameterized tests for predefined arrow_pos arrow positioning (12 tests) - parameterized tests for flexible flex_arrow_pos arrow positioing (40 tests) Signed-off-by: AnthonyZimmermann <anthony.zimmermann@protonmail.com>
The textinput uses a Bubble for "cut", "copy", "paste" functionality. Three example scripts and kv files contained the Bubble widget. Signed-off-by: AnthonyZimmermann <anthony.zimmermann@protonmail.com>
Thanks for opening your first pull request here! 💖 Please check out our contributing guidelines. |
|
||
def adjust_position(self): | ||
if self.limit_to is not None and not self._temporarily_ignore_limits: | ||
if self.limit_to is EventLoop.window: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part was mainly copied from the old implementation. I use the Bubble widget mainly in a Scatter Plane where this logic does somehow not really make sense. Maybe someone else can verify that this code still "usefull" in other use cases.
add = self_arrow_layout.add_widget | ||
for widg in arrow_list: | ||
add(widg) | ||
if not (lim_x > self.x and lim_right < self.right): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapted this part a little to make it only "intelligent" if there is a possible better solution (widget is completely within the limits).
Hey, this is my first PR here. I am wondering if there is something blocking the review process. Is someone/something waiting for me to take some action? Tanks in advance! |
Updates documentation: - Adds further documentation - More details about 'versionadded' and 'versionchanged' Little improvement/fix (found during update of the documentation): - Update the arrow image size information on arrow_image change.
Congrats on merging your first pull request! 🎉🎉🎉 |
@AnthonyZi thanks 👍 |
This commit comprises three commits:
The old Bubble widget design was complicated and used a GridLayout with
multiple dummy widgets solely to get an arrow placed as desired.
Multiple magic numbers like 99 columns or 99 rows were undocumented
and unintuitive. Probably some of these numbers even add unnecessary
limitations to the Bubble widget.
The Bubble widget was fused with the 'BubbleContent' which by design
makes the Bubble widget feel very unflexible.
Sizing the Bubble according to the content was unintuitive if not even
unpossible for some cases and the arrow positioning was relying on magic
numbers as well. Lastly, the old implementation lacked test coverage
with very few tests that did not even cover the core logic of the
widget.
The new implementation reduces the core logic (formerly "on_arrow_pos",
~100 lines of code) to ~30 lines plus a well documented lookup structure
without magic but intuitive values. Furthermore, it adds proper inline
documentation for maintainers.
This PR also adds unit tests for the core logic of the Bubble widget.
Maintainer merge checklist
Component: xxx
label.api-deprecation
orapi-break
label.release-highlight
label to be highlighted in release notes.versionadded
,versionchanged
as needed.