mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-19 00:26:27 +01:00
style stuff
This commit is contained in:
parent
08f157d2c4
commit
e95fd7b9e2
@ -3,7 +3,9 @@ package gearth;
|
|||||||
import gearth.misc.AdminValidator;
|
import gearth.misc.AdminValidator;
|
||||||
import gearth.misc.Cacher;
|
import gearth.misc.Cacher;
|
||||||
import gearth.misc.UpdateChecker;
|
import gearth.misc.UpdateChecker;
|
||||||
|
import gearth.misc.listenerpattern.Observable;
|
||||||
import gearth.ui.GEarthController;
|
import gearth.ui.GEarthController;
|
||||||
|
import gearth.ui.subforms.logger.loggerdisplays.PacketLogger;
|
||||||
import gearth.ui.themes.Theme;
|
import gearth.ui.themes.Theme;
|
||||||
import gearth.ui.themes.ThemeFactory;
|
import gearth.ui.themes.ThemeFactory;
|
||||||
import gearth.ui.titlebar.TitleBarConfig;
|
import gearth.ui.titlebar.TitleBarConfig;
|
||||||
@ -17,12 +19,15 @@ import javafx.scene.image.Image;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.StageStyle;
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class GEarth extends Application {
|
public class GEarth extends Application {
|
||||||
|
|
||||||
public static GEarth main;
|
public static GEarth main;
|
||||||
public static String version = "1.5.1";
|
public static String version = "1.5.1";
|
||||||
public static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest";
|
public static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest";
|
||||||
public static Theme theme;
|
public static Theme theme;
|
||||||
|
public static Observable<Consumer<Theme>> themeObservable = new Observable<>();
|
||||||
|
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private GEarthController controller;
|
private GEarthController controller;
|
||||||
@ -54,6 +59,16 @@ public class GEarth extends Application {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean displayMinimizeButton() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean allowResizing() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCloseClicked() {
|
public void onCloseClicked() {
|
||||||
closeGEarth();
|
closeGEarth();
|
||||||
@ -94,9 +109,11 @@ public class GEarth extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setGearthTheme(Theme theme) {
|
private void setGearthTheme(Theme theme) {
|
||||||
|
themeObservable.fireEvent(t -> t.accept(theme));
|
||||||
GEarth.theme = theme;
|
GEarth.theme = theme;
|
||||||
Theme defaultTheme = ThemeFactory.getDefaultTheme();
|
Theme defaultTheme = ThemeFactory.getDefaultTheme();
|
||||||
|
|
||||||
|
// Platform.runLater(() -> {
|
||||||
stage.getScene().getStylesheets().clear();
|
stage.getScene().getStylesheets().clear();
|
||||||
stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", theme.internalName())).toExternalForm());
|
stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", theme.internalName())).toExternalForm());
|
||||||
|
|
||||||
@ -111,6 +128,8 @@ public class GEarth extends Application {
|
|||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
controller.infoController.version.setText(stage.getTitle());
|
controller.infoController.version.setText(stage.getTitle());
|
||||||
|
// });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] args;
|
public static String[] args;
|
||||||
@ -139,4 +158,8 @@ public class GEarth extends Application {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Observable<Consumer<Theme>> getThemeObservable() {
|
||||||
|
return themeObservable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package gearth.misc;
|
package gearth.misc;
|
||||||
|
|
||||||
import gearth.GEarth;
|
|
||||||
import gearth.ui.titlebar.DefaultTitleBarConfig;
|
|
||||||
import gearth.ui.titlebar.TitleBarController;
|
import gearth.ui.titlebar.TitleBarController;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.InvalidationListener;
|
|
||||||
import javafx.beans.Observable;
|
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.ButtonType;
|
import javafx.scene.control.ButtonType;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
@ -51,35 +46,13 @@ public class AdminValidator {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
if (!AdminValidator.isAdmin()) {
|
if (!AdminValidator.isAdmin()) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
Alert alert = new Alert(Alert.AlertType.WARNING, "G-Earth needs admin privileges in order to work on Flash, please restart G-Earth with admin permissions unless you're using Unity", ButtonType.OK);
|
Alert alert = new Alert(Alert.AlertType.WARNING, "", ButtonType.OK);
|
||||||
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
|
alert.getDialogPane().setContent(new Label("G-Earth needs admin privileges in order to work on Flash,\nplease restart G-Earth with admin permissions unless\nyou're using Unity"));
|
||||||
stage.getIcons().add(new Image(GEarth.class.getResourceAsStream("/gearth/ui/themes/G-Earth/logoSmall.png")));
|
try {
|
||||||
stage.getScene().getStylesheets().add(GEarth.class.getResource(String.format("/gearth/ui/themes/%s/styling.css", GEarth.theme.internalName())).toExternalForm());
|
TitleBarController.create(alert).showAlert();
|
||||||
// try {
|
} catch (IOException e) {
|
||||||
// TitleBarController.create(stage, new DefaultTitleBarConfig(stage));
|
e.printStackTrace();
|
||||||
// } catch (IOException e) {
|
}
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// alert.getDialogPane().setMaxHeight(-1);
|
|
||||||
// alert.getDialogPane().setMinHeight(200);
|
|
||||||
// alert.getDialogPane()
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// boolean[] once = new boolean[]{false};
|
|
||||||
// stage.heightProperty().addListener(observable -> {
|
|
||||||
// if (!once[0]) {
|
|
||||||
// once[0] = true;
|
|
||||||
// stage.setMinHeight(alert.getDialogPane().getHeight() + 25);
|
|
||||||
// stage.setHeight(alert.getDialogPane().getHeight() + 25);
|
|
||||||
// stage.setMaxHeight(alert.getDialogPane().getHeight() + 25);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
|
|
||||||
// stage.setHeight(stage.getHeight() + 25);
|
|
||||||
// stage.setResizable(false);
|
|
||||||
// stage.sizeToScene();x
|
|
||||||
stage.show();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package gearth.services.internal_extensions.uilogger;
|
|||||||
|
|
||||||
import gearth.GEarth;
|
import gearth.GEarth;
|
||||||
import gearth.extensions.InternalExtensionFormLauncher;
|
import gearth.extensions.InternalExtensionFormLauncher;
|
||||||
|
import gearth.ui.titlebar.DefaultTitleBarConfig;
|
||||||
|
import gearth.ui.titlebar.TitleBarController;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
@ -30,6 +32,13 @@ public class UiLoggerLauncher extends InternalExtensionFormLauncher<UiLogger> {
|
|||||||
controller.setStage(stage);
|
controller.setStage(stage);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
|
// TitleBarController.create(stage, new DefaultTitleBarConfig(stage) {
|
||||||
|
// @Override
|
||||||
|
// public void onCloseClicked() {
|
||||||
|
// stage.hide();
|
||||||
|
//// uiLogger.onHide();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
return uiLogger;
|
return uiLogger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import gearth.protocol.connection.proxy.ProxyProviderFactory;
|
|||||||
import gearth.protocol.connection.proxy.SocksConfiguration;
|
import gearth.protocol.connection.proxy.SocksConfiguration;
|
||||||
import gearth.ui.subforms.logger.loggerdisplays.PacketLoggerFactory;
|
import gearth.ui.subforms.logger.loggerdisplays.PacketLoggerFactory;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import gearth.protocol.HConnection;
|
import gearth.protocol.HConnection;
|
||||||
import gearth.ui.subforms.connection.ConnectionController;
|
import gearth.ui.subforms.connection.ConnectionController;
|
||||||
|
@ -2,6 +2,7 @@ package gearth.ui.subforms.extensions.logger;
|
|||||||
|
|
||||||
import gearth.GEarth;
|
import gearth.GEarth;
|
||||||
import gearth.ui.titlebar.DefaultTitleBarConfig;
|
import gearth.ui.titlebar.DefaultTitleBarConfig;
|
||||||
|
import gearth.ui.titlebar.GEarthThemedTitleBarConfig;
|
||||||
import gearth.ui.titlebar.TitleBarController;
|
import gearth.ui.titlebar.TitleBarController;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
@ -49,7 +50,7 @@ public class ExtensionLogger {
|
|||||||
controller.setStage(stage);
|
controller.setStage(stage);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
TitleBarController.create(stage, new DefaultTitleBarConfig(stage) {
|
TitleBarController.create(stage, new GEarthThemedTitleBarConfig(stage) {
|
||||||
@Override
|
@Override
|
||||||
public void onCloseClicked() {
|
public void onCloseClicked() {
|
||||||
stage.hide();
|
stage.hide();
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package gearth.ui.subforms.info;
|
package gearth.ui.subforms.info;
|
||||||
|
|
||||||
import gearth.GEarth;
|
import gearth.GEarth;
|
||||||
|
import gearth.ui.titlebar.TitleBarController;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import gearth.ui.SubForm;
|
import gearth.ui.SubForm;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.web.WebView;
|
import javafx.scene.web.WebView;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
*/
|
*/
|
||||||
@ -53,15 +57,20 @@ public class InfoController extends SubForm {
|
|||||||
Alert alert = new Alert(Alert.AlertType.INFORMATION, "Donate Bitcoins", ButtonType.OK);
|
Alert alert = new Alert(Alert.AlertType.INFORMATION, "Donate Bitcoins", ButtonType.OK);
|
||||||
alert.setHeaderText("Donate Bitcoins");
|
alert.setHeaderText("Donate Bitcoins");
|
||||||
|
|
||||||
WebView webView = new WebView();
|
VBox test = new VBox();
|
||||||
webView.getEngine().loadContent("<html>Bitcoin public address:<br><br>" +
|
test.getChildren().add(new Label("Bitcoin public address:"));
|
||||||
"<textarea>" + pubkey +"</textarea>" +
|
TextArea pubText = new TextArea(pubkey);
|
||||||
"</html>");
|
pubText.setPrefHeight(28);
|
||||||
webView.setPrefSize(200, 100);
|
pubText.setMaxWidth(250);
|
||||||
|
test.getChildren().add(pubText);
|
||||||
|
|
||||||
alert.setResizable(false);
|
alert.setResizable(false);
|
||||||
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
|
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
|
||||||
alert.getDialogPane().setContent(webView);
|
alert.getDialogPane().setContent(test);
|
||||||
alert.show();
|
try {
|
||||||
|
TitleBarController.create(alert).showAlert();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package gearth.ui.titlebar;
|
|||||||
import gearth.GEarth;
|
import gearth.GEarth;
|
||||||
import gearth.ui.themes.Theme;
|
import gearth.ui.themes.Theme;
|
||||||
import gearth.ui.themes.ThemeFactory;
|
import gearth.ui.themes.ThemeFactory;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
@ -15,16 +16,30 @@ public class DefaultTitleBarConfig implements TitleBarConfig {
|
|||||||
|
|
||||||
|
|
||||||
public DefaultTitleBarConfig(Stage stage) {
|
public DefaultTitleBarConfig(Stage stage) {
|
||||||
|
this(stage, ThemeFactory.getDefaultTheme());
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultTitleBarConfig(Stage stage, Theme theme) {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
currentTheme = ThemeFactory.getDefaultTheme();
|
currentTheme = theme;
|
||||||
setTheme(currentTheme);
|
setTheme(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean displayThemePicker() {
|
public boolean displayThemePicker() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean displayMinimizeButton() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean allowResizing() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCloseClicked() {
|
public void onCloseClicked() {
|
||||||
stage.close();
|
stage.close();
|
||||||
@ -38,6 +53,7 @@ public class DefaultTitleBarConfig implements TitleBarConfig {
|
|||||||
@Override
|
@Override
|
||||||
public void setTheme(Theme theme) {
|
public void setTheme(Theme theme) {
|
||||||
currentTheme = theme;
|
currentTheme = theme;
|
||||||
|
Platform.runLater(() -> {
|
||||||
Theme defaultTheme = ThemeFactory.getDefaultTheme();
|
Theme defaultTheme = ThemeFactory.getDefaultTheme();
|
||||||
if (currentStylesheet != null) {
|
if (currentStylesheet != null) {
|
||||||
stage.getScene().getStylesheets().remove(currentStylesheet);
|
stage.getScene().getStylesheets().remove(currentStylesheet);
|
||||||
@ -47,6 +63,8 @@ public class DefaultTitleBarConfig implements TitleBarConfig {
|
|||||||
|
|
||||||
stage.getIcons().clear();
|
stage.getIcons().clear();
|
||||||
stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", theme.overridesLogo() ? theme.internalName() : defaultTheme.internalName()))));
|
stage.getIcons().add(new Image(GEarth.class.getResourceAsStream(String.format("/gearth/ui/themes/%s/logoSmall.png", theme.overridesLogo() ? theme.internalName() : defaultTheme.internalName()))));
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package gearth.ui.titlebar;
|
||||||
|
|
||||||
|
import gearth.GEarth;
|
||||||
|
import gearth.ui.themes.Theme;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class GEarthThemedTitleBarConfig extends DefaultTitleBarConfig {
|
||||||
|
|
||||||
|
public GEarthThemedTitleBarConfig(Stage stage) {
|
||||||
|
super(stage, GEarth.theme);
|
||||||
|
GEarth.themeObservable.addListener(this::setTheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean displayThemePicker() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,8 @@ import gearth.ui.themes.Theme;
|
|||||||
public interface TitleBarConfig {
|
public interface TitleBarConfig {
|
||||||
|
|
||||||
boolean displayThemePicker();
|
boolean displayThemePicker();
|
||||||
|
boolean displayMinimizeButton();
|
||||||
|
// boolean allowResizing();
|
||||||
|
|
||||||
void onCloseClicked();
|
void onCloseClicked();
|
||||||
void onMinimizeClicked();
|
void onMinimizeClicked();
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
package gearth.ui.titlebar;
|
package gearth.ui.titlebar;
|
||||||
|
|
||||||
import gearth.GEarth;
|
import gearth.GEarth;
|
||||||
import gearth.ui.themes.Theme;
|
|
||||||
import gearth.ui.themes.ThemeFactory;
|
import gearth.ui.themes.ThemeFactory;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.beans.InvalidationListener;
|
import javafx.beans.InvalidationListener;
|
||||||
import javafx.beans.Observable;
|
import javafx.beans.Observable;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Cursor;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
@ -24,24 +28,54 @@ public class TitleBarController {
|
|||||||
public Label titleLabel;
|
public Label titleLabel;
|
||||||
public Pane titleBar;
|
public Pane titleBar;
|
||||||
public ImageView titleIcon;
|
public ImageView titleIcon;
|
||||||
|
public ImageView themeBtn;
|
||||||
|
public ImageView minimizeBtn;
|
||||||
|
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private TitleBarConfig config;
|
private TitleBarConfig config;
|
||||||
|
|
||||||
public static TitleBarController create(Stage stage, TitleBarConfig config) throws IOException {
|
public static TitleBarController create(Stage stage, TitleBarConfig config) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml"));
|
FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml"));
|
||||||
Parent root = loader.load();
|
Parent titleBar = loader.load();
|
||||||
|
TitleBarController controller = initNewController(loader, stage, config);
|
||||||
|
|
||||||
|
VBox newParent = new VBox(titleBar, stage.getScene().getRoot());
|
||||||
|
newParent.setId("titlebar-main-container");
|
||||||
|
stage.getScene().setRoot(newParent);
|
||||||
|
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TitleBarController create(Alert alert) throws IOException {
|
||||||
|
|
||||||
|
FXMLLoader loader = new FXMLLoader(TitleBarController.class.getResource("Titlebar.fxml"));
|
||||||
|
Parent titleBar = loader.load();
|
||||||
|
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
|
||||||
|
|
||||||
|
TitleBarConfig config = new GEarthThemedTitleBarConfig(stage) {
|
||||||
|
@Override
|
||||||
|
public boolean displayMinimizeButton() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
TitleBarController controller = initNewController(loader, stage, config);
|
||||||
|
|
||||||
|
Parent parent = alert.getDialogPane().getScene().getRoot();
|
||||||
|
VBox newParent = new VBox(titleBar, parent);
|
||||||
|
newParent.setId("titlebar-main-container");
|
||||||
|
stage.setScene(new Scene(newParent));
|
||||||
|
stage.getScene().setFill(Color.TRANSPARENT);
|
||||||
|
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TitleBarController initNewController(FXMLLoader loader, Stage stage, TitleBarConfig config) throws IOException {
|
||||||
TitleBarController controller = loader.getController();
|
TitleBarController controller = loader.getController();
|
||||||
|
|
||||||
controller.stage = stage;
|
controller.stage = stage;
|
||||||
controller.config = config;
|
controller.config = config;
|
||||||
stage.initStyle(StageStyle.TRANSPARENT);
|
stage.initStyle(StageStyle.TRANSPARENT);
|
||||||
|
stage.getScene().setFill(Color.TRANSPARENT);
|
||||||
Parent parent = stage.getScene().getRoot();
|
|
||||||
|
|
||||||
VBox newParent = new VBox(root, parent);
|
|
||||||
newParent.setId("titlebar-main-container");
|
|
||||||
stage.getScene().setRoot(newParent);
|
|
||||||
parent.getScene().setFill(Color.TRANSPARENT);
|
|
||||||
|
|
||||||
stage.titleProperty().addListener((i) -> controller.setTitle(stage.getTitle()));
|
stage.titleProperty().addListener((i) -> controller.setTitle(stage.getTitle()));
|
||||||
controller.setTitle(stage.getTitle());
|
controller.setTitle(stage.getTitle());
|
||||||
@ -49,17 +83,23 @@ public class TitleBarController {
|
|||||||
stage.getIcons().addListener((InvalidationListener) observable -> controller.updateIcon());
|
stage.getIcons().addListener((InvalidationListener) observable -> controller.updateIcon());
|
||||||
controller.updateIcon();
|
controller.updateIcon();
|
||||||
|
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
controller.themeBtn.setVisible(config.displayThemePicker());
|
||||||
|
if (!config.displayMinimizeButton()) {
|
||||||
|
((GridPane) controller.minimizeBtn.getParent()).getChildren().remove(controller.minimizeBtn);
|
||||||
|
}
|
||||||
|
});
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateIcon() {
|
public void updateIcon() {
|
||||||
titleIcon.setImage(stage.getIcons().size() > 0 ? stage.getIcons().get(0) :
|
Platform.runLater(() -> titleIcon.setImage(stage.getIcons().size() > 0 ? stage.getIcons().get(0) :
|
||||||
new Image(GEarth.class.getResourceAsStream(
|
new Image(GEarth.class.getResourceAsStream(
|
||||||
String.format("/gearth/ui/themes/%s/logoSmall.png", ThemeFactory.getDefaultTheme().internalName()))));
|
String.format("/gearth/ui/themes/%s/logoSmall.png", ThemeFactory.getDefaultTheme().internalName())))));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
titleLabel.setText(title);
|
Platform.runLater(() -> titleLabel.setText(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -72,20 +112,33 @@ public class TitleBarController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double xOffset, yOffset;
|
private double xOffset, yOffset;
|
||||||
|
private boolean isMoving = false;
|
||||||
|
|
||||||
public void handleClickAction(MouseEvent event) {
|
public void handleClickAction(MouseEvent event) {
|
||||||
xOffset = event.getSceneX();
|
xOffset = event.getSceneX();
|
||||||
yOffset = event.getSceneY();
|
yOffset = event.getSceneY();
|
||||||
|
isMoving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMovementAction(MouseEvent event) {
|
public void handleMovementAction(MouseEvent event) {
|
||||||
|
if (isMoving) {
|
||||||
stage.setX(event.getScreenX() - xOffset);
|
stage.setX(event.getScreenX() - xOffset);
|
||||||
stage.setY(event.getScreenY() - yOffset);
|
stage.setY(event.getScreenY() - yOffset);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleClickReleaseAction(MouseEvent mouseEvent) {
|
||||||
|
isMoving = false;
|
||||||
|
}
|
||||||
|
|
||||||
public void toggleTheme(MouseEvent event) {
|
public void toggleTheme(MouseEvent event) {
|
||||||
int themeIndex = ThemeFactory.allThemes().indexOf(config.getCurrentTheme());
|
int themeIndex = ThemeFactory.allThemes().indexOf(config.getCurrentTheme());
|
||||||
config.setTheme(ThemeFactory.allThemes().get((themeIndex + 1) % ThemeFactory.allThemes().size()));
|
config.setTheme(ThemeFactory.allThemes().get((themeIndex + 1) % ThemeFactory.allThemes().size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showAlert() {
|
||||||
|
stage.show();
|
||||||
|
Platform.runLater(() -> stage.sizeToScene());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.geometry.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<!--maxHeight="19.0" minHeight="19.0"-->
|
<!--maxHeight="19.0" minHeight="19.0"-->
|
||||||
|
|
||||||
<VBox prefWidth="650.0" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.GEarthController">
|
<VBox prefWidth="650.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.GEarthController">
|
||||||
<TabPane id="main-tab-pane" fx:id="tabBar" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="295.0" prefWidth="650.0" tabClosingPolicy="UNAVAILABLE">
|
<TabPane id="main-tab-pane" fx:id="tabBar" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="295.0" prefWidth="650.0" tabClosingPolicy="UNAVAILABLE">
|
||||||
<Tab text="Connection">
|
<Tab text="Connection">
|
||||||
<fx:include fx:id="connection" source="subforms/connection/Connection.fxml" />
|
<fx:include fx:id="connection" source="subforms/connection/Connection.fxml" />
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<RowConstraints maxHeight="25.0" minHeight="25.0" prefHeight="25.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="25.0" minHeight="25.0" prefHeight="25.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<ImageView id="minimize-button" fitHeight="25.0" fitWidth="50.0" onMouseClicked="#handleMinimizeAction" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1">
|
<ImageView fx:id="minimizeBtn" id="minimize-button" fitHeight="25.0" fitWidth="50.0" onMouseClicked="#handleMinimizeAction" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1">
|
||||||
<image>
|
<image>
|
||||||
<Image url="@files/minimizeButton.png" />
|
<Image url="@files/minimizeButton.png" />
|
||||||
</image>
|
</image>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<Image url="@files/closeButton.png" />
|
<Image url="@files/closeButton.png" />
|
||||||
</image>
|
</image>
|
||||||
</ImageView>
|
</ImageView>
|
||||||
<GridPane maxHeight="25.0" maxWidth="1.7976931348623157E308" minHeight="25.0" minWidth="-Infinity" onMouseDragged="#handleMovementAction" onMousePressed="#handleClickAction" prefHeight="25.0">
|
<GridPane maxHeight="25.0" maxWidth="1.7976931348623157E308" minHeight="25.0" minWidth="-Infinity" onMouseDragged="#handleMovementAction" onMousePressed="#handleClickAction" onMouseReleased="#handleClickReleaseAction" prefHeight="25.0">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="7.0" minWidth="7.0" prefWidth="7.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="7.0" minWidth="7.0" prefWidth="7.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" />
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<Insets left="2.0" />
|
<Insets left="2.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</Label>
|
</Label>
|
||||||
<ImageView id="theme-button" fitHeight="20.0" fitWidth="38.0" onMouseClicked="#toggleTheme" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="3">
|
<ImageView fx:id="themeBtn" id="theme-button" fitHeight="20.0" fitWidth="38.0" onMouseClicked="#toggleTheme" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="3">
|
||||||
<image>
|
<image>
|
||||||
<Image url="@../themes/G-Earth/themeButton.png" />
|
<Image url="@../themes/G-Earth/themeButton.png" />
|
||||||
</image>
|
</image>
|
||||||
|
Loading…
Reference in New Issue
Block a user