Fixed dialog scrolling
This commit is contained in:
@@ -188,7 +188,8 @@
|
|||||||
up: button,
|
up: button,
|
||||||
over: button-over,
|
over: button-over,
|
||||||
imageDisabledColor: gray,
|
imageDisabledColor: gray,
|
||||||
imageUpColor: white
|
imageUpColor: white,
|
||||||
|
disabled: button-disabled
|
||||||
},
|
},
|
||||||
node: {
|
node: {
|
||||||
up: button-over,
|
up: button-over,
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ public class FileChooser extends FloatingDialog{
|
|||||||
private Predicate<FileHandle> filter;
|
private Predicate<FileHandle> filter;
|
||||||
private Consumer<FileHandle> selectListener;
|
private Consumer<FileHandle> selectListener;
|
||||||
private boolean open;
|
private boolean open;
|
||||||
private int lastWidth = Core.graphics.getWidth(), lastHeight = Core.graphics.getHeight();
|
|
||||||
|
|
||||||
public static final Predicate<String> pngFiles = str -> str.equals("png");
|
public static final Predicate<String> pngFiles = str -> str.equals("png");
|
||||||
public static final Predicate<String> anyMapFiles = str -> str.equals(oldMapExtension) || str.equals(mapExtension);
|
public static final Predicate<String> anyMapFiles = str -> str.equals(oldMapExtension) || str.equals(mapExtension);
|
||||||
@@ -44,12 +43,14 @@ public class FileChooser extends FloatingDialog{
|
|||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.selectListener = result;
|
this.selectListener = result;
|
||||||
|
|
||||||
update(() -> {
|
onResize(() -> {
|
||||||
if(Core.graphics.getWidth() != lastWidth || Core.graphics.getHeight() != lastHeight){
|
cont.clear();
|
||||||
updateFiles(false);
|
setupWidgets();
|
||||||
lastHeight = Core.graphics.getHeight();
|
});
|
||||||
lastWidth = Core.graphics.getWidth();
|
|
||||||
}
|
shown(() -> {
|
||||||
|
cont.clear();
|
||||||
|
setupWidgets();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +122,9 @@ public class FileChooser extends FloatingDialog{
|
|||||||
forward.resizeImage(isize);
|
forward.resizeImage(isize);
|
||||||
|
|
||||||
forward.clicked(() -> stack.forward());
|
forward.clicked(() -> stack.forward());
|
||||||
|
|
||||||
back.clicked(() -> stack.back());
|
back.clicked(() -> stack.back());
|
||||||
|
forward.setDisabled(() -> !stack.canForward());
|
||||||
|
back.setDisabled(() -> !stack.canBack());
|
||||||
|
|
||||||
ImageButton home = new ImageButton("icon-home");
|
ImageButton home = new ImageButton("icon-home");
|
||||||
home.resizeImage(isize);
|
home.resizeImage(isize);
|
||||||
@@ -206,7 +208,7 @@ public class FileChooser extends FloatingDialog{
|
|||||||
|
|
||||||
//macs are confined to the Downloads/ directory
|
//macs are confined to the Downloads/ directory
|
||||||
if(!OS.isMac){
|
if(!OS.isMac){
|
||||||
Image upimage = new Image("icon-folder-parent");
|
Image upimage = new Image("icon-folder-parent-small");
|
||||||
TextButton upbutton = new TextButton(".." + directory.toString(), "clear-toggle");
|
TextButton upbutton = new TextButton(".." + directory.toString(), "clear-toggle");
|
||||||
upbutton.clicked(() -> {
|
upbutton.clicked(() -> {
|
||||||
directory = directory.parent();
|
directory = directory.parent();
|
||||||
@@ -214,7 +216,7 @@ public class FileChooser extends FloatingDialog{
|
|||||||
updateFiles(true);
|
updateFiles(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
upbutton.left().add(upimage).padRight(4f).size(iconsize);
|
upbutton.left().add(upimage).padRight(4f).size(iconsizesmall).padLeft(4);
|
||||||
upbutton.getLabel().setAlignment(Align.left);
|
upbutton.getLabel().setAlignment(Align.left);
|
||||||
upbutton.getCells().reverse();
|
upbutton.getCells().reverse();
|
||||||
|
|
||||||
@@ -248,9 +250,9 @@ public class FileChooser extends FloatingDialog{
|
|||||||
button.setChecked(filename.equals(filefield.getText()));
|
button.setChecked(filename.equals(filefield.getText()));
|
||||||
});
|
});
|
||||||
|
|
||||||
Image image = new Image(file.isDirectory() ? "icon-folder" : "icon-file-text");
|
Image image = new Image(file.isDirectory() ? "icon-folder-small" : "icon-file-text-small");
|
||||||
|
|
||||||
button.add(image).padRight(4f).size(iconsize);
|
button.add(image).padRight(4f).padLeft(4).size(iconsizesmall);
|
||||||
button.getCells().reverse();
|
button.getCells().reverse();
|
||||||
files.top().left().add(button).align(Align.topLeft).fillX().expandX()
|
files.top().left().add(button).align(Align.topLeft).fillX().expandX()
|
||||||
.height(50).pad(2).padTop(0).padBottom(0).colspan(2);
|
.height(50).pad(2).padTop(0).padBottom(0).colspan(2);
|
||||||
@@ -273,17 +275,6 @@ public class FileChooser extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog show(){
|
|
||||||
Time.runTask(2f, () -> {
|
|
||||||
cont.clear();
|
|
||||||
setupWidgets();
|
|
||||||
super.show();
|
|
||||||
Core.scene.setScrollFocus(pane);
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FileHistory{
|
public class FileHistory{
|
||||||
private Array<FileHandle> history = new Array<>();
|
private Array<FileHandle> history = new Array<>();
|
||||||
private int index;
|
private int index;
|
||||||
|
|||||||
@@ -39,18 +39,6 @@ public class FloatingDialog extends Dialog{
|
|||||||
state.set(State.paused);
|
state.set(State.paused);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
boolean[] done = {false};
|
|
||||||
|
|
||||||
shown(() -> Core.app.post(() ->
|
|
||||||
forEach(child -> {
|
|
||||||
if(done[0]) return;
|
|
||||||
|
|
||||||
if(child instanceof ScrollPane){
|
|
||||||
Core.scene.setScrollFocus(child);
|
|
||||||
done[0] = true;
|
|
||||||
}
|
|
||||||
})));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FloatingDialog(String title){
|
public FloatingDialog(String title){
|
||||||
@@ -59,8 +47,9 @@ public class FloatingDialog extends Dialog{
|
|||||||
|
|
||||||
protected void onResize(Runnable run){
|
protected void onResize(Runnable run){
|
||||||
Events.on(ResizeEvent.class, event -> {
|
Events.on(ResizeEvent.class, event -> {
|
||||||
if(isShown()){
|
if(isShown() && Core.scene.getDialog() == this){
|
||||||
run.run();
|
run.run();
|
||||||
|
updateScrollFocus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user