Changeset 888


Ignore:
Timestamp:
02/14/14 01:55:45 (10 years ago)
Author:
ngw8
Message:

Added stop button to JFX browser, changed 'go' button to be inside the URL bar, and changed back/forward buttons to use icons rather than text.

Location:
trunk/src/org/expeditee
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/assets/style/jfx.css

    r840 r888  
    33 * Author: ngw8
    44 */
     5
    56#jfxbrowser {
    67    -light-gray: rgb(245, 245, 245);
    78    -dark-gray: rgb(10, 10, 10);
    89    -highlight: #79b3d4;
     10    -red-highlight: #d44747;
     11    -red-highlight-transparent: rgba(248,118,92.0.2);
     12   
     13    -green-highlight: #62c139;
     14    -green-highlight-transparent: rgba(135,212,101, 0.4);
     15   
    916    -fx-accent: -highlight;
    10     -fx-shadow-highlight-color: rgba(255,255, 255, 0.4);
     17    -fx-shadow-highlight-color: rgba(255, 255, 255, 0.5);
    1118    -fx-base: #eee;
    1219}
     
    5562    -fx-background-color:-light-gray;
    5663   
    57     -fx-background-radius: 2 0 0 2; 
    58 
     64    -fx-background-radius: 2;
    5965}
    6066
     
    7379}
    7480
     81.fa {
     82    -fx-font-family: FontAwesome;   
     83}
     84
     85.button.fa .text :not(.tooltip) {
     86    -fx-effect: dropshadow(one-pass-box, -fx-shadow-highlight-color, 0,0,0,1);
     87}
     88
     89.url-button {
     90    -fx-background-color: transparent;
     91    -fx-padding: 0 8 0 2;
     92    -fx-text-fill: derive(-fx-base, -30%);
     93}
     94
     95.url-button .text :not(.tooltip) {
     96    -fx-effect: dropshadow(two-pass-box, -light-gray, 6,0.8,0,0) !important;   
     97}
     98
     99.url-cancel-button {
     100    -hover-color: -red-highlight;
     101    -glow-color: -red-highlight-transparent;
     102}
     103
     104.url-go-button {
     105    -hover-color: -green-highlight;
     106    -glow-color: -green-highlight-transparent;
     107}
     108
     109.url-button:hover  {
     110    -fx-text-fill: -hover-color;
     111}
     112
     113/* Tooltip is a child of the button, so have to exclude it from the style */
     114.url-button:hover .text :not(.tooltip) {
     115     -fx-effect: dropshadow( two-pass-box , -glow-color, 6,0,0,0 );
     116}
     117
     118.url-button:active {
     119    -fx-text-fill: derive(-hover-color, -30%);
     120}
     121
    75122.scrollbars-hidden .scroll-bar {
    76123    visibility: hidden;
  • trunk/src/org/expeditee/items/widgets/JfxBrowser.java

    r887 r888  
    4848import javafx.scene.layout.StackPane;
    4949import javafx.scene.layout.VBox;
     50import javafx.scene.text.Font;
    5051import javafx.scene.web.WebEngine;
    5152import javafx.scene.web.WebView;
     
    8990        private Button _forwardButton;
    9091        private Button _backButton;
     92        private Button _stopButton;
     93        private Button _goButton;
    9194        private Button _convertButton;
    9295        private ToggleButton _readableModeButton;
     
    102105        static {
    103106                Platform.setImplicitExit(false);
     107               
     108                Font.loadFont(ClassLoader.getSystemResourceAsStream("org/expeditee/assets/resources/fonts/fontawesome/fontawesome-webfont.ttf"), 12);
    104109               
    105110                try {
     
    179184                        horizontal.getStyleClass().add("custom-toolbar");
    180185                       
    181                         this._backButton = new Button("Back");
     186                        this._backButton = new Button("\uf060");
     187                        this._backButton.setTooltip(new Tooltip("Back"));
    182188                        this._backButton.setMinWidth(Button.USE_PREF_SIZE);
     189                        this._backButton.setMaxHeight(Double.MAX_VALUE);
    183190                        this._backButton.setFocusTraversable(false);
    184                         this._backButton.getStyleClass().add("first");
     191                        this._backButton.getStyleClass().addAll("first", "fa");
    185192
    186193                        this._backButton.setDisable(true);
    187 
    188                         this._forwardButton = new Button("Forward");
     194                       
     195                        this._forwardButton = new Button("\uf061");
     196                        this._forwardButton.setTooltip(new Tooltip("Forward"));
    189197                        this._forwardButton.setMinWidth(Button.USE_PREF_SIZE);
     198                        this._forwardButton.setMaxHeight(Double.MAX_VALUE);
    190199                        this._forwardButton.setFocusTraversable(false);
    191                         this._forwardButton.getStyleClass().add("last");
     200                        this._forwardButton.getStyleClass().addAll("last", "fa");
    192201
    193202                        this._urlField = new TextField(url);
    194                         this._urlField.getStyleClass().addAll("first", "url-field");
     203                        this._urlField.getStyleClass().add("url-field");
    195204                        this._urlField.setMaxWidth(Double.MAX_VALUE);
    196205                        this._urlField.setFocusTraversable(false);
    197 
    198                         Button goButton = new Button("Go");
    199                         goButton.getStyleClass().add("last");
    200                         goButton.setMinWidth(Button.USE_PREF_SIZE);
    201                         goButton.setFocusTraversable(false);
     206                       
     207                        this._stopButton = new Button("\uF00D");
     208                        this._stopButton.setTooltip(new Tooltip("Stop loading the page"));
     209                        this._stopButton.getStyleClass().addAll("url-button", "url-cancel-button", "fa");
     210                        this._stopButton.setMinWidth(Button.USE_PREF_SIZE);
     211                        this._stopButton.setMaxHeight(Double.MAX_VALUE);
     212                        StackPane.setAlignment(this._stopButton, Pos.CENTER_RIGHT);
     213                        this._stopButton.setFocusTraversable(false);
     214
     215                        this._goButton = new Button("\uf061");
     216                        this._goButton.setTooltip(new Tooltip("Load the entered address"));
     217                        this._goButton.getStyleClass().addAll("url-button", "url-go-button", "fa");
     218                        this._goButton.setMinWidth(Button.USE_PREF_SIZE);
     219                        this._goButton.setMaxHeight(Double.MAX_VALUE);
     220                        StackPane.setAlignment(this._goButton, Pos.CENTER_RIGHT);
     221                        this._goButton.setFocusTraversable(false);
    202222                       
    203223                        this._readableModeButton = new ToggleButton();
     
    214234                                               
    215235                        this._urlProgressBar = new ProgressBar();               
    216                         this._urlProgressBar.getStyleClass().addAll("first", "url-progress-bar");
     236                        this._urlProgressBar.getStyleClass().add("url-progress-bar");
    217237                        this._urlProgressBar.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    218238
    219239                        StackPane urlbar = new StackPane();
    220                         urlbar.getChildren().addAll(_urlProgressBar, this._urlField);
     240                        urlbar.getChildren().addAll(_urlProgressBar, this._urlField, this._stopButton, this._goButton);
    221241                                               
    222                         horizontal.getChildren().addAll(this._backButton, this._forwardButton, urlbar, goButton, this._readableModeButton, this._convertButton);
     242                        horizontal.getChildren().addAll(this._backButton, this._forwardButton, urlbar, this._readableModeButton, this._convertButton);
    223243
    224244                        HBox.setHgrow(this._backButton, Priority.NEVER);
    225245                        HBox.setHgrow(this._forwardButton, Priority.NEVER);
    226246                        HBox.setHgrow(this._convertButton, Priority.NEVER);
    227                         HBox.setHgrow(goButton, Priority.NEVER);
    228247                        HBox.setHgrow(this._readableModeButton, Priority.NEVER);
    229248                        HBox.setHgrow(urlbar, Priority.ALWAYS);
    230249                       
    231                         HBox.setMargin(goButton, new Insets(0, 5, 0, 0));
    232                         HBox.setMargin(this._readableModeButton, new Insets(0, 5, 0, 0));
     250                        HBox.setMargin(this._readableModeButton, new Insets(0, 5, 0, 5));
    233251                        HBox.setMargin(this._forwardButton, new Insets(0, 5, 0, 0));
    234252
     
    328346                        });
    329347                       
    330                         goButton.setOnAction(new EventHandler<ActionEvent>() {
     348                        this._stopButton.setOnAction(new EventHandler<ActionEvent>() {
     349                               
     350                                @Override
     351                                public void handle(ActionEvent arg0) {
     352                                        JfxBrowser.this._webEngine.getLoadWorker().cancel();
     353                                }
     354                        });
     355                       
     356                        this._goButton.setOnAction(new EventHandler<ActionEvent>() {
    331357                               
    332358                                @Override
     
    494520                                                JfxBrowser.this._urlProgressBar.getStyleClass().remove("completed");
    495521
     522                                                JfxBrowser.this._stopButton.setVisible(true);
     523                                                JfxBrowser.this._goButton.setVisible(false);
     524                                               
    496525                                                if (JfxBrowser.this._webEngine.getHistory().getCurrentIndex() + 1 >= JfxBrowser.this._webEngine.getHistory().getEntries().size()) {
    497526                                                        JfxBrowser.this._forwardButton.setDisable(true);
     
    523552                                                JfxBrowser.this._convertButton.setDisable(false);
    524553                                                JfxBrowser.this._readableModeButton.setDisable(false);
     554                                                JfxBrowser.this._stopButton.setVisible(false);
     555                                                JfxBrowser.this._goButton.setVisible(true);
    525556                                                break;
    526557                                        case FAILED: // FAILED
    527558                                                MessageBay.displayMessage("Failed to load page");
     559                                                JfxBrowser.this._stopButton.setVisible(false);
     560                                                JfxBrowser.this._goButton.setVisible(true);
    528561                                                break;
    529562                                        }
Note: See TracChangeset for help on using the changeset viewer.