First commit
This commit is contained in:
commit
61e97d3bbd
|
@ -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<HeaderMenuItem> items;
|
||||
|
||||
|
||||
/* Constructor */
|
||||
public HeaderMenu(){
|
||||
this.items = new ArrayList<HeaderMenuItem>();
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
|
||||
<FlowPane alignment="CENTER_RIGHT" columnHalignment="RIGHT" layoutX="273.0" layoutY="-86.0" maxHeight="40.0" maxWidth="1240.0" orientation="VERTICAL" prefHeight="40.0" prefWrapLength="1240.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Pane prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: red; -fx-background-size: auto;">
|
||||
<FlowPane.margin>
|
||||
<Insets right="1.0" />
|
||||
</FlowPane.margin>
|
||||
</Pane>
|
||||
<Pane layoutX="10.0" layoutY="10.0" prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: green;" />
|
||||
<Pane layoutX="10.0" layoutY="10.0" prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: red; -fx-background-size: auto;" />
|
||||
</children>
|
||||
</FlowPane>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="1280.0" style="-fx-background-color: #edf0f5;" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<AnchorPane id="header" fx:id="header" layoutX="200.0" maxHeight="40.0" maxWidth="1280.0" prefHeight="40.0" prefWidth="1080.0" stylesheets="@../css/header.css" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<FlowPane id="header_menu" fx:id="header_menu" alignment="CENTER_RIGHT" layoutX="791.0" layoutY="-80.0" maxHeight="40.0" maxWidth="1240.0" minHeight="40.0" minWidth="40.0" prefHeight="40.0" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane id="menu" fx:id="menu" maxHeight="700.0" maxWidth="251.0" minHeight="680.0" minWidth="40.0" prefHeight="700.0" prefWidth="234.0" stylesheets="@../css/menu.css" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Pane id="header_icon" fx:id="header_icon" maxHeight="40.0" minHeight="40.0" minWidth="40.0" prefHeight="40.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
<VBox id="menu_container" fx:id="menu_list" layoutX="50.0" layoutY="40.0" prefHeight="660.0" prefWidth="237.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="40.0">
|
||||
<children>
|
||||
<FlowPane alignment="CENTER_LEFT" prefHeight="114.0" prefWidth="234.0" style="-fx-border-width: 0 0 1 0; -fx-border-color: #fafafa;">
|
||||
<children>
|
||||
<ImageView fitHeight="57.0" fitWidth="56.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../src/menu_profile_1.png" />
|
||||
</image>
|
||||
<FlowPane.margin>
|
||||
<Insets left="20.0" right="20.0" />
|
||||
</FlowPane.margin>
|
||||
</ImageView>
|
||||
<Pane prefHeight="56.0" prefWidth="125.0">
|
||||
<children>
|
||||
<Text fill="#838383" layoutX="4.0" layoutY="40.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Designer of App">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="11.0" />
|
||||
</font></Text>
|
||||
<Text fill="#545454" layoutX="4.0" layoutY="23.0" strokeType="OUTSIDE" strokeWidth="0.0" text="ADRIEN MARQUES" wrappingWidth="120.7770004272461">
|
||||
<font>
|
||||
<Font name="Lato Regular" size="13.0" />
|
||||
</font>
|
||||
</Text>
|
||||
</children>
|
||||
</Pane>
|
||||
</children>
|
||||
</FlowPane>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<AnchorPane maxHeight="40.0" maxWidth="1280.0" prefHeight="40.0" prefWidth="1280.0" style="-fx-background-color: #3f51b5;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Pane layoutX="100.0" layoutY="-27.0" maxHeight="40.0" maxWidth="40.0" prefHeight="40.0" prefWidth="40.0" style="-fx-background-color: #3240a3;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
|
@ -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<String> The name of the menu item
|
||||
* @param p_image_uri<String> 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;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 640 B |
Binary file not shown.
After Width: | Height: | Size: 877 B |
Binary file not shown.
After Width: | Height: | Size: 841 B |
Binary file not shown.
After Width: | Height: | Size: 713 B |
Binary file not shown.
After Width: | Height: | Size: 997 KiB |
Loading…
Reference in New Issue