robotools / vanilla

A Pythonic wrapper around Cocoa.
MIT License
78 stars 28 forks source link

Stack + "fill" + edgeInsets #176

Closed typesupply closed 1 year ago

typesupply commented 1 year ago

The edge insets are being ignored for items with their size (width for vertical stacks, height for horizontal stacks) set to "fill". Here's a test case:

import AppKit
import vanilla

def makeBox(color):
    box = vanilla.Box(
        (0, 0, 400, 100),
        fillColor=color,
        cornerRadius=10
    )
    return box

class Test:

    def __init__(self):
        self.w = vanilla.Window(
            (500, 0)
        )
        self.redBox = makeBox(AppKit.NSColor.redColor())
        self.blueBox = makeBox(AppKit.NSColor.blueColor())
        self.w.stack = vanilla.VerticalStackView(
            (0, 0, 0, 0),
            views=[
                dict(view=self.redBox, width=400, height=100),
                dict(view=self.blueBox, width="fill", height=100)
            ],
            edgeInsets=(50, 50, 50, 50)
        )
        self.w.open()

from vanilla.test.testTools import executeVanillaTest
executeVanillaTest(Test)
typesupply commented 1 year ago

I think this is happening because constraints are added to the view that make it the same size as the stack size.

typesupply commented 1 year ago

This should be closed with 3f2f311d123b9a3de82e3fa72943633e7e24891d.