Fixed resize problems and some other stuff

This commit is contained in:
DieGurke 2020-07-18 14:41:25 +02:00
parent 0674035183
commit 01f81fadac
7 changed files with 52 additions and 106 deletions

View File

@ -235,7 +235,7 @@ public final class LoginScene {
// Load ChatScene
sceneContext.pop();
sceneContext.getStage().setMinHeight(400);
sceneContext.getStage().setMinWidth(350);
sceneContext.getStage().setMinWidth(843);
sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE);
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
}

View File

@ -37,6 +37,7 @@ import envoy.util.EnvoyLog;
public class MessageControl extends Label {
private static User client;
private boolean ownMessage;
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")
.withZone(ZoneId.systemDefault());
@ -95,7 +96,11 @@ public class MessageControl extends Label {
statusIcon.setPreserveRatio(true);
vbox.getChildren().add(statusIcon);
getStyleClass().add("own-message");
} else getStyleClass().add("received-message");
ownMessage = true;
} else {
getStyleClass().add("received-message");
ownMessage = false;
}
// Adjusting height and weight of the cell to the corresponding ListView
paddingProperty().setValue(new Insets(5, 20, 5, 20));
setContextMenu(contextMenu);
@ -123,4 +128,6 @@ public class MessageControl extends Label {
* @since Envoy Client v0.1-beta
*/
public static void setUser(User client) { MessageControl.client = client; }
public boolean isOwnMessage() { return ownMessage; }
}

View File

@ -1,5 +1,6 @@
package envoy.client.ui.listcell;
import javafx.geometry.Pos;
import javafx.scene.control.ListView;
import envoy.data.Message;
@ -15,7 +16,6 @@ import envoy.data.Message;
* @since Envoy Client v0.1-beta
*/
public final class MessageListCell extends AbstractListCell<Message, MessageControl> {
/**
* @param listView the list view inside of which the cell will be displayed
* @since Envoy Client v0.1-beta
@ -25,7 +25,9 @@ public final class MessageListCell extends AbstractListCell<Message, MessageCont
@Override
protected MessageControl renderItem(Message message) {
final var control = new MessageControl(message);
prefWidthProperty().bind(listView.widthProperty().multiply(0.6));
maxWidthProperty().bind(listView.widthProperty().multiply(0.6));
if (control.isOwnMessage()) setAlignment(Pos.CENTER_RIGHT);
else setAlignment(Pos.CENTER_LEFT);
return control;
}
}

View File

@ -135,7 +135,3 @@
.listElement {
-fx-background-color: transparent;
}
.listElement {
-fx-background-color: transparent;
}

View File

@ -18,33 +18,19 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<GridPane fx:id="scene" maxHeight="-Infinity"
maxWidth="-Infinity" minHeight="400.0" minWidth="500.0"
prefHeight="1152.0" prefWidth="2042.0"
xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="envoy.client.ui.controller.ChatScene">
<GridPane fx:id="scene" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="500.0" prefHeight="1152.0" prefWidth="2042.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.ChatScene">
<columnConstraints>
<ColumnConstraints hgrow="NEVER"
maxWidth="327.99997965494794" minWidth="-Infinity" prefWidth="317.0" />
<ColumnConstraints hgrow="ALWAYS"
maxWidth="1.7976931348623157E308" />
<ColumnConstraints hgrow="NEVER" maxWidth="327.99997965494794" minWidth="-Infinity" prefWidth="317.0" />
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="122.00000508626302"
minHeight="-Infinity" prefHeight="96.66666158040364" vgrow="NEVER" />
<RowConstraints maxHeight="1.7976931348623157E308"
minHeight="50.0" prefHeight="949.3333384195963" vgrow="ALWAYS" />
<RowConstraints maxHeight="59.3333740234375"
minHeight="-Infinity" prefHeight="22.666748046875" vgrow="NEVER" />
<RowConstraints maxHeight="120.0" minHeight="-Infinity"
prefHeight="83.333251953125" vgrow="NEVER" />
<RowConstraints maxHeight="122.00000508626302" minHeight="-Infinity" prefHeight="96.66666158040364" vgrow="NEVER" />
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="50.0" prefHeight="949.3333384195963" vgrow="ALWAYS" />
<RowConstraints maxHeight="59.3333740234375" minHeight="-Infinity" prefHeight="22.666748046875" vgrow="NEVER" />
<RowConstraints maxHeight="120.0" minHeight="-Infinity" prefHeight="83.333251953125" vgrow="NEVER" />
</rowConstraints>
<children>
<ListView id="chatList" fx:id="chatList"
focusTraversable="false" onMouseClicked="#chatListClicked"
prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1"
GridPane.rowSpan="2147483647">
<ListView id="chatList" fx:id="chatList" focusTraversable="false" onMouseClicked="#chatListClicked" prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1" GridPane.rowSpan="2147483647">
<GridPane.margin>
<Insets right="1.0" />
</GridPane.margin>
@ -54,23 +40,19 @@
<contextMenu>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT">
<items>
<MenuItem fx:id="deleteContactMenuItem"
mnemonicParsing="false" onAction="#deleteContact" text="Delete" />
<MenuItem fx:id="deleteContactMenuItem" mnemonicParsing="false" onAction="#deleteContact" text="Delete" />
</items>
</ContextMenu>
</contextMenu>
</ListView>
<HBox id="topBar" alignment="CENTER_LEFT" prefHeight="100.0">
<children>
<ImageView id="profilePic" fx:id="clientProfilePic"
fitHeight="43.0" fitWidth="43.0" pickOnBounds="true"
preserveRatio="true">
<ImageView id="profilePic" fx:id="clientProfilePic" fitHeight="43.0" fitWidth="43.0" pickOnBounds="true" preserveRatio="true">
<HBox.margin>
<Insets left="15.0" top="5.0" />
</HBox.margin>
</ImageView>
<Label id="transparentBackground" fx:id="contactLabel"
prefHeight="27.0" prefWidth="134.0">
<Label id="transparentBackground" fx:id="contactLabel" prefHeight="27.0" prefWidth="134.0">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
@ -81,13 +63,10 @@
<Insets left="10.0" top="5.0" />
</HBox.margin>
</Label>
<Region id="transparentBackground" prefHeight="77.0"
prefWidth="115.0" />
<VBox id="transparentBackground" alignment="CENTER_RIGHT"
prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<Region id="transparentBackground" prefHeight="77.0" prefWidth="115.0" />
<VBox id="transparentBackground" alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children>
<Button fx:id="settingsButton" mnemonicParsing="true"
onAction="#settingsButtonClicked" text="">
<Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" text="">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
@ -95,8 +74,7 @@
<Insets />
</VBox.margin>
</Button>
<Button mnemonicParsing="true"
onAction="#addContactButtonClicked" text=" + ">
<Button mnemonicParsing="true" onAction="#addContactButtonClicked" text=" + ">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
@ -114,10 +92,7 @@
<Insets bottom="1.0" right="1.0" />
</GridPane.margin>
</HBox>
<ListView id="messageList" fx:id="messageList"
focusTraversable="false" GridPane.columnIndex="1"
GridPane.columnSpan="2147483647" GridPane.rowIndex="1"
GridPane.rowSpan="2">
<ListView id="messageList" fx:id="messageList" focusTraversable="false" GridPane.columnIndex="1" GridPane.columnSpan="2147483647" GridPane.rowIndex="1" GridPane.rowSpan="2">
<GridPane.margin>
<Insets />
</GridPane.margin>
@ -125,17 +100,11 @@
<Insets bottom="5.0" top="5.0" />
</padding>
</ListView>
<HBox alignment="CENTER" GridPane.columnIndex="1"
GridPane.rowIndex="3">
<HBox alignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="3">
<children>
<Label id="messageEnterContainer" alignment="CENTER"
minWidth="500.0" prefHeight="100.0" prefWidth="1300.0">
<Label id="messageEnterContainer" alignment="CENTER" minWidth="300.0" prefHeight="100.0" prefWidth="800.0">
<graphic>
<TextArea id="messageEnter" fx:id="messageTextArea"
disable="true" onInputMethodTextChanged="#messageTextUpdated"
onKeyPressed="#checkPostConditions"
onKeyTyped="#checkKeyCombination" prefHeight="100.0"
prefWidth="1250.0" promptText="Enter Message" wrapText="true">
<TextArea id="messageEnter" fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination" prefHeight="100.0" prefWidth="1250.0" promptText="Enter Message" wrapText="true">
<opaqueInsets>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</opaqueInsets>
@ -147,46 +116,35 @@
</Label>
<HBox prefHeight="38.0" prefWidth="100.0" spacing="5.0">
<children>
<Button id="roundButton" fx:id="postButton"
defaultButton="true" disable="true" minWidth="40.0"
mnemonicParsing="true" onAction="#postMessage" prefHeight="40.0"
prefWidth="40.0" text="Post">
<Button id="roundButton" fx:id="postButton" defaultButton="true" disable="true" minWidth="40.0" mnemonicParsing="true" onAction="#postMessage" prefHeight="40.0" prefWidth="40.0" text="Post">
<tooltip>
<Tooltip anchorLocation="WINDOW_TOP_LEFT"
autoHide="true" maxWidth="350.0"
text="Click this button to send the message. If it is disabled, you first have to select a contact to send it to. A message may automatically be sent when you press (Ctrl + ) Enter, according to your preferences. Additionally sends a message when pressing &quot;Alt&quot; + &quot;P&quot;."
wrapText="true" />
<Tooltip anchorLocation="WINDOW_TOP_LEFT" autoHide="true" maxWidth="350.0" text="Click this button to send the message. If it is disabled, you first have to select a contact to send it to. A message may automatically be sent when you press (Ctrl + ) Enter, according to your preferences. Additionally sends a message when pressing &quot;Alt&quot; + &quot;P&quot;." wrapText="true" />
</tooltip>
<contextMenu>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT">
<items>
<MenuItem mnemonicParsing="false"
onAction="#copyAndPostMessage" text="Copy and Send" />
<MenuItem mnemonicParsing="false" onAction="#copyAndPostMessage" text="Copy and Send" />
</items>
</ContextMenu>
</contextMenu>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<HBox.margin>
<Insets left="10.0" />
</HBox.margin>
</Button>
<Button id="roundButton" fx:id="voiceButton" disable="true"
minWidth="40.0" onAction="#voiceButtonClicked" prefHeight="40.0"
prefWidth="40.0">
<Button id="roundButton" fx:id="voiceButton" disable="true" minWidth="40.0" onAction="#voiceButtonClicked" prefHeight="40.0" prefWidth="40.0">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</Button>
<Button id="roundButton" fx:id="attachmentButton"
disable="true" minWidth="40.0" mnemonicParsing="false"
onAction="#attachmentButtonClicked" prefHeight="40.0"
prefWidth="40.0">
<Button id="roundButton" fx:id="attachmentButton" disable="true" minWidth="40.0" mnemonicParsing="false" onAction="#attachmentButtonClicked" prefHeight="40.0" prefWidth="40.0">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</Button>
<Button id="roundButton" fx:id="rotateButton"
minWidth="40.0" mnemonicParsing="false" onAction="#doABarrelRoll"
prefHeight="40.0" prefWidth="40.0">
<Button id="roundButton" fx:id="rotateButton" minWidth="40.0" mnemonicParsing="false" onAction="#doABarrelRoll" prefHeight="40.0" prefWidth="40.0">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
@ -198,16 +156,12 @@
</HBox>
</children>
<GridPane.margin>
<Insets bottom="40.0" left="300.0" right="300.0" top="15.0" />
<Insets bottom="40.0" left="10.0" right="10.0" top="15.0" />
</GridPane.margin>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0"
GridPane.columnIndex="1" GridPane.rowIndex="2">
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="2">
<children>
<Label id="remainingCharsLabel" fx:id="remainingChars"
ellipsisString="" maxHeight="30.0" maxWidth="180.0"
prefHeight="30.0" prefWidth="180.0" text="remaining chars: 0/x"
textFill="LIME" textOverrun="LEADING_WORD_ELLIPSIS" visible="false">
<Label id="remainingCharsLabel" fx:id="remainingChars" ellipsisString="" maxHeight="30.0" maxWidth="180.0" prefHeight="30.0" prefWidth="180.0" text="remaining chars: 0/x" textFill="LIME" textOverrun="LEADING_WORD_ELLIPSIS" visible="false">
<padding>
<Insets bottom="5.0" top="5.0" />
</padding>
@ -215,23 +169,17 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</opaqueInsets>
<tooltip>
<Tooltip
text="Shows how many chars you can still enter in this message"
wrapText="true" />
<Tooltip text="Shows how many chars you can still enter in this message" wrapText="true" />
</tooltip>
</Label>
<Label fx:id="infoLabel" text="Something happened"
textFill="#faa007" visible="false" wrapText="true">
<Label fx:id="infoLabel" text="Something happened" textFill="#faa007" visible="false" wrapText="true">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</Label>
</children>
</HBox>
<ImageView fx:id="attachmentView" pickOnBounds="true"
preserveRatio="true" visible="false" GridPane.columnIndex="1"
GridPane.columnSpan="2147483647" GridPane.halignment="RIGHT"
GridPane.rowIndex="2">
<ImageView fx:id="attachmentView" pickOnBounds="true" preserveRatio="true" visible="false" GridPane.columnIndex="1" GridPane.columnSpan="2147483647" GridPane.halignment="RIGHT" GridPane.rowIndex="2">
<viewport>
<Rectangle2D height="20.0" width="20.0" />
</viewport>
@ -239,18 +187,14 @@
<Insets bottom="5.0" right="10.0" top="5.0" />
</GridPane.margin>
</ImageView>
<HBox id="topBar" alignment="CENTER_LEFT" prefHeight="100.0"
prefWidth="200.0" GridPane.columnIndex="1">
<HBox id="topBar" alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1">
<children>
<ImageView id="profilePic" fx:id="recipientProfilePic"
fitHeight="43.0" fitWidth="43.0" pickOnBounds="true"
preserveRatio="true">
<ImageView id="profilePic" fx:id="recipientProfilePic" fitHeight="43.0" fitWidth="43.0" pickOnBounds="true" preserveRatio="true">
<HBox.margin>
<Insets left="20.0" top="5.0" />
</HBox.margin>
</ImageView>
<VBox alignment="CENTER_LEFT" prefHeight="97.0"
prefWidth="316.0">
<VBox alignment="CENTER_LEFT" prefHeight="97.0" prefWidth="316.0">
<children>
<Label fx:id="topBarContactLabel" text="">
<font>
@ -263,11 +207,8 @@
<Insets left="15.0" />
</HBox.margin>
</VBox>
<Region prefHeight="200.0" prefWidth="200.0"
HBox.hgrow="ALWAYS" />
<Button id="roundButton" fx:id="messageSearchButton"
contentDisplay="CENTER" mnemonicParsing="false" prefHeight="40.0"
prefWidth="40.0" visible="false">
<Region prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
<Button id="roundButton" fx:id="messageSearchButton" contentDisplay="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="40.0" prefWidth="40.0" visible="false">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB