Skip to content

Commit

Permalink
Fix Windows compatibility for Kivy >= 2.2.0 again
Browse files Browse the repository at this point in the history
No Windows machine to test with so I missed a few things
  • Loading branch information
Cheaterman committed Oct 16, 2023
1 parent 95c5005 commit 2df9fc1
Showing 1 changed file with 44 additions and 17 deletions.
61 changes: 44 additions & 17 deletions panda3d_kivy/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,23 +283,6 @@ def update_size(self):
for i in range(2)
]

def _get_size(self):
r = self._rotation
w, h = self._size

if self.softinput_mode == 'resize':
h -= self.keyboard_height

if r in (0, 180):
return w, h

return h, w

def _set_size(self, size):
return super()._set_size(size)

size = AliasProperty(_get_size, _set_size, bind=('_size', '_rotation'))

def on_draw(self):
if self._has_updated and not self._has_drawn:
super().on_draw()
Expand Down Expand Up @@ -393,3 +376,47 @@ def to_parent(self, x, y):
for wh, offset in zip(self.size, self.offsets)
]
return tuple(xy - offset for xy, offset in zip((x, y), offsets))

# Patching all this for Kivy >= 2.2.0 on Windows - no _win attribute
def _get_size(self):
r = self._rotation
w, h = self._size

if self.softinput_mode == 'resize':
h -= self.keyboard_height

if r in (0, 180):
return w, h

return h, w

def _set_size(self, size):
return super()._set_size(size)

size = AliasProperty(_get_size, _set_size, bind=('_size', '_rotation'))

def _get_width(self):
r = self._rotation
_size = self._size

if r in (0, 180):
return _size[0]

return _size[1]

width = AliasProperty(_get_width, bind=('_rotation', '_size', '_density'))

def _get_height(self):
r = self._rotation
_size = self._size
kb = self.keyboard_height if self.softinput_mode == 'resize' else 0

if r in (0, 180):
return _size[1] - kb

return _size[0] - kb

height = AliasProperty(
_get_height,
bind=('_rotation', '_size', '_density')
)

0 comments on commit 2df9fc1

Please sign in to comment.