Margin=0;
Spacing=3;
}
+SaturationValueSelector {
+ Foreground=Red;
+}
+HueSelector {
+ ClipToClientRect=False;
+}
ColorSpinner {
Minimum = 0;
Maximum = 255;
<Border Background="{./Background}" Foreground="{./Foreground}"
CornerRadius="{./CornerRadius}" BorderWidth="1">
<HorizontalStack Spacing="0">
- <VerticalStack Margin="10">
+ <VerticalStack Margin="4">
<SaturationValueSelector S="{²./S}" V="{²./V}" Focusable="true" Name="colorSelector" Margin="0"
Foreground="{../hueSelector.HueColor}"
- Width="140" Height="140" Background="DimGray"/>
- <HueSelector Hue="{²./H}" Focusable="true" Name="hueSelector" Margin="0" Width="140" Height="20" Background="DimGray"/>
+ Width="120" Height="120"/>
+ <HueSelector Hue="{²./H}" Focusable="true" Name="hueSelector" Margin="0" Width="120" Height="20"/>
</VerticalStack>
- <VerticalStack Margin="5" Height="Stretched">
- <HorizontalStack Height="Fit" Width="Stretched">
- <GraphicObject Width="40" Height="30" Background="{./SelectedColor}"/>
- <VerticalStack Margin="2">
- <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./SelectedColor}" />
- <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./HexColor}" />
- </VerticalStack>
+ <VerticalStack Margin="4" Height="Stretched">
+ <HorizontalStack Height="Fit" Width="Stretched" Spacing="4">
+ <GraphicObject Width="34" Height="21" Background="{./SelectedColor}"/>
+ <Label Focusable="true" Selectable="true" Width="Stretched" Text="{./HexColor}" />
</HorizontalStack>
<HorizontalStack Height="Fit">
<Label Text="Red:" Width="40"/>
mousePos = mPos - r.Position;
mousePos.X = Math.Max(cb.X, mousePos.X);
- mousePos.X = Math.Min(cb.Right-1, mousePos.X);
+ mousePos.X = Math.Min(cb.Right, mousePos.X);
mousePos.Y = Math.Max(cb.Y, mousePos.Y);
- mousePos.Y = Math.Min(cb.Bottom-1, mousePos.Y);
+ mousePos.Y = Math.Min(cb.Bottom, mousePos.Y);
}
-// virtual protected void updateColorFromPicking(bool redraw = true){
-// SelectedColor = new SolidColor(getPixelAt(mousePos.X, mousePos.Y));
-//
-// updateHSV ();
-//
-// NotifyValueChanged ("R", R);
-// NotifyValueChanged ("G", G);
-// NotifyValueChanged ("B", B);
-// NotifyValueChanged ("A", A);
-//
-// if (redraw)
-// RegisterForRedraw ();
-// }
-//
-// protected Color getPixelAt(int x, int y){
-// if (bmp == null)
-// return Color.Transparent;
-//
-// int ptr = y * Slot.Width * 4 + x * 4;
-//
-// return new Color(
-// (double)bmp[ptr + 2] * colDiv,
-// (double)bmp[ptr + 1] * colDiv,
-// (double)bmp[ptr] * colDiv,
-// (double)bmp[ptr + 3] * colDiv);
-// }
}
}
if (hue == value)
return;
hue = value;
-
notifyHueChanged ();
updateMousePosFromHue ();
+ RegisterForRedraw ();
}
}
protected override void onDraw (Cairo.Context gr)
ctx.SetSourceColor (Color.White);
Rectangle r = ClientRectangle;
if (Orientation == Orientation.Horizontal) {
- r.Width = 5;
- r.X = mousePos.X;
+ r.Width = 4;
+ r.X = mousePos.X - 2;
} else {
- r.Height = 5;
- r.Y = mousePos.Y;
+ r.Height = 4;
+ r.Y = mousePos.Y - 2;
}
CairoHelpers.CairoRectangle (ctx, r, 2);
else
hue = (double)mousePos.Y / (double)ClientRectangle.Height;
notifyHueChanged ();
+ RegisterForRedraw ();
}
void updateMousePosFromHue(){
if (Orientation == Orientation.Horizontal)
mousePos.X = (int)Math.Floor(hue * (double)ClientRectangle.Width);
else
mousePos.Y = (int)Math.Floor(hue * (double)ClientRectangle.Height);
- CurrentInterface.EnqueueForRepaint (this);
}
void notifyHueChanged(){
NotifyValueChanged ("Hue", hue);
NotifyValueChanged ("V", v);
mousePos.Y = (int)Math.Floor((1.0-v) * (double)ClientRectangle.Height);
- CurrentInterface.EnqueueForRepaint (this);
+ RegisterForRedraw ();
}
}
[XmlAttributeAttribute()]
s = value;
NotifyValueChanged ("S", s);
mousePos.X = (int)Math.Floor(s * (double)ClientRectangle.Width);
- CurrentInterface.EnqueueForRepaint (this);
+
+ RegisterForRedraw ();
}
}
protected override void onDraw (Cairo.Context gr)
base.onDraw (gr);
Rectangle r = ClientRectangle;
- Rectangle rGrad = r;
- rGrad.Inflate (-1);
if (Foreground != null) {//TODO:test if null should be removed
Foreground.SetAsSource (gr, r);
Crow.Gradient grad = new Gradient (Gradient.Type.Horizontal);
grad.Stops.Add (new Gradient.ColorStop (0, new Color (1, 1, 1, 1)));
grad.Stops.Add (new Gradient.ColorStop (1, new Color (1, 1, 1, 0)));
- grad.SetAsSource (gr, rGrad);
+ grad.SetAsSource (gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
gr.Fill();
grad = new Gradient (Gradient.Type.Vertical);
grad.Stops.Add (new Gradient.ColorStop (0, new Color (0, 0, 0, 0)));
grad.Stops.Add (new Gradient.ColorStop (1, new Color (0, 0, 0, 1)));
- grad.SetAsSource (gr, rGrad);
+ grad.SetAsSource (gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
gr.Fill();
}
ctx.Translate (rb.X, rb.Y);
ctx.SetSourceColor (Color.White);
- ctx.Arc (mousePos.X, mousePos.Y, 3.0, 0, Math.PI * 2.0);
+ ctx.Arc (mousePos.X, mousePos.Y, 3.5, 0, Math.PI * 2.0);
ctx.LineWidth = 1.0;
ctx.Stroke ();
v = 1.0 - (double)mousePos.Y / (double)cb.Height;
NotifyValueChanged ("S", s);
NotifyValueChanged ("V", v);
+
+ RegisterForRedraw ();
}
public override void OnLayoutChanges (LayoutingType layoutType)
{