Style rework

This commit is contained in:
crschnick 2024-10-26 13:04:00 +00:00
parent b9b3f7907f
commit ba92419c6d
15 changed files with 94 additions and 34 deletions

View file

@ -130,7 +130,7 @@ public final class BrowserFileListComp extends SimpleComp {
table.setAccessibleText("Directory contents");
table.setPlaceholder(new Region());
table.getStyleClass().add(Styles.STRIPED);
table.getColumns().setAll(filenameCol, sizeCol, modeCol, ownerCol, mtimeCol);
table.getColumns().setAll(filenameCol, mtimeCol, modeCol, ownerCol, sizeCol);
table.getSortOrder().add(filenameCol);
table.setFocusTraversable(true);
table.setSortPolicy(param -> {

View file

@ -160,7 +160,7 @@ public class StoreCreationComp extends DialogComp {
store);
skippable.bind(Bindings.createBooleanBinding(() -> {
if (name.get() != null && store.get().isComplete() && store.get() instanceof ValidatableStore<?>) {
if (name.get() != null && store.get().isComplete() && store.get() instanceof ValidatableStore) {
return true;
} else {
return false;

View file

@ -18,6 +18,7 @@ import java.util.*;
public class AppStyle {
private static final Map<Path, String> STYLESHEET_CONTENTS = new LinkedHashMap<>();
private static final Map<AppTheme.Theme, String> THEME_SPECIFIC_STYLESHEET_CONTENTS = new LinkedHashMap<>();
private static final List<Scene> scenes = new ArrayList<>();
private static String FONT_CONTENTS = "";
@ -33,6 +34,9 @@ public class AppStyle {
AppPrefs.get().useSystemFont().addListener((c, o, n) -> {
changeFontUsage(n);
});
AppPrefs.get().theme.addListener((c, o, n) -> {
changeTheme(n);
});
}
}
@ -73,6 +77,20 @@ public class AppStyle {
});
});
}
AppResources.with(AppResources.XPIPE_MODULE, "theme", path -> {
if (!Files.exists(path)) {
return;
}
for (AppTheme.Theme theme : AppTheme.Theme.ALL) {
var file = path.resolve(theme.getId() + ".css");
var bytes = Files.readAllBytes(file);
var s = "data:text/css;base64,"
+ Base64.getEncoder().encodeToString(bytes);
THEME_SPECIFIC_STYLESHEET_CONTENTS.put(theme, s);
}
});
}
private static void changeFontUsage(boolean use) {
@ -87,8 +105,16 @@ public class AppStyle {
}
}
private static void changeTheme(AppTheme.Theme theme) {
scenes.forEach(scene -> {
scene.getStylesheets().removeAll(THEME_SPECIFIC_STYLESHEET_CONTENTS.values());
scene.getStylesheets().add(THEME_SPECIFIC_STYLESHEET_CONTENTS.get(theme));
});
}
public static void reloadStylesheets(Scene scene) {
STYLESHEET_CONTENTS.clear();
THEME_SPECIFIC_STYLESHEET_CONTENTS.clear();
FONT_CONTENTS = "";
init();
@ -107,7 +133,7 @@ public class AppStyle {
if (AppPrefs.get() != null) {
var t = AppPrefs.get().theme.get();
if (t != null) {
scene.getStylesheets().addAll(t.getAdditionalStylesheets());
scene.getStylesheets().add(THEME_SPECIFIC_STYLESHEET_CONTENTS.get(t));
}
}
TrackEvent.debug("Added stylesheets for scene");

View file

@ -4,7 +4,7 @@ import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.store.*;
public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore<ShellValidationContext>, SingletonSessionStore<ShellSession> {
public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore, SingletonSessionStore<ShellSession> {
default ShellControl getOrStartSession() throws Exception {
var session = getSession();
@ -29,7 +29,12 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
@Override
default ShellSession newSession() throws Exception {
var func = shellFunction();
return new ShellSession(this, () -> func.control());
var c = func instanceof ShellControlParentStoreFunction s ? s.control(s.getParentStore().getOrStartSession()) :
func instanceof ShellControlParentFunction p ? p.control(p.parentControl()) : func.control();
if (!isInStorage()) {
c.withoutLicenseCheck();
}
return new ShellSession(this, () -> c);
}
@Override
@ -46,20 +51,7 @@ public interface ShellStore extends DataStore, FileSystemStore, ValidatableStore
ShellControlFunction shellFunction();
@Override
default ShellValidationContext validate() throws Exception {
var func = shellFunction();
var c = func instanceof ShellControlParentStoreFunction s ? s.control(s.getParentStore().getOrStartSession()) :
func instanceof ShellControlParentFunction p ? p.control(p.parentControl()) : func.control();
if (!isInStorage()) {
c.withoutLicenseCheck();
}
return new ShellValidationContext(c.start());
}
@Override
default ShellValidationContext createContext() throws Exception {
var func = shellFunction();
return func instanceof ShellControlParentStoreFunction s ? new ShellValidationContext(s.getParentStore().getOrStartSession()) :
func instanceof ShellControlParentFunction p ? new ShellValidationContext(p.parentControl()) : null;
default void validate() throws Exception {
getOrStartSession();
}
}

View file

@ -520,7 +520,7 @@ public class DataStoreEntry extends StorageElement {
return;
}
if (!(store instanceof ValidatableStore<?> l)) {
if (!(store instanceof ValidatableStore l)) {
return;
}

View file

@ -2,7 +2,7 @@
-fx-background-color: transparent;
-fx-background-radius: 4px;
-fx-border-radius: 4px;
-fx-border-width: 1px;
-fx-border-width: 0;
-fx-padding: 0 0 0 2;
-fx-background-insets: 0;
}
@ -20,6 +20,10 @@
-fx-background-color: -color-bg-default;
}
.category:selected .category-button .name {
-fx-font-weight: BOLD;
}
.root:light .category.yellow > .category-button .expand-button .ikonli-font-icon {
-fx-icon-color: #888800;
}

View file

@ -1,5 +1,11 @@
.root { -color-bg-default-transparent: #1C1C1ED2; }
.root.cupertino .button {
.root .button {
-fx-effect: NONE;
}
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, -45%);
-color-cell-bg: derive(-color-bg-subtle, -30%);
}

View file

@ -1,5 +1,9 @@
.root { -color-bg-default-transparent: #FFFFFFCC; }
.root.cupertino .button {
.root .button {
-fx-effect: NONE;
}
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, 35%);
}

View file

@ -1 +1,7 @@
.root { -color-bg-default-transparent: #0d1117d2; }
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, -45%);
-color-cell-bg: derive(-color-bg-subtle, -30%);
}

View file

@ -1 +1,7 @@
.root { -color-bg-default-transparent: #282a36D2; }
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, -35%);
-color-cell-bg: derive(-color-bg-subtle, -28%);
}

View file

@ -1 +1,5 @@
.root { -color-bg-default-transparent: #FFFFFFCC; }
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, 35%);
}

View file

@ -114,3 +114,8 @@
-fx-background-insets: inherit;
-fx-padding: inherit;
}
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, -35%);
-color-cell-bg: derive(-color-bg-subtle, -30%);
}

View file

@ -1 +1,6 @@
.root { -color-bg-default-transparent: #2E3440d2; }
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, -15%);
-color-cell-bg: derive(-color-bg-subtle, -10%);
}

View file

@ -1 +1,5 @@
.root { -color-bg-default-transparent: #fafafcCC; }
.root .table-view {
-color-cell-bg-odd: derive(-color-bg-subtle, 20%);
}

View file

@ -1,6 +1,6 @@
package io.xpipe.core.store;
public interface ValidatableStore<T extends ValidationContext<?>> extends DataStore {
public interface ValidatableStore extends DataStore {
/**
* Performs a validation of this data store.
@ -18,7 +18,5 @@ public interface ValidatableStore<T extends ValidationContext<?>> extends DataSt
*
* @throws Exception if any part of the validation went wrong
*/
T validate() throws Exception;
T createContext() throws Exception;
void validate() throws Exception;
}