Revert "[*] ScaleX and ScaleY"

This reverts commit fc7d556848.
This commit is contained in:
Stephane Delcroix 2017-02-06 15:18:16 +01:00
Родитель fc7d556848
Коммит faa6eae8e7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: EDD442EF80530554
7 изменённых файлов: 26 добавлений и 75 удалений

Просмотреть файл

@ -72,8 +72,7 @@ public class FormsViewGroup extends ViewGroup {
float rotation, float rotation,
float rotationX, float rotationX,
float rotationY, float rotationY,
float scaleX, float scale,
float scaleY
float translationX, float translationX,
float translationY){ float translationY){
setPivotX (pivotX); setPivotX (pivotX);
@ -89,8 +88,8 @@ public class FormsViewGroup extends ViewGroup {
setRotation (rotation); setRotation (rotation);
setRotationX (rotationX); setRotationX (rotationX);
setRotationY (rotationY); setRotationY (rotationY);
setScaleX (scaleX); setScaleX (scale);
setScaleY (sclaeY); setScaleY (scale);
setTranslationX (translationX); setTranslationX (translationX);
setTranslationY (translationY); setTranslationY (translationY);
} }

Просмотреть файл

@ -39,41 +39,19 @@ namespace Xamarin.Forms.Controls
scaleSlider.SetBinding(Slider.ValueProperty, scaleSlider.SetBinding(Slider.ValueProperty,
new Binding("Scale", BindingMode.TwoWay)); new Binding("Scale", BindingMode.TwoWay));
// Label and Slider for ScaleX property.
Label scaleXSliderValue = new Label {
VerticalTextAlignment = TextAlignment.Center
};
Grid.SetRow(scaleXSliderValue, 1);
Grid.SetColumn(scaleXSliderValue, 0);
Slider scaleXSlider = new Slider {
Maximum = 10
};
Grid.SetRow(scaleXSlider, 1);
Grid.SetColumn(scaleXSlider, 1);
// Set Bindings.
scaleXSliderValue.BindingContext = scaleXSlider;
scaleXSliderValue.SetBinding(Label.TextProperty,
new Binding("Value", BindingMode.OneWay, null, null, "ScaleX = {0:F1}"));
scaleXSlider.BindingContext = label;
scaleXSlider.SetBinding(Slider.ValueProperty,
new Binding("ScaleX", BindingMode.TwoWay));
// Label and Slider for Rotation property. // Label and Slider for Rotation property.
Label rotationSliderValue = new Label Label rotationSliderValue = new Label
{ {
VerticalTextAlignment = TextAlignment.Center VerticalTextAlignment = TextAlignment.Center
}; };
Grid.SetRow(rotationSliderValue, 2); Grid.SetRow(rotationSliderValue, 1);
Grid.SetColumn(rotationSliderValue, 0); Grid.SetColumn(rotationSliderValue, 0);
Slider rotationSlider = new Slider Slider rotationSlider = new Slider
{ {
Maximum = 360 Maximum = 360
}; };
Grid.SetRow(rotationSlider, 2); Grid.SetRow(rotationSlider, 1);
Grid.SetColumn(rotationSlider, 1); Grid.SetColumn(rotationSlider, 1);
// Set Bindings. // Set Bindings.
@ -90,7 +68,7 @@ namespace Xamarin.Forms.Controls
{ {
VerticalTextAlignment = TextAlignment.Center VerticalTextAlignment = TextAlignment.Center
}; };
Grid.SetRow(anchorxStepperValue, 3); Grid.SetRow(anchorxStepperValue, 2);
Grid.SetColumn(anchorxStepperValue, 0); Grid.SetColumn(anchorxStepperValue, 0);
Stepper anchorxStepper = new Stepper Stepper anchorxStepper = new Stepper
@ -99,7 +77,7 @@ namespace Xamarin.Forms.Controls
Minimum = -1, Minimum = -1,
Increment = 0.5 Increment = 0.5
}; };
Grid.SetRow(anchorxStepper, 3); Grid.SetRow(anchorxStepper, 2);
Grid.SetColumn(anchorxStepper, 1); Grid.SetColumn(anchorxStepper, 1);
// Set bindings. // Set bindings.
@ -116,7 +94,7 @@ namespace Xamarin.Forms.Controls
{ {
VerticalTextAlignment = TextAlignment.Center VerticalTextAlignment = TextAlignment.Center
}; };
Grid.SetRow(anchoryStepperValue, 4); Grid.SetRow(anchoryStepperValue, 3);
Grid.SetColumn(anchoryStepperValue, 0); Grid.SetColumn(anchoryStepperValue, 0);
Stepper anchoryStepper = new Stepper Stepper anchoryStepper = new Stepper
@ -125,7 +103,7 @@ namespace Xamarin.Forms.Controls
Minimum = -1, Minimum = -1,
Increment = 0.5 Increment = 0.5
}; };
Grid.SetRow(anchoryStepper, 4); Grid.SetRow(anchoryStepper, 3);
Grid.SetColumn(anchoryStepper, 1); Grid.SetColumn(anchoryStepper, 1);
// Set bindings. // Set bindings.
@ -152,7 +130,6 @@ namespace Xamarin.Forms.Controls
new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
}, },
ColumnDefinitions = ColumnDefinitions =
{ {
@ -163,8 +140,6 @@ namespace Xamarin.Forms.Controls
{ {
scaleSliderValue, scaleSliderValue,
scaleSlider, scaleSlider,
scaleXSliderValue,
scaleXSlider,
rotationSliderValue, rotationSliderValue,
rotationSlider, rotationSlider,
anchorxStepperValue, anchorxStepperValue,

Просмотреть файл

@ -48,10 +48,6 @@ namespace Xamarin.Forms
public static readonly BindableProperty ScaleProperty = BindableProperty.Create("Scale", typeof(double), typeof(VisualElement), 1d); public static readonly BindableProperty ScaleProperty = BindableProperty.Create("Scale", typeof(double), typeof(VisualElement), 1d);
public static readonly BindableProperty ScaleXProperty = BindableProperty.Create("ScaleX", typeof(double), typeof(VisualElement), 1d);
public static readonly BindableProperty ScaleYProperty = BindableProperty.Create("ScaleY", typeof(double), typeof(VisualElement), 1d);
public static readonly BindableProperty IsVisibleProperty = BindableProperty.Create("IsVisible", typeof(bool), typeof(VisualElement), true, public static readonly BindableProperty IsVisibleProperty = BindableProperty.Create("IsVisible", typeof(bool), typeof(VisualElement), true,
propertyChanged: (bindable, oldvalue, newvalue) => ((VisualElement)bindable).OnIsVisibleChanged((bool)oldvalue, (bool)newvalue)); propertyChanged: (bindable, oldvalue, newvalue) => ((VisualElement)bindable).OnIsVisibleChanged((bool)oldvalue, (bool)newvalue));
@ -246,16 +242,6 @@ namespace Xamarin.Forms
set { SetValue(ScaleProperty, value); } set { SetValue(ScaleProperty, value); }
} }
public double ScaleX {
get { return (double)GetValue(ScaleXProperty); }
set { SetValue(ScaleXProperty, value); }
}
public double ScaleY {
get { return (double)GetValue(ScaleYProperty); }
set { SetValue(ScaleYProperty, value); }
}
public Style Style public Style Style
{ {
get { return (Style)GetValue(StyleProperty); } get { return (Style)GetValue(StyleProperty); }

Просмотреть файл

@ -120,7 +120,7 @@ namespace Xamarin.Forms.Platform.Android
if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName || if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
e.PropertyName == VisualElement.HeightProperty.PropertyName) e.PropertyName == VisualElement.HeightProperty.PropertyName)
_layoutNeeded = true; _layoutNeeded = true;
else if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName || e.PropertyName == VisualElement.ScaleYProperty.PropertyName || else if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName ||
e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName || e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName ||
e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName || e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName ||
e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName) e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName)
@ -138,7 +138,7 @@ namespace Xamarin.Forms.Platform.Android
UpdateAnchorX(); UpdateAnchorX();
else if (e.PropertyName == VisualElement.AnchorYProperty.PropertyName) else if (e.PropertyName == VisualElement.AnchorYProperty.PropertyName)
UpdateAnchorY(); UpdateAnchorY();
else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName || e.PropertyName == VisualElement.ScaleYProperty.PropertyName) else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName)
UpdateScale(); UpdateScale();
else if (e.PropertyName == VisualElement.RotationProperty.PropertyName) else if (e.PropertyName == VisualElement.RotationProperty.PropertyName)
UpdateRotation(); UpdateRotation();
@ -230,7 +230,7 @@ namespace Xamarin.Forms.Platform.Android
UpdateRotationX(); UpdateRotationX();
if (oldElement.RotationY != newElement.RotationY) if (oldElement.RotationY != newElement.RotationY)
UpdateRotationY(); UpdateRotationY();
if (oldElement.Scale != newElement.Scale || oldElement.ScaleX != newElement.ScaleY || oldElement.ScaleY != newElement.ScaleY) if (oldElement.Scale != newElement.Scale)
UpdateScale(); UpdateScale();
// ReSharper restore CompareOfFloatsByEqualityOperator // ReSharper restore CompareOfFloatsByEqualityOperator
@ -299,18 +299,9 @@ namespace Xamarin.Forms.Platform.Android
if (aview is FormsViewGroup) if (aview is FormsViewGroup)
{ {
var formsViewGroup = (FormsViewGroup)aview; var formsViewGroup = (FormsViewGroup)aview;
formsViewGroup.SendBatchUpdate((float)(view.AnchorX * _context.ToPixels(view.Width)), formsViewGroup.SendBatchUpdate((float)(view.AnchorX * _context.ToPixels(view.Width)), (float)(view.AnchorY * _context.ToPixels(view.Height)),
(float)(view.AnchorY * _context.ToPixels(view.Height)), (int)(view.IsVisible ? ViewStates.Visible : ViewStates.Invisible), view.IsEnabled, (float)view.Opacity, (float)view.Rotation, (float)view.RotationX, (float)view.RotationY, (float)view.Scale,
(int)(view.IsVisible ? ViewStates.Visible : ViewStates.Invisible), _context.ToPixels(view.TranslationX), _context.ToPixels(view.TranslationY));
view.IsEnabled,
(float)view.Opacity,
(float)view.Rotation,
(float)view.RotationX,
(float)view.RotationY,
(float)view.ScaleX,
(float)view.ScaleY,
_context.ToPixels(view.TranslationX),
_context.ToPixels(view.TranslationY));
} }
else else
{ {
@ -374,8 +365,8 @@ namespace Xamarin.Forms.Platform.Android
VisualElement view = _renderer.Element; VisualElement view = _renderer.Element;
AView aview = _renderer.ViewGroup; AView aview = _renderer.ViewGroup;
aview.ScaleX = (float)view.Scale * (float)view.ScaleX; aview.ScaleX = (float)view.Scale;
aview.ScaleY = (float)view.Scale * (float)view.ScaleY; aview.ScaleY = (float)view.Scale;
} }
void UpdateTranslationX() void UpdateTranslationX()

Просмотреть файл

@ -160,7 +160,7 @@ namespace Xamarin.Forms.Platform.WinPhone
MaybeInvalidate(); MaybeInvalidate();
else if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName) else if (e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName)
UpdateScaleAndRotation(Model, Element); UpdateScaleAndRotation(Model, Element);
else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName || e.PropertyName == VisualElement.ScaleYProperty.PropertyName ) else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName)
UpdateScaleAndRotation(Model, Element); UpdateScaleAndRotation(Model, Element);
else if (e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName || else if (e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName ||
e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName) e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName)
@ -350,8 +350,9 @@ namespace Xamarin.Forms.Platform.WinPhone
{ {
double anchorX = view.AnchorX; double anchorX = view.AnchorX;
double anchorY = view.AnchorY; double anchorY = view.AnchorY;
double scale = view.Scale;
frameworkElement.RenderTransformOrigin = new System.Windows.Point(anchorX, anchorY); frameworkElement.RenderTransformOrigin = new System.Windows.Point(anchorX, anchorY);
frameworkElement.RenderTransform = new ScaleTransform { ScaleX = view.Scale * view.ScaleX, ScaleY = view.Scale * view.ScaleY }; frameworkElement.RenderTransform = new ScaleTransform { ScaleX = scale, ScaleY = scale };
UpdateRotation(view, frameworkElement); UpdateRotation(view, frameworkElement);
} }

Просмотреть файл

@ -188,7 +188,7 @@ namespace Xamarin.Forms.Platform.WinRT
{ {
UpdateScaleAndRotation(Element, Container); UpdateScaleAndRotation(Element, Container);
} }
else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName ||)e.PropertyName == VisualElement.ScaleYProperty.PropertyName else if (e.PropertyName == VisualElement.ScaleProperty.PropertyName)
{ {
UpdateScaleAndRotation(Element, Container); UpdateScaleAndRotation(Element, Container);
} }
@ -470,8 +470,9 @@ namespace Xamarin.Forms.Platform.WinRT
{ {
double anchorX = view.AnchorX; double anchorX = view.AnchorX;
double anchorY = view.AnchorY; double anchorY = view.AnchorY;
double scale = view.Scale;
frameworkElement.RenderTransformOrigin = new Windows.Foundation.Point(anchorX, anchorY); frameworkElement.RenderTransformOrigin = new Windows.Foundation.Point(anchorX, anchorY);
frameworkElement.RenderTransform = new ScaleTransform { ScaleX = view.Scale * view.ScaleX, view.Scale * view.ScaleY = scale }; frameworkElement.RenderTransform = new ScaleTransform { ScaleX = scale, ScaleY = scale };
UpdateRotation(view, frameworkElement); UpdateRotation(view, frameworkElement);
} }

Просмотреть файл

@ -78,7 +78,7 @@ namespace Xamarin.Forms.Platform.MacOS
{ {
if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName || if (e.PropertyName == VisualElement.XProperty.PropertyName || e.PropertyName == VisualElement.YProperty.PropertyName || e.PropertyName == VisualElement.WidthProperty.PropertyName ||
e.PropertyName == VisualElement.HeightProperty.PropertyName || e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName || e.PropertyName == VisualElement.HeightProperty.PropertyName || e.PropertyName == VisualElement.AnchorXProperty.PropertyName || e.PropertyName == VisualElement.AnchorYProperty.PropertyName ||
e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName || e.PropertyName == VisualElement.ScaleXProperty.PropertyName || e.PropertyName == VisualElement.ScaleYProperty.PropertyName || e.PropertyName == VisualElement.TranslationXProperty.PropertyName || e.PropertyName == VisualElement.TranslationYProperty.PropertyName || e.PropertyName == VisualElement.ScaleProperty.PropertyName ||
e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName || e.PropertyName == VisualElement.RotationProperty.PropertyName || e.PropertyName == VisualElement.RotationXProperty.PropertyName || e.PropertyName == VisualElement.RotationYProperty.PropertyName ||
e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.IsEnabledProperty.PropertyName || e.PropertyName == VisualElement.IsVisibleProperty.PropertyName || e.PropertyName == VisualElement.IsEnabledProperty.PropertyName ||
e.PropertyName == VisualElement.InputTransparentProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName) e.PropertyName == VisualElement.InputTransparentProperty.PropertyName || e.PropertyName == VisualElement.OpacityProperty.PropertyName)
@ -135,8 +135,6 @@ namespace Xamarin.Forms.Platform.MacOS
var rotationY = (float)view.RotationY; var rotationY = (float)view.RotationY;
var rotation = (float)view.Rotation; var rotation = (float)view.Rotation;
var scale = (float)view.Scale; var scale = (float)view.Scale;
var scaleX = (float)view.ScaleX * scale;
var scaleY = (float)view.ScaleY * scale;
var width = (float)view.Width; var width = (float)view.Width;
var height = (float)view.Height; var height = (float)view.Height;
var x = (float)view.X; var x = (float)view.X;
@ -229,8 +227,8 @@ namespace Xamarin.Forms.Platform.MacOS
if (Math.Abs(translationX) > epsilon || Math.Abs(translationY) > epsilon) if (Math.Abs(translationX) > epsilon || Math.Abs(translationY) > epsilon)
transform = transform.Translate(translationX, translationY, 0); transform = transform.Translate(translationX, translationY, 0);
if (Math.Abs(scaleX - 1) > epsilon || Math.Abs(scaleY - 1) > epsilon) if (Math.Abs(scale - 1) > epsilon)
transform = transform.Scale(scaleX, scaleY, scale); transform = transform.Scale(scale);
// not just an optimization, iOS will not "pixel align" a view which has m34 set // not just an optimization, iOS will not "pixel align" a view which has m34 set
if (Math.Abs(rotationY % 180) > epsilon || Math.Abs(rotationX % 180) > epsilon) if (Math.Abs(rotationY % 180) > epsilon || Math.Abs(rotationX % 180) > epsilon)