mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-10-06 15:11:38 +00:00
Rework svg image handling
This commit is contained in:
1 parent
140b734142
commit
2c5d3b326d
69 files changed
+16
-10
No files matched your search
@@ -81,7 +81,7 @@ public class BrowserWelcomeComp extends SimpleComp {
|
||||
var listBox = new ListBoxViewComp<>(list, list, e -> {
|
||||
var entry = DataStorage.get().getStoreEntryIfPresent(e.getUuid());
|
||||
var graphic = entry.get().getProvider().getDisplayIconFileName(entry.get().getStore());
|
||||
var view = PrettyImageHelper.ofFixed(graphic, 50, 40);
|
||||
var view = PrettyImageHelper.ofFixedSize(graphic, 50, 40);
|
||||
view.padding(new Insets(2, 8, 2, 8));
|
||||
var content =
|
||||
JfxHelper.createNamedEntry(DataStorage.get().getStoreDisplayName(entry.get()), e.getPath(), graphic);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class OsLogoComp extends SimpleComp {
|
||||
var hide = BindingsHelper.map(img, s -> s != null);
|
||||
return new StackComp(List.of(
|
||||
new SystemStateComp(state).hide(hide),
|
||||
PrettyImageHelper.ofSvg(img, 24, 24).visible(hide)))
|
||||
PrettyImageHelper.ofRasterized(img, 24, 24).visible(hide)))
|
||||
.createRegion();
|
||||
}
|
||||
|
||||
@@ -66,8 +66,9 @@ public class OsLogoComp extends SimpleComp {
|
||||
if (ICONS.isEmpty()) {
|
||||
AppResources.with(AppResources.XPIPE_MODULE, "img/os", file -> {
|
||||
try (var list = Files.list(file)) {
|
||||
list.filter(path -> !path.toString().endsWith(LINUX_DEFAULT)).map(path -> FileNames.getFileName(path.toString())).forEach(path -> {
|
||||
var base = FileNames.getBaseName(path).replace("-dark", "") + ".svg";
|
||||
list.filter(path -> path.toString().endsWith(".svg") && !path.toString().endsWith(LINUX_DEFAULT))
|
||||
.map(path -> FileNames.getFileName(path.toString())).forEach(path -> {
|
||||
var base = FileNames.getBaseName(path).replace("-dark", "") + "-24.png";
|
||||
ICONS.put(FileNames.getBaseName(base).split("-")[0], "os/" + base);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DenseStoreEntryComp extends StoreEntryComp {
|
||||
}, grid.widthProperty()));
|
||||
|
||||
if (showIcon) {
|
||||
var storeIcon = createIcon(30, 25);
|
||||
var storeIcon = createIcon(30, 24);
|
||||
grid.getColumnConstraints().add(new ColumnConstraints(46));
|
||||
grid.add(storeIcon, 0, 0);
|
||||
GridPane.setHalignment(storeIcon, HPos.CENTER);
|
||||
|
||||
@@ -160,7 +160,7 @@ public abstract class StoreEntryComp extends SimpleComp {
|
||||
: wrapper.getEntry()
|
||||
.getProvider()
|
||||
.getDisplayIconFileName(wrapper.getEntry().getStore());
|
||||
var imageComp = PrettyImageHelper.ofFixed(img, w, h);
|
||||
var imageComp = PrettyImageHelper.ofFixedSize(img, w, h);
|
||||
var storeIcon = imageComp.createRegion();
|
||||
if (wrapper.getValidity().getValue().isUsable()) {
|
||||
new FancyTooltipAugment<>(new SimpleStringProperty(
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.xpipe.app.core.AppImages;
|
||||
import io.xpipe.app.fxcomps.SimpleComp;
|
||||
import io.xpipe.app.fxcomps.util.PlatformThread;
|
||||
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
|
||||
import io.xpipe.app.issue.TrackEvent;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.core.store.FileNames;
|
||||
import javafx.beans.binding.Bindings;
|
||||
@@ -78,6 +79,7 @@ public class PrettyImageComp extends SimpleComp {
|
||||
} else if (AppImages.hasNormalImage(image.getValue().replace("-dark", ""))) {
|
||||
return AppImages.image(image.getValue().replace("-dark", ""));
|
||||
} else {
|
||||
TrackEvent.withWarn("Image file not found").tag("file",image.getValue()).handle();
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -23,10 +23,10 @@ public class PrettyImageHelper {
|
||||
}
|
||||
|
||||
public static Comp<?> ofFixedSquare(String img, int size) {
|
||||
return ofFixed(img, size, size);
|
||||
return ofFixedSize(img, size, size);
|
||||
}
|
||||
|
||||
public static Comp<?> ofFixed(String img, int w, int h) {
|
||||
public static Comp<?> ofFixedSize(String img, int w, int h) {
|
||||
if (img == null) {
|
||||
return new PrettyImageComp(new SimpleStringProperty(null), w, h);
|
||||
}
|
||||
@@ -39,13 +39,16 @@ public class PrettyImageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Comp<?> ofSvg(ObservableValue<String> img, int w, int h) {
|
||||
return new PrettySvgComp(img, w, h);
|
||||
}
|
||||
|
||||
public static Comp<?> ofRasterized(ObservableValue<String> img, int w, int h) {
|
||||
return new PrettyImageComp(img, w, h);
|
||||
}
|
||||
|
||||
public static Comp<?> ofFixedSmallSquare(String img) {
|
||||
return ofFixed(img, 16, 16);
|
||||
return ofFixedSize(img, 16, 16);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user