Browse Source

Localisation for JTabFrame close button.

Removed automatic html conversion for tooltips.
Set clip when painting text.
pull/188/head
weisj 4 years ago
parent
commit
ea22785147
  1. 1
      core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java
  2. 4
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java
  3. 7
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java
  4. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties
  5. 3
      core/src/test/java/ui/toolTip/ToolTipDemo.java
  6. 8
      utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java

1
core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java

@ -343,6 +343,7 @@ public class PaintUtil {
drawingGraphics.fillRect(0, 0, img.getWidth(), img.getHeight()); drawingGraphics.fillRect(0, 0, img.getWidth(), img.getHeight());
drawingGraphics.setColor(g.getColor()); drawingGraphics.setColor(g.getColor());
textRect.setLocation(0, 0); textRect.setLocation(0, 0);
drawingGraphics.setClip(0, 0, img.getWidth(), img.getHeight());
drawingGraphics.scale(scaleX, scaleY); drawingGraphics.scale(scaleX, scaleY);
} else { } else {
drawingGraphics.clipRect(textRect.x, textRect.y, textRect.width, textRect.height); drawingGraphics.clipRect(textRect.x, textRect.y, textRect.width, textRect.height);

4
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java

@ -45,6 +45,7 @@ import com.github.weisj.darklaf.ui.panel.DarkPanelUI;
import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants; import com.github.weisj.darklaf.ui.tooltip.ToolTipConstants;
import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.ResourceUtil;
public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListener, AWTEventListener, public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListener, AWTEventListener,
TabFramePopupUI { TabFramePopupUI {
@ -135,7 +136,8 @@ public class DarkPanelPopupUI extends DarkPanelUI implements PropertyChangeListe
HeaderButton closeButton = new HeaderButton(UIManager.getIcon("TabFramePopup.close.icon"), this); HeaderButton closeButton = new HeaderButton(UIManager.getIcon("TabFramePopup.close.icon"), this);
closeButton.setBorder(new EmptyBorder(4, 4, 4, 4)); closeButton.setBorder(new EmptyBorder(4, 4, 4, 4));
closeButton.addActionListener(e -> popupComponent.close()); closeButton.addActionListener(e -> popupComponent.close());
String tooltip = UIManager.getString("TabFramePopup.closeTooltipText"); String tooltip = ResourceUtil.getResourceBundle("actions", popupComponent).getString("Actions.close");
tooltip = tooltip + " (" + UIManager.getString("TabFramePopup.closeTooltipTextHint") + ")";
closeButton.setToolTipText(tooltip); closeButton.setToolTipText(tooltip);
return closeButton; return closeButton;
} }

7
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkToolTipUI.java

@ -349,12 +349,7 @@ public class DarkToolTipUI extends BasicToolTipUI implements PropertyChangeListe
} }
protected void updateTipText(final JToolTip tooltip) { protected void updateTipText(final JToolTip tooltip) {
String tipText = tooltip.getTipText(); effectiveTipText = tooltip.getTipText();
if (tipText != null && !tipText.startsWith("<html>") && tipText.contains("\n")) {
effectiveTipText = "<html>" + tipText.replaceAll("\n", "<\\br>") + "</html>";
} else {
effectiveTipText = tipText;
}
if (effectiveTipText == null) effectiveTipText = ""; if (effectiveTipText == null) effectiveTipText = "";
} }

2
core/src/main/resources/com/github/weisj/darklaf/properties/ui/tabFrame.properties

@ -42,7 +42,7 @@ TabFramePopup.headerButtonFocusHoverBackground = %hoverHighlightColorful
TabFramePopup.headerButtonFocusClickBackground = %clickHighlightColorful TabFramePopup.headerButtonFocusClickBackground = %clickHighlightColorful
TabFramePopup.closeAccelerator = shift pressed ESCAPE TabFramePopup.closeAccelerator = shift pressed ESCAPE
TabFramePopup.closeTooltipText = Close (shift ESC) TabFramePopup.closeTooltipTextHint = shift ESC
TabFramePopup.headerButton.tooltipInsets = 5,5,5,5 TabFramePopup.headerButton.tooltipInsets = 5,5,5,5
TabFramePopup.headerButton.insets = 1,1,1,1 TabFramePopup.headerButton.insets = 1,1,1,1

3
core/src/test/java/ui/toolTip/ToolTipDemo.java

@ -35,6 +35,7 @@ import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.ui.tooltip.DarkToolTipUI; import com.github.weisj.darklaf.ui.tooltip.DarkToolTipUI;
import com.github.weisj.darklaf.util.Alignment; import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.StringUtil;
public class ToolTipDemo implements ComponentDemo { public class ToolTipDemo implements ComponentDemo {
@ -49,7 +50,7 @@ public class ToolTipDemo implements ComponentDemo {
ToolTipContext context = new ToolTipContext(button).setAlignment(Alignment.CENTER) ToolTipContext context = new ToolTipContext(button).setAlignment(Alignment.CENTER)
.setCenterAlignment(Alignment.SOUTH); .setCenterAlignment(Alignment.SOUTH);
ToolTipContext.setDefaultContext(context); ToolTipContext.setDefaultContext(context);
button.setToolTipText("This is the ToolTip demo text!"); button.setToolTipText(StringUtil.toHtml(StringUtil.repeat("This is the ToolTip demo text!\n", 3)));
button.putClientProperty(DarkToolTipUI.KEY_STYLE, DarkToolTipUI.VARIANT_BALLOON); button.putClientProperty(DarkToolTipUI.KEY_STYLE, DarkToolTipUI.VARIANT_BALLOON);
JPanel controlPanel = panel.addControls(3); JPanel controlPanel = panel.addControls(3);

8
utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java

@ -36,6 +36,14 @@ public final class StringUtil {
private StringUtil() {} private StringUtil() {}
public static String toHtml(final String text) {
if (text == null) return "";
if (!text.startsWith("<html>") && text.contains("\n")) {
return "<html>" + text.replaceAll("\n", "<\\br>") + "</html>";
}
return text;
}
public static String toUpperCase(final String a) { public static String toUpperCase(final String a) {
return a == null ? null : toUpperCase((CharSequence) a).toString(); return a == null ? null : toUpperCase((CharSequence) a).toString();
} }

Loading…
Cancel
Save