diff --git a/controller/RootLayout.java b/controller/RootLayout.java index 6d2f51c..7758927 100644 --- a/controller/RootLayout.java +++ b/controller/RootLayout.java @@ -94,6 +94,11 @@ public class RootLayout extends Application implements EventObserver { /* (4) #header_icon*/ new HeaderIconStyleSheet( this.root_scene.lookup("#header_icon") ); + + + NewsListModel.getInstance().addObserver("MainClass", this); + NewsListModel.getInstance().setCategory(Category.all); + NewsListModel.getInstance().setSortType(SortTypes.relevancy); this.handleMainLayoutChange("magazines"); } @@ -208,6 +213,7 @@ public class RootLayout extends Application implements EventObserver { case "changeMagCategory": NewsListModel.getInstance().setCategory(Category.valueOf(e.getObjectId().toLowerCase())); + break; } } @@ -237,19 +243,22 @@ public class RootLayout extends Application implements EventObserver { p.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent event) { - //horreur...malheur - p.setStyle("-fx-background-color: #DDDDDD"); - RootLayout.this.root_layout.lookup("#"+NewsListModel.getInstance().getCategory().getLabel()).setStyle("fx-background-color: #F3F3F3"); - RootLayout.this.handleEvent(new Classes.Event(p.getChildren().get(0).getId(), "changeMagCategory")); + + // De-active last gui category (TODO: make this line work) + RootLayout.this.root_layout.lookup("#"+NewsListModel.getInstance().getCategory().getLabel()).getStyleClass().clear(); + + // Change category + NewsListModel.getInstance().setCategory(Category.valueOf(p.getChildren().get(0).getId().toLowerCase())); + + // Active gui category + p.getStyleClass().add("active"); + + // Re-launch request + NewsListModel.getInstance().query(NewsListModel.getInstance().getQuery()); } }); } - NewsListModel.getInstance().addObserver("MainClass", this); - NewsListModel.getInstance().setCategory(Category.gaming); - NewsListModel.getInstance().setSortType(SortTypes.relevancy); - NewsListModel.getInstance().query("the evil within"); - break; } diff --git a/css/menu.css b/css/menu.css index a442f4c..c6b193d 100644 --- a/css/menu.css +++ b/css/menu.css @@ -41,8 +41,4 @@ -fx-border-width: 0 1 0 0; -fx-border-color: #eeeeee; -} - -#submenu{ - -fx-background-color: null; } \ No newline at end of file diff --git a/css/submenu.css b/css/submenu.css new file mode 100644 index 0000000..0e33524 --- /dev/null +++ b/css/submenu.css @@ -0,0 +1,7 @@ +@import "./constants.css"; + + +#submenu .active{ + -fx-fill: #000000; + -fx-font-weight: bold; +} \ No newline at end of file diff --git a/fxml/model.fxml b/fxml/model.fxml index df7b83d..838dea1 100644 --- a/fxml/model.fxml +++ b/fxml/model.fxml @@ -114,9 +114,9 @@ - + - + @@ -124,7 +124,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -156,7 +156,7 @@ - + @@ -166,13 +166,13 @@ - + - + @@ -188,7 +188,7 @@ - + @@ -204,7 +204,7 @@ - + @@ -220,7 +220,7 @@ - + @@ -236,7 +236,7 @@ - + @@ -252,7 +252,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -284,7 +284,7 @@ - + @@ -300,7 +300,7 @@ - + diff --git a/model/NewsListModel.java b/model/NewsListModel.java index 01d2653..9407e56 100644 --- a/model/NewsListModel.java +++ b/model/NewsListModel.java @@ -243,6 +243,11 @@ public class NewsListModel implements Observable{ } } + + public String getQuery() { + return this.query; + } + public ArrayList getNews(){ return this.news; } diff --git a/src/submenu/all.png b/src/submenu/all.png new file mode 100644 index 0000000..5ec7987 Binary files /dev/null and b/src/submenu/all.png differ diff --git a/src/submenu/business.png b/src/submenu/business.png new file mode 100644 index 0000000..83e2c3c Binary files /dev/null and b/src/submenu/business.png differ diff --git a/src/submenu/economics.png b/src/submenu/economics.png new file mode 100644 index 0000000..375a5d3 Binary files /dev/null and b/src/submenu/economics.png differ diff --git a/src/submenu/entertainment.png b/src/submenu/entertainment.png new file mode 100644 index 0000000..3114d8a Binary files /dev/null and b/src/submenu/entertainment.png differ diff --git a/src/submenu/gaming.png b/src/submenu/gaming.png new file mode 100644 index 0000000..23b2bfe Binary files /dev/null and b/src/submenu/gaming.png differ diff --git a/src/submenu/health.png b/src/submenu/health.png new file mode 100644 index 0000000..65dcfff Binary files /dev/null and b/src/submenu/health.png differ diff --git a/src/submenu/music.png b/src/submenu/music.png new file mode 100644 index 0000000..d1724af Binary files /dev/null and b/src/submenu/music.png differ diff --git a/src/submenu/nature.png b/src/submenu/nature.png new file mode 100644 index 0000000..9324377 Binary files /dev/null and b/src/submenu/nature.png differ diff --git a/src/submenu/politics.png b/src/submenu/politics.png new file mode 100644 index 0000000..ec6384d Binary files /dev/null and b/src/submenu/politics.png differ diff --git a/src/submenu/science.png b/src/submenu/science.png new file mode 100644 index 0000000..80b8299 Binary files /dev/null and b/src/submenu/science.png differ diff --git a/src/submenu/sport.png b/src/submenu/sport.png new file mode 100644 index 0000000..a0a2e25 Binary files /dev/null and b/src/submenu/sport.png differ diff --git a/src/submenu/technology.png b/src/submenu/technology.png new file mode 100644 index 0000000..c994fa2 Binary files /dev/null and b/src/submenu/technology.png differ