mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
dgui: fix regression in DirectScrolledFrame (see #699)
Made initialization ignore the setScrollBarWidth function Respect the length/height of the scrollbar and only change the actual width in the setScrollBarWidth function Added a very basic unittest class for the scrolledFrame Closes #864
This commit is contained in:
parent
2b632c8e20
commit
5d93237386
@ -77,9 +77,11 @@ class DirectScrolledFrame(DirectFrame):
|
|||||||
self.initialiseoptions(DirectScrolledFrame)
|
self.initialiseoptions(DirectScrolledFrame)
|
||||||
|
|
||||||
def setScrollBarWidth(self):
|
def setScrollBarWidth(self):
|
||||||
|
if self.fInit: return
|
||||||
|
|
||||||
w = self['scrollBarWidth']
|
w = self['scrollBarWidth']
|
||||||
self.verticalScroll["frameSize"] = (-w / 2.0, w / 2.0, -1, 1)
|
self.verticalScroll["frameSize"] = (-w / 2.0, w / 2.0, self.verticalScroll["frameSize"][2], self.verticalScroll["frameSize"][3])
|
||||||
self.horizontalScroll["frameSize"] = (-1, 1, -w / 2.0, w / 2.0)
|
self.horizontalScroll["frameSize"] = (self.horizontalScroll["frameSize"][0], self.horizontalScroll["frameSize"][1], -w / 2.0, w / 2.0)
|
||||||
|
|
||||||
def setCanvasSize(self):
|
def setCanvasSize(self):
|
||||||
f = self['canvasSize']
|
f = self['canvasSize']
|
||||||
|
36
tests/gui/test_DirectScrolledFrame.py
Normal file
36
tests/gui/test_DirectScrolledFrame.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
from direct.gui.DirectScrolledFrame import DirectScrolledFrame
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_scrollbar_width():
|
||||||
|
w = 1
|
||||||
|
|
||||||
|
frm = DirectScrolledFrame(scrollBarWidth=w)
|
||||||
|
|
||||||
|
assert frm['scrollBarWidth'] == 1
|
||||||
|
|
||||||
|
assert frm.verticalScroll['frameSize'] == (-w / 2.0, w / 2.0, -1, 1)
|
||||||
|
assert frm.horizontalScroll['frameSize'] == (-1, 1, -w / 2.0, w / 2.0)
|
||||||
|
|
||||||
|
# manual changes to the framesize
|
||||||
|
frm.verticalScroll['frameSize'] = (-2, 2, -4, 4)
|
||||||
|
frm.horizontalScroll['frameSize'] = (-4, 4, -2, 2)
|
||||||
|
assert frm.verticalScroll['frameSize'] == (-2, 2, -4, 4)
|
||||||
|
assert frm.horizontalScroll['frameSize'] == (-4, 4, -2, 2)
|
||||||
|
|
||||||
|
# change scrollbar width to a new value
|
||||||
|
w = 2
|
||||||
|
frm['scrollBarWidth'] = w
|
||||||
|
|
||||||
|
# check, new value is set correct
|
||||||
|
assert frm['scrollBarWidth'] == 2
|
||||||
|
|
||||||
|
# check if new size is set correct
|
||||||
|
assert frm.verticalScroll['frameSize'] == (-w / 2.0, w / 2.0, -4, 4)
|
||||||
|
assert frm.horizontalScroll['frameSize'] == (-4, 4, -w / 2.0, w / 2.0)
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_scrollbar_width_on_init():
|
||||||
|
frm = DirectScrolledFrame(verticalScroll_frameSize=(-2, 2, -4, 4), horizontalScroll_frameSize=(-4, 4, -2, 2))
|
||||||
|
assert frm.verticalScroll['frameSize'] == (-2, 2, -4, 4)
|
||||||
|
assert frm.horizontalScroll['frameSize'] == (-4, 4, -2, 2)
|
Loading…
x
Reference in New Issue
Block a user