Skip to content

Commit

Permalink
Move UIKit.Xaml DependencyProperty registration out of UIKit.Layer's …
Browse files Browse the repository at this point in the history
…constructor. (#1949)

Fixes #1930.
  • Loading branch information
jaredhms authored Feb 11, 2017
1 parent 650e749 commit ee6d1b8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Frameworks/UIKit.Xaml/Label.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Canvas^ Label::SublayerCanvas::get() {

Windows::Foundation::Size Label::ArrangeOverride(Windows::Foundation::Size finalSize) {
// Make sure we render vertically-centered text if possible, else cap at the containing layer's height.
// TODO: Issue #1946: Do we actually need this call to Measure?
TextBlock->Measure(finalSize);
if (TextBlock->DesiredSize.Height >= finalSize.Height) {
TextBlock->VerticalAlignment = Windows::UI::Xaml::VerticalAlignment::Top;
Expand Down
5 changes: 5 additions & 0 deletions Frameworks/UIKit.Xaml/Layer.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ void Layer::_RegisterDependencyProperties() {
// ObjectiveC Interop
////////////////////////////////////////////////////////////////////////////////////

// Initializes our library for use; registers dependency properties, etc.
UIKIT_XAML_EXPORT void UIKitXamlInitialize() {
UIKit::Xaml::Private::CoreAnimation::Layer::_RegisterDependencyProperties();
}

// Set one or more layer properties for the specified target xaml element
UIKIT_XAML_EXPORT void XamlSetFrameworkElementLayerProperties(
const Microsoft::WRL::ComPtr<IInspectable>& targetElement,
Expand Down
5 changes: 4 additions & 1 deletion Frameworks/UIKit.Xaml/Layer.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ public ref class Layer sealed : public ILayer {
Windows::UI::Xaml::DependencyProperty^ get();
}

internal:
// Static entry point to register our dependency properties
static void _RegisterDependencyProperties();

private:
// Layer elements; created on demand
Windows::UI::Xaml::Controls::Image^ _content;

// Dependency properties for adding layer-like functionality to any FrameworkElement
static void _RegisterDependencyProperties();
static bool s_dependencyPropertiesRegistered;
static Windows::UI::Xaml::DependencyProperty^ s_layerContentProperty;
static Windows::UI::Xaml::DependencyProperty^ s_sublayerCanvasProperty;
Expand Down
3 changes: 3 additions & 0 deletions Frameworks/UIKit.Xaml/ObjCXamlControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ UIKIT_XAML_EXPORT IInspectable* XamlGetLabelTextBox(const Microsoft::WRL::ComPtr
// Layer.xaml.cpp
////////////////////////////////////////////////////////////////////////////////////

// Initializes our library for use; registers dependency properties, etc.
UIKIT_XAML_EXPORT void UIKitXamlInitialize();

// Set one or more layer properties for the specified target xaml element
UIKIT_XAML_EXPORT void XamlSetFrameworkElementLayerProperties(const Microsoft::WRL::ComPtr<IInspectable>& targetElement,
const Microsoft::WRL::ComPtr<IInspectable>& sublayerCanvasProperty,
Expand Down
3 changes: 3 additions & 0 deletions Frameworks/UIKit/StarboardXaml/XamlCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "DisplayProperties.h"
#include "LayerProxy.h"
#include "../UIKit.Xaml/ObjCXamlControls.h"

using namespace Microsoft::WRL;
using namespace UIKit::Xaml::Private::CoreAnimation;
Expand Down Expand Up @@ -69,6 +70,8 @@ void Initialize(Windows::UI::Xaml::Controls::Grid^ rootGrid, ActivationType acti
s_rootGrid->InvalidateArrange();

s_rootGrid->SizeChanged += ref new SizeChangedEventHandler(&OnGridSizeChanged);

UIKitXamlInitialize();
}

ComPtr<IInspectable> GetRootElement() {
Expand Down

0 comments on commit ee6d1b8

Please sign in to comment.