Resizable ui panels

This commit is contained in:
luboslenco
2019-09-10 11:39:55 +02:00
parent 2caf6eebac
commit a9bbea7a17
5 changed files with 32 additions and 17 deletions
+2 -1
View File
@@ -14,5 +14,6 @@
"window_mode": 0,
"window_resizable": true,
"window_scale": 1.0,
"window_vsync": true
"window_vsync": true,
"plugins": []
}
+3 -3
View File
@@ -50,7 +50,7 @@ class TabLayers {
if (Context.layer == l) {
if (Context.layerIsMask) {
ui.rect(ui._windowW / 100 * 24 - 2, 0, ui._windowW / 100 * 16, step * 2, ui.t.HIGHLIGHT_COL, 2);
ui.rect(ui._windowW / 100 * 24 - 2, 0, step * 2, step * 2, ui.t.HIGHLIGHT_COL, 2);
}
else {
ui.fill(checkw, 0, (ui._windowW / ui.SCALE - 2) - checkw, step * 2, ui.t.HIGHLIGHT_COL);
@@ -79,7 +79,7 @@ class TabLayers {
#end
ui._y += 3;
var state = ui.image(l.material_mask == null ? l.texpaint_preview : l.material_mask.imageIcon);
var state = ui.image(l.material_mask == null ? l.texpaint_preview : l.material_mask.imageIcon, 0xffffffff, (ui.t.ELEMENT_H - 3) * 2);
ui._y -= 3;
#if (kha_opengl || kha_webgl)
@@ -102,7 +102,7 @@ class TabLayers {
if (l.texpaint_mask != null) {
ui._y += 3;
var state = ui.image(l.texpaint_mask_preview);
var state = ui.image(l.texpaint_mask_preview, 0xffffffff, (ui.t.ELEMENT_H - 3) * 2);
ui._y -= 3;
if (ui.isHovered) {
ui.tooltipImage(l.texpaint_mask_preview);
+7 -4
View File
@@ -72,14 +72,17 @@ class TabMaterials {
}
else if (ui.isHovered) ui.tooltip("Show Node Editor (TAB)");
for (row in 0...Std.int(Math.ceil(materials.length / 5))) {
ui.row([1/5,1/5,1/5,1/5,1/5]);
var slotw = ui.SCALE > 1 ? 102 : 51;
var num = Std.int(UITrait.inst.windowW / slotw);
for (row in 0...Std.int(Math.ceil(materials.length / num))) {
ui.row([for (i in 0...num) 1/num]);
if (row > 0) ui._y += 6;
for (j in 0...5) {
for (j in 0...num) {
var imgw = ui.SCALE > 1 ? 100 : 50;
var i = j + row * 5;
var i = j + row * num;
if (i >= materials.length) {
@:privateAccess ui.endElement(imgw);
continue;
+9 -5
View File
@@ -27,12 +27,16 @@ class TabTextures {
if (ui.button("2D View")) UITrait.inst.show2DView(1);
if (Project.assets.length > 0) {
var slotw = ui.SCALE > 1 ? 102 : 51;
var num = Std.int(UITrait.inst.windowW / slotw);
for (i in 0...Project.assets.length) {
// Align into 5 items per row
if (i % 5 == 0) {
// Align into rows
if (i % num == 0) {
ui._y += ui.ELEMENT_OFFSET() * 1.5;
ui.row([1/5, 1/5, 1/5, 1/5, 1/5]);
ui.row([for (i in 0...num) 1/num]);
}
var asset = Project.assets[i];
@@ -81,8 +85,8 @@ class TabTextures {
}
// Fill in unused row space
if (Project.assets.length % 5 > 0) {
for (i in 0...5 - (Project.assets.length % 5)) {
if (Project.assets.length % num > 0) {
for (i in 0...num - (Project.assets.length % num)) {
@:privateAccess ui.endElement(ui._w);
}
}
+11 -4
View File
@@ -585,21 +585,28 @@ class UITrait {
if (borderHandle == UINodes.inst.hwnd || borderHandle == UIView2D.inst.hwnd) {
UINodes.inst.defaultWindowW -= Std.int(mouse.movementX);
if (UINodes.inst.defaultWindowW < 32) UINodes.inst.defaultWindowW = 32;
else if (UINodes.inst.defaultWindowW > kha.System.windowWidth() * 0.7) UINodes.inst.defaultWindowW = Std.int(kha.System.windowWidth() * 0.7);
}
else {
if (borderStarted == 0) {
defaultWindowW -= Std.int(mouse.movementX);
if (defaultWindowW < 32) defaultWindowW = 32;
else if (defaultWindowW > kha.System.windowWidth() - 32) defaultWindowW = kha.System.windowWidth() - 32;
windowW = Std.int(defaultWindowW * Config.raw.window_scale);
}
else {
var my = Std.int(mouse.movementY);
if (borderHandle == hwnd1 && borderStarted == 2) {
tabh += Std.int(mouse.movementY);
tabh1 -= Std.int(mouse.movementY);
if (tabh + my > 32 && tabh1 - my > 32) {
tabh += my;
tabh1 -= my;
}
}
else if (borderHandle == hwnd2 && borderStarted == 2) {
tabh1 += Std.int(mouse.movementY);
tabh2 -= Std.int(mouse.movementY);
if (tabh1 + my > 32 && tabh2 - my > 32) {
tabh1 += my;
tabh2 -= my;
}
}
}
}