Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new Yosemite views, controls, etc. #17

Closed
typesupply opened this issue Nov 2, 2014 · 32 comments
Closed

Add support for new Yosemite views, controls, etc. #17

typesupply opened this issue Nov 2, 2014 · 32 comments

Comments

@typesupply
Copy link
Member

AppKit Release notes: https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/

NSVisualEffectView (done)

This is handled simply with a new Group kwarg:

self.w.group = vanilla.Group((10, 10, -10, -10), blendingMode="withinWindow")

Internally, this is handled not so simply.

Window Styles (done)

These are the current init kwargs that specify window appearance.

closable = True | False
miniaturizable = True | False
initiallyVisible = True | False
fullScreenMode = None | "primary" | "auxillary"

10.10 adds new appearance options: https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/#10_10Window

Full Size Content View

This pushes the content view underneath the title and toolbars. Those should then be set to be transparent. (Not always, but I don't want two flags so if the transparency is not desired a coder can override this with getNSWindow().setTitlebarAppearsTransparent_(False).) I'm not sure when this is used but we may as well make it possible.

self.w = vanilla.Window(..., fullSizeContentView=False, ...)
try:
    NSFullSizeContentViewWindowMask
except NameError:
    NSFullSizeContentViewWindowMask = 1 << 15
if fullSizeContentView and osVersion >= "10.10":
    mask = mask | NSFullSizeContentViewWindowMask

# ... later ...

if fullSizeContentView and osVersion >= "10.10":
    self._window.setTitlebarAppearsTransparent_(True)

Titlebar Visibility

This will show/hide the title of the window. If it is hidden, the toolbar moves to the space formally occupied by the title.

self.w = vanilla.Window(..., titleVisible=True, ...)
try:
    NSWindowTitleVisible
except NameError:
    NSWindowTitleVisible  = 0
    NSWindowTitleHidden = 1
if osVersion >= "10.10":
    if not titleVisible:
        self._window.setTitleVisibility_(NSWindowTitleHidden)
    else:
        self._window.setTitleVisibility_(NSWindowTitleVisible)

NSTitlebarAccessoryViewController

This is an advanced thing that should be handled outside of vanilla.

HUDWindow (done)

Action Button with Menu

How would callbacks work?

List

  • more cell types
    • add ticks to list slider (done)
    • image cell (done)
    • segmented cell (done)
  • demos
    • image cell
    • checkbox cell
    • slider cell
    • popup cell
  • column width bug (hopefully done)
  • should the column resizing behavior be an init kwarg? (no. this is handled with column construction data.)
  • make it possible to disable column sorting. (done)
  • is dataSource needed? It adds lots of complexity to the code.
  • more documentation about and examples of drag and drop.

Cell vs. View Mode

Here's a tricky one: the use of cells in NSTableView is now deprecated. Instead, we are supposed to use views. That's easy enough to switch but mixing cells and views in the same table is not permitted. So, we can't simply change things like SliderListCell to be view based instead of cell based. We do need to make the change though. (Plus, view based tables can do some really useful stuff.)

I think we could handle this change by automatically detecting the cell types during __init__ by skimming the "cell" settings in columnDescriptions. If anything there is cell based, the table view would be set to cell mode. Otherwise it would be set to view mode.

I'm still researching this so this could change.

Localization

This is going to require some research on how localization is handled at the app level. I'm not sure if localization will be able to be specified on the fly per control, which is what would be ideal for vanilla.

Auto-Layout

This is going to be tricky but it might be a very worthwhile thing to add.

NSMatrix

This class is now deprecated. It looks like RadioGroup can be rebuilt with a Group as a parent and individual buttons set to be radio buttons. According to the documentation, those will automatically be linked as a group in 10.8+.

Misc

  • Remove any hacks needed for < 10.6. (done)
  • conditionally remove cell interaction when osVersion >= 10.10 since cells are slowly being deprecated. (done. Apple hasn't assigned view based methods for everything yet so there are still some cell calls.)
  • add a convenience method for getting the selected item from a popup button
@typemytype
Copy link
Member

A checkbox also needs some editing. The title seems always disabled…

see https://github.com/typemytype/vanilla/commit/ffdee5d7a6a3e9f6a188f195e7f4a09fb261f315

@typemytype
Copy link
Member

A small proposal showing how localization could work, without losing the cocoa default implementation.
There are lots of UI element that arent made by vanilla, like menu item, some dialogs, this will somehow be supported, I guess...

will make a sample app later on this week

https://dl.dropboxusercontent.com/u/41873/locaVanillaTest.zip

@typesupply
Copy link
Member Author

The checkbox issue should be fixed now: f4836f0

@typesupply
Copy link
Member Author

This looks like a good way to handle localization. I guess my dream of RoboFont extensions being able to declare their localizations isn't going to work out since NSBundle is immutable.

@typemytype
Copy link
Member

maybe a small request: make column headers in a List not sortable. (this could be an argument in init

def __init__(self, posSize, … columnsCanSort=True, ….):
    …
    self._columnsCanSort = columnsCanSort

def _makeColumnsWithColumnDescriptions(self, columnDescriptions):
    bindingOptions = None
    if self._columnsCanSort:
        bindingOptions={NSCreatesSortDescriptorBindingOption:False}
    …
    column.bind_toObject_withKeyPath_options_(binding, self._arrayController, keyPath, bindingOptions)

https://github.com/typesupply/vanilla/blob/yosemite/Lib/vanilla/vanillaList.py#L659

@typemytype
Copy link
Member

yeah a nsBundle is idd immutable and once it is loaded, it seems very hacky to reload it.
On the fly localization could be possible in a sub class of a nsBundle, I guess

will check it out...

@typesupply
Copy link
Member Author

Column sorting can now be turned off on a full list or single column basis. Example:

import vanilla

class Test(object):

    def __init__(self):
        self.w = vanilla.Window((500, 500))
        columnDescriptions = [
            dict(title="one"),
            dict(title="two", allowsSorting=False),
            dict(title="three"),
        ]
        self.w.l = vanilla.List((10, 10, -10, -10),
            [
                dict(one="A", two="D", three="G"),
                dict(one="B", two="E", three="H"),
                dict(one="C", two="F", three="I"),
            ],
            columnDescriptions=columnDescriptions,
            allowsSorting=True
        )
        self.w.open()


from vanilla.test.testTools import executeVanillaTest

executeVanillaTest(Test)

@typemytype
Copy link
Member

a proposal for the auto layout https://gist.github.com/typemytype/b9c85801762c579448d7

As this could be a radical change, it maybe better to first concentrate on getting all elements 10.10 ready and then make a new branch focussed on auto layout…

but this could be very cool :)

@typesupply
Copy link
Member Author

This looks great! It's all coming back to me now. Using "auto" as the posSize will be a nice indicator. We'll have to look through the vanilla objects to make sure that there aren't any posSize dependencies. I don't think this is going to be that big of a change, but yeah let's get 10.10 support done first.

@typemytype
Copy link
Member

and all the existing subclasses...

@typemytype
Copy link
Member

a Window object could have an optional argument supporting full screen: supportFullScreen=True/False (available from 10.7+)

# not sure if NSWindowCollectionBehaviorFullScreenPrimary is already in pyObjC
if supportFullSCreen:
    try:
        self._window.setCollectionBehavior_(128) #NSWindowCollectionBehaviorFullScreenPrimary
    except:
        # fail silently on 10.6
        pass

@typesupply
Copy link
Member Author

We already have support for full screen. I've sketched out the new window appearance settings API above. Let me know what you think. I'm happy with it.

@typesupply
Copy link
Member Author

I committed and pushed the window appearance changes.

@typemytype
Copy link
Member

running against some issues on 10.9.5
mainly the default python string compare doest work well with '10.9.5' >= '10.10' -->True
even '10.9' >= '10.10' --> True

maybe testing version nrs with distutils is better

from distutils.version import StrictVersion
print '10.9' >= '10.10'
print StrictVersion('10.9.5') > StrictVersion('10.10')

@typesupply
Copy link
Member Author

Hm. We could define some constants that use this. Something like:

osVersionCurrent = StrictVersion(platform.mac_ver()[0])
osVersion10_10 = StrictVersion("10.10")
osVersion10_9 = StrictVersion("10.9")
osVersion10_8 = StrictVersion("10.8")
osVersion10_7 = StrictVersion("10.7")
osVersion10_6 = StrictVersion("10.6")

That way the code wouldn't have a lot of StrictVersion(...) sprinkled throughout.

@typemytype
Copy link
Member

I would even add the results as a bool in the constants

@typemytype
Copy link
Member

I patched vanilla with using the StrictVersion osVersion comparison. Will send a pull request soon.

An other thing that could be handy is a convenient way to put a vanilla.Group into a vanilla.ScrollView.
Will make a small example. It should be as easy as adding an nsView to a scrollView but not hard resetting the frame...

@typemytype
Copy link
Member

a patch to support embedded Groups into a ScrollView

https://gist.github.com/typemytype/c9ac5349183209a7d3e7

I can also implement this and send a pull request...

@typesupply
Copy link
Member Author

Thanks. I'm hoping to get back to updating vanilla next week. I had to do some of my day job work and the problem with List made me not want to work on vanilla for a while. I think List is going to have to be rewritten to not use bindings. Ugh.

@typemytype
Copy link
Member

added an ActionButton to my fork, can send a pull request when you are ready

https://github.com/typemytype/vanilla/blob/fc3ab1ec91553eb01adf7ec8be673f61aa33c407/Lib/vanilla/vanillaPopUpButton.py#L121

screen shot 2014-12-17 at 11 32 45

@schriftgestalt
Copy link
Contributor

Column sorting can now be turned off on a full list or single column basis. Example

Are there any plans to move that into that master branch?

@typesupply
Copy link
Member Author

I'd love to, but I don't have time right now. My open source time is going to other projects. Patches are welcome!

@schriftgestalt
Copy link
Contributor

I had a quick look at the changes. Some are really related to changes in Yosemite. But there are several things that should work in earlier version, too.

Why I can across this is someone tried to write a script that works in RoboFont and Glyphs. And RF 1.7 seems to use a version of vanilla that supports this particular argument (so it might use this branch?).

@justvanrossum
Copy link
Collaborator

Some of this stuff apparently is integrated now, some is not. I suggest to close this issue and open new ones for the remaining feature requests, if that's indeed what they are.

@typemytype
Copy link
Member

This was referenced Oct 27, 2017
@typemytype
Copy link
Member

related to Lists:

  • is dataSource needed? It adds lots of complexity to the code.

yes that is needed, only to support searching and shared dateSource over different views

  • more documentation about and examples of drag and drop.

will create a new issue for that

@form-follows-function
Copy link
Contributor

Is there any possibility to get the dark VisualEffectViews working?

I can trigger light vibrant windows by adding
self.w.blend = Group((0, 0, 0, 0), blendingMode='behindWindow')

Anyways since there is https://github.com/typesupply/vanilla/blob/2d27b1fe7abfd94a3cc6d574efe804dfad1d4029/Lib/vanilla/vanillaGroup.py#L11 we have no option to choose between the VisualEffectViews, not even when _nsObject is triggered, or is there?

@form-follows-function
Copy link
Contributor

form-follows-function commented May 16, 2019

So, I've got that fixed by adding:

view = self.w

visualEffectView = NSVisualEffectView.new()
visualEffectView.setAutoresizingMask_(NSViewWidthSizable|NSViewHeightSizable)
    
visualEffectView.setWantsLayer_(True)
visualEffectView.setFrame_(frame)
visualEffectView.setState_(NSVisualEffectStateActive)
visualEffectView.setMaterial_(NSVisualEffectMaterialDark)
visualEffectView.setBlendingMode_(NSVisualEffectBlendingModeBehindWindow)

self.w._window.contentView().addSubview_positioned_relativeTo_(visualEffectView, NSWindowBelow, self.w)

self.w._window.setTitlebarAppearsTransparent_(True)
self.w._window.setStyleMask_(self.w._window.styleMask() | NSFullSizeContentViewWindowMask)
        
appearance = NSAppearance.appearanceNamed_('NSAppearanceNameVibrantDark')
self.w._window.setAppearance_(appearance)

@form-follows-function
Copy link
Contributor

form-follows-function commented Jul 15, 2020

@typemytype

a patch to support embedded Groups into a ScrollView

https://gist.github.com/typemytype/c9ac5349183209a7d3e7

I can also implement this and send a pull request...

Been 6 years, but could you pull request this? It would be handy to use ScrollView without relying on pyobjc and keep vanilla interoperable within itself.

@schriftgestalt
Copy link
Contributor

Just started to read the thread again after seeing the notification. I found this:

Full Size Content View
This pushes the content view underneath the title and toolbars. Those should then be set to be transparent.

The full size content view and titlebar transparency should not be set together. There are a lot cases that need a visible titlebar. It is used when there is a scroll view adjacent to the toolbar and the scrolled content should go under the (translucent) title bar. See Safari and Maps.

@form-follows-function
Copy link
Contributor

form-follows-function commented Jul 15, 2020

@schriftgestalt

Just started to read the thread again after seeing the notification. I found this:

Full Size Content View
This pushes the content view underneath the title and toolbars. Those should then be set to be transparent.

The full size content view and titlebar transparency should not be set together. There are a lot cases that need a visible titlebar. It is used when there is a scroll view adjacent to the toolbar and the scrolled content should go under the (translucent) title bar. See Safari and Maps.

Totally makes sense to me and agree, however my concerns on NSFullSizeContentViewWindowMask and ScrollView weren't related. Anyways, I think this should be stated in the pull request's documentation or maybe add an additional exception.

@typemytype
Copy link
Member

@form-follows-function made a new issue for this request --> #132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants