microsoft / xaml-standard

XAML Standard : a set of principles that drive XAML dialect alignment
Other
804 stars 50 forks source link

More common P/M/Es on all relevant types #8

Open harinikmsft opened 7 years ago

harinikmsft commented 7 years ago

Introduce more P/M/Es that are common across all relevant controls/panels etc.,

h82258652 commented 7 years ago

good, also need Visibility.

birbilis commented 7 years ago

would be nice to group and define such things in interfaces (and in more interfaces that just extend several interfaces to group them)

e.g. IHitTestVisible, ISizable, etc.

unless this incurs too much overhead. Wouldn't mind having a special kind of inline(d) interfaces that are just used at compile time btw. (similar to how TypeScript interfaces work)

dotMorten commented 7 years ago

IsVisible

Please don't do this but use Visibility. IsVisible has a much more important connotation in WPF, and one that is sorely missing in UWP/Forms. It's a calculated read-only boolean telling you if the control is currently visible in the tree, and is driven by whether it is rooted in the visual tree, whether it is loaded, and whether itself or any of its parents are visible, and is also joined by an IsVisibleChanged event that control developers can listen to, and for instance stop rendering expensive DirectX/OpenGL when the control is no longer visible.

I realize Xamarin.Forms already messed up and is using 'IsVisible', but that's the framework that needs to fall in line.

dotMorten commented 7 years ago

@birbilis What purpose would these interfaces serve? How would you code against them in a concrete use-case? Why isn't say "HitTestVisible" on the base class not sufficient? Why would control developers implement this interface, rather than just inherit it?

skendrot commented 7 years ago

Visibility has run it's course. Unless there are plans to bring back Hidden the IsVisible property is so much easier to use

dotMorten commented 7 years ago

You already got implicit conversion from boolean, and this change wouldn't add any new capability - on the contrary it would just introduce a second property to do the same thing introducing a confusing mess. Was it a poor design choice with the enum? Perhaps, but it's kind of a moot point at this point.

Also as mentioned 'IsVisible' already means something different and quite important and only becomes more important with defer-load.

birbilis commented 7 years ago

If you have a control hierarchy you don't necessarily need interfaces. With those you can skip hierarchies or bridge different ones. However, if they're for runtime too they're probably expensive

hawkerm commented 7 years ago

This ties into #11 for Padding/Margin/Border/CornerRadius as well.

tpetrina commented 7 years ago

IsVisible should mean visible to the user, not to the rendering engine. Maybe we should rename that one?

birbilis commented 7 years ago

btw, regarding Visibility, I see in UWP only Visible and Collapsed values available. Wasn't there also a Hidden state in WPF where the control isn't visible but takes part in layout? Also, when using Collapsed what are the semantics? Is the control added to a graphics peer from the begging (when interoperating with native/media stuff sometimes this is needed) or lazy added? With hidden I suppose the semantics are to have it added to a peer (not sure what the terminology is in UWP about such stuff though)