Added display of settings-icon for the settings button

additionally modified margin of elements in ChatScene
This commit is contained in:
delvh 2020-06-26 17:33:32 +02:00
parent 374f23c3c3
commit 487cac77fb
4 changed files with 171 additions and 110 deletions

View File

@ -35,7 +35,7 @@ public final class Startup extends Application {
/** /**
* The version of this client. Used to verify compatibility with the server. * The version of this client. Used to verify compatibility with the server.
* *
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
public static final String VERSION = "0.1-beta"; public static final String VERSION = "0.1-beta";

View File

@ -12,6 +12,7 @@ import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
@ -22,9 +23,7 @@ import envoy.client.data.Settings;
import envoy.client.event.MessageCreationEvent; import envoy.client.event.MessageCreationEvent;
import envoy.client.net.Client; import envoy.client.net.Client;
import envoy.client.net.WriteProxy; import envoy.client.net.WriteProxy;
import envoy.client.ui.ContactListCell; import envoy.client.ui.*;
import envoy.client.ui.MessageListCell;
import envoy.client.ui.SceneContext;
import envoy.data.*; import envoy.data.*;
import envoy.event.EventBus; import envoy.event.EventBus;
import envoy.event.MessageStatusChange; import envoy.event.MessageStatusChange;
@ -90,6 +89,12 @@ public final class ChatScene {
messageList.setCellFactory(listView -> new MessageListCell()); messageList.setCellFactory(listView -> new MessageListCell());
userList.setCellFactory(listView -> new ContactListCell()); userList.setCellFactory(listView -> new ContactListCell());
try {
settingsButton.setGraphic(new ImageView(IconUtil.load("/icons/settings.png", 16)));
} catch (final IOException e2) {
logger.log(Level.WARNING, "Could not load settings icon", e2);
}
// Listen to received messages // Listen to received messages
eventBus.register(MessageCreationEvent.class, e -> { eventBus.register(MessageCreationEvent.class, e -> {
final var message = e.get(); final var message = e.get();

View File

@ -21,11 +21,6 @@
-fx-background-color: transparent; -fx-background-color: transparent;
} }
#remainingCharsLabel {
-fx-text-fill: #00FF00;
-fx-background-color: transparent;
}
.scroll-bar:horizontal, .scroll-bar:horizontal *, .scroll-bar:horizontal > *{ .scroll-bar:horizontal, .scroll-bar:horizontal *, .scroll-bar:horizontal > *{
-fx-background-color: transparent; -fx-background-color: transparent;
-fx-text-fill: transparent; -fx-text-fill: transparent;
@ -58,3 +53,8 @@
-fx-background-radius: 4.0em; -fx-background-radius: 4.0em;
-fx-text-alignment: left; -fx-text-alignment: left;
} }
#remainingCharsLabel {
-fx-text-fill: #00FF00;
-fx-background-color: transparent;
}

View File

@ -12,111 +12,167 @@
<?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="350.0" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.ChatScene"> <GridPane maxHeight="-Infinity" maxWidth="-Infinity"
minHeight="400.0" minWidth="350.0" prefHeight="400.0" prefWidth="600.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>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" percentWidth="20.0" prefWidth="161.0" /> <ColumnConstraints hgrow="SOMETIMES"
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" percentWidth="65.0" prefWidth="357.0" /> maxWidth="1.7976931348623157E308" minWidth="10.0" percentWidth="20.0"
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="6.285736083984375" percentWidth="15.0" prefWidth="48.000030517578125" /> prefWidth="161.0" />
<ColumnConstraints hgrow="SOMETIMES"
maxWidth="1.7976931348623157E308" minWidth="10.0" percentWidth="65.0"
prefWidth="357.0" />
<ColumnConstraints hgrow="SOMETIMES"
maxWidth="1.7976931348623157E308" minWidth="6.285736083984375"
percentWidth="15.0" prefWidth="48.000030517578125" />
</columnConstraints> </columnConstraints>
<rowConstraints> <rowConstraints>
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" percentHeight="10.0" prefHeight="70.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="1.7976931348623157E308"
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" percentHeight="70.0" prefHeight="326.2857404436384" vgrow="SOMETIMES" /> minHeight="10.0" percentHeight="10.0" prefHeight="70.0"
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" percentHeight="5.0" prefHeight="50.0" vgrow="SOMETIMES" /> vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308" minHeight="10.0" percentHeight="15.0" prefHeight="100.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="1.7976931348623157E308"
minHeight="10.0" percentHeight="70.0" prefHeight="326.2857404436384"
vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308"
minHeight="10.0" percentHeight="5.0" prefHeight="50.0"
vgrow="SOMETIMES" />
<RowConstraints maxHeight="1.7976931348623157E308"
minHeight="10.0" percentHeight="15.0" prefHeight="100.0"
vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<ListView fx:id="userList" onMouseClicked="#userListClicked" prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1" GridPane.rowSpan="2147483647"> <ListView fx:id="userList" onMouseClicked="#userListClicked"
<GridPane.margin> prefHeight="211.0" prefWidth="300.0" GridPane.rowIndex="1"
<Insets bottom="10.0" left="10.0" right="5.0" top="5.0" /> GridPane.rowSpan="2147483647">
</GridPane.margin> <GridPane.margin>
<padding> <Insets bottom="10.0" left="10.0" right="5.0" top="5.0" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </GridPane.margin>
</padding> <padding>
<contextMenu> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<ContextMenu anchorLocation="CONTENT_TOP_LEFT"> </padding>
<items> <contextMenu>
<MenuItem fx:id="deleteContactMenuItem" mnemonicParsing="false" text="Delete" onAction="#deleteContact"/> <ContextMenu anchorLocation="CONTENT_TOP_LEFT">
</items> <items>
</ContextMenu> <MenuItem fx:id="deleteContactMenuItem"
</contextMenu> mnemonicParsing="false" text="Delete" onAction="#deleteContact" />
</ListView> </items>
<Label fx:id="contactLabel" prefHeight="16.0" prefWidth="250.0" text="Select a contact to chat with" GridPane.columnSpan="2"> </ContextMenu>
<GridPane.margin> </contextMenu>
<Insets bottom="5.0" left="10.0" right="5.0" top="10.0" /> </ListView>
</GridPane.margin> <Label fx:id="contactLabel" prefHeight="16.0" prefWidth="250.0"
<padding> text="Select a contact to chat with" GridPane.columnSpan="2">
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <GridPane.margin>
</padding></Label> <Insets left="15.0" right="5.0" top="5.0" />
<Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" text="_Settings" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER"> </GridPane.margin>
<GridPane.margin> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</GridPane.margin> </padding>
<padding> </Label>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Button fx:id="settingsButton" mnemonicParsing="true"
</padding></Button> onAction="#settingsButtonClicked" text="_Settings"
<ListView fx:id="messageList" prefHeight="257.0" prefWidth="155.0" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1" GridPane.rowSpan="2"> GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="RIGHT"
<GridPane.margin> GridPane.valignment="CENTER">
<Insets bottom="5.0" left="5.0" right="10.0" top="5.0" /> <GridPane.margin>
</GridPane.margin> <Insets bottom="10.0" left="5.0" right="10.0" top="10.0" />
<padding> </GridPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <padding>
</padding> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<contextMenu> </padding>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT"> </Button>
<items> <ListView fx:id="messageList" prefHeight="257.0"
<MenuItem mnemonicParsing="false" text="Copy" onAction="#copyMessage"/> prefWidth="155.0" GridPane.columnIndex="1" GridPane.columnSpan="2"
<MenuItem mnemonicParsing="false" text="Delete" onAction="#deleteMessage"/> GridPane.rowIndex="1" GridPane.rowSpan="2">
<MenuItem mnemonicParsing="false" text="Forward" onAction="#forwardMessage"/> <GridPane.margin>
<MenuItem mnemonicParsing="false" text="Quote" onAction="#quoteMessage"/> <Insets bottom="5.0" left="5.0" right="10.0" top="5.0" />
</items> </GridPane.margin>
</ContextMenu> <padding>
</contextMenu></ListView> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<Button fx:id="postButton" defaultButton="true" disable="true" mnemonicParsing="true" onAction="#postMessage" prefHeight="10.0" prefWidth="65.0" text="_Post" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER"> </padding>
<GridPane.margin> <contextMenu>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <ContextMenu anchorLocation="CONTENT_TOP_LEFT">
</GridPane.margin> <items>
<padding> <MenuItem mnemonicParsing="false" text="Copy"
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> onAction="#copyMessage" />
</padding> <MenuItem mnemonicParsing="false" text="Delete"
<tooltip> onAction="#deleteMessage" />
<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" /> <MenuItem mnemonicParsing="false" text="Forward"
</tooltip> onAction="#forwardMessage" />
<contextMenu> <MenuItem mnemonicParsing="false" text="Quote"
<ContextMenu anchorLocation="CONTENT_TOP_LEFT"> onAction="#quoteMessage" />
<items> </items>
<MenuItem mnemonicParsing="false" text="Copy and Send" onAction="#copyAndPostMessage"/> </ContextMenu>
</items> </contextMenu>
</ContextMenu> </ListView>
</contextMenu> <Button fx:id="postButton" defaultButton="true" disable="true"
</Button> mnemonicParsing="true" onAction="#postMessage" prefHeight="10.0"
<TextArea fx:id="messageTextArea" disable="true" onInputMethodTextChanged="#messageTextUpdated" onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination" prefHeight="200.0" prefWidth="200.0" wrapText="true" GridPane.columnIndex="1" GridPane.rowIndex="3"> prefWidth="65.0" text="_Post" GridPane.columnIndex="2"
<GridPane.margin> GridPane.halignment="CENTER" GridPane.rowIndex="3"
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" /> GridPane.valignment="CENTER">
</GridPane.margin> <GridPane.margin>
<opaqueInsets> <Insets bottom="5.0" left="5.0" right="5.0"/>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </GridPane.margin>
</opaqueInsets></TextArea> <padding>
<Button mnemonicParsing="true" onAction="#addContactButtonClicked" text="_Add Contacts" GridPane.halignment="CENTER" GridPane.rowIndex="3" GridPane.valignment="CENTER"> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<padding> </padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <tooltip>
</padding> <Tooltip anchorLocation="WINDOW_TOP_LEFT" autoHide="true"
<GridPane.margin> maxWidth="350.0"
<Insets bottom="5.0" left="5.0" right="5.0" top="5.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;."
</GridPane.margin> wrapText="true" />
</Button> </tooltip>
<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" GridPane.columnIndex="1" GridPane.rowIndex="2"> <contextMenu>
<GridPane.margin> <ContextMenu anchorLocation="CONTENT_TOP_LEFT">
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <items>
</GridPane.margin> <MenuItem mnemonicParsing="false" text="Copy and Send"
<padding> onAction="#copyAndPostMessage" />
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </items>
</padding> </ContextMenu>
<opaqueInsets> </contextMenu>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> </Button>
</opaqueInsets> <TextArea fx:id="messageTextArea" disable="true"
<tooltip> onInputMethodTextChanged="#messageTextUpdated"
<Tooltip text="Shows how many chars you can still enter in this message" wrapText="true" /> onKeyPressed="#checkPostConditions" onKeyTyped="#checkKeyCombination"
</tooltip> prefHeight="200.0" prefWidth="200.0" wrapText="true"
</Label> GridPane.columnIndex="1" GridPane.rowIndex="3">
<GridPane.margin>
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" />
</GridPane.margin>
<opaqueInsets>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</opaqueInsets>
</TextArea>
<Button mnemonicParsing="true"
onAction="#addContactButtonClicked" text="_Add Contacts"
GridPane.halignment="CENTER" GridPane.rowIndex="3"
GridPane.valignment="CENTER">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<GridPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</GridPane.margin>
</Button>
<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"
GridPane.columnIndex="1" GridPane.rowIndex="2">
<GridPane.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</GridPane.margin>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<opaqueInsets>
<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>
</Label>
</children> </children>
</GridPane> </GridPane>