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 */
Context.bind("header-height", 50);
Context.bind("menu-width", 237);
Context.bind("submenu-width", 200);
Context.bind("submenu-width", 166);
Context.bind("article-width", 800);
Context.bind("article-height", 96);
/* (3) Colors */
Context.bind("main-color", 63, 81, 181);
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{
/* (1) Set rules */
Ruleset.load(target)
.add("top", Context.getInt("header-height"))
.add("left", Context.getInt("menu-width")-3)
.add("bottom", 0)
// Ruleset.load(target)
// .add("top", Context.getInt("header-height"))
// .add("left", Context.getInt("menu-width")-3)
// .add("bottom", 0)
//
// .add("min-width", Context.getInt("submenu-width"))
// .add("max-width", Context.getInt("submenu-width"))
//
// .add("min-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("min-width", Context.getInt("submenu-width"))
.add("max-width", Context.getInt("submenu-width"))
.add("min-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("background-color", Context.getString("submenu-bg"))
.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-max-height: -vn-header-height;
-fx-background-color: #fffffd;
-fx-background-color: #ffffff;
}
.menu_item{
-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.scene.Cursor?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
@ -21,10 +22,17 @@
</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">
<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">
<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>
<ImageView fitHeight="57.0" fitWidth="56.0" pickOnBounds="true" preserveRatio="true">
<image>
@ -105,8 +113,204 @@
</VBox>
</children>
</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" />
<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">
<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">
<children>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Tout afficher" />
<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" top="25.0" />
</VBox.margin>
</FlowPane>
<FlowPane alignment="CENTER_RIGHT" columnHalignment="CENTER" layoutX="30.0" layoutY="60.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Science" />
<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="95.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Business" />
<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="130.0" prefHeight="35.0" prefWidth="234.0" styleClass="menu_item">
<children>
<Text fill="#656565" strokeType="OUTSIDE" strokeWidth="0.0" text="Entertainement" />
<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="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>
@ -163,6 +367,9 @@
</children>
<opaqueInsets>
<Insets />
</opaqueInsets></FlowPane>
</opaqueInsets>
</FlowPane>
</content>
</ScrollPane>
</children>
</AnchorPane>

BIN
src/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB