Skip to content

Commit

Permalink
Added the stylesheet directly to the control as there were still issu…
Browse files Browse the repository at this point in the history
…es properly styling the control. Fixed some CSS rules to more easily pick up inherited colors. More consistent with Modena rules now. Added CSSFX to the demo app.
  • Loading branch information
dlemmermann committed Feb 22, 2022
1 parent e676978 commit 73bd9b3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 38 deletions.
7 changes: 7 additions & 0 deletions pdfviewfx-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
<artifactId>pdfviewfx</artifactId>
<version>1.6.0</version>
</dependency>

<dependency>
<groupId>fr.brouillard.oss</groupId>
<artifactId>cssfx</artifactId>
<version>11.5.0</version>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.dlsc.pdfviewfx.demo;

import com.dlsc.pdfviewfx.PDFView;

import java.io.File;

import fr.brouillard.oss.cssfx.CSSFX;
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.collections.ObservableList;
Expand All @@ -18,6 +16,8 @@
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;

import java.io.File;

public class PDFViewApp extends Application {

private FileChooser chooser;
Expand Down Expand Up @@ -67,6 +67,9 @@ public void start(Stage primaryStage) {
box.setFillWidth(true);

Scene scene = new Scene(box);

CSSFX.start(primaryStage);

primaryStage.setTitle("PDF View");
primaryStage.setWidth(1000);
primaryStage.setHeight(900);
Expand Down
1 change: 1 addition & 0 deletions pdfviewfx-demo/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module com.dlsc.pdfviewfx.demo {
requires com.dlsc.pdfviewfx;
requires fr.brouillard.oss.cssfx;
exports com.dlsc.pdfviewfx.demo;
}
30 changes: 9 additions & 21 deletions pdfviewfx/src/main/java/com/dlsc/pdfviewfx/PDFView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import com.dlsc.pdfviewfx.PDFView.Document.DocumentProcessingException;
import com.dlsc.pdfviewfx.skins.PDFViewSkin;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Rectangle2D;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.scene.paint.Color;

import java.awt.image.BufferedImage;
import java.io.File;
Expand All @@ -10,27 +17,6 @@
import java.util.Objects;
import java.util.function.Supplier;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Rectangle2D;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.scene.paint.Color;

/**
* A PDF viewer based on Apache PDFBox. The view shows thumbnails
* on the left and the full page on the right. The user can zoom in,
Expand Down Expand Up @@ -75,6 +61,8 @@ public PDFView() {

setSearchText(null);
});

getStylesheets().add(getUserAgentStylesheet());
}

@Override
Expand Down
45 changes: 31 additions & 14 deletions pdfviewfx/src/main/resources/com/dlsc/pdfviewfx/pdf-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

.pdf-view .search-result-list-view .list-cell .matches-label {
-fx-font-size: .9em;
-fx-text-fill: grey;
-fx-text-fill: -fx-text-background-color;
-fx-opacity: .5
}

.pdf-view .search-result-list-view:focused .list-cell:focused .matches-label,
.pdf-view .search-result-list-view:focused .list-cell:selected .matches-label {
-fx-text-fill: white;
}

.pdf-view .search-result-list-view .list-cell .image-view-wrapper {
Expand All @@ -39,19 +39,31 @@
/* ------------------------------------------------------------------
* Thumbnail List View
*/
.pdf-view .thumbnail-list-view .list-cell {
.pdf-view .thumbnail-list-view .list-cell,
.pdf-view .thumbnail-list-view:focused .list-cell {
-fx-background: rgb(245, 245, 245);
-fx-background-color: -fx-background;
-fx-padding: 20 20 10 10;
-fx-background-color: rgb(245, 245, 245) !important;
}

.pdf-view .thumbnail-list-view .list-cell:odd,
.pdf-view .thumbnail-list-view:focused .list-cell:odd {
-fx-background: rgb(245, 245, 245);
-fx-background-color: -fx-background;
}

.pdf-view .thumbnail-list-view .list-cell .page-number-label,
.pdf-view .thumbnail-list-view .list-cell:selected .page-number-label {
-fx-text-fill: grey;
.pdf-view .thumbnail-list-view:focused .list-cell .page-number-label,
.pdf-view .thumbnail-list-view .list-cell:selected .page-number-label,
.pdf-view .thumbnail-list-view:focused .list-cell:selected .page-number-label {
-fx-text-fill: -fx-text-background-color;
-fx-font-size: 10px;
}

.pdf-view .thumbnail-list-view .list-cell:selected {
-fx-background-color: rgb(245, 245, 245) !important;
.pdf-view .thumbnail-list-view .list-cell:selected,
.pdf-view .thumbnail-list-view:focused .list-cell:selected {
-fx-background: rgb(245, 245, 245);
-fx-background-color: -fx-background;
}

.pdf-view .thumbnail-list-view {
Expand All @@ -70,17 +82,22 @@
-fx-background-radius: 2px;
}

.pdf-view .label {
-fx-text-fill: -fx-text-background-color;
}

.pdf-view .tool-bar .search-field .ikonli-font-icon {
-fx-icon-color: gray;
-fx-opacity: .66;
-fx-icon-color: -fx-text-background-color;
-fx-icon-size: 16px;
}

.pdf-view .tool-bar .search-field .ikonli-font-icon:hover {
-fx-icon-color: black;
-fx-opacity: 1;
}

.pdf-view .tool-bar .search-field .ikonli-font-icon:pressed {
-fx-icon-color: black;
-fx-opacity: 1;
}

.pdf-view .search-navigator {
Expand All @@ -92,15 +109,15 @@
}

.pdf-view .search-navigator .search-result-label {
-fx-text-fill: black;
-fx-text-fill: -fx-text-background-color;
}

.pdf-view .search-navigator .search-bar-button {
-fx-padding: 2 5;
-fx-background-radius: 2, 2;
-fx-background-color: gray, -fx-base;
-fx-background-insets: 0, 1 1 1 1;
-fx-text-fill: black;
-fx-text-fill: -fx-text-background-color;
}

.pdf-view .search-navigator .search-bar-button:hover {
Expand Down Expand Up @@ -137,7 +154,7 @@

.pdf-view .tool-bar .tool-bar-button .ikonli-font-icon {
-fx-icon-size: 18px;
-fx-icon-color: black;
-fx-icon-color: -fx-text-background-color;
}

.pdf-view .page-control .previous-page-button {
Expand Down

0 comments on commit 73bd9b3

Please sign in to comment.