guanghuispark
4 年前
当前提交
73942a6a
共有 4 个文件被更改,包括 126 次插入 和 2 次删除
-
52com.unity.uiwidgets/Runtime/rendering/layer.cs
-
12com.unity.uiwidgets/Runtime/rendering/object.cs
-
59com.unity.uiwidgets/Runtime/widgets/color_filter.cs
-
5com.unity.uiwidgets/Runtime/widgets/constants.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); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|
|||
namespace Unity.UIWidgets.widgets { |
|||
public class constants { |
|||
const float kMinInteractiveDimension = 48.0f; |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue