浏览代码

add some files about inspector

/zgh-devtools
guanghuispark 4 年前
当前提交
f2fccc90
共有 6 个文件被更改,包括 354 次插入20 次删除
  1. 2
      com.unity.uiwidgets.devtools/Editor/enum_utils.cs
  2. 1
      com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/overflow_indicator_painter.cs
  3. 36
      com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/theme.cs
  4. 24
      com.unity.uiwidgets.devtools/Editor/theme.cs
  5. 311
      com.unity.uiwidgets.devtools/Editor/ui/icons.cs

2
com.unity.uiwidgets.devtools/Editor/enum_utils.cs


{
public class EnumUtils<T> {
EnumUtils(List<T> enumValues) {
public EnumUtils(List<T> enumValues) {
foreach (var val in enumValues) {
var enumDescription = DiagnosticUtils.describeEnum(val);
_lookupTable[enumDescription] = val;

1
com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/overflow_indicator_painter.cs


(side != ((OverflowIndicatorPainter)oldDelegate).side || size != ((OverflowIndicatorPainter)oldDelegate).size);
}
// [!!!] Not Implemented
public bool? hitTest(Offset position)
{
throw new System.NotImplementedException();

36
com.unity.uiwidgets.devtools/Editor/inspector/layout_explorer/ui/theme.cs


public static readonly Color backgroundColorSelectedDark = new Color(
0x4d474747); // TODO(jacobr): we would like Color(0x4dedeeef) but that makes the background show through.
public static readonly Color backgroundColorSelectedLight = new Color(0x4dedeeef);
public static bool isLight = false;
return isLight? mainAxisLightColor : mainAxisDarkColor;
return CommonThemeUtils.isLight? mainAxisLightColor : mainAxisDarkColor;
}
}

{
return isLight ? Colors.white : Colors.black;
return CommonThemeUtils.isLight? Colors.white : Colors.black;
}
}

{
return isLight ? crossAxisLightColor : crossAxisDarkColor;
return CommonThemeUtils.isLight? crossAxisLightColor : crossAxisDarkColor;
}
}

{
return isLight ? mainAxisTextColorLight : mainAxisTextColorDark;
return CommonThemeUtils.isLight? mainAxisTextColorLight : mainAxisTextColorDark;
}
}

{
return isLight ? crossAxisTextColorLight : crossAxisTextColorsDark;
return CommonThemeUtils.isLight? crossAxisTextColorLight : crossAxisTextColorsDark;
}
}

{
return isLight ? overflowBackgroundColorLight : overflowBackgroundColorDark;
return CommonThemeUtils.isLight? overflowBackgroundColorLight : overflowBackgroundColorDark;
}
}

{
return isLight ? overflowTextColorLight : overflowTextColorDark;
return CommonThemeUtils.isLight? overflowTextColorLight : overflowTextColorDark;
}
}

{
return isLight ? backgroundColorSelectedLight : backgroundColorSelectedDark;
return CommonThemeUtils.isLight? backgroundColorSelectedLight : backgroundColorSelectedDark;
}
}

{
return isLight ? backgroundColorLight : backgroundColorDark;
return CommonThemeUtils.isLight? backgroundColorLight : backgroundColorDark;
}
}

{
return isLight ? unconstrainedLightColor : unconstrainedDarkColor;
return CommonThemeUtils.isLight? unconstrainedLightColor : unconstrainedDarkColor;
}
}

public static TextStyle overflowingDimensionIndicatorTextStyle(ColorScheme colorScheme)
{
return new TextStyle(
height: 1.0f,
letterSpacing: 1.1f,
color: overflowTextColor,
fontWeight: FontWeight.bold
return dimensionIndicatorTextStyle.merge(
new TextStyle(
fontWeight: FontWeight.bold,
color: overflowTextColor
)
public Widget buildUnderline() {
public static Widget buildUnderline() {
return new Container(
height: 1.0f,
decoration: new BoxDecoration(

24
com.unity.uiwidgets.devtools/Editor/theme.cs


using System;
using uiwidgets;
using Unity.UIWidgets.DevTools.inspector.layout_explorer.ui;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.DevTools
{
public class CommonThemeUtils

public static readonly TimeSpan defaultDuration = TimeSpan.FromMilliseconds(200);
public static bool isLight = false;
public static Color defaultBackground
{
get
{
return isLight ? Colors.white : Colors.black;
}
}
public static Color defaultForeground
{
get
{
return isLight ? Colors.black : Color.fromARGB(255, 187, 187, 187);
}
}
}
}

311
com.unity.uiwidgets.devtools/Editor/ui/icons.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.DevTools.ui;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.DevTools.ui
{
public class IconsUtils
{
public static Image createImageIcon(string url, float? size = null) {
return new Image(
image: new AssetImage(url),
height: size?? CommonThemeUtils.defaultIconSize,
width: size?? CommonThemeUtils.defaultIconSize
);
}
}
public class CustomIcon : StatelessWidget {
public CustomIcon(
IconKind kind = null,
string text = null,
bool isAbstract = false
)
{
this.kind = kind;
this.text = text;
this.isAbstract = isAbstract;
}
public readonly IconKind kind;
public readonly string text;
public readonly bool isAbstract;
public Image baseIcon
{
get
{
return kind.icon;
}
}
public override Widget build(BuildContext context) {
return new Container(
width: baseIcon.width,
height: baseIcon.height,
child: new Stack(
alignment: AlignmentDirectional.center,
children: new List<Widget>{
baseIcon,
new Text(
text,
textAlign: TextAlign.center,
style: new TextStyle(fontSize: 9, color: new Color(0xFF231F20))
),
}
)
);
}
}
public class CustomIconMaker {
public readonly Dictionary<string, CustomIcon> iconCache = new Dictionary<string, CustomIcon>();
public CustomIcon getCustomIcon(string fromText, IconKind kind = null, bool isAbstract = false)
{
kind = kind ?? IconKind.classIcon;
if (fromText?.isEmpty() != false)
{
return null;
}
string text = char.ToUpper(fromText[0]).ToString();
string mapKey = $"{text}_${kind.name}_{isAbstract}";
return iconCache.putIfAbsent(mapKey, () => {
return new CustomIcon(kind: kind, text: text, isAbstract: isAbstract);
});
}
CustomIcon fromWidgetName(string name) {
if (name == null) {
return null;
}
bool isPrivate = name.StartsWith("_");
while (name.isNotEmpty() && !isAlphabetic(name[0])) {
name = name.Substring(1);
}
if (name.isEmpty()) {
return null;
}
return getCustomIcon(
name,
kind: isPrivate ? IconKind.method : IconKind.classIcon
);
}
CustomIcon fromInfo(String name) {
if (name == null) {
return null;
}
if (name.isEmpty()) {
return null;
}
return getCustomIcon(name, kind: IconKind.info);
}
bool isAlphabetic(int ch) {
return (ch < '0' || ch > '9') &&
ch != '_' &&
ch != '$';
}
}
public class IconKind {
public IconKind(string name, Image icon, Image abstractIcon = null)
{
this.name = name;
this.icon = icon;
this.abstractIcon = abstractIcon ?? icon;
}
public static IconKind classIcon = new IconKind(
"class",
IconsUtils.createImageIcon("icons/custom/class.png"),
IconsUtils.createImageIcon("icons/custom/class_abstract.png")
);
public static IconKind field = new IconKind(
"fields",
IconsUtils.createImageIcon("icons/custom/fields.png")
);
public static IconKind _interface = new IconKind(
"interface",
IconsUtils.createImageIcon("icons/custom/interface.png")
);
public static IconKind method = new IconKind(
"method",
IconsUtils.createImageIcon("icons/custom/method.png"),
IconsUtils.createImageIcon("icons/custom/method_abstract.png")
);
public static IconKind property = new IconKind(
"property",
IconsUtils.createImageIcon("icons/custom/property.png")
);
public static IconKind info = new IconKind(
"info",
IconsUtils.createImageIcon("icons/custom/info.png")
);
public readonly string name;
public readonly Image icon;
public readonly Image abstractIcon;
}
public class ColorIcon : StatelessWidget {
public ColorIcon(Color color)
{
this.color = color;
}
public readonly Color color;
public override Widget build(BuildContext context) {
var colorScheme = Theme.of(context).colorScheme;
return new CustomPaint(
painter: new _ColorIconPainter(color, colorScheme),
size: new Size(CommonThemeUtils.defaultIconSize, CommonThemeUtils.defaultIconSize)
);
}
}
public class ColorIconMaker {
public readonly Dictionary<Color, ColorIcon> iconCache = new Dictionary<Color, ColorIcon>();
ColorIcon getCustomIcon(Color color) {
return iconCache.putIfAbsent(color, () => new ColorIcon(color));
}
}
public class _ColorIconPainter : CustomPainter {
public _ColorIconPainter(Color color, ColorScheme colorScheme)
{
this.color = color;
this.colorScheme = colorScheme;
}
public readonly Color color;
public readonly ColorScheme colorScheme;
public const float iconMargin = 1;
public void paint(Canvas canvas, Size size)
{
var greyPaint = new Paint();
greyPaint.color = Colors.grey;
var iconRect = Rect.fromLTRB(
iconMargin,
iconMargin,
size.width - iconMargin,
size.height - iconMargin
);
Paint bgPaint = new Paint();
bgPaint.color = CommonThemeUtils.defaultBackground;
canvas.drawRect(
Rect.fromLTRB(
iconMargin,
iconMargin,
size.width - iconMargin,
size.height - iconMargin
),
bgPaint
);
canvas.drawRect(
Rect.fromLTRB(
iconMargin,
iconMargin,
size.width * 0.5f,
size.height * 0.5f
),
greyPaint
);
canvas.drawRect(
Rect.fromLTRB(
size.width * 0.5f,
size.height * 0.5f,
size.width - iconMargin,
size.height - iconMargin
),
greyPaint
);
canvas.drawRect(
iconRect,
new Paint()
{
color = color
}
);
Paint temp2 = new Paint();
canvas.drawRect(
iconRect,
new Paint()
{
style = PaintingStyle.stroke,
color = CommonThemeUtils.defaultForeground
}
);
}
public bool shouldRepaint(CustomPainter oldDelegate) {
// if (oldDelegate is _ColorIconPainter) {
// return ((_ColorIconPainter)oldDelegate).colorScheme.isLight != CommonThemeUtils.isLight;
// }
return true;
}
public bool? hitTest(Offset position)
{
throw new NotImplementedException();
}
public void addListener(VoidCallback listener)
{
throw new NotImplementedException();
}
public void removeListener(VoidCallback listener)
{
throw new NotImplementedException();
}
}
public class FlutterMaterialIcons {
public FlutterMaterialIcons(){}
static Icon getIconForCodePoint(int charCode, ColorScheme colorScheme) {
return new Icon(new IconData(charCode), color: CommonThemeUtils.defaultForeground);
}
}
public class Octicons {
public static readonly IconData bug = new IconData(61714, fontFamily: "Octicons");
public static readonly IconData info = new IconData(61778, fontFamily: "Octicons");
public static readonly IconData deviceMobile = new IconData(61739, fontFamily: "Octicons");
public static readonly IconData fileZip = new IconData(61757, fontFamily: "Octicons");
public static readonly IconData clippy = new IconData(61724, fontFamily: "Octicons");
public static readonly IconData package = new IconData(61812, fontFamily: "Octicons");
public static readonly IconData dashboard = new IconData(61733, fontFamily: "Octicons");
public static readonly IconData pulse = new IconData(61823, fontFamily: "Octicons");
}
}
正在加载...
取消
保存