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

Label: allow different values of left, top, right and bottom for padding. #8162

Merged
merged 12 commits into from Apr 12, 2023

Conversation

DexerBR
Copy link
Contributor

@DexerBR DexerBR commented Mar 11, 2023

Previously, padding only accepted 2 values: [padding_horizontal, padding_vertical], now it has the same behavior as padding in BoxLayout/GridLayout:

  • [10][10, 10, 10, 10]
  • [10, 20][10, 20, 10, 20]
  • [10, 20, 30, 40][10, 20, 30, 40]

Test code:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout


class UI(FloatLayout):
    pass


Builder.load_string(
    """
<UI>:
    padding_left: 0
    padding_top: 0
    padding_right: 0
    padding_bottom: 0
    Label:
        text: "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        size_hint: None, None
        center: root.center
        size: 300, 300

        text_size: self.size
        # size: self.texture_size

        # markup: True

        # base_direction: "rtl"

        halign: 'center'
        valign: 'center'

        padding: root.padding_left, root.padding_top, root.padding_right, root.padding_bottom

        canvas:
            Color:
                rgba: 0.2, 0.2, 0.8, 0.5
            Rectangle:
                pos: self.pos
                size: self.size

            Color:
                rgba: 1, 0, 0, 0.5
            Rectangle:
                pos: self.pos
                size: root.padding_left, self.height

            Rectangle:
                pos: self.x, self.top - root.padding_top
                size: self.width, root.padding_top

            Rectangle:
                pos: self.right - root.padding_right, self.y
                size: root.padding_right, self.height

            Rectangle:
                pos: self.pos
                size: self.width, root.padding_bottom

    BoxLayout:
        size_hint_y: 0.4
        orientation: "vertical"

        Slider:
            size_hint_y: None
            height: 50
            min: 0
            max: 400
            step: 1
            on_value:
                root.padding_left = self.value
        Slider:
            size_hint_y: None
            height: 50
            min: 0
            max: 400
            step: 1
            on_value:
                root.padding_top = self.value
        Slider:
            size_hint_y: None
            height: 50
            min: 0
            max: 400
            step: 1
            on_value:
                root.padding_right = self.value
        Slider:
            size_hint_y: None
            height: 50
            min: 0
            max: 400
            step: 1
            on_value:
                root.padding_bottom = self.value

"""
)


class Testapp(App):

    def build(self):
        return UI()


Testapp().run()

Maintainer merge checklist

  • Title is descriptive/clear for inclusion in release notes.
  • Applied a Component: xxx label.
  • Applied the api-deprecation or api-break label.
  • Applied the release-highlight label to be highlighted in release notes.
  • Added to the milestone version it was merged into.
  • Unittests are included in PR.
  • Properly documented, including versionadded, versionchanged as needed.

Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

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

I like the feature, a lot.

But, unfortunately, we should keep the padding_x and padding_y properties for a long time, and these properties can't be removed without having them deprecated first.

kivy/uix/label.py Show resolved Hide resolved
@DexerBR DexerBR requested a review from misl6 March 12, 2023 17:30
@misl6 misl6 added this to the 2.2.0 milestone Mar 19, 2023
Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

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

Hi @DexerBR !

The feature is great, and I really want to have it into 2.2.0 release, but we need to fix a few things regarding deprecations and migration paths.

I've left a few comments, which are trying to explain what needs to be done.

Feel free to ping me if you need any additional guidance.

kivy/core/text/__init__.py Outdated Show resolved Hide resolved
kivy/uix/label.py Outdated Show resolved Hide resolved
@misl6 misl6 added Component: core-providers kivy/core Component: Widgets kivy/uix, style.kv Notes: Release-highlight Highlight this PR in the release notes. labels Mar 25, 2023
@DexerBR DexerBR requested a review from misl6 March 29, 2023 19:51
kivy/core/text/__init__.py Outdated Show resolved Hide resolved
kivy/core/text/__init__.py Outdated Show resolved Hide resolved
kivy/core/text/__init__.py Show resolved Hide resolved
@DexerBR DexerBR requested a review from misl6 March 30, 2023 19:49
kivy/core/text/__init__.py Outdated Show resolved Hide resolved
kivy/core/text/__init__.py Show resolved Hide resolved
@DexerBR DexerBR requested a review from misl6 April 1, 2023 10:24
kivy/core/text/__init__.py Outdated Show resolved Hide resolved
kivy/core/text/__init__.py Outdated Show resolved Hide resolved
kivy/core/text/markup.py Outdated Show resolved Hide resolved
@DexerBR DexerBR requested a review from misl6 April 6, 2023 12:36
kivy/core/text/markup.py Outdated Show resolved Hide resolved
kivy/core/text/__init__.py Outdated Show resolved Hide resolved
@DexerBR DexerBR requested a review from misl6 April 8, 2023 14:47
Copy link
Member

@misl6 misl6 left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@misl6 misl6 merged commit cd4cb0f into kivy:master Apr 12, 2023
34 checks passed
@DexerBR DexerBR deleted the label_padding branch April 12, 2023 18:19
@misl6 misl6 removed the Component: Widgets kivy/uix, style.kv label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: core-providers kivy/core Notes: Release-highlight Highlight this PR in the release notes.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants