This commit is contained in:
Lubos Lenco
2022-03-18 16:16:05 +01:00
5 changed files with 23 additions and 8 deletions
+2 -1
View File
@@ -461,8 +461,9 @@ class App {
Krom.setMouseCursor(0); // Arrow
isDragging = false;
}
if (Context.colorPickerCallback != null && mouse.released()) {
if (Context.colorPickerCallback != null && (mouse.released() || mouse.released("right"))) {
Context.colorPickerCallback = null;
Context.selectTool(Context.colorPickerPreviousTool);
}
handleDropPaths();
+1
View File
@@ -66,6 +66,7 @@ class Context {
public static var swatch: TSwatchColor;
public static var pickedColor: TSwatchColor = Project.makeSwatch();
public static var colorPickerCallback: TSwatchColor->Void = null;
public static var colorPickerPreviousTool = ToolBrush;
public static var materialIdPicked = 0;
public static var uvxPicked = 0.0;
public static var uvyPicked = 0.0;
+12 -6
View File
@@ -132,20 +132,26 @@ class TabSwatches {
h.color = Context.swatch.base;
Context.swatch.base = zui.Ext.colorWheel(ui, h, false, null, 11 * ui.t.ELEMENT_H * ui.SCALE(), true, function () {
Context.colorPickerPreviousTool = Context.tool;
Context.selectTool(ToolPicker);
Context.colorPickerCallback = function (color: TSwatchColor) {
Project.raw.swatches[i].base = color.base;
Project.raw.swatches[i] = Project.cloneSwatch(color);
};
});
var hopacity = Id.handle({ value: Context.swatch.opacity });
var hopacity = Id.handle();
hopacity.value = Context.swatch.opacity;
Context.swatch.opacity = ui.slider(hopacity, "Opacity", 0, 1, true);
var hocclusion = Id.handle({ value: Context.swatch.occlusion });
var hocclusion = Id.handle();
hocclusion.value = Context.swatch.occlusion;
Context.swatch.occlusion = ui.slider(hocclusion, "Occlusion", 0, 1, true);
var hroughness = Id.handle({ value: Context.swatch.roughness });
var hroughness = Id.handle();
hroughness.value = Context.swatch.roughness;
Context.swatch.roughness = ui.slider(hroughness, "Roughness", 0, 1, true);
var hmetallic = Id.handle({ value: Context.swatch.metallic });
var hmetallic = Id.handle();
hmetallic.value = Context.swatch.metallic;
Context.swatch.metallic = ui.slider(hmetallic, "Metallic", 0, 1, true);
var hheight = Id.handle({ value: Context.swatch.height });
var hheight = Id.handle();
hheight.value = Context.swatch.height;
Context.swatch.height = ui.slider(hheight, "Height", 0, 1, true);
if (ui.changed || ui.isTyping) UIMenu.keepOpen = true;
+1
View File
@@ -683,6 +683,7 @@ class UINodes {
}
if (nodes.colorPickerCallback != null) {
Context.colorPickerPreviousTool = Context.tool;
Context.selectTool(ToolPicker);
var tmp = nodes.colorPickerCallback;
Context.colorPickerCallback = function(color: TSwatchColor) {
+7 -1
View File
@@ -815,7 +815,7 @@ class UISidebar {
}
// Show picked material next to cursor
if (Context.tool == ToolPicker && Context.pickerSelectMaterial) {
if (Context.tool == ToolPicker && Context.pickerSelectMaterial && Context.colorPickerCallback == null) {
var img = Context.material.imageIcon;
#if kha_opengl
g.drawScaledImage(img, mx + 10, my + 10 + img.height, img.width, -img.height);
@@ -823,6 +823,12 @@ class UISidebar {
g.drawImage(img, mx + 10, my + 10);
#end
}
if (Context.tool == ToolPicker && Context.colorPickerCallback != null) {
var img = Res.get("icons.k");
var rect = Res.tile50(img, ToolPicker, 0);
g.drawSubImage(img, mx + 10, my + 10, rect.x, rect.y, rect.w, rect.h);
}
var cursorImg = Res.get("cursor.k");
var psize = Std.int(cursorImg.width * (Context.brushRadius * Context.brushNodesRadius) * ui.SCALE());