浏览代码

add color_filter.cs and constants.cs

/siyaoH-1.17-PlatformMessage
guanghuispark 4 年前
当前提交
73942a6a
共有 4 个文件被更改,包括 126 次插入2 次删除
  1. 52
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  2. 12
      com.unity.uiwidgets/Runtime/rendering/object.cs
  3. 59
      com.unity.uiwidgets/Runtime/widgets/color_filter.cs
  4. 5
      com.unity.uiwidgets/Runtime/widgets/constants.cs

52
com.unity.uiwidgets/Runtime/rendering/layer.cs


}
}
}
EngineLayer _engineLayer;
protected EngineLayer _engineLayer;
internal virtual void updateSubtreeNeedsAddToScene() {
_needsAddToScene = _needsAddToScene || alwaysNeedsAddToScene;

}
}
/// A composite layer that applies a [ColorFilter] to its children.
public class ColorFilterLayer : ContainerLayer {
/// Creates a layer that applies a [ColorFilter] to its children.
///
/// The [colorFilter] property must be non-null before the compositing phase
/// of the pipeline.
public ColorFilterLayer(ColorFilter colorFilter = null) {
_colorFilter = colorFilter;
}
/// The color filter to apply to children.
///
/// The scene must be explicitly recomposited after this property is changed
/// (as described at [Layer]).
public ColorFilter colorFilter {
get {
return _colorFilter;
}
set {
D.assert(value != null);
if (value != _colorFilter) {
_colorFilter = value;
markNeedsAddToScene();
}
}
}
ColorFilter _colorFilter;
//[!!!]builder.pushColorFilter?
/*public override void addToScene(ui.SceneBuilder builder, Offset layerOffset = null ) {
D.assert(colorFilter != null);
engineLayer = builder.pushColorFilter(
colorFilter,
oldLayer: _engineLayer as ui.ColorFilterEngineLayer
);
addChildrenToScene(builder, layerOffset);
builder.pop();
}*/
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ColorFilter>("colorFilter", colorFilter));
}
}
public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix4 transform = null, Offset offset = null) : base(offset) {
_transform = transform ?? Matrix4.identity();

12
com.unity.uiwidgets/Runtime/rendering/object.cs


return
$"{GetType()}#{GetHashCode()}(layer: {_containerLayer}, canvas bounds: {estimatedBounds}";
}
public ColorFilterLayer pushColorFilter(Offset offset, ColorFilter colorFilter, PaintingContextCallback painter, ColorFilterLayer oldLayer = null) {
D.assert(colorFilter != null);
ColorFilterLayer layer = oldLayer ?? new ColorFilterLayer();
layer.colorFilter = colorFilter;
pushLayer(layer, painter, offset);
return layer;
}
}
public abstract class Constraints {

get {
D.assert(!isRepaintBoundary || (_layer == null || _layer is OffsetLayer));
return _layer;
}
set {
D.assert(!isRepaintBoundary);
_layer = value;
}
}

59
com.unity.uiwidgets/Runtime/widgets/color_filter.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public class ColorFiltered : SingleChildRenderObjectWidget {
/// Creates a widget that applies a [ColorFilter] to its child.
///
/// The [colorFilter] must not be null.
protected ColorFiltered(ColorFilter colorFilter = null, Widget child = null, Key key = null)
: base(key: key, child: child) {
D.assert(colorFilter != null);
}
/// The color filter to apply to the child of this widget.
public readonly ColorFilter colorFilter;
public override RenderObject createRenderObject(BuildContext context) => new _ColorFilterRenderObject(colorFilter);
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
((_ColorFilterRenderObject)renderObject).colorFilter = colorFilter;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ColorFilter>("colorFilter", colorFilter));
}
}
public class _ColorFilterRenderObject : RenderProxyBox {
public _ColorFilterRenderObject(ColorFilter _colorFilter) {
this._colorFilter = _colorFilter;
}
public ColorFilter colorFilter {
get { return _colorFilter; }
set {
D.assert(value != null);
if (value != _colorFilter) {
_colorFilter = value;
markNeedsPaint();
}
}
}
ColorFilter _colorFilter;
public bool alwaysNeedsCompositing {
get { return child != null; }
}
public override void paint(PaintingContext context, Offset offset) {
layer = context.pushColorFilter(offset, colorFilter, base.paint, oldLayer: layer as ColorFilterLayer);
}
}
}

5
com.unity.uiwidgets/Runtime/widgets/constants.cs


namespace Unity.UIWidgets.widgets {
public class constants {
const float kMinInteractiveDimension = 48.0f;
}
}
正在加载...
取消
保存