Improve context menu align

This commit is contained in:
luboslenco
2020-02-01 12:39:23 +01:00
parent b4a62ed459
commit 5c8d85cdec
9 changed files with 36 additions and 34 deletions
+1 -2
View File
@@ -145,13 +145,12 @@ class BoxExport {
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, @:privateAccess ui._w / ui.SCALE(), ui.t.ELEMENT_H * 2, ui.t.SEPARATOR_COL);
ui.text(t.name, Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Delete", Left)) {
preset.textures.remove(t);
savePreset();
}
});
}, 2);
}
var hr = htex.nest(0);
+2 -4
View File
@@ -75,7 +75,6 @@ class BoxPreferences {
ui.row([0.5]);
if (ui.button("Restore")) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 2, ui.t.SEPARATOR_COL);
ui.text("Restore defaults?", Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Confirm", Left)) {
ui.t.ELEMENT_H = App.ELEMENT_H;
@@ -85,7 +84,7 @@ class BoxPreferences {
filesPlugin = null;
filesKeymap = null;
}
});
}, 2);
}
}
if (ui.tab(htab, "Usage", true)) {
@@ -307,7 +306,6 @@ plugin.drawUI = function(ui) {
}
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 5, ui.t.SEPARATOR_COL);
ui.text(f, Right, ui.t.HIGHLIGHT_COL);
var path = Path.data() + Path.sep + "plugins" + Path.sep + f;
if (ui.button("Edit in Text Editor", Left)) {
@@ -335,7 +333,7 @@ plugin.drawUI = function(ui) {
filesPlugin.remove(f);
File.delete(path);
}
});
}, 5);
}
}
}
+1 -2
View File
@@ -56,13 +56,12 @@ class TabBrowser {
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 2, ui.t.SEPARATOR_COL);
ui.text(folder, Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Delete", Left)) {
Config.raw.bookmarks.remove(b);
Config.save();
}
});
}, 2);
}
}
+1 -2
View File
@@ -71,7 +71,6 @@ class TabBrushes {
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui: Zui) {
//var b = Project.brushes[i];
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 2, ui.t.SEPARATOR_COL);
ui.text(Project.brushes[i].canvas.name, Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Delete", Left) && Project.brushes.length > 1) {
@@ -79,7 +78,7 @@ class TabBrushes {
Project.brushes.splice(i, 1);
UITrait.inst.hwnd1.redraws = 2;
}
});
}, 2);
}
if (ui.isHovered) ui.tooltipImage(imgFull);
}
+17 -15
View File
@@ -20,14 +20,14 @@ class TabLayers {
if (ui.button("New")) {
// UIMenu.draw(function(ui:Zui) {
// ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 6, ui.t.SEPARATOR_COL);
// ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.SEPARATOR_COL);
// ui.text("New", Right, ui.t.HIGHLIGHT_COL);
// if (ui.button("Paint Layer", Left)) {}
// if (ui.button("Fill Layer", Left, "Material 1")) {}
// if (ui.button("Black Mask", Left, "Layer 1")) {}
// if (ui.button("White Mask", Left, "Layer 1")) {}
// if (ui.button("Folder", Left)) {}
// });
// }, 6);
Layers.newLayer();
History.newLayer();
@@ -188,7 +188,6 @@ class TabLayers {
}
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 3, ui.t.SEPARATOR_COL);
ui.text(l.name + " Mask", Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Delete", Left)) {
Context.setLayer(l);
@@ -208,7 +207,7 @@ class TabLayers {
}
iron.App.notifyOnRender(makeApply);
}
});
}, 3);
}
if (state == State.Started) {
Context.setLayer(l, true);
@@ -238,17 +237,20 @@ class TabLayers {
}
if (contextMenu) {
var add = l.material_mask != null ? 1 : 0;
var menuElements = 0;
if (l.getChildren() != null) {
menuElements = 6;
}
else if (l == Project.layers[0]) {
menuElements = (12 + add);
}
else {
menuElements = (20 + add);
}
UIMenu.draw(function(ui: Zui) {
var add = l.material_mask != null ? 1 : 0;
if (l.getChildren() != null) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 6, ui.t.SEPARATOR_COL);
}
else if (l == Project.layers[0]) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * (12 + add), ui.t.SEPARATOR_COL);
}
else {
ui.fill(0, 0, ui._w, ui.t.ELEMENT_H * (20 + add), ui.t.SEPARATOR_COL);
}
ui.text(l.name, Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Export", Left)) BoxExport.showTextures();
@@ -451,7 +453,7 @@ class TabLayers {
UIMenu.keepOpen = true;
}
}
});
}, menuElements);
}
if (i == 0 || l.getChildren() != null) {
+2 -3
View File
@@ -113,10 +113,9 @@ class TabMaterials {
UITrait.inst.selectTime = Time.time();
}
if (ui.isHovered && ui.inputReleasedR) {
var add = materials.length > 1 ? 1 : 0;
UIMenu.draw(function(ui: Zui) {
var m = materials[i];
var add = materials.length > 1 ? 1 : 0;
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * (13 + add), ui.t.SEPARATOR_COL);
ui.text(materials[i].canvas.name, Right, ui.t.HIGHLIGHT_COL);
if (ui.button("To Fill Layer", Left)) {
@@ -181,7 +180,7 @@ class TabMaterials {
MaterialParser.parsePaintMaterial();
UIMenu.keepOpen = true;
}
});
}, 13 + add);
}
if (ui.isHovered) ui.tooltipImage(imgFull);
+1 -2
View File
@@ -17,7 +17,6 @@ class TabMeshes {
if (ui.button("Tools...")) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 6, ui.t.SEPARATOR_COL);
ui.text("Tools", Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Flip Normals", Left)) {
MeshUtil.flipNormals();
@@ -39,7 +38,7 @@ class TabMeshes {
MeshUtil.swapAxis(0, 1);
Context.ddirty = 2;
}
});
}, 6);
}
if (ui.panel(Id.handle({selected: false}), "Scene", true)) {
+1 -2
View File
@@ -82,7 +82,6 @@ class TabTextures {
if (ui.isHovered && ui.inputReleasedR) {
UIMenu.draw(function(ui: Zui) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * 4, ui.t.SEPARATOR_COL);
ui.text(asset.name, Right, ui.t.HIGHLIGHT_COL);
if (ui.button("Export", Left)) {
UIFiles.show("png", true, function(path: String) {
@@ -119,7 +118,7 @@ class TabTextures {
UITrait.inst.hwnd1.redraws = 2;
});
}
});
}, 4);
}
}
}
+10 -2
View File
@@ -28,6 +28,7 @@ class UIMenu {
public static var menuCategory = 0;
public static var menuX = 0;
public static var menuY = 0;
public static var menuElements = 0;
public static var keepOpen = false;
public static var menuCommands: Zui->Void = null;
static var changeStarted = false;
@@ -50,6 +51,7 @@ class UIMenu {
ui.beginRegion(g, menuX, menuY, menuW);
if (menuCommands != null) {
ui.fill(0, 0, ui._w / ui.SCALE(), ui.t.ELEMENT_H * menuElements, ui.t.SEPARATOR_COL);
menuCommands(ui);
}
else {
@@ -416,14 +418,20 @@ class UIMenu {
}
}
public static function draw(commands: Zui->Void = null, x = -1, y = -1) {
public static function draw(commands: Zui->Void = null, elements: Int, x = -1, y = -1) {
show = true;
menuCommands = commands;
menuElements = elements;
menuX = x > -1 ? x : Std.int(Input.getMouse().x);
menuY = y > -1 ? y : Std.int(Input.getMouse().y);
var menuW = App.uimenu.ELEMENT_W() * 1.7;
var menuW = App.uimenu.ELEMENT_W() * 2.0;
if (menuX + menuW > System.windowWidth()) {
menuX = Std.int(System.windowWidth() - menuW);
}
var menuH = menuElements * 28; // ui.t.ELEMENT_H
if (menuY + menuH > System.windowHeight()) {
menuY = System.windowHeight() - menuH;
menuX += 1; // Move out of mouse focus
}
}
}