Revision: 2977
http://sourceforge.net/p/swingme/code/2977
Author: yuranet
Date: 2025-12-24 14:28:28 +0000 (Wed, 24 Dec 2025)
Log Message:
-----------
make all title bars edge-to-edge
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java
SwingME/src/net/yura/mobile/gui/components/Frame.java
SwingME/src/net/yura/mobile/gui/components/FrameTitlePane.java
SwingME/src/net/yura/mobile/gui/plaf/MetalLookAndFeel.java
Modified: SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java 2025-12-23 13:24:30 UTC (rev 2976)
+++ SwingME/src/net/yura/mobile/gui/border/EdgeToEdgeBorder.java 2025-12-24 14:28:28 UTC (rev 2977)
@@ -3,19 +3,38 @@
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.components.Component;
+import net.yura.mobile.gui.plaf.Style;
public class EdgeToEdgeBorder implements Border {
private final Border border;
+ private Style style; // for dynamic borders that can change based on component state
public EdgeToEdgeBorder(Border border) {
this.border = border;
+ style = null;
}
public EdgeToEdgeBorder(int color) {
+ border = createFromColor(color);
+ style = null;
+ }
+
+ public EdgeToEdgeBorder(Style style) {
+ this.style = style;
+ border = null;
+ }
+
+ public void updateUI(Style style) {
+ if (border == null) { // only if this is a dynamic border
+ this.style = style;
+ }
+ }
+
+ private static Border createFromColor(int color) {
MatteBorder tint = new MatteBorder(0, 0, 0, 0, color);
tint.paintCenter = true;
- border = tint;
+ return tint;
}
public void paintBorder(Component cmpnt, Graphics2D g, int w, int h) {
@@ -57,7 +76,7 @@
}
g.translate(startX, startY);
- border.paintBorder(cmpnt, g, width - startX, height - startY);
+ getBorder(cmpnt.getCurrentState()).paintBorder(cmpnt, g, width - startX, height - startY);
g.translate(-startX, -startY);
// for debugging:
@@ -65,23 +84,38 @@
//g.drawRect(startX, startY, width-1, height-1);
}
+ private Border getBorder(int state) {
+ if (border != null) {
+ return border;
+ }
+ Border themeBorder = style.getBorder(state);
+ if (themeBorder != null) {
+ return themeBorder;
+ }
+ int themeBackground = style.getBackground(state);
+ if (themeBackground != Style.NO_COLOR) {
+ return createFromColor(themeBackground);
+ }
+ return Component.empty;
+ }
+
public int getTop() {
- return border.getTop();
+ return getBorder(Style.ALL).getTop();
}
public int getBottom() {
- return border.getBottom();
+ return getBorder(Style.ALL).getBottom();
}
public int getRight() {
- return border.getRight();
+ return getBorder(Style.ALL).getRight();
}
public int getLeft() {
- return border.getLeft();
+ return getBorder(Style.ALL).getLeft();
}
public boolean isBorderOpaque() {
- return border.isBorderOpaque();
+ return getBorder(Style.ALL).isBorderOpaque();
}
}
Modified: SwingME/src/net/yura/mobile/gui/components/Frame.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Frame.java 2025-12-23 13:24:30 UTC (rev 2976)
+++ SwingME/src/net/yura/mobile/gui/components/Frame.java 2025-12-24 14:28:28 UTC (rev 2977)
@@ -18,7 +18,6 @@
package net.yura.mobile.gui.components;
import java.util.Vector;
-
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Icon;
import net.yura.mobile.gui.layout.BorderLayout;
Modified: SwingME/src/net/yura/mobile/gui/components/FrameTitlePane.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/FrameTitlePane.java 2025-12-23 13:24:30 UTC (rev 2976)
+++ SwingME/src/net/yura/mobile/gui/components/FrameTitlePane.java 2025-12-24 14:28:28 UTC (rev 2977)
@@ -24,6 +24,8 @@
import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Icon;
import net.yura.mobile.gui.KeyEvent;
+import net.yura.mobile.gui.border.Border;
+import net.yura.mobile.gui.border.EdgeToEdgeBorder;
import net.yura.mobile.gui.layout.BorderLayout;
import net.yura.mobile.gui.layout.GridLayout;
import net.yura.mobile.gui.plaf.Style;
@@ -43,26 +45,35 @@
public FrameTitlePane() {
super(new BorderLayout());
- setName("TitleBar");
-
+
buttonPanel = new Panel( new GridLayout(1,0,2) );
// always want it to take the style of this instead
buttonPanel.setName("WindowControlPanel");
-
+
title = new Label();
title.setName("TitleBarLabel");
-
+
add(title);
add(buttonPanel,Graphics.RIGHT);
- updateUI();
+ // special border to allow painting edge-to-edge of UI on iOS and android
+ setBorder(new EdgeToEdgeBorder(theme));
}
+ public String getDefaultName() {
+ return "TitleBar";
+ }
+
public void updateUI() {
super.updateUI();
- if (title!=null) {
+ Border border = getBorder();
+ if (border instanceof EdgeToEdgeBorder) {
+ ((EdgeToEdgeBorder)border).updateUI(theme);
+ }
+
+ if (title != null) {
String titleAlignment = (String)theme.getProperty("titleAlignment", Style.ALL);
if ("center".equals(titleAlignment)) {
setTitleAlignment(Graphics.HCENTER);
Modified: SwingME/src/net/yura/mobile/gui/plaf/MetalLookAndFeel.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/plaf/MetalLookAndFeel.java 2025-12-23 13:24:30 UTC (rev 2976)
+++ SwingME/src/net/yura/mobile/gui/plaf/MetalLookAndFeel.java 2025-12-24 14:28:28 UTC (rev 2977)
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU Lesser General Public License
* along with 'yura.net Swing ME'. If not, see <http://www.gnu.org/licenses/>.
*/
-
package net.yura.mobile.gui.plaf;
import javax.microedition.lcdui.Graphics;
@@ -105,6 +104,7 @@
buttonStyle.addBorder(new BevelBorder( 1, getSecondary1(), getWhite() ), Style.SELECTED);
buttonStyle.addBorder(disabledButtonBorder, Style.DISABLED);
setStyleFor("Button",buttonStyle);
+ setStyleFor("SmallButton",buttonStyle);
Style menuItemStyle = new Style(defaultStyle);
menuItemStyle.addProperty(spinnerRightIcon, "arrow", Style.ALL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|