Skip to content

Commit

Permalink
Merge pull request #40 from kadampabookings/prod
Browse files Browse the repository at this point in the history
Work up to prod 17/01
  • Loading branch information
salmonb authored Jan 17, 2025
2 parents e321814 + 25d4fce commit f82b76d
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.sun.javafx.binding.BidirectionalBinding;
import com.sun.javafx.binding.IntegerConstant;
import com.sun.javafx.collections.ImmutableObservableList;
import dev.webfx.platform.util.Strings;
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.Property;
Expand Down Expand Up @@ -561,4 +562,40 @@ public ObservableList<?> getDependencies() {
};
}

/**
* Creates a new {@link javafx.beans.binding.BooleanBinding} that holds {@code true}
* if the value of a {@link javafx.beans.value.ObservableStringValue} is empty.
* <p>
* Note: In this comparison a {@code String} that is {@code null} is
* considered to be empty.
*
* @param op
* the {@code ObservableStringValue}
* @return the new {@code BooleanBinding}
* @throws NullPointerException
* if the {@code ObservableStringValue} is {@code null}
* @since JavaFX 8.0
*/
public static BooleanBinding isEmpty(final ObservableStringValue op) {
return createBooleanBinding(() -> Strings.isEmpty(op.get()), op);
}

/**
* Creates a new {@link javafx.beans.binding.BooleanBinding} that holds {@code true}
* if the value of a {@link javafx.beans.value.ObservableStringValue} is not empty.
* <p>
* Note: In this comparison a {@code String} that is {@code null} is
* considered to be empty.
*
* @param op
* the {@code ObservableStringValue}
* @return the new {@code BooleanBinding}
* @throws NullPointerException
* if the {@code ObservableStringValue} is {@code null}
* @since JavaFX 8.0
*/
public static BooleanBinding isNotEmpty(final ObservableStringValue op) {
return createBooleanBinding(() -> Strings.isNotEmpty(op.get()), op);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,22 @@ public final String getValueSafe() {
return value == null ? "" : value;
}

// removed
public BooleanBinding isEmpty() {
return Bindings.isEmpty(this);
}

/**
* Creates a new {@link BooleanBinding} that holds {@code true} if this
* {@code StringExpression} is not empty.
* <p>
* Note: If the value of this {@code StringExpression} is {@code null},
* it is considered to be empty.
*
* @return the new {@code BooleanBinding}
* @since JavaFX 8.0
*/
public BooleanBinding isNotEmpty() {
return Bindings.isNotEmpty(this);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.webfx.kit.mapper.peers.javafxcontrols.gwtj2cl.html;

import dev.webfx.platform.util.collection.Collections;
import elemental2.dom.HTMLElement;
import javafx.scene.control.ToggleButton;
import dev.webfx.kit.mapper.peers.javafxcontrols.base.ToggleButtonPeerBase;
Expand All @@ -18,7 +19,7 @@ public final class HtmlToggleButtonPeer
implements ToggleButtonPeerMixin<N, NB, NM>, HtmlLayoutMeasurable {

public HtmlToggleButtonPeer() {
this((NB) new ToggleButtonPeerBase(), HtmlUtil.createButtonElement());
this((NB) new ToggleButtonPeerBase(), HtmlUtil.createElement("fx-togglebutton"));
}

public HtmlToggleButtonPeer(NB base, HTMLElement element) {
Expand All @@ -27,6 +28,7 @@ public HtmlToggleButtonPeer(NB base, HTMLElement element) {

@Override
public void updateSelected(Boolean selected) {
Collections.addIfNotContainsOrRemove(getNode().getStyleClass(), selected,"selected");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
--fx-border-color-focus: #0096D6;
--fx-textfield-background: white;
--fx-button-background: linear-gradient(180deg, white, #e0e0e0);
--fx-togglebutton-selected-background: linear-gradient(180deg, #f0f0f0, #d0d0d0);
}

::placeholder {
color: #888;
}

fx-button > fx-background {
fx-button > fx-background, fx-togglebutton > fx-background {
background: var(--fx-button-background);
border-radius: var(--fx-border-radius);
}

fx-button > fx-border, fx-textfield > fx-border, textarea {
fx-togglebutton.selected > fx-background {
background: var(--fx-togglebutton-selected-background);
}

fx-button > fx-border, fx-togglebutton > fx-border, fx-textfield > fx-border, textarea {
border-color: var(--fx-border-color);
border-style: var(--fx-border-style);
border-width: var(--fx-border-width);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,19 @@ private void recomputeWidthHeight() {
double localFitWidth = getFitWidth();
double localFitHeight = getFitHeight();

if (isPreserveRatio() && w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) {
if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) {
if (isPreserveRatio() && w > 0 && h > 0 && (localFitWidth > 0 && localFitHeight <= 0 || localFitHeight > 0 && localFitWidth <= 0)) {
if (localFitWidth <= 0) {
w = w * localFitHeight / h;
h = localFitHeight;
} else {
h = h * localFitWidth / w;
w = localFitWidth;
}
} else {
if (localFitWidth > 0f) {
if (localFitWidth > 0) {
w = localFitWidth;
}
if (localFitHeight > 0f) {
if (localFitHeight > 0) {
h = localFitHeight;
}
}
Expand Down
5 changes: 0 additions & 5 deletions webfx-kit/webfx-kit-javafxgraphics-peers-gwt-j2cl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
<artifactId>elemental2-svg</artifactId>
</dependency>

<dependency>
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-webstorage</artifactId>
</dependency>

<dependency>
<groupId>com.google.jsinterop</groupId>
<artifactId>jsinterop-annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ private void installMouseListeners() {
}
return null;
};
// Disabling default browser drag & drop as JavaFX has its own
//container.setAttribute("ondragstart", "return false;");
//container.setAttribute("ondrop", "return false;");
// Disabling default browser drag & drop as JavaFX has its own. Without doing this, the setOnMouseDragged()
// handler would be called only once (when the drag starts) and not continuously during the drag operation.
// Also without doing this, the browser would display a ghost image of the dragged element (which is not the
// case with JavaFX). Ex of use case: Modality user profile picture drag (in ChangePictureUI).
container.setAttribute("ondragstart", "return false;");
container.setAttribute("ondrop", "return false;"); // TODO check if this is necessary
}

private void registerMouseListener(String type) {
Expand Down
6 changes: 6 additions & 0 deletions webfx-kit/webfx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
<library name="javafx-web">
</library>

<library name="javafx-swing"> <!-- Not emulated by WebFX but may be used in some pure OpenJFX modules -->
<exported-packages>
<package>javafx.embed.swing</package>
</exported-packages>
</library>

</group>
</required-libraries>

Expand Down

0 comments on commit f82b76d

Please sign in to comment.