mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 01:10:08 +00:00
增加UISlider扩展组件
This commit is contained in:
@@ -349,6 +349,69 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
|
||||
{
|
||||
UpdateRuntimeData(graphWidth, graphWidth);
|
||||
|
||||
float x, y, width, height;
|
||||
|
||||
width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth;
|
||||
height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight;
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||
y = graphY + runtimeBottom;
|
||||
break;
|
||||
|
||||
case Align.BottomLeft:
|
||||
x = graphX + runtimeLeft;
|
||||
y = graphY + runtimeBottom;
|
||||
break;
|
||||
|
||||
case Align.BottomRight:
|
||||
x = graphX + graphWidth - runtimeRight - width;
|
||||
y = graphY + runtimeBottom;
|
||||
break;
|
||||
|
||||
case Align.Center:
|
||||
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||
break;
|
||||
|
||||
case Align.CenterLeft:
|
||||
x = graphX + runtimeLeft;
|
||||
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||
break;
|
||||
|
||||
case Align.CenterRight:
|
||||
x = graphX + graphWidth - runtimeRight - width;
|
||||
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||
break;
|
||||
|
||||
case Align.TopCenter:
|
||||
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||
y = graphY + graphHeight - runtimeTop - height;
|
||||
break;
|
||||
|
||||
case Align.TopLeft:
|
||||
x = graphX + runtimeLeft;
|
||||
y = graphY + graphHeight - runtimeTop - height;
|
||||
break;
|
||||
|
||||
case Align.TopRight:
|
||||
x = graphX + graphWidth - runtimeRight - width;
|
||||
y = graphY + graphHeight - runtimeTop - height;
|
||||
break;
|
||||
|
||||
default:
|
||||
return new Rect(0, 0, 0, 0);
|
||||
}
|
||||
return new Rect(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
||||
/// </summary>
|
||||
|
||||
@@ -791,6 +791,14 @@ namespace XCharts.Runtime
|
||||
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
|
||||
}
|
||||
|
||||
public static float GetMaxCeilRate(float value, float ceilRate)
|
||||
{
|
||||
if (ceilRate == 0) return value;
|
||||
var mod = value % ceilRate;
|
||||
int rate = (int)(value / ceilRate);
|
||||
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
|
||||
}
|
||||
|
||||
public static double GetMinCeilRate(double value, double ceilRate)
|
||||
{
|
||||
if (ceilRate == 0) return value;
|
||||
@@ -799,6 +807,14 @@ namespace XCharts.Runtime
|
||||
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
|
||||
}
|
||||
|
||||
public static float GetMinCeilRate(float value, float ceilRate)
|
||||
{
|
||||
if (ceilRate == 0) return value;
|
||||
var mod = value % ceilRate;
|
||||
int rate = (int)(value / ceilRate);
|
||||
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
|
||||
}
|
||||
|
||||
public static double GetMinDivisibleValue(double min, double ceilRate)
|
||||
{
|
||||
if (min == 0) return 0;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public static class UIHelper
|
||||
{
|
||||
internal static void DrawBackground(VertexHelper vh, UIComponent component)
|
||||
public static void DrawBackground(VertexHelper vh, UIComponent component)
|
||||
{
|
||||
var background = component.background;
|
||||
var rect = component.graphRect;
|
||||
@@ -34,10 +34,19 @@ namespace XCharts.Runtime
|
||||
if (background.image != null)
|
||||
return;
|
||||
var backgroundColor = component.theme.GetBackgroundColor(background);
|
||||
DrawBackground(vh, background, backgroundColor);
|
||||
}
|
||||
|
||||
public static void DrawBackground(VertexHelper vh, Background background, Color32 color)
|
||||
{
|
||||
if (!background.show)
|
||||
return;
|
||||
if (background.image != null)
|
||||
return;
|
||||
var borderWidth = background.borderStyle.GetRuntimeBorderWidth();
|
||||
var borderColor = background.borderStyle.GetRuntimeBorderColor();
|
||||
var cornerRadius = background.borderStyle.GetRuntimeCornerRadius();
|
||||
UGL.DrawRoundRectangleWithBorder(vh, background.rect, backgroundColor, backgroundColor, cornerRadius,
|
||||
UGL.DrawRoundRectangleWithBorder(vh, background.rect, color, color, cornerRadius,
|
||||
borderWidth, borderColor);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user