Skip to content

Commit

Permalink
Move UIKit.Xaml dependency property registration out of UIKit.Layer's…
Browse files Browse the repository at this point in the history
… constructor.

Fixes microsoft#1930.
  • Loading branch information
jaredhms committed Feb 10, 2017
1 parent a47428f commit c2b6d56
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Frameworks/UIKit.Xaml/Label.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Private::CoreAnimation::LayerProperty^ Label::GetBorderThicknessProperty() {

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: Do we actually need this call to Measure?
// 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 @@ -130,6 +130,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 @@ -100,12 +100,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 @@ -65,6 +65,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 c2b6d56

Please sign in to comment.