community icon indicating copy to clipboard operation
community copied to clipboard

BorderImage: display_border breaks auto_scale

Open tshirtman opened this issue 4 years ago • 7 comments

Versions

  • Python: 3.6.3
  • OS: linux
  • Kivy: master
  • Kivy installation method: git clone && pip install --editable in virtualenv

Description

when BorderImage's display_size option is used, it overrides the auto_scale parameter, simply because it first computes the value auto_scale would need, and then look if there is a dispaly_border setting, and overrides the values if that's the case, i think it would be better to do things in the opposite direction.

Code and Logs

here is an example demonstrating the problem in a variety of configurations, just use the slider to select a small value of width or height, and you'll see that the setting for auto_scale doesn't work when display_size is used.

from kivy.app import App
from kivy.lang import Builder
from kivy.factory import Factory


KV = '''
BoxLayout:
    orientation: 'vertical'

    GridLayout:
        cols: 4
        Widget:
        Label:
            text: 'default'
        Label:
            text: 'display_border'
        Label:
            text: 'display_border dp'

        # line
        Label:
            text: 'default'

        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: 16, 16, 16, 16
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: dp(16), dp(16), dp(16), dp(16)
        # line
        Label:
            text: 'both'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    auto_scale: 'both'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: 16, 16, 16, 16
                    auto_scale: 'both'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: dp(16), dp(16), dp(16), dp(16)
                    auto_scale: 'both'
        # line
        Label:
            text: 'both_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    auto_scale: 'both_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: 16, 16, 16, 16
                    auto_scale: 'both_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: dp(16), dp(16), dp(16), dp(16)
                    auto_scale: 'both_lower'
        # line
        Label:
            text: 'x_full_y_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    auto_scale: 'x_full_y_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: 16, 16, 16, 16
                    auto_scale: 'x_full_y_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: dp(16), dp(16), dp(16), dp(16)
                    auto_scale: 'x_full_y_lower'
        # line
        Label:
            text: 'y_full_x_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    auto_scale: 'y_full_x_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: 16, 16, 16, 16
                    auto_scale: 'y_full_x_lower'
        Widget:
            size_hint: None, None
            pos_hint: {'center': (.5, .5)}
            size: width.value, height.value
            canvas:
                BorderImage:
                    size: self.size
                    pos: self.pos
                    source: 'atlas://data/images/defaulttheme/button'
                    border: 16, 16, 16, 16
                    display_border: dp(16), dp(16), dp(16), dp(16)
                    auto_scale: 'y_full_x_lower'

    GridLayout:
        cols: 2
        size_hint_y: None
        height: 50
        Label:
            text: 'width'
        Label:
            text: 'height'
        Slider:
            id: width
            value: 50
            min: 1
            max: 100
        Slider:
            id: height
            value: 50
            min: 1
            max: 100
'''

class Application(App):
    def build(self):
        return Builder.load_string(KV)


if __name__ == "__main__":
    Application().run()

tshirtman avatar Jan 04 '20 15:01 tshirtman