Improve layout and fix issue with phase breaks

This commit is contained in:
Christoph Atteneder 2019-03-25 20:47:28 +01:00
parent 942d8366b2
commit f6f2a663e8
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
4 changed files with 42 additions and 16 deletions

View file

@ -1681,6 +1681,7 @@ dao.proposal.active.remove.confirm=Are you sure you want to remove that proposal
The already paid proposal fee will be lost.
dao.proposal.active.remove.doRemove=Yes, remove my proposal
dao.proposal.active.remove.failed=Could not remove proposal.
dao.proposal.myVote.title=Voting
dao.proposal.myVote.accept=Accept proposal
dao.proposal.myVote.reject=Reject proposal
dao.proposal.myVote.removeMyVote=Ignore proposal

View file

@ -140,9 +140,10 @@ public class ProposalDisplay {
private final ChangeListener<Object> inputListener;
private ChangeListener<Param> paramChangeListener;
private ChangeListener<BondedRoleType> requiredBondForRoleListener;
private TitledGroupBg titledGroupBg;
private TitledGroupBg myVoteTitledGroup;
private int titledGroupBgRowSpan;
private VBox linkWithIconContainer, comboBoxValueContainer, myVoteBox, voteResultBox;
private int votingBoxRowSpan;
public ProposalDisplay(GridPane gridPane,
BsqFormatter bsqFormatter,
@ -176,6 +177,11 @@ public class ProposalDisplay {
public void createAllFields(String title, int gridRowStartIndex, double top, ProposalType proposalType,
boolean isMakeProposalScreen) {
createAllFields(title, gridRowStartIndex, top, proposalType, isMakeProposalScreen, null);
}
public void createAllFields(String title, int gridRowStartIndex, double top, ProposalType proposalType,
boolean isMakeProposalScreen, String titledGroupStyle) {
removeAllFields();
this.gridRowStartIndex = gridRowStartIndex;
this.gridRow = gridRowStartIndex;
@ -200,16 +206,22 @@ public class ProposalDisplay {
break;
}
titledGroupBg = addTitledGroupBg(gridPane, gridRow, titledGroupBgRowSpan, title, top);
TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, gridRow, titledGroupBgRowSpan, title, top);
if (titledGroupStyle != null) titledGroupBg.getStyleClass().add(titledGroupStyle);
double proposalTypeTop;
if (top == Layout.GROUP_DISTANCE_WITHOUT_SEPARATOR) {
proposalTypeTop = Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE_WITHOUT_SEPARATOR;
} else if (top == Layout.GROUP_DISTANCE) {
proposalTypeTop = Layout.FIRST_ROW_AND_GROUP_DISTANCE;
} else {
} else if (top == 0) {
proposalTypeTop = Layout.FIRST_ROW_DISTANCE;
} else {
proposalTypeTop = Layout.FIRST_ROW_DISTANCE + top;
}
proposalTypeTextField = addTopLabelTextField(gridPane, gridRow,
Res.get("dao.proposal.display.type"), proposalType.getDisplayName(), proposalTypeTop).second;
@ -325,7 +337,7 @@ public class ProposalDisplay {
}
});
comboBoxes.add(bondedRoleTypeComboBox);
requiredBondForRoleTextField = addTopLabelTextField(gridPane, ++gridRow,
requiredBondForRoleTextField = addTopLabelReadOnlyTextField(gridPane, ++gridRow,
Res.get("dao.proposal.display.requiredBondForRole.label")).second;
requiredBondForRoleListener = (observable, oldValue, newValue) -> {
@ -407,7 +419,11 @@ public class ProposalDisplay {
proposalFeeTextField.setText(bsqFormatter.formatCoinWithCode(daoFacade.getProposalFee(daoFacade.getChainHeight())));
}
Tuple3<Label, TextField, VBox> tuple3 = addTopLabelTextField(gridPane, ++gridRow, Res.get("dao.proposal.display.myVote"));
votingBoxRowSpan = 4;
myVoteTitledGroup = addTitledGroupBg(gridPane, ++gridRow, 4, Res.get("dao.proposal.myVote.title"), Layout.COMPACT_FIRST_ROW_DISTANCE);
Tuple3<Label, TextField, VBox> tuple3 = addTopLabelTextField(gridPane, ++gridRow, Res.get("dao.proposal.display.myVote"), Layout.COMPACT_FIRST_ROW_DISTANCE);
myVoteBox = tuple3.third;
setMyVoteBoxVisibility(false);
@ -439,7 +455,6 @@ public class ProposalDisplay {
}
public void applyEvaluatedProposal(@Nullable EvaluatedProposal evaluatedProposal) {
GridPane.setRowSpan(titledGroupBg, titledGroupBgRowSpan + 1);
boolean isEvaluatedProposalNotNull = evaluatedProposal != null;
if (isEvaluatedProposalNotNull) {
@ -475,6 +490,8 @@ public class ProposalDisplay {
String myVoteSummary = Res.get("dao.proposal.myVote.summary", myVote,
weight, meritString, stakeString);
myVoteTextField.setText(myVoteSummary);
GridPane.setRowSpan(myVoteTitledGroup, votingBoxRowSpan - 1);
}
boolean show = ballotIsNotNull && hasVoted;
@ -666,11 +683,9 @@ public class ProposalDisplay {
}
private void setMyVoteBoxVisibility(boolean visibility) {
myVoteTitledGroup.setVisible(visibility);
myVoteTitledGroup.setManaged(visibility);
myVoteBox.setVisible(visibility);
myVoteBox.setManaged(visibility);
if (visibility) {
GridPane.setRowSpan(titledGroupBg, titledGroupBgRowSpan);
}
}
}

View file

@ -394,8 +394,8 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
.findAny()
.orElse(null);
showVoteOnProposalWindow(selectedItem.getProposal(), selectedItem.getBallot(), evaluatedProposal);
applyMerit();
showVoteOnProposalWindow(selectedItem.getProposal(), selectedItem.getBallot(), evaluatedProposal);
}
onPhaseChanged(daoFacade.phaseProperty().get());

View file

@ -3,6 +3,7 @@ package bisq.desktop.main.overlays.windows;
import bisq.desktop.Navigation;
import bisq.desktop.main.dao.governance.ProposalDisplay;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.util.Layout;
import bisq.core.dao.DaoFacade;
import bisq.core.dao.governance.myvote.MyVote;
@ -127,8 +128,8 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
private void addContent(Proposal proposal, EvaluatedProposal evaluatedProposal, Ballot ballot) {
ProposalDisplay proposalDisplay = new ProposalDisplay(gridPane, bsqFormatter, daoFacade, changeParamValidator,
navigation, preferences);
proposalDisplay.createAllFields("", rowIndex, 0, proposal.getType(),
false);
proposalDisplay.createAllFields("", rowIndex, -Layout.FIRST_ROW_DISTANCE, proposal.getType(),
false, "last");
proposalDisplay.setEditable(false);
proposalDisplay.applyProposalPayload(proposal);
proposalDisplay.applyEvaluatedProposal(evaluatedProposal);
@ -142,7 +143,9 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
List<MyVote> myVoteListForCycle = daoFacade.getMyVoteListForCycle();
boolean hasAlreadyVoted = !myVoteListForCycle.isEmpty();
if (daoFacade.phaseProperty().get() == DaoPhase.Phase.PROPOSAL) {
DaoPhase.Phase currentPhase = daoFacade.phaseProperty().get();
if (currentPhase == DaoPhase.Phase.PROPOSAL) {
Tuple2<Button, Button> proposalPhaseButtonsTuple = add2ButtonsAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.remove"), Res.get("shared.close"));
Button removeProposalButton = proposalPhaseButtonsTuple.first;
@ -158,9 +161,12 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
proposalPhaseButtonsTuple.second.setOnAction(event -> doClose());
} else if (daoFacade.phaseProperty().get() == DaoPhase.Phase.BLIND_VOTE && !hasAlreadyVoted) {
} else if (currentPhase == DaoPhase.Phase.BLIND_VOTE &&
!hasAlreadyVoted &&
daoFacade.isInPhaseButNotLastBlock(currentPhase)) {
int rowIndexForVoting = proposalDisplay.incrementAndGetGridRow();
Tuple3<Button, Button, Button> tuple = add3ButtonsAfterGroup(gridPane,
proposalDisplay.incrementAndGetGridRow(),
rowIndexForVoting,
Res.get("dao.proposal.myVote.accept"),
Res.get("dao.proposal.myVote.reject"),
Res.get("dao.proposal.myVote.removeMyVote"));
@ -191,6 +197,10 @@ public class SelectProposalWindow extends Overlay<SelectProposalWindow> {
ignoreHandlerOptional.ifPresent(Runnable::run);
doClose();
});
Button closeButton = addButtonAfterGroup(gridPane, ++rowIndexForVoting, Res.get("shared.close"));
closeButton.setOnAction(event -> doClose());
} else {
Button closeButton = addButtonAfterGroup(gridPane, proposalDisplay.incrementAndGetGridRow(), Res.get("shared.close"));
closeButton.setOnAction(event -> doClose());