Various fixes [stage]

This commit is contained in:
crschnick 2024-11-15 09:53:03 +00:00
parent 9208e52e83
commit d01403c8a2
7 changed files with 81 additions and 43 deletions

View file

@ -57,7 +57,7 @@ public class BrowserSessionTabsComp extends SimpleComp {
var tabs = createTabPane();
var topBackground = Comp.hspacer().styleClass("top-spacer").createRegion();
leftPadding.subscribe(number -> {
StackPane.setMargin(topBackground, new Insets(0, 0, 0, -number.doubleValue()));
StackPane.setMargin(topBackground, new Insets(0, 0, 0, -number.doubleValue() - 6));
});
var stack = new StackPane(topBackground, tabs);
stack.setAlignment(Pos.TOP_CENTER);

View file

@ -37,6 +37,10 @@ public class BrowserFileListFilterComp extends Comp<BrowserFileListFilterComp.St
button.minWidthProperty().bind(button.heightProperty());
button.setFocusTraversable(true);
InputHelper.onExactKeyCode(text, KeyCode.ESCAPE, true, keyEvent -> {
if (!expanded.get()) {
return;
}
text.clear();
button.fire();
keyEvent.consume();

View file

@ -58,6 +58,7 @@ public class FilterComp extends Comp<CompStructure<CustomTextField>> {
filter.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if (new KeyCodeCombination(KeyCode.ESCAPE).match(event)) {
filter.clear();
filter.getScene().getRoot().requestFocus();
event.consume();
}

View file

@ -4,6 +4,9 @@ import io.xpipe.app.comp.SimpleComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.window.AppMainWindow;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.control.Label;
@ -29,46 +32,6 @@ public class TerminalDockComp extends SimpleComp {
stack.boundsInParentProperty().addListener((observable, oldValue, newValue) -> {
update(stack);
});
var s = AppMainWindow.getInstance().getStage();
s.xProperty().addListener((observable, oldValue, newValue) -> {
update(stack);
});
s.yProperty().addListener((observable, oldValue, newValue) -> {
update(stack);
});
s.widthProperty().addListener((observable, oldValue, newValue) -> {
update(stack);
});
s.heightProperty().addListener((observable, oldValue, newValue) -> {
update(stack);
});
s.iconifiedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
model.onWindowMinimize();
} else {
model.onWindowActivate();
}
});
s.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
model.onFocusGain();
} else {
model.onFocusLost();
}
});
s.addEventFilter(WindowEvent.WINDOW_SHOWN, event -> {
update(stack);
});
s.addEventFilter(WindowEvent.WINDOW_HIDING, event -> {
model.onClose();
});
s.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
model.onFocusGain();
} else {
model.onFocusLost();
}
});
stack.setOnMouseClicked(event -> {
model.clickView();
event.consume();
@ -76,9 +39,78 @@ public class TerminalDockComp extends SimpleComp {
stack.getStyleClass().add("terminal-dock-comp");
stack.setMinWidth(100);
stack.setMinHeight(100);
setupListeners(stack);
return stack;
}
private void setupListeners(StackPane stack) {
var s = AppMainWindow.getInstance().getStage();
var update = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
update(stack);
}
};
s.xProperty().addListener(update);
s.yProperty().addListener(update);
s.widthProperty().addListener(update);
s.heightProperty().addListener(update);
var iconified = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue) {
model.onWindowMinimize();
} else {
model.onWindowActivate();
}
}
};
s.iconifiedProperty().addListener(iconified);
var focus = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue) {
model.onFocusGain();
} else {
model.onFocusLost();
}
}
};
s.focusedProperty().addListener(focus);
var show = new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
update(stack);
}
};
s.addEventFilter(WindowEvent.WINDOW_SHOWN, show);
var hide = new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
update(stack);
}
};
s.addEventFilter(WindowEvent.WINDOW_HIDING, hide);
stack.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (oldValue != null && newValue == null) {
s.xProperty().removeListener(update);
s.yProperty().removeListener(update);
s.widthProperty().removeListener(update);
s.heightProperty().removeListener(update);
s.iconifiedProperty().removeListener(iconified);
s.focusedProperty().removeListener(focus);
s.removeEventFilter(WindowEvent.WINDOW_SHOWN, show);
s.removeEventFilter(WindowEvent.WINDOW_HIDING, hide);
}
});
}
private void update(Region region) {
if (region.getScene() == null || region.getScene().getWindow() == null) {
return;

View file

@ -51,6 +51,7 @@
-fx-background-color: -color-bg-inset;
-fx-border-width: 0 0 1 0;
-fx-border-color: -color-border-default;
-fx-opacity: 0.7;
}
.root:seamless-frame .browser .top-spacer {

View file

@ -16,6 +16,6 @@
.dialog-comp .buttons {
-fx-padding: 10;
-fx-border-color: -color-border-default;
-fx-background-color: -color-bg-overlay;
-fx-background-color: -color-bg-subtle;
-fx-border-width: 1 0 0 0;
}

View file

@ -1 +1 @@
13.0-18
13.0-19