Skip to content

Commit

Permalink
Auto-layout improvements. (#135)
Browse files Browse the repository at this point in the history
* Wrap NSGridView.

* Solved sizing for views without intrinsic size.

* Allow alignment customization. Defaults for column and row heights in special case.

* Make the terminology consistent to make the doc shorter.

* Documentation.

* Add post-init column count manipulation.

* Add post-init row count manipulation.

* Add doc file.

* Add support for customizing the view. Useful for testing and demos.

* Move import.

* Missed part of the doc process.

* Add the customization to the init.

* The content view isn't always the main view. Dumb oversight.

* Check StackGroup to StackView and make it work more like GridView.

* Import error.

* Move tests.
  • Loading branch information
typesupply committed Feb 11, 2021
1 parent 353cb6f commit ace5871
Show file tree
Hide file tree
Showing 14 changed files with 1,188 additions and 184 deletions.
5 changes: 3 additions & 2 deletions Documentation/source/index.rst
Expand Up @@ -38,8 +38,9 @@ Layout Views
objects/Popover
objects/HorizontalLine
objects/VerticalLine
objects/HorizontalStackGroup
objects/VerticalStackGroup
objects/GridView
objects/HorizontalStackView
objects/VerticalStackView

Data Views
^^^^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions Documentation/source/objects/GridView.rst
@@ -0,0 +1,10 @@
.. highlight:: python

========
GridView
========

.. module:: vanilla
.. autoclass:: GridView
:inherited-members:
:members:
10 changes: 0 additions & 10 deletions Documentation/source/objects/HorizontalStackGroup.rst

This file was deleted.

10 changes: 10 additions & 0 deletions Documentation/source/objects/HorizontalStackView.rst
@@ -0,0 +1,10 @@
.. highlight:: python

===================
HorizontalStackView
===================

.. module:: vanilla
.. autoclass:: HorizontalStackView
:inherited-members:
:members:
10 changes: 0 additions & 10 deletions Documentation/source/objects/VerticalStackGroup.rst

This file was deleted.

10 changes: 10 additions & 0 deletions Documentation/source/objects/VerticalStackView.rst
@@ -0,0 +1,10 @@
.. highlight:: python

=================
VerticalStackView
=================

.. module:: vanilla
.. autoclass:: VerticalStackView
:inherited-members:
:members:
4 changes: 4 additions & 0 deletions Lib/vanilla/__init__.py
Expand Up @@ -9,6 +9,7 @@
from vanilla.vanillaDrawer import Drawer
from vanilla.vanillaEditText import EditText, SecureEditText
from vanilla.vanillaGradientButton import GradientButton
from vanilla.vanillaGridView import GridView
from vanilla.vanillaGroup import Group
from vanilla.vanillaImageView import ImageView
from vanilla.vanillaLevelIndicator import LevelIndicator, LevelIndicatorListCell
Expand All @@ -24,6 +25,7 @@
from vanilla.vanillaSlider import Slider
from vanilla.vanillaSplitView import SplitView, SplitView2
from vanilla.vanillaStackGroup import HorizontalStackGroup, VerticalStackGroup
from vanilla.vanillaStackView import HorizontalStackView, VerticalStackView
from vanilla.vanillaTabs import Tabs
from vanilla.vanillaTextBox import TextBox
from vanilla.vanillaTextEditor import TextEditor
Expand Down Expand Up @@ -57,7 +59,9 @@
"Slider",
"SplitView",
"SplitView2",
"GridView",
"HorizontalStackGroup", "VerticalStackGroup",
"HorizontalStackView", "VerticalStackView",
"Tabs",
"TextBox",
"TextEditor",
Expand Down
10 changes: 9 additions & 1 deletion Lib/vanilla/test/testAll.py
Expand Up @@ -12,6 +12,8 @@
from importlib import reload
reload(vanilla)
from vanilla import *
from vanilla.test.testStackView import TestStackView
from vanilla.test.testGridView import TestGridView

import objc
objc.setVerbose(True)
Expand Down Expand Up @@ -576,7 +578,7 @@ def buttonCallback(self, sender):
class Test(object):

def __init__(self):
self.w = FloatingWindow((200, 300, 120, 340))
self.w = FloatingWindow((200, 300, 120, 400))
self.w.drawGrid = CheckBox((10, 10, -10, 22), "Draw Grid", value=False)
self.w.windows = Button((10, 40, -10, 20), "Windows", callback=self.openTestCallback)
self.w.geometry = Button((10, 70, -10, 20), "Geometry", callback=self.openTestCallback)
Expand All @@ -588,6 +590,8 @@ def __init__(self):
self.w.toolbar = Button((10, 250, -10, 20), "Toolbar", callback=self.openTestCallback)
self.w.misc = Button((10, 280, -10, 20), "Misc.", callback=self.openTestCallback)
self.w.split = Button((10, 310, -10, 20), "SplitView", callback=self.openTestCallback)
self.w.stack = Button((10, 340, -10, 20), "StackView", callback=self.openTestCallback)
self.w.grid = Button((10, 370, -10, 20), "GridView", callback=self.openTestCallback)
self.w.open()

def openTestCallback(self, sender):
Expand All @@ -614,6 +618,10 @@ def openTestCallback(self, sender):
MiscTest(self.w.drawGrid.get())
elif title == "SplitView":
TestSplitView(self.w.drawGrid.get())
elif title == "StackView":
TestStackView()
elif title == "GridView":
TestGridView()
except:
import traceback
print(traceback.format_exc())
Expand Down

0 comments on commit ace5871

Please sign in to comment.