Skip to content

Commit

Permalink
update menu icons for material design style
Browse files Browse the repository at this point in the history
  • Loading branch information
firm1 committed Mar 12, 2016
1 parent ddd7155 commit 2177036
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 42 deletions.
8 changes: 2 additions & 6 deletions src/com/zestedesavoir/zestwriter/view/Editor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@
<Tooltip text="Bloc spéciaux" />
</tooltip>
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@static/icons/information.png" />
</image>
</ImageView>
<MaterialDesignIconView fill="#084561" glyphName="INFORMATION" size="1.8em" />
</graphic></Button>
<Button layoutX="10.0" layoutY="11.0" mnemonicParsing="false" onAction="#HandleTableButtonAction">
<tooltip>
Expand Down Expand Up @@ -164,7 +160,7 @@
<Tooltip text="Plein écran" />
</tooltip>
<graphic>
<MaterialDesignIconView fill="#084561" glyphName="CROP_FREE" size="1.8em" />
<MaterialDesignIconView fill="#084561" glyphName="FULLSCREEN" size="1.8em" />
</graphic>
</Button>

Expand Down
79 changes: 64 additions & 15 deletions src/com/zestedesavoir/zestwriter/view/MdTextController.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import com.zestedesavoir.zestwriter.MainApp;
import com.zestedesavoir.zestwriter.model.ExtractFile;

import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import javafx.collections.MapChangeListener;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
Expand Down Expand Up @@ -52,7 +54,6 @@
import javafx.scene.input.KeyEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.text.Font;
import javafx.stage.WindowEvent;
import javafx.util.Callback;

public class MdTextController {
Expand All @@ -77,7 +78,6 @@ public class MdTextController {

@FXML
private void initialize() {

loadConsolePython();
loadFonts();

Expand Down Expand Up @@ -117,6 +117,48 @@ public MdTextController() {
super();
}

private MaterialDesignIconView createFolderIcon() {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.FOLDER_MULTIPLE);
icon.setSize("1.8em");
icon.setGlyphStyle("-fx-fill:#084561");
return icon;
}

private MaterialDesignIconView createAddFolderIcon() {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.FOLDER_PLUS);
icon.setSize("1.8em");
icon.setGlyphStyle("-fx-fill:#084561");
return icon;
}

private MaterialDesignIconView createDeleteIcon() {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.CLOSE);
icon.setSize("1.8em");
icon.setGlyphStyle("-fx-fill:#f44336");
return icon;
}

private MaterialDesignIconView createRemoveIcon() {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.DELETE);
icon.setSize("1.8em");
icon.setGlyphStyle("-fx-fill:#f44336");
return icon;
}

private MaterialDesignIconView createFileIcon() {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.FILE);
icon.setSize("1.8em");
icon.setGlyphStyle("-fx-fill:#ef9708");
return icon;
}

private MaterialDesignIconView createEditIcon() {
MaterialDesignIconView icon = new MaterialDesignIconView(MaterialDesignIcon.BORDER_COLOR);
icon.setSize("1.8em");
icon.setGlyphStyle("-fx-fill:#084561");
return icon;
}

public PythonInterpreter getPyconsole() {
return pyconsole;
}
Expand Down Expand Up @@ -395,10 +437,15 @@ public String toSlug(String input) {
private ContextMenu addMenu = new ContextMenu();

public void initContextMenu(ExtractFile item) {
MenuItem addMenuItem1 = new MenuItem("Ajouter un extrait", new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/child.png"), 16, 16, true, true)));
MenuItem addMenuItem2 = new MenuItem("Ajouter un conteneur", new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/container.png"), 16, 16, true, true)));
MenuItem addMenuItem3 = new MenuItem("Renommer", new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/editor.png"), 16, 16, true, true)));
MenuItem addMenuItem4 = new MenuItem("Supprimer", new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/delete.png"), 16, 16, true, true)));

MenuItem addMenuItem1 = new MenuItem("Ajouter un extrait");
MenuItem addMenuItem2 = new MenuItem("Ajouter un conteneur");
MenuItem addMenuItem3 = new MenuItem("Renommer");
MenuItem addMenuItem4 = new MenuItem("Supprimer");
addMenuItem1.setGraphic(createFileIcon());
addMenuItem2.setGraphic(createAddFolderIcon());
addMenuItem3.setGraphic(createEditIcon());
addMenuItem4.setGraphic(createRemoveIcon());
addMenu.getItems().clear();
if (item.canTakeContainer(getAncestorContainerCount(getTreeItem()))) {
addMenu.getItems().add(addMenuItem2);
Expand Down Expand Up @@ -543,9 +590,9 @@ protected void updateItem(ExtractFile item, boolean empty) {
} else {
setText(getString());
if (getItem().isContainer()) {
setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/container.png"), 20, 20, true, true)));
setGraphic(createFolderIcon());
} else {
setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/child.png"), 20, 20, true, true)));
setGraphic(createFileIcon());
}
setContextMenu(addMenu);
initContextMenu(item);
Expand Down Expand Up @@ -587,9 +634,9 @@ private String getString() {

treeCell.setOnDragExited(dragEvent -> {
if (treeCell.getItem().isContainer()) {
treeCell.setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/container.png"), 20, 20, true, true)));
treeCell.setGraphic(createFolderIcon());
} else {
treeCell.setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/child.png"), 20, 20, true, true)));
treeCell.setGraphic(createFileIcon());
}
dragEvent.consume();
});
Expand All @@ -608,7 +655,7 @@ public void handle(DragEvent dragEvent) {
getDescendantContainerCount(newParent.getParent()))
)
{
treeCell.setGraphic(new ImageView(new Image(this.getClass().getResourceAsStream("static/icons/delete.png"))));
treeCell.setGraphic(createDeleteIcon());
} else {
dragEvent.acceptTransferModes(TransferMode.MOVE);
}
Expand Down Expand Up @@ -676,9 +723,11 @@ public static int getAncestorContainerCount(TreeItem<ExtractFile> node) {
*/
public static int getDescendantContainerCount(TreeItem<ExtractFile> node) {
int maxDepth = 0;
for (TreeItem<ExtractFile> n : node.getChildren()) {
if (n.getValue().isContainer()) {
maxDepth = Math.max(maxDepth, getDescendantContainerCount(n) + 1);
if(node != null ) {
for (TreeItem<ExtractFile> n : node.getChildren()) {
if (n.getValue().isContainer()) {
maxDepth = Math.max(maxDepth, getDescendantContainerCount(n) + 1);
}
}
}
return maxDepth;
Expand Down
37 changes: 16 additions & 21 deletions src/com/zestedesavoir/zestwriter/view/Root.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<?import javafx.scene.image.*?>
<?import javafx.scene.input.KeyCodeCombination?>
<?import javafx.scene.layout.BorderPane?>
<?import de.jensd.fx.glyphs.materialdesignicons.*?>

<BorderPane prefHeight="600.0" prefWidth="900.0" stylesheets="@dark.css" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zestedesavoir.zestwriter.view.MenuController">
<top>
Expand All @@ -15,12 +16,22 @@
<Menu mnemonicParsing="false" text="Fichier">
<items>
<MenuItem mnemonicParsing="false" onAction="#HandleOpenButtonAction" text="Ouvrir">
<graphic>
<MaterialDesignIconView fill="#084561" glyphName="FOLDER" size="1.8em" />
</graphic>
<accelerator>
<KeyCodeCombination alt="UP" code="O" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#HandleSwitchWorkspaceAction" text="Changer son répertoire de travail" />
<MenuItem mnemonicParsing="false" onAction="#HandleSwitchWorkspaceAction" text="Changer son répertoire de travail">
<graphic>
<MaterialDesignIconView fill="#084561" glyphName="FOLDER_MOVE" size="1.8em" />
</graphic>
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#HandleQuitButtonAction" text="Quitter">
<graphic>
<MaterialDesignIconView fill="#084561" glyphName="EXIT_TO_APP" size="1.8em" />
</graphic>
<accelerator>
<KeyCodeCombination alt="UP" code="Q" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
Expand All @@ -30,11 +41,7 @@
<items>
<MenuItem fx:id="menuReport" disable="true" mnemonicParsing="false" onAction="#HandleReportWithoutTypoButtonAction" text="Rapport de correction">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@static/icons/editor.png" />
</image>
</ImageView>
<MaterialDesignIconView fill="#084561" glyphName="SPELLCHECK" size="1.8em" />
</graphic>
<accelerator>
<KeyCodeCombination alt="UP" code="F7" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
Expand All @@ -46,11 +53,7 @@
<MenuItem mnemonicParsing="false" onAction="#HandleGunningButtonAction" text="Indice Gunning-Fog" />
</items>
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@static/icons/view.png" />
</image>
</ImageView>
<MaterialDesignIconView fill="#084561" glyphName="READ" size="1.8em" />
</graphic>
</Menu>
</items>
Expand All @@ -59,23 +62,15 @@
<items>
<MenuItem fx:id="menuDownload" mnemonicParsing="false" onAction="#HandleDownloadButtonAction" text="Téléchargez vos contenus ZdS">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@static/icons/download.png" />
</image>
</ImageView>
<MaterialDesignIconView fill="#084561" glyphName="CLOUD_DOWNLOAD" size="1.8em" />
</graphic>
<accelerator>
<KeyCodeCombination alt="UP" code="D" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem fx:id="menuUpload" disable="true" mnemonicParsing="false" onAction="#HandleUploadButtonAction" text="Envoyez votre contenu sur ZdS">
<graphic>
<ImageView fitHeight="16.0" fitWidth="16.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@static/icons/upload.png" />
</image>
</ImageView>
<MaterialDesignIconView fill="#084561" glyphName="CLOUD_UPLOAD" size="1.8em" />
</graphic>
<accelerator>
<KeyCodeCombination alt="UP" code="U" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
Expand Down

0 comments on commit 2177036

Please sign in to comment.