Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ Alice.Block.background = #FFFFFF
# Text/outlines
Alice.Block.foreground = #F2F2F7
# Dots on the edge
Alice.Block.knurlForeground = #D9D9D9
Alice.Block.lightKnurlForeground = #D9D9D9
Alice.Block.darkKnurlForeground = #3E3E41

# contrasting text/backgrounds
Alice.Block.contrastForeground = #3E3E41
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void layoutContainer(Container parent) {
}

private static final Color BASE_COLOR = UIManager.getColor("List.background");
private static final Color KNURL_COLOR = UIManager.getColor("Alice.Block.knurlForeground");
private static final Color KNURL_COLOR = UIManager.getColor("Alice.Block.darkKnurlForeground");
private static final Color OUTLINE_COLOR = UIManager.getColor("Alice.differentBackground");
private static final Color SELECTED_OUTLINE_COLOR = UIManager.getColor("List.selectionBackground");

Expand Down
17 changes: 16 additions & 1 deletion core/ide/src/main/java/org/alice/ide/DefaultTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@
*/
public class DefaultTheme implements Theme {

// Closer to zero the darker it is. This threshold is arbitrary and may need adjustment.
private static final int DARK_THRESHOLD = 600;

@Override
public Color getKnurlColorFor(Color backgroundColor) {
return isDark(backgroundColor)
? UIManager.getColor("Alice.Block.lightKnurlForeground")
: UIManager.getColor("Alice.Block.darkKnurlForeground");
}

private static boolean isDark(Color color) {
int brightness = color.getRed() + color.getGreen() + color.getBlue();
return brightness < DARK_THRESHOLD;
}

@Override
public Color getColorFor(Class<? extends Node> cls) {
if (Statement.class.isAssignableFrom(cls)) {
Expand All @@ -68,7 +83,7 @@ public Color getColorFor(Class<? extends Node> cls) {
private static Color getStatementColor(Class<? extends Node> cls) {
if (Comment.class.isAssignableFrom(cls)) {
return UIManager.getColor("Alice.Comment.background");
} else if (org.lgna.project.ast.LocalDeclarationStatement.class.isAssignableFrom(cls)) {
} else if (LocalDeclarationStatement.class.isAssignableFrom(cls)) {
// aka variable creation
return UIManager.getColor("Alice.Block.background");
} else if (ClassUtilities.isAssignableToAtLeastOne(cls, AbstractStatementWithBody.class, ConditionalStatement.class)) {
Expand Down
30 changes: 16 additions & 14 deletions core/ide/src/main/java/org/alice/ide/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,26 @@
* @author Dennis Cosgrove
*/
public interface Theme {
public static final Dimension EXTRA_SMALL_RECT_ICON_SIZE = new Dimension(24, 18);
public static final Dimension SMALL_RECT_ICON_SIZE = new Dimension(32, 24);
public static final Dimension MEDIUM_RECT_ICON_SIZE = new Dimension(40, 30);
public static final Dimension LARGE_RECT_ICON_SIZE = new Dimension(120, 90);
Dimension EXTRA_SMALL_RECT_ICON_SIZE = new Dimension(24, 18);
Dimension SMALL_RECT_ICON_SIZE = new Dimension(32, 24);
Dimension MEDIUM_RECT_ICON_SIZE = new Dimension(40, 30);
Dimension LARGE_RECT_ICON_SIZE = new Dimension(120, 90);

public static final Dimension EXTRA_SMALL_SQUARE_ICON_SIZE = new Dimension(16, 16);
public static final Dimension SMALL_SQUARE_ICON_SIZE = new Dimension(22, 22);
public static final Dimension MEDIUM_SQUARE_ICON_SIZE = new Dimension(32, 32);
public static final Dimension LARGE_SQUARE_ICON_SIZE = new Dimension(90, 90);
Dimension EXTRA_SMALL_SQUARE_ICON_SIZE = new Dimension(16, 16);
Dimension SMALL_SQUARE_ICON_SIZE = new Dimension(22, 22);
Dimension MEDIUM_SQUARE_ICON_SIZE = new Dimension(32, 32);
Dimension LARGE_SQUARE_ICON_SIZE = new Dimension(90, 90);

public static final int BLOCK_MARGINS_WIDTH = 2;
public static final int BLOCK_MARGINS_HEIGHT = 1;
public static final Border BLOCK_BORDER = BorderFactory.createEmptyBorder(BLOCK_MARGINS_HEIGHT, BLOCK_MARGINS_WIDTH, BLOCK_MARGINS_HEIGHT, BLOCK_MARGINS_WIDTH);
int BLOCK_MARGINS_WIDTH = 2;
int BLOCK_MARGINS_HEIGHT = 1;
Border BLOCK_BORDER = BorderFactory.createEmptyBorder(BLOCK_MARGINS_HEIGHT, BLOCK_MARGINS_WIDTH, BLOCK_MARGINS_HEIGHT, BLOCK_MARGINS_WIDTH);

public Color getColorFor(Class<? extends Node> cls);
Color getKnurlColorFor(Color backgroundColor);

public Color getColorFor(Node node);
Color getColorFor(Class<? extends Node> cls);

public Color getCodeColor(Code code);
Color getColorFor(Node node);

Color getCodeColor(Code code);

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ControlFlowPanel(ControlFlowComposite composite) {
this.internalAddComponent(BoxUtilities.createHorizontalSliver(8));
}
}
this.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
this.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 0));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import edu.cmu.cs.dennisc.java.util.ResourceBundleUtilities;
import edu.cmu.cs.dennisc.javax.swing.tooltips.JToolTip;
import org.alice.ide.Theme;
import org.alice.ide.ast.draganddrop.statement.ExpressionStatementTemplateDragModel;
import org.alice.ide.ast.draganddrop.statement.StatementTemplateDragModel;
import org.alice.ide.templates.StatementTemplate;
Expand Down Expand Up @@ -136,6 +137,7 @@ protected void handleDisplayable() {
this.label.setForegroundColor(UIManager.getColor("Alice.Comment.foreground"));
}
//this.label.setFontToScaledFont( 1.2f );
this.label.setBorder(Theme.BLOCK_BORDER);
this.addComponent(this.label);
this.setToolTipText("");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import edu.cmu.cs.dennisc.java.awt.ColorUtilities;
import edu.cmu.cs.dennisc.java.awt.KnurlUtilities;
import org.alice.ide.Theme;
import org.alice.ide.ThemeUtilities;
import org.lgna.croquet.DragModel;
import org.lgna.croquet.views.AwtComponentView;
import org.lgna.croquet.views.DragComponent;
Expand All @@ -54,7 +55,6 @@
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JToolTip;
import javax.swing.UIManager;
import java.awt.*;
import java.awt.event.MouseEvent;

Expand Down Expand Up @@ -238,12 +238,15 @@ protected void paintEpilogue(Graphics2D g2, int x, int y, int width, int height)
Shape shape = this.createShape(x, y, width, height);
this.paintOutline(g2, shape);
if (isKnurlDesired()) {
Color c = this.isActive() ? getOutlineColor() : UIManager.getColor("Alice.Block.knurlForeground");
g2.setColor(c);
g2.setColor(getKnurlColor());
KnurlUtilities.paintKnurl5(g2, x + this.getDockInsetLeft(), y + 2, KNURL_WIDTH, height - 5);
}
}

protected Color getKnurlColor() {
return this.isActive() ? getOutlineColor() : ThemeUtilities.getActiveTheme().getKnurlColorFor(getBackgroundColor());
}

public void addComponent(AwtComponentView<?> component) {
this.internalAddComponent(component);
}
Expand Down