Skip to content

Commit

Permalink
Merge pull request #2831 from axpoems/fix-dropdown-menu-user-selection
Browse files Browse the repository at this point in the history
Update user selection menu with new dropdown menu
  • Loading branch information
HenrikJannsen authored Sep 16, 2024
2 parents 0d938f7 + b421143 commit 09a9204
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 380 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
package bisq.desktop.components.controls;

import bisq.desktop.common.utils.ImageUtil;
import bisq.desktop.components.containers.Spacer;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.WeakChangeListener;
import javafx.collections.ObservableList;
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
Expand All @@ -49,7 +50,7 @@ public class DropdownMenu extends HBox {
private final BooleanProperty isMenuShowing = new SimpleBooleanProperty(false);
private final ContextMenu contextMenu = new ContextMenu();
@Getter
private Label label = new Label();
private final HBox hBox = new HBox();
private ImageView buttonIcon;
private boolean isFirstRun = false;
@Setter
Expand All @@ -71,7 +72,9 @@ public DropdownMenu(String defaultIconId, String activeIconId, boolean useIconOn

buttonIcon = defaultIcon;

getChildren().addAll(label, buttonIcon);
getChildren().addAll(hBox, buttonIcon);
hBox.setAlignment(Pos.BASELINE_LEFT);
hBox.getStyleClass().add("dropdown-menu-content-hbox");

getStyleClass().add("dropdown-menu");
contextMenu.getStyleClass().add("dropdown-menu-popup");
Expand All @@ -84,8 +87,7 @@ public DropdownMenu(String defaultIconId, String activeIconId, boolean useIconOn
setAlignment(Pos.CENTER);
} else {
setSpacing(5);
setAlignment(Pos.CENTER_RIGHT);
setPadding(new Insets(0, 5, 0, 0));
setAlignment(Pos.BASELINE_LEFT);
}

widthPropertyChangeListener = (observable, oldValue, newValue) -> {
Expand All @@ -111,13 +113,18 @@ public DropdownMenu(String defaultIconId, String activeIconId, boolean useIconOn
attachListeners();
}

public void setLabel(String text) {
label.setText(text);
public void setLabelAsContent(String text) {
Label label = new Label(text);
label.setAlignment(Pos.BASELINE_LEFT);
setContent(label);
}

public void setLabel(Label label) {
this.label = label;
getChildren().set(0, label);
public void setContent(Node content) {
hBox.getChildren().setAll(content);
}

public void useSpaceBetweenContentAndIcon() {
getChildren().setAll(hBox, Spacer.fillHBox(), buttonIcon);
}

private void toggleContextMenu() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public DropdownMenuItem(String defaultIconId, String activeIconId, Node node) {
setContent(hBox);
}

public DropdownMenuItem(Node node) {
this(null, null, node);
}

public void updateWidth(Double width) {
hBox.setPrefWidth(width);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,13 @@ private RichTableView(SortedList<T> sortedList,
filterItems.ifPresent(filterMenu::addMenuItems);
tooltip = new BisqTooltip();
filterMenu.setTooltip(tooltip);
filterMenu.setAlignment(Pos.BASELINE_LEFT);

searchBox = new SearchBox();
searchBox.setManaged(searchTextHandler.isPresent());
searchBox.setVisible(searchBox.isManaged());
searchBox.setPrefWidth(90);
searchBox.setAlignment(Pos.BASELINE_LEFT);
HBox.setMargin(filterMenu, new Insets(0, 20, 0, 0));
HBox filterBox = new HBox(20, searchBox, filterMenu);
HBox filterBox = new HBox(10, searchBox, filterMenu);
filterBox.setAlignment(Pos.BASELINE_LEFT);

HBox headerBox = new HBox(headlineLabel, Spacer.fillHBox(), filterBox);
Expand All @@ -163,7 +161,7 @@ private RichTableView(SortedList<T> sortedList,
HBox footerHBox = new HBox(numEntriesLabel, Spacer.fillHBox(), exportHyperlink);
footerHBox.setAlignment(Pos.BASELINE_LEFT);

VBox.setMargin(headerBox, new Insets(0, 0, 5, 10));
VBox.setMargin(headerBox, new Insets(0, 10, 5, 10));
VBox.setVgrow(tableView, Priority.ALWAYS);
VBox.setMargin(footerHBox, new Insets(-5, 0, 0, 10));
getChildren().addAll(headerBox, tableView, footerHBox);
Expand Down Expand Up @@ -271,7 +269,7 @@ private void selectedFilterMenuItemChanged() {
toggleGroup.flatMap(toggleGroup -> FilterMenuItem.fromToggle(toggleGroup.getSelectedToggle()))
.ifPresent(filterMenuItem -> {
tooltip.setText(Res.get("component.standardTable.filter.tooltip", filterMenuItem.getTitle()));
filterMenu.setLabel(filterMenuItem.getTitle());
filterMenu.setLabelAsContent(filterMenuItem.getTitle());
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public class OfferbookListView extends bisq.desktop.common.view.View<VBox, Offer
showOnlyMyMessages = new CheckBox();
showOnlyMyMessagesHBox = new HBox(5, showOnlyMyMessages, showMyOffersOnlyLabel);
showOnlyMyMessagesHBox.getStyleClass().add("offerbook-subheader-checkbox");
showOnlyMyMessagesHBox.setAlignment(Pos.CENTER);
showOnlyMyMessagesHBox.setAlignment(Pos.CENTER_LEFT);

HBox subheader = new HBox(10);
subheader.setAlignment(Pos.CENTER_LEFT);
subheader.getStyleClass().add("offer-list-subheader");
subheader.setAlignment(Pos.CENTER_LEFT);
subheader.getChildren().addAll(offerDirectionFilterMenu, paymentsFilterMenu, showOnlyMyMessagesHBox);

tableView = new BisqTableView<>(model.getSortedOfferbookListItems());
Expand Down Expand Up @@ -263,7 +263,7 @@ private DropdownMenu createAndGetOffersDirectionFilterMenu() {
menu.getStyleClass().add("dropdown-offer-list-direction-filter-menu");
menu.setOpenToTheRight(true);
offerDirectionFilterLabel = new Label();
menu.setLabel(offerDirectionFilterLabel);
menu.setContent(offerDirectionFilterLabel);
buyFromOffers = new DropdownBisqMenuItem(Res.get("bisqEasy.offerbook.offerList.table.filters.offerDirection.buyFrom"));
sellToOffers = new DropdownBisqMenuItem(Res.get("bisqEasy.offerbook.offerList.table.filters.offerDirection.sellTo"));
menu.addMenuItems(buyFromOffers, sellToOffers);
Expand All @@ -275,7 +275,7 @@ private DropdownMenu createAndGetPaymentsFilterDropdownMenu() {
menu.getStyleClass().add("dropdown-offer-list-payment-filter-menu");
menu.setOpenToTheRight(true);
paymentsFilterLabel = new Label();
menu.setLabel(paymentsFilterLabel);
menu.setContent(paymentsFilterLabel);
return menu;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.content.chat.message_container;

import bisq.bisq_easy.NavigationTarget;
import bisq.chat.*;
import bisq.chat.ChatChannel;
import bisq.chat.ChatChannelDomain;
import bisq.chat.ChatChannelSelectionService;
import bisq.chat.ChatMessage;
import bisq.chat.ChatService;
import bisq.chat.Citation;
import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookChannel;
import bisq.chat.bisqeasy.open_trades.BisqEasyOpenTradeChannel;
import bisq.chat.common.CommonPublicChatChannel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.content.chat.message_container;

import bisq.common.util.StringUtils;
import bisq.desktop.common.threading.UIThread;
import bisq.desktop.common.utils.ImageUtil;
import bisq.desktop.components.controls.BisqTextArea;
Expand All @@ -20,7 +36,6 @@
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.util.StringConverter;
import lombok.extern.slf4j.Slf4j;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
Expand Down Expand Up @@ -157,23 +172,13 @@ private void setUpInputFieldAtMentions() {

private void setUpUserProfileSelection(UserProfileSelection userProfileSelection) {
userProfileSelection.setMaxComboBoxWidth(165);
userProfileSelection.setConverter(new StringConverter<>() {
@Override
public String toString(UserProfileSelection.ListItem item) {
return item != null ? StringUtils.truncate(item.getUserIdentity().getUserName(), 10) : "";
}

@Override
public UserProfileSelection.ListItem fromString(String string) {
return null;
}
});
userProfileSelection.openMenuUpwards();
userProfileSelection.openMenuToTheRight();
userProfileSelectionRoot = userProfileSelection.getRoot();
userProfileSelectionRoot.setMaxHeight(44);
userProfileSelectionRoot.setMaxHeight(45);
userProfileSelectionRoot.setMaxWidth(165);
userProfileSelectionRoot.setMinWidth(165);
userProfileSelectionRoot.setId("chat-user-profile-bg");
HBox.setMargin(userProfileSelectionRoot, new Insets(0, -20, 0, -8));
userProfileSelectionRoot.getStyleClass().add("chat-user-profile-bg");
}

private void createChatDialogEnabledSubscription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class MaterialUserProfileSelection extends Pane {
protected final Region bg = new Region();
protected final Region line = new Region();
protected final Region selectionLine = new Region();
@Getter
protected final Label descriptionLabel = new Label();
protected final Pane userProfileSelectionRoot;
@Getter
Expand Down Expand Up @@ -98,7 +99,6 @@ public MaterialUserProfileSelection(UserProfileSelection userProfileSelection,
descriptionLabel.setText(description);
}


userProfileSelectionRoot = userProfileSelection.getRoot();
userProfileSelectionRoot.setLayoutX(6.5);
userProfileSelectionRoot.getStyleClass().add("material-text-field");
Expand Down Expand Up @@ -152,10 +152,6 @@ public final StringProperty descriptionProperty() {
return descriptionLabel.textProperty();
}

public Label getDescriptionLabel() {
return descriptionLabel;
}


///////////////////////////////////////////////////////////////////////////////////////////////////
// Help
Expand Down
Loading

0 comments on commit 09a9204

Please sign in to comment.