added scroller + global layout fixes

This commit is contained in:
xdrm-brackets 2017-12-12 08:58:26 +01:00
parent d08f2362e4
commit 2e78af3d52
6 changed files with 344 additions and 79 deletions

View File

@ -13,14 +13,14 @@ public class ContextBuilder{
/* (2) Base layout dimension */ /* (2) Base layout dimension */
Context.bind("header-height", 50); Context.bind("header-height", 50);
Context.bind("menu-width", 237); Context.bind("menu-width", 237);
Context.bind("submenu-width", 200); Context.bind("submenu-width", 166);
Context.bind("article-width", 800); Context.bind("article-width", 800);
Context.bind("article-height", 96); Context.bind("article-height", 96);
/* (3) Colors */ /* (3) Colors */
Context.bind("main-color", 63, 81, 181); Context.bind("main-color", 63, 81, 181);
Context.bind("menu-bg", 255, 255, 253); Context.bind("menu-bg", 255, 255, 253);
Context.bind("submenu-bg", 255, 0, 0); Context.bind("submenu-bg", 250, 250, 250);
} }

View File

@ -10,22 +10,22 @@ public class SubMenuStyleSheet{
public SubMenuStyleSheet(Node target) throws Exception{ public SubMenuStyleSheet(Node target) throws Exception{
/* (1) Set rules */ /* (1) Set rules */
Ruleset.load(target) // Ruleset.load(target)
.add("top", Context.getInt("header-height")) // .add("top", Context.getInt("header-height"))
.add("left", Context.getInt("menu-width")-3) // .add("left", Context.getInt("menu-width")-3)
.add("bottom", 0) // .add("bottom", 0)
//
.add("min-width", Context.getInt("submenu-width")) // .add("min-width", Context.getInt("submenu-width"))
.add("max-width", Context.getInt("submenu-width")) // .add("max-width", Context.getInt("submenu-width"))
//
.add("min-height", Context.getInt("screen-height") - Context.getInt("header-height")) // .add("min-height", Context.getInt("screen-height") - Context.getInt("header-height"))
.add("max-height", Context.getInt("screen-height") - Context.getInt("header-height")) // .add("max-height", Context.getInt("screen-height") - Context.getInt("header-height"))
//
// .add("pref-width", Context.getInt("submenu-width"))
// .add("pref-height", Context.getInt("screen-height") - Context.getInt("header-height"))
.add("pref-width", Context.getInt("submenu-width")) // .add("background-color", Context.getString("submenu-bg"))
.add("pref-height", Context.getInt("screen-height") - Context.getInt("header-height")) // .apply();
.add("background-color", Context.getString("submenu-bg"))
.apply();
} }
} }

47
controller/MainMenu.java Normal file
View File

@ -0,0 +1,47 @@
package controller;
import java.util.ArrayList;
import Interfaces.EventObserver;
import javafx.event.EventHandler;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
public class MainMenu{
/* Data */
private ArrayList<ImageView> items;
private FlowPane parent;
private EventObserver observer;
/* Constructor */
public MainMenu(FlowPane p_parent, EventObserver observer){
this.parent = p_parent;
this.items = new ArrayList<ImageView>();
this.observer = observer;
}
public void addItem(String p_name, String p_image_uri) {
ImageView menuItem = new ImageView();
menuItem.setImage(new Image(p_image_uri));
menuItem.setId("header_menu_item_"+p_name);
menuItem.getStyleClass().add("header_menu_item");
menuItem.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
MainMenu.this.observer.handleEvent(new Classes.Event(menuItem.getId(), "changeMainLayout"));
}
});
this.items.add(menuItem);
// Add to parent
parent.getChildren().add(menuItem);
}
}

View File

@ -27,11 +27,22 @@
-fx-min-height: -vn-header-height; -fx-min-height: -vn-header-height;
-fx-max-height: -vn-header-height; -fx-max-height: -vn-header-height;
-fx-background-color: #fffffd; -fx-background-color: #ffffff;
} }
.menu_item{ .menu_item{
-fx-border-width: 0 0 1 0; -fx-border-width: 0 0 1 0;
-fx-border-color: #dddddd -fx-border-color: #eeeeee;
}
#menu{
-fx-background-color: #ffffff;
-fx-border-width: 0 1 0 0;
-fx-border-color: #eeeeee;
}
#submenu{
-fx-background-color: null;
} }

View File

@ -2,6 +2,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?> <?import javafx.scene.Cursor?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.Image?> <?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?> <?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
@ -21,10 +22,17 @@
</AnchorPane> </AnchorPane>
<AnchorPane id="menu_wrapper" fx:id="menu_wrapper" 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"> <AnchorPane id="menu_wrapper" fx:id="menu_wrapper" 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> <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" /> <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">
<children>
<ImageView fitHeight="35.0" fitWidth="32.0" layoutX="10.0" layoutY="9.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../src/icon.png" />
</image>
</ImageView>
</children></Pane>
<VBox id="menu" fx:id="menu" layoutX="50.0" layoutY="40.0" prefHeight="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0"> <VBox id="menu" fx:id="menu" layoutX="50.0" layoutY="40.0" prefHeight="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
<children> <children>
<FlowPane alignment="CENTER_LEFT" prefHeight="114.0" prefWidth="234.0" style="-fx-border-width: 0 0 1 0; -fx-border-color: #fafafa;"> <FlowPane alignment="CENTER_LEFT" prefHeight="114.0" prefWidth="234.0" style="-fx-border-width: 0 0 1 0; -fx-border-color: #eeeeee;">
<children> <children>
<ImageView fitHeight="57.0" fitWidth="56.0" pickOnBounds="true" preserveRatio="true"> <ImageView fitHeight="57.0" fitWidth="56.0" pickOnBounds="true" preserveRatio="true">
<image> <image>
@ -105,64 +113,263 @@
</VBox> </VBox>
</children> </children>
</AnchorPane> </AnchorPane>
<VBox id="submenu" fx:id="submenu" layoutX="234.0" layoutY="50.0" prefHeight="650.0" prefWidth="194.0" style="-fx-background-color: white;" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="50.0" /> <VBox id="submenu" fx:id="submenu" layoutX="234.0" layoutY="50.0" prefHeight="650.0" prefWidth="166.0" style="-fx-background-color: white;" AnchorPane.bottomAnchor="0.0" AnchorPane.topAnchor="50.0">
<FlowPane id="container" fx:id="container" alignment="TOP_CENTER" columnHalignment="CENTER" layoutX="421.0" layoutY="50.0" prefWrapLength="1000.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="429.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
<children> <children>
<AnchorPane fx:id="card1" prefHeight="118.0" style="-fx-border-insets: 10; -fx-background-insets: 10; -fx-background-color: #fff; -fx-background-radius: 3; -fx-border-radius: 3; -fx-border-color: #ddd;"> <FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<opaqueInsets> <children>
<Insets /> <Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Tout afficher" />
</opaqueInsets> <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<children> <FlowPane.margin>
<ImageView fitHeight="56.0" fitWidth="56.0" layoutX="-28.0" layoutY="38.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="20.0"> <Insets left="15.0" />
<image> </FlowPane.margin>
<Image url="@../src/menu_profile_1.png" /> <image>
</image> <Image url="@../src/menu/dictionary.png" />
</ImageView> </image>
<Text fill="#808080" fontSmoothingType="LCD" layoutX="118.0" layoutY="78.8439998626709" strokeType="OUTSIDE" strokeWidth="0.0" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam posuere odio ut sem vestibulum, at tempus neque luctus. Curabitur quis tortor bibendum" wrappingWidth="653.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="50.0"> </ImageView>
<font> </children>
<Font name="Lato Regular" size="12.0" /> <VBox.margin>
</font> <Insets left="20.0" right="20.0" top="25.0" />
</Text> </VBox.margin>
<Text fill="#757575" layoutX="611.0" layoutY="37.0" strokeType="OUTSIDE" strokeWidth="0.0" text="10 days ago" textAlignment="RIGHT" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="20.0"> </FlowPane>
<font> <FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="30.0" layoutY="60.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<Font name="Lato Bold" size="12.0" /> <children>
</font> <Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Science" />
</Text> <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<HBox layoutX="118.0" layoutY="39.0" prefHeight="21.0" prefWidth="200.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="20.0"> <FlowPane.margin>
<children> <Insets left="15.0" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Some Article Title"> </FlowPane.margin>
<font> <image>
<Font name="Lato Bold" size="17.0" /> <Image url="@../src/menu/dictionary.png" />
</font> </image>
</Text> </ImageView>
<FlowPane alignment="CENTER" columnHalignment="CENTER" prefHeight="20.0" style="-fx-background-color: red; -fx-background-radius: 3;"> </children>
<children> <VBox.margin>
<Text fill="WHITE" fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="nature"> <Insets left="20.0" right="20.0" />
<font> </VBox.margin>
<Font name="Lato Regular" size="14.0" /> </FlowPane>
</font> <FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="30.0" layoutY="95.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<FlowPane.margin> <children>
<Insets /> <Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Business" />
</FlowPane.margin> <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
</Text> <FlowPane.margin>
</children> <Insets left="15.0" />
<HBox.margin> </FlowPane.margin>
<Insets left="10.0" /> <image>
</HBox.margin> <Image url="@../src/menu/dictionary.png" />
<padding> </image>
<Insets left="5.0" right="5.0" /> </ImageView>
</padding> </children>
</FlowPane> <VBox.margin>
</children> <Insets left="20.0" right="20.0" />
</HBox> </VBox.margin>
</children> </FlowPane>
<cursor> <FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="30.0" layoutY="130.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<Cursor fx:constant="HAND" /> <children>
</cursor> <Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Entertainement" />
</AnchorPane> <ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
</children> <FlowPane.margin>
<opaqueInsets> <Insets left="15.0" />
<Insets /> </FlowPane.margin>
</opaqueInsets></FlowPane> <image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="165.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Gaming" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="200.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Health" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="30.0" layoutY="235.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Music" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="270.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Sport" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="305.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Nature" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="340.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Economics" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="375.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Politics" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="10.0" layoutY="410.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Technology" />
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<FlowPane.margin>
<Insets left="15.0" />
</FlowPane.margin>
<image>
<Image url="@../src/menu/dictionary.png" />
</image>
</ImageView>
</children>
<VBox.margin>
<Insets left="20.0" right="20.0" />
</VBox.margin>
</FlowPane>
</children></VBox>
<ScrollPane hbarPolicy="NEVER" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="400.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="50.0">
<content>
<FlowPane id="container" fx:id="container" alignment="TOP_CENTER" columnHalignment="CENTER" prefHeight="650.0" prefWidth="880.0" prefWrapLength="1000.0">
<children>
<AnchorPane fx:id="card1" prefHeight="118.0" style="-fx-border-insets: 10; -fx-background-insets: 10; -fx-background-color: #fff; -fx-background-radius: 3; -fx-border-radius: 3; -fx-border-color: #ddd;">
<opaqueInsets>
<Insets />
</opaqueInsets>
<children>
<ImageView fitHeight="56.0" fitWidth="56.0" layoutX="-28.0" layoutY="38.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="20.0">
<image>
<Image url="@../src/menu_profile_1.png" />
</image>
</ImageView>
<Text fill="#808080" fontSmoothingType="LCD" layoutX="118.0" layoutY="78.8439998626709" strokeType="OUTSIDE" strokeWidth="0.0" text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam posuere odio ut sem vestibulum, at tempus neque luctus. Curabitur quis tortor bibendum" wrappingWidth="653.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="50.0">
<font>
<Font name="Lato Regular" size="12.0" />
</font>
</Text>
<Text fill="#757575" layoutX="611.0" layoutY="37.0" strokeType="OUTSIDE" strokeWidth="0.0" text="10 days ago" textAlignment="RIGHT" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="20.0">
<font>
<Font name="Lato Bold" size="12.0" />
</font>
</Text>
<HBox layoutX="118.0" layoutY="39.0" prefHeight="21.0" prefWidth="200.0" AnchorPane.leftAnchor="96.0" AnchorPane.topAnchor="20.0">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Some Article Title">
<font>
<Font name="Lato Bold" size="17.0" />
</font>
</Text>
<FlowPane alignment="CENTER" columnHalignment="CENTER" prefHeight="20.0" style="-fx-background-color: red; -fx-background-radius: 3;">
<children>
<Text fill="WHITE" fontSmoothingType="LCD" strokeType="OUTSIDE" strokeWidth="0.0" text="nature">
<font>
<Font name="Lato Regular" size="14.0" />
</font>
<FlowPane.margin>
<Insets />
</FlowPane.margin>
</Text>
</children>
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</FlowPane>
</children>
</HBox>
</children>
<cursor>
<Cursor fx:constant="HAND" />
</cursor>
</AnchorPane>
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
</FlowPane>
</content>
</ScrollPane>
</children> </children>
</AnchorPane> </AnchorPane>

BIN
src/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB