commit 61e97d3bbd7462512e2abdff4ff39f857f7a78ac Author: xdrm-brackets Date: Tue Nov 14 08:22:26 2017 +0100 First commit diff --git a/controller/HeaderMenu.java b/controller/HeaderMenu.java new file mode 100644 index 0000000..2910346 --- /dev/null +++ b/controller/HeaderMenu.java @@ -0,0 +1,81 @@ +package controller; + +import java.util.ArrayList; + +import javafx.event.ActionEvent; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.FlowPane; +import model.HeaderMenuItem; + +public class HeaderMenu{ + + /* Data */ + private ArrayList items; + + + /* Constructor */ + public HeaderMenu(){ + this.items = new ArrayList(); + } + + + public void addItem(HeaderMenuItem p_item) { + this.items.add(p_item); + } + + + + + /* Content Builder */ + public void render(FlowPane p_parent) { + + /* (1) Initialize variables */ + int i, il; + + /* (2) Create each item */ + for( i = 0, il = this.items.size() ; i < il ; i++ ) { + + // Create ImageView + ImageView v_view = new ImageView(); + + // Get image + Image v_img = new Image( this.items.get(i).getImageURI() ); + + // Set image on button + v_view.setImage(v_img); + + // Set default props. + v_view.setId("header_menu_item_"+this.items.get(i).getName()); + v_view.getStyleClass().add("header_menu_item"); + + // HOVER + v_view.addEventHandler(MouseEvent.MOUSE_MOVED, e -> { + System.out.println("hover"); + ImageView view = (ImageView) e.getTarget(); + System.out.println( view.getId() ); + e.consume(); + }); + + // CLICK + v_view.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> { + System.out.println("clicked"); + ImageView view = (ImageView) e.getTarget(); + e.consume(); + }); + + // Add to parent + p_parent.getChildren().add(v_view); + + } + + } + + + + public void onClick(ActionEvent p_event){ + System.out.println("You clicked the button"); + } + +} diff --git a/controller/RootLayout.java b/controller/RootLayout.java new file mode 100644 index 0000000..dce7b44 --- /dev/null +++ b/controller/RootLayout.java @@ -0,0 +1,89 @@ +package controller; + +import java.io.IOException; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import javafx.stage.Stage; +import model.HeaderMenuItem; + +public class RootLayout extends Application { + + private Stage root_stage; + private Scene root_scene; + private AnchorPane root_layout; + + + + @Override + public void start(Stage primary_stage) { + + /* (1) store primary stage + title it */ + this.root_stage = primary_stage; + this.root_stage.setTitle("Inifiny Mail Client"); + + /* (2) Load the root layout*/ + this.loadRootLayout(); + + + + + /* (1) HEADER + -------------------------------------*/ + /* (1) Create header menu */ + HeaderMenu hm = new HeaderMenu(); + + hm.addItem( new HeaderMenuItem("notification", "/src/header-notif.png") ); + hm.addItem( new HeaderMenuItem("mail", "/src/header-mail.png") ); + hm.addItem( new HeaderMenuItem("search", "/src/header-search.png") ); + hm.addItem( new HeaderMenuItem("menu", "/src/header-menu.png") ); + + hm.render( (FlowPane) this.root_scene.lookup("#header_menu") ); + + + } + + + + + public void loadRootLayout(){ + + try{ + + /* (1) Load the root_disp.fxml */ + FXMLLoader loader = new FXMLLoader(); + + loader.setLocation(getClass().getResource("/fxml/model.fxml")); + + /* (2) Load the layout into the scene */ + this.root_layout = (AnchorPane) loader.load(); + this.root_scene = new Scene(this.root_layout); + + /* (3) Add the scene to the stage */ + this.root_stage.setScene(this.root_scene); + + /* (4) Show the stage */ + this.root_stage.show(); + + }catch(IOException e){ + e.printStackTrace(); + } + + } + + + + + + + + + + + public static void main(String[] args) { + launch(args); + } +} diff --git a/css/header.css b/css/header.css new file mode 100644 index 0000000..5285536 --- /dev/null +++ b/css/header.css @@ -0,0 +1,28 @@ +#header{ + + -fx-min-height: 40; + -fx-max-height: 40; + -fx-pref-height: 40; + + -fx-min-width: 1280; + + -fx-background-color: #3f51b5; + + -fx-border-width: 0 0 1 0; + -fx-border-color: #3240a3; + +} + +#header_menu{ + + -fx-min-width: 40; + -fx-max-width: 1280; + +} + +.header_menu_item{ + + -fx-scale-x: 0.5; + -fx-scale-y: 0.5; + +} \ No newline at end of file diff --git a/css/menu.css b/css/menu.css new file mode 100644 index 0000000..25aa1b6 --- /dev/null +++ b/css/menu.css @@ -0,0 +1,22 @@ +#header_icon{ + + + -fx-min-width: 40; + -fx-max-width: 660; + + -fx-min-height: 40; + -fx-max-height: 40; + -fx-pref-height: 40; + + + + -fx-background-color: #3240a3; + + -fx-border-width: 0 0 1 0; + -fx-border-color: #2a378a; + +} + +#menu_container{ + -fx-background-color: #fffffd; +} \ No newline at end of file diff --git a/fxml/header_menu_disp.fxml b/fxml/header_menu_disp.fxml new file mode 100644 index 0000000..9e78237 --- /dev/null +++ b/fxml/header_menu_disp.fxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/fxml/model.fxml b/fxml/model.fxml new file mode 100644 index 0000000..0d7b306 --- /dev/null +++ b/fxml/model.fxml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fxml/root_disp.fxml b/fxml/root_disp.fxml new file mode 100644 index 0000000..348ddc7 --- /dev/null +++ b/fxml/root_disp.fxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/model/HeaderMenuItem.java b/model/HeaderMenuItem.java new file mode 100644 index 0000000..fdaebeb --- /dev/null +++ b/model/HeaderMenuItem.java @@ -0,0 +1,33 @@ +package model; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +public class HeaderMenuItem{ + + private final StringProperty name; + private final String image_uri; + + + /* Constructor + * + * @param p_name The name of the menu item + * @param p_image_uri The URI of the image + * + */ + public HeaderMenuItem(String p_name, String p_image_uri){ + this.name = new SimpleStringProperty(p_name); + this.image_uri = p_image_uri; + } + + + + public StringProperty getName(){ + return this.name; + } + + public String getImageURI(){ + return this.image_uri; + } + +} diff --git a/src/header-mail.png b/src/header-mail.png new file mode 100644 index 0000000..59d8c01 Binary files /dev/null and b/src/header-mail.png differ diff --git a/src/header-menu.png b/src/header-menu.png new file mode 100644 index 0000000..697f251 Binary files /dev/null and b/src/header-menu.png differ diff --git a/src/header-notif.png b/src/header-notif.png new file mode 100644 index 0000000..8d08d07 Binary files /dev/null and b/src/header-notif.png differ diff --git a/src/header-search.png b/src/header-search.png new file mode 100644 index 0000000..f373566 Binary files /dev/null and b/src/header-search.png differ diff --git a/src/menu_profile_1.png b/src/menu_profile_1.png new file mode 100644 index 0000000..db18159 Binary files /dev/null and b/src/menu_profile_1.png differ