forked from j62/ctbrec
1
0
Fork 0

Move token label and buy button to ThumbOverviewTab

This commit is contained in:
0xboobface 2018-12-11 15:47:19 +01:00
parent dd76774145
commit 2d1ac40c72
2 changed files with 11 additions and 25 deletions

View File

@ -1,40 +1,18 @@
package ctbrec.ui; package ctbrec.ui;
import ctbrec.sites.Site; import ctbrec.sites.Site;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
public class SiteTab extends Tab implements TabSelectionListener { public class SiteTab extends Tab implements TabSelectionListener {
private BorderPane rootPane = new BorderPane();
private HBox tokenPanel;
private SiteTabPane siteTabPane; private SiteTabPane siteTabPane;
public SiteTab(Site site, Scene scene) { public SiteTab(Site site, Scene scene) {
super(site.getName()); super(site.getName());
setClosable(false); setClosable(false);
setContent(rootPane);
siteTabPane = new SiteTabPane(site, scene); siteTabPane = new SiteTabPane(site, scene);
rootPane.setCenter(siteTabPane); setContent(siteTabPane);
if (site.supportsTips() && site.credentialsAvailable()) {
Button buyTokens = new Button("Buy Tokens");
buyTokens.setOnAction((e) -> DesktopIntegration.open(site.getBuyTokensLink()));
TokenLabel tokenBalance = new TokenLabel(site);
tokenPanel = new HBox(5, tokenBalance, buyTokens);
tokenPanel.setAlignment(Pos.BASELINE_RIGHT);
rootPane.setTop(tokenPanel);
// HBox.setMargin(tokenBalance, new Insets(0, 5, 0, 0));
// HBox.setMargin(buyTokens, new Insets(0, 5, 0, 0));
tokenBalance.loadBalance();
BorderPane.setMargin(tokenPanel, new Insets(5, 10, 0, 10));
}
} }
@Override @Override

View File

@ -143,7 +143,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
+ "Try \"1080\" or \">720\" or \"public\""); + "Try \"1080\" or \">720\" or \"public\"");
filterInput.setTooltip(filterTooltip); filterInput.setTooltip(filterTooltip);
filterInput.getStyleClass().remove("search-box-icon"); filterInput.getStyleClass().remove("search-box-icon");
BorderPane.setMargin(filterInput, new Insets(5));
SearchBox searchInput = new SearchBox(); SearchBox searchInput = new SearchBox();
searchInput.setPromptText("Search Model"); searchInput.setPromptText("Search Model");
@ -154,7 +153,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
popover.hide(); popover.hide();
} }
}); });
BorderPane.setMargin(searchInput, new Insets(5));
popover = new SearchPopover(); popover = new SearchPopover();
popover.maxWidthProperty().bind(popover.minWidthProperty()); popover.maxWidthProperty().bind(popover.minWidthProperty());
@ -170,9 +168,19 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
HBox topBar = new HBox(5); HBox topBar = new HBox(5);
HBox.setHgrow(filterInput, Priority.ALWAYS); HBox.setHgrow(filterInput, Priority.ALWAYS);
topBar.getChildren().add(filterInput); topBar.getChildren().add(filterInput);
if (site.supportsTips() && site.credentialsAvailable()) {
Button buyTokens = new Button("Buy Tokens");
buyTokens.setOnAction((e) -> DesktopIntegration.open(site.getBuyTokensLink()));
TokenLabel tokenBalance = new TokenLabel(site);
tokenBalance.setAlignment(Pos.CENTER_RIGHT);
tokenBalance.prefHeightProperty().bind(buyTokens.heightProperty());
topBar.getChildren().addAll(tokenBalance, buyTokens);
tokenBalance.loadBalance();
}
if(site.supportsSearch()) { if(site.supportsSearch()) {
topBar.getChildren().add(searchInput); topBar.getChildren().add(searchInput);
} }
BorderPane.setMargin(topBar, new Insets(0, 5, 0, 5));
scrollPane.setContent(grid); scrollPane.setContent(grid);
scrollPane.setFitToHeight(true); scrollPane.setFitToHeight(true);