message: issues 30 & 43 add color wheel and recent colors

diff:
+package builder.views;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+
+import javax.swing.JPanel;
+
+
+public class ColorWheel extends JPanel {
+ private static final long serialVersionUID = 1L;
+
+ protected void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+
+ float hueDegree = 1 / 360.0f;
+
+ for (int i = 0; i < 360; i++)
+ {
+ Color color = Color.getHSBColor(i * hueDegree, 1.0f, 1.0f);
+ g.setColor( color );
+ g.fillArc( 30, 15, 250, 250, i, 1);
+ }
+ }
+
+ @Override
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(250, 250);
+ }
+}

diff:
*/
package builder.views;
-import java.awt.BorderLayout;
+import java.awt.AWTException;
+//import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Cursor;
import java.awt.Font;
+import java.awt.Point;
+import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.util.List;
import javax.swing.JFrame;
@@ -40,6 +46,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import builder.Builder;
import builder.common.ColorFactory;
import builder.common.ColorIcon;
import builder.common.ColorItem;
@@ -51,6 +58,7 @@ import java.awt.Dimension;
import javax.swing.DefaultListModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
+import javax.swing.ImageIcon;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JList;
@@ -110,7 +118,7 @@ public class GUIsliceColorChooser extends JDialog {
private JTabbedPane tabbedPane;
/** The rgb panel. */
- private JPanel rgbPanel;
+ private JPanel rgbTab;
/** The color panel. */
private JPanel colorPanel;
@@ -127,6 +135,9 @@ public class GUIsliceColorChooser extends JDialog {
/** The current color. */
private Color currentColor;
+ /** recent color panel */
+ private SwatchPanel recentColorsPanel;
+
/** The red value. */
private int redValue;
@@ -154,23 +165,31 @@ public class GUIsliceColorChooser extends JDialog {
/** The spinner B. */
private JSpinner spinnerB;
- /** The is spinner. */
+ /** The data from spinner. */
private boolean isSpinner = false;
- /** The is list. */
+ /** The data from list. */
private boolean isList = false;
+ /** The data from eye dropper. */
+ private boolean isEyeDropper = false;
+
+ Robot robot;
+
/** The cf. */
ColorFactory cf;
/** The b save dialog. */
boolean bSaveDialog;
- /** The b init UI. */
+ /** The flag to indicate UI initialized. */
boolean bInitUI = false;
+ /** our cross hair cursor */
+ Cursor crossHairCursor;
+
/**
- * Instantiates a new GU islice color chooser.
+ * Instantiates a new GUIslice color chooser.
*
* @param owner
* the owner
@@ -178,6 +197,11 @@ public class GUIsliceColorChooser extends JDialog {
public GUIsliceColorChooser(JFrame owner) {
super(owner, "GUIslice Color Chooser", true);
cf = ColorFactory.getInstance();
+ try {
+ this.robot = new Robot();
+ } catch (AWTException e) {
+ e.printStackTrace();
+ }
}
/**
@@ -210,22 +234,23 @@ public class GUIsliceColorChooser extends JDialog {
*/
private void initUI() {
setBounds(100, 100, 550, 450);
+ crossHairCursor = new Cursor(Cursor.CROSSHAIR_CURSOR);
redValue = currentColor.getRed();
greenValue = currentColor.getGreen();
blueValue = currentColor.getBlue();
contentPane = (JPanel) getContentPane();
+
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- contentPane.setLayout(new BorderLayout(2, 0));
+// contentPane.setLayout(new BorderLayout(2, 0));
setContentPane(contentPane);
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
- contentPane.add(tabbedPane, BorderLayout.CENTER);
- JScrollPane scrollPane = new JScrollPane();
- tabbedPane.addTab("GUIslice Colors", null, scrollPane, null);
- scrollPane.setPreferredSize(new Dimension(250, 300));
+ JScrollPane guisliceTab = new JScrollPane();
+ tabbedPane.addTab("GUIslice Colors", null, guisliceTab, null);
+ guisliceTab.setPreferredSize(new Dimension(250, 300));
// create the model and add elements
listModel = new DefaultListModel<>();
itemList = cf.getColorList();
@@ -236,10 +261,10 @@ public class GUIsliceColorChooser extends JDialog {
listSelectionModel = colorList.getSelectionModel();
colorList.setCellRenderer(new GUIsliceColorRenderer());
- scrollPane.setViewportView(colorList);
+ guisliceTab.setViewportView(colorList);
- rgbPanel = new JPanel();
- tabbedPane.addTab("RGB Colors", null, rgbPanel, null);
+ rgbTab = new JPanel();
+ tabbedPane.addTab("RGB Colors", null, rgbTab, null);
JLabel lblRed = new JLabel("Red:");
lblRed.setFont(new Font("Tahoma", Font.PLAIN, 14));
@@ -274,44 +299,32 @@ public class GUIsliceColorChooser extends JDialog {
sliderB.setPaintLabels(true);
sliderB.addChangeListener(new SliderListener());
- GroupLayout gl_rgbPanel = new GroupLayout(rgbPanel);
- gl_rgbPanel.setHorizontalGroup(
- gl_rgbPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_rgbPanel.createSequentialGroup()
- .addGap(57)
- .addGroup(gl_rgbPanel.createParallelGroup(Alignment.LEADING)
- .addComponent(lblRed)
- .addComponent(lblGreen)
- .addComponent(lblBlue))
+ GroupLayout gl_rgbTab = new GroupLayout(rgbTab);
+ gl_rgbTab.setHorizontalGroup(gl_rgbTab.createParallelGroup(Alignment.LEADING).addGroup(gl_rgbTab
+ .createSequentialGroup().addGap(57)
+ .addGroup(gl_rgbTab
+ .createParallelGroup(Alignment.LEADING).addComponent(lblRed).addComponent(lblGreen).addComponent(lblBlue))
.addGap(30)
- .addGroup(gl_rgbPanel.createParallelGroup(Alignment.TRAILING)
+ .addGroup(gl_rgbTab.createParallelGroup(Alignment.TRAILING)
.addComponent(sliderG, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(sliderB, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(sliderR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addContainerGap(54, Short.MAX_VALUE))
- );
- gl_rgbPanel.setVerticalGroup(
- gl_rgbPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_rgbPanel.createSequentialGroup()
- .addGap(57)
- .addGroup(gl_rgbPanel.createParallelGroup(Alignment.LEADING)
- .addComponent(lblRed)
+ .addContainerGap(54, Short.MAX_VALUE)));
+ gl_rgbTab.setVerticalGroup(gl_rgbTab.createParallelGroup(Alignment.LEADING).addGroup(gl_rgbTab
+ .createSequentialGroup().addGap(57)
+ .addGroup(gl_rgbTab.createParallelGroup(Alignment.LEADING).addComponent(lblRed)
.addComponent(sliderR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(53)
- .addGroup(gl_rgbPanel.createParallelGroup(Alignment.LEADING)
- .addComponent(lblGreen)
+ .addGroup(gl_rgbTab.createParallelGroup(Alignment.LEADING).addComponent(lblGreen)
.addComponent(sliderG, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(61)
- .addGroup(gl_rgbPanel.createParallelGroup(Alignment.LEADING)
- .addComponent(lblBlue)
- .addComponent(sliderB, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addContainerGap(74, Short.MAX_VALUE))
- );
- rgbPanel.setLayout(gl_rgbPanel);
+ .addGroup(gl_rgbTab.createParallelGroup(Alignment.LEADING).addComponent(lblBlue).addComponent(sliderB,
+ GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(74, Short.MAX_VALUE)));
+ rgbTab.setLayout(gl_rgbTab);
colorPanel = new JPanel();
colorPanel.setPreferredSize(new Dimension(125, 350));
- contentPane.add(colorPanel, BorderLayout.EAST);
JLabel lblspinnerR = new JLabel("Red:");
spinnerR = new JSpinner();
@@ -338,13 +351,19 @@ public class GUIsliceColorChooser extends JDialog {
JLabel lblTxtPreview = new JLabel("Preview");
lblTxtPreview.setFont(new Font("Tahoma", Font.BOLD, 12));
+ JLabel lblRecentColors = new JLabel("Recent Colors");
+
+ recentColorsPanel = new SwatchPanel();
+ RecentSwatchListener recentSwatchListener = new RecentSwatchListener();
+ recentColorsPanel.addMouseListener(recentSwatchListener);
+
GroupLayout gl_colorPanel = new GroupLayout(colorPanel);
gl_colorPanel.setHorizontalGroup(
gl_colorPanel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_colorPanel.createSequentialGroup()
- .addContainerGap()
- .addGroup(gl_colorPanel.createParallelGroup(Alignment.TRAILING)
+ .addGroup(gl_colorPanel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_colorPanel.createSequentialGroup()
+ .addContainerGap()
.addGroup(gl_colorPanel.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_colorPanel.createSequentialGroup()
.addComponent(lblspinnerB)
@@ -357,23 +376,35 @@ public class GUIsliceColorChooser extends JDialog {
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_colorPanel.createParallelGroup(Alignment.LEADING)
.addComponent(spinnerG, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(spinnerR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
- .addContainerGap(28, Short.MAX_VALUE))
+ .addComponent(spinnerR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addGap(1))))
.addGroup(gl_colorPanel.createSequentialGroup()
- .addGap(12)
- .addGroup(gl_colorPanel.createParallelGroup(Alignment.TRAILING)
- .addComponent(lblTxtPreview)
- .addComponent(lblPreview, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(39))))
+ .addGap(38)
+ .addComponent(lblPreview, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
+ .addGap(30))
+ .addGroup(gl_colorPanel.createSequentialGroup()
+ .addGap(21)
+ .addComponent(lblRecentColors)
+ .addGap(37))
+ .addGroup(gl_colorPanel.createSequentialGroup()
+ .addGap(30)
+ .addGroup(gl_colorPanel.createParallelGroup(Alignment.LEADING)
+ .addComponent(recentColorsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblTxtPreview, GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE))
+ .addContainerGap())
);
gl_colorPanel.setVerticalGroup(
gl_colorPanel.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_colorPanel.createSequentialGroup()
- .addContainerGap(103, Short.MAX_VALUE)
+ .addContainerGap()
+ .addComponent(lblRecentColors)
+ .addGap(18)
+ .addComponent(recentColorsPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
.addComponent(lblTxtPreview)
- .addPreferredGap(ComponentPlacement.UNRELATED)
+ .addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblPreview, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addGap(38)
+ .addGap(13)
.addGroup(gl_colorPanel.createParallelGroup(Alignment.BASELINE)
.addComponent(lblspinnerR)
.addComponent(spinnerR, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
@@ -391,11 +422,11 @@ public class GUIsliceColorChooser extends JDialog {
JPanel commandPanel = new JPanel();
commandPanel.setPreferredSize(new Dimension(450, 50));
- contentPane.add(commandPanel, BorderLayout.SOUTH);
btnOK = new JButton("OK");
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
+ recentColorsPanel.setMostRecentColor(currentColor);
bSaveDialog = true;
Closed_Option = JOptionPane.OK_OPTION;
dispose();
@@ -414,25 +445,62 @@ public class GUIsliceColorChooser extends JDialog {
btnCANCEL.addActionListener(actionListener);
GroupLayout gl_commandPanel = new GroupLayout(commandPanel);
- gl_commandPanel.setHorizontalGroup(
- gl_commandPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(Alignment.TRAILING, gl_commandPanel.createSequentialGroup()
- .addContainerGap(230, Short.MAX_VALUE)
- .addComponent(btnCANCEL)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(btnOK)
- .addContainerGap())
- );
- gl_commandPanel.setVerticalGroup(
- gl_commandPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(Alignment.TRAILING, gl_commandPanel.createSequentialGroup()
- .addContainerGap(16, Short.MAX_VALUE)
- .addGroup(gl_commandPanel.createParallelGroup(Alignment.BASELINE)
- .addComponent(btnOK)
- .addComponent(btnCANCEL))
- .addContainerGap())
- );
+ gl_commandPanel
+ .setHorizontalGroup(gl_commandPanel.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
+ gl_commandPanel.createSequentialGroup().addContainerGap(230, Short.MAX_VALUE).addComponent(btnCANCEL)
+ .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnOK).addContainerGap()));
+ gl_commandPanel.setVerticalGroup(gl_commandPanel.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
+ gl_commandPanel.createSequentialGroup().addContainerGap(16, Short.MAX_VALUE)
+ .addGroup(
+ gl_commandPanel.createParallelGroup(Alignment.BASELINE).addComponent(btnOK).addComponent(btnCANCEL))
+ .addContainerGap()));
commandPanel.setLayout(gl_commandPanel);
+ GroupLayout gl_contentPane = new GroupLayout(contentPane);
+ gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_contentPane.createSequentialGroup()
+ .addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 397, GroupLayout.PREFERRED_SIZE).addGap(2)
+ .addComponent(colorPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+ .addComponent(commandPanel, GroupLayout.PREFERRED_SIZE, 524, GroupLayout.PREFERRED_SIZE));
+ gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_contentPane.createSequentialGroup()
+ .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+ .addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 351, GroupLayout.PREFERRED_SIZE)
+ .addComponent(colorPanel, GroupLayout.PREFERRED_SIZE, 351, GroupLayout.PREFERRED_SIZE))
+ .addComponent(commandPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
+ GroupLayout.PREFERRED_SIZE)));
+
+ JPanel wheelTab = new JPanel();
+ tabbedPane.addTab("Color Wheel", null, wheelTab, null);
+
+ JButton btnEyeDropper = new JButton("");
+ btnEyeDropper.setIcon(new ImageIcon(Builder.class.getResource("/resources/icons/eyedropper.png")));
+ btnEyeDropper.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ isEyeDropper = true;
+ setCursor(crossHairCursor);
+ }
+ });
+
+ JPanel wheelPanel = new ColorWheel();
+ wheelPanel.addMouseListener(new MouseHandler());
+
+ JLabel lblUseEyeDropper = new JLabel("Use Eye Dropper to Choose your Color");
+ GroupLayout gl_wheelTab = new GroupLayout(wheelTab);
+ gl_wheelTab.setHorizontalGroup(gl_wheelTab.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_wheelTab.createSequentialGroup().addContainerGap()
+ .addComponent(wheelPanel, GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
+ .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btnEyeDropper).addGap(18))
+ .addGroup(gl_wheelTab.createSequentialGroup().addGap(67)
+ .addComponent(lblUseEyeDropper, GroupLayout.PREFERRED_SIZE, 218, GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(107, Short.MAX_VALUE)));
+ gl_wheelTab.setVerticalGroup(gl_wheelTab.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_wheelTab.createSequentialGroup().addGap(4).addComponent(lblUseEyeDropper)
+ .addPreferredGap(ComponentPlacement.UNRELATED)
+ .addGroup(gl_wheelTab.createParallelGroup(Alignment.LEADING)
+ .addComponent(wheelPanel, GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE).addComponent(btnEyeDropper))
+ .addContainerGap()));
+ wheelTab.setLayout(gl_wheelTab);
+ contentPane.setLayout(gl_contentPane);
// create the model and add elements
listModel = new DefaultListModel<>();
@@ -442,18 +510,44 @@ public class GUIsliceColorChooser extends JDialog {
}
listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
listSelectionModel.addListSelectionListener(new ColorSelectionHandler());
+ }
- pack();
- setResizable(false);
+ public void setSelectedColor(Color c) {
+ currentColor = c;
+ isList = true;
+ if (redValue != currentColor.getRed()) {
+ redValue = currentColor.getRed();
+ spinnerR.setValue(Integer.valueOf(redValue));
+ sliderR.setValue(Integer.valueOf(redValue));
+ }
+ if (greenValue != currentColor.getGreen()) {
+ greenValue = currentColor.getGreen();
+ spinnerG.setValue(Integer.valueOf(greenValue));
+ sliderG.setValue(Integer.valueOf(greenValue));
+ }
+ if (blueValue != currentColor.getBlue()) {
+ blueValue = currentColor.getBlue();
+ spinnerB.setValue(Integer.valueOf(blueValue));
+ sliderB.setValue(Integer.valueOf(blueValue));
+ }
+ previewIcon.setColor(currentColor);
+ ColorItem item = cf.findColorItem(currentColor);
+ colorIndex = item.getIndex();
+ colorList.setSelectedIndex(colorIndex);
+ colorList.ensureIndexIsVisible(colorIndex);
+ colorPanel.repaint();
}
- /**
- * Gets the option.
- *
- * @return the option
- */
- public int getOption() {
- return Closed_Option;
+ class RecentSwatchListener extends MouseAdapter {
+ public void mousePressed(MouseEvent e) {
+ if (isEnabled()) {
+ Color color = recentColorsPanel.getColorForLocation(e.getX(), e.getY());
+ recentColorsPanel.setSelectedColorFromLocation(e.getX(), e.getY());
+ // ignore if setting to default color
+ if (color.getRGB() != -1118482)
+ setSelectedColor(color);
+ }
+ }
}
/**
@@ -489,22 +583,7 @@ public class GUIsliceColorChooser extends JDialog {
repaint();
}
- /**
- * The listener interface for receiving spinner events. The class that is
- * interested in processing a spinner event implements this interface, and the
- * object created with that class is registered with a component using the
- * component's addSpinnerListener method. When the spinner event
- * occurs, that object's appropriate method is invoked.
- *
- * @see SpinnerEvent
- */
class SpinnerListener implements ChangeListener {
-
- /**
- * stateChanged
- *
- * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
- */
@Override
public void stateChanged(ChangeEvent e) {
JSpinner spinner = (JSpinner) e.getSource();
@@ -527,27 +606,12 @@ public class GUIsliceColorChooser extends JDialog {
colorList.setSelectedIndex(colorIndex);
colorList.ensureIndexIsVisible(colorIndex);
isSpinner = false;
- repaint();
+ colorPanel.repaint();
+ }
}
}
- };
- /**
- * The listener interface for receiving slider events. The class that is
- * interested in processing a slider event implements this interface, and the
- * object created with that class is registered with a component using the
- * component's addSliderListener method. When the slider event
- * occurs, that object's appropriate method is invoked.
- *
- * @see SliderEvent
- */
class SliderListener implements ChangeListener {
-
- /**
- * stateChanged
- *
- * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
- */
public void stateChanged(ChangeEvent e) {
JSlider slider = (JSlider) e.getSource();
if (isList == false && isSpinner == false) {
@@ -573,16 +637,7 @@ public class GUIsliceColorChooser extends JDialog {
}
}
- /**
- * The Class ColorSelectionHandler.
- */
class ColorSelectionHandler implements ListSelectionListener {
-
- /**
- * valueChanged
- *
- * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
- */
public void valueChanged(ListSelectionEvent e) {
ColorItem item;
int idx = colorList.getSelectedIndex();
@@ -614,5 +669,51 @@ public class GUIsliceColorChooser extends JDialog {
}
}
}
+ /**
+ * The Class MouseHandler.
+ */
+ private class MouseHandler extends MouseAdapter {
+
+ /**
+ * mouseClicked.
+ *
+ * @param e
+ * the e
+ * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (isEyeDropper) {
+ Point p = e.getLocationOnScreen();
+ Color c = robot.getPixelColor(p.x, p.y);
+ setSelectedColor(c);
+ setCursor(Cursor.getDefaultCursor());
+ isEyeDropper = false;
+ }
+ } // end mouseClicked
+
+ /**
+ * mouseReleased.
+ *
+ * @param e
+ * the e
+ * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ } // end mouseReleased
+
+ /**
+ * mousePressed.
+ *
+ * @param e
+ * the e
+ * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent)
+ */
+ @Override
+ public void mousePressed(MouseEvent e) {
+ } // end mousePressed
+ } // end MouseHandler
+
}

diff:
+/**
+ *
+ * The MIT License
+ *
+ * Copyright 2019 Paul Conti
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+package builder.views;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.MouseEvent;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Base64;
+import java.util.LinkedList;
+
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+
+import builder.prefs.GeneralEditor;
+
+/**
+ * The Class SwatchPanel manages recent color selection
+ * They are stored inside the users preferences General Model.
+ *
+ * @author Paul Conti
+ */
+public class SwatchPanel extends JPanel {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 1L;
+
+ /** The Constant CUSTOM_COLORS_FILE. */
+ public static final String CUSTOM_COLORS_FILE = "custom_colors.list";
+
+ /** size of color square in our recent colors panel */
+ public static final int NSQUARE = 15;
+
+ /** number of columns in our recent colors panel */
+ public static final int NCOLUMNS = 4;
+
+ /** number of rows in our recent colors panel */
+ public static final int NROWS = 4;
+
+ /** The general editor. */
+ private GeneralEditor generalEditor;
+
+ /** lru cache of recent colors */
+ LinkedList<Color> lruList = new LinkedList<Color>();
+
+ /** The swatch size. */
+ protected Dimension swatchSize;
+
+ /** The num swatches. */
+ protected Dimension numSwatches;
+
+ /** The gap. */
+ protected Dimension gap;
+
+ /** The selected row. */
+ private int selRow;
+
+ /** The selected col. */
+ private int selCol;
+
+ /** The num colors. */
+ private int numColors;
+
+ /**
+ * Instantiates a new swatch panel.
+ */
+ public SwatchPanel() {
+ initValues();
+ initColors();
+ setToolTipText(""); // register for events
+ setOpaque(true);
+ setBackground(Color.white);
+ setFocusable(true);
+ setInheritsPopupMenu(true);
+
+ addFocusListener(new FocusAdapter() {
+ public void focusGained(FocusEvent e) {
+ repaint();
+ }
+
+ public void focusLost(FocusEvent e) {
+ repaint();
+ }
+ });
+ }
+
+ /**
+ * Gets the selected color.
+ *
+ * @return the selected color
+ */
+ public Color getSelectedColor() {
+ return getColorForCell(selCol, selRow);
+ }
+
+ /**
+ * Initializes the values.
+ */
+ protected void initValues() {
+ swatchSize = new Dimension(NSQUARE, NSQUARE);
+ numSwatches = new Dimension(NCOLUMNS, NROWS);
+ numColors = NCOLUMNS * NROWS;
+ gap = new Dimension(1, 1);
+ generalEditor = GeneralEditor.getInstance();
+ }
+
+ /**
+ * paintComponent
+ *
+ * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
+ */
+ public void paintComponent(Graphics g) {
+ g.setColor(getBackground());
+ g.fillRect(0, 0, getWidth(), getHeight());
+ for (int row = 0; row < numSwatches.height; row++) {
+ int y = row * (swatchSize.height + gap.height);
+ for (int column = 0; column < numSwatches.width; column++) {
+ Color c = getColorForCell(column, row);
+ g.setColor(c);
+ int x;
+ if (!this.getComponentOrientation().isLeftToRight()) {
+ x = (numSwatches.width - column - 1) * (swatchSize.width + gap.width);
+ } else {
+ x = column * (swatchSize.width + gap.width);
+ }
+ g.fillRect(x, y, swatchSize.width, swatchSize.height);
+ g.setColor(Color.black);
+ g.drawLine(x + swatchSize.width - 1, y, x + swatchSize.width - 1, y + swatchSize.height - 1);
+ g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1, y + swatchSize.height - 1);
+
+ if (selRow == row && selCol == column && this.isFocusOwner()) {
+ Color c2 = new Color(c.getRed() < 125 ? 255 : 0, c.getGreen() < 125 ? 255 : 0, c.getBlue() < 125 ? 255 : 0);
+ g.setColor(c2);
+
+ g.drawLine(x, y, x + swatchSize.width - 1, y);
+ g.drawLine(x, y, x, y + swatchSize.height - 1);
+ g.drawLine(x + swatchSize.width - 1, y, x + swatchSize.width - 1, y + swatchSize.height - 1);
+ g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1, y + swatchSize.height - 1);
+ g.drawLine(x, y, x + swatchSize.width - 1, y + swatchSize.height - 1);
+ g.drawLine(x, y + swatchSize.height - 1, x + swatchSize.width - 1, y);
+ }
+ }
+ }
+ }
+
+ /**
+ * getPreferredSize
+ *
+ * @see javax.swing.JComponent#getPreferredSize()
+ */
+ public Dimension getPreferredSize() {
+ int x = numSwatches.width * (swatchSize.width + gap.width) - 1;
+ int y = numSwatches.height * (swatchSize.height + gap.height) - 1;
+ return new Dimension(x, y);
+ }
+
+ /**
+ * Initializes the colors.
+ */
+ @SuppressWarnings("unchecked")
+ protected void initColors() {
+ Color defaultColor = UIManager.getColor("ColorChooser.swatchesDefaultRecentColor", getLocale());
+ String recentColors = generalEditor.getRecentColors();
+ // do we have any user preferences for colors?
+ if (recentColors.length() > 0) {
+ ObjectInputStream in;
+ try {
+ byte[] data = Base64.getDecoder().decode(recentColors);
+ in = new ObjectInputStream(new ByteArrayInputStream(data));
+ lruList = (LinkedList<Color>) in.readObject();
+ in.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ } else {
+ // first time we initialize lru with default colors
+ for (int i = 0; i < numColors; i++) {
+ lruList.addFirst(defaultColor);
+ }
+ }
+ }
+
+ /**
+ * getToolTipText
+ *
+ * @see javax.swing.JComponent#getToolTipText(java.awt.event.MouseEvent)
+ */
+ public String getToolTipText(MouseEvent e) {
+ Color color = getColorForLocation(e.getX(), e.getY());
+ return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();
+ }
+
+ /**
+ * Sets the selected color from location.
+ *
+ * @param x
+ * the x
+ * @param y
+ * the y
+ */
+ public void setSelectedColorFromLocation(int x, int y) {
+ if (!this.getComponentOrientation().isLeftToRight()) {
+ selCol = numSwatches.width - x / (swatchSize.width + gap.width) - 1;
+ } else {
+ selCol = x / (swatchSize.width + gap.width);
+ }
+ selRow = y / (swatchSize.height + gap.height);
+ repaint();
+ }
+
+ /**
+ * Gets the color for location.
+ *
+ * @param x
+ * the x
+ * @param y
+ * the y
+ * @return the color for location
+ */
+ public Color getColorForLocation(int x, int y) {
+ int column;
+ if (!this.getComponentOrientation().isLeftToRight()) {
+ column = numSwatches.width - x / (swatchSize.width + gap.width) - 1;
+ } else {
+ column = x / (swatchSize.width + gap.width);
+ }
+ int row = y / (swatchSize.height + gap.height);
+ return getColorForCell(column, row);
+ }
+
+ /**
+ * Gets the color for cell.
+ *
+ * @param column
+ * the column
+ * @param row
+ * the row
+ * @return the color for cell
+ */
+ private Color getColorForCell(int column, int row) {
+ // convert a 2D array index into a 1D index
+ int idx = row * NCOLUMNS + column;
+ return lruList.get(idx);
+ }
+
+ /**
+ * Sets the most recent color.
+ *
+ * @param c
+ * the new most recent color
+ */
+ public void setMostRecentColor(Color c) {
+ // update our lru but first check and see if the color is already present
+ // if so, remove it then add to front of list
+ if (!lruList.remove(c)) {
+ lruList.removeLast();
+ }
+ lruList.addFirst(c);
+ repaint();
+ // now push the recent colors panel to user preferences
+ ObjectOutputStream out;
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ out = new ObjectOutputStream(baos);
+ out.writeObject(lruList);
+ out.close();
+ String recentColors = Base64.getEncoder().encodeToString(baos.toByteArray());
+ generalEditor.setRecentColors(recentColors);
+ generalEditor.savePreferences();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}


message: issue 41 - new folder dialog allowing sub folders

change_type: MODIFY

diff:
@@ -61,6 +61,7 @@ import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileView;
import builder.Builder;
import builder.commands.AddPageCommand;
@@ -861,36 +862,89 @@ public class Controller extends JInternalFrame
}
}
+ /**
+ * Checks, whether the child directory is a subdirectory of the base
+ * directory.
+ *
+ * @param base the base directory.
+ * @param child the suspected child directory.
+ * @return true, if the child is a subdirectory of the base directory.
+ * @throws IOException if an IOError occured during the test.
+ */
+ public boolean isSubDirectory(File base, File child) {
+
+ boolean res = false;
+ try {
+ base = base.getCanonicalFile();
+ if (child != null) {
+ if (child.isDirectory()) {
+ child = child.getCanonicalFile();
+ File parentFile = child;
+ while (!res && parentFile != null) {
+ if (base.equals(parentFile)) {
+ res = true;
+ }
+ parentFile = parentFile.getParentFile();
+ }
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return res;
+ }
+
/**
* Create folder dialog.
*
* @return the file object
*/
public File createFolderDialog() {
- String name = (String) JOptionPane.showInputDialog(null,
- "Enter Name of Project Folder",
- "Create Project Folder", JOptionPane.PLAIN_MESSAGE);
- if (name == null) // operation cancelled
- return null;
File currentDirectory;
- String projectDir = ((GeneralModel) generalEditor.getModel()).getProjectDir();
- projectDir = projectDir + System.getProperty("file.separator") + name;
+ String folderPath = ((GeneralModel) generalEditor.getModel()).getProjectDir();
// absolute path or relative?
- Path path = Paths.get(projectDir);
+ Path path = Paths.get(folderPath);
if (path.isAbsolute()) {
- currentDirectory = new File(projectDir);
+ currentDirectory = new File(folderPath);
} else {
String workingDir = CommonUtil.getInstance().getWorkingDir();
- projectDir = workingDir + projectDir;
- currentDirectory = new File(projectDir);
+ folderPath = workingDir + folderPath;
+ currentDirectory = new File(folderPath);
}
- if(!currentDirectory.exists()){
- currentDirectory.mkdir();
+ File directorylock = new File(folderPath);
+ JFileChooser chooser = new JFileChooser(folderPath);
+ // lock the user into only using the project directory or its sub-directories
+ chooser.setFileView(new FileView() {
+ @Override
+ public Boolean isTraversable(File f) {
+ return isSubDirectory(directorylock, f);
+ }
+ });
+ chooser.addChoosableFileFilter(new FileFilter() {
+ public String getDescription() {
+ String descr = new String("GUIslice Builder Project Folder");
+ return descr;
+ }
+ public boolean accept(File f) {
+ return f.isDirectory();
+ }
+ });
+ chooser.setDialogTitle("Choose your Project Folder");
+ chooser.setApproveButtonText("Select Folder");
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setAcceptAllFileFilterUsed(false);
+ chooser.setAcceptAllFileFilterUsed(false);
+ // Open Dialog
+ if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
+ currentDirectory = chooser.getSelectedFile();
+ } else {
+ return null;
}
projectFolder = currentDirectory;
- File project = new File(new String(projectDir
+ File project = new File(new String(currentDirectory.toString()
+ System.getProperty("file.separator")
- + name + ".prj"));
+ + currentDirectory.getName() + ".prj"));
+ System.out.println("New project file: " + project.toString());
return project;
}
@@ -980,7 +1034,7 @@ public class Controller extends JInternalFrame
// System.out.println("command: " + command);
switch(command) {
case "about":
- JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.10.4-beta7", "About", JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc1", "About", JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(null, "GUIsliceBuider ver SNAPSHOT", "About", JOptionPane.INFORMATION_MESSAGE);
break;

license: MIT License

repo: impulseadventure/guislice


message: issue 42 - Don't overwrite .bak file

diff:
@@ -641,6 +641,18 @@ public class CodeGenerator {
// Make a backup copy of projectFile and overwrite backup file if it exists.
backupName = new String(skeletonName + ".bak");
backupFile = new File(backupName);
+ if (backupFile.exists()) {
+ // rename previous backup files so we don't lose them
+ String newTemplate = new String(skeletonName + ".ba");
+ int idx = 0;
+ String newName = newTemplate + String.valueOf(++idx);
+ File newFile = new File(newName);
+ while (newFile.exists()) {
+ newName = newTemplate + String.valueOf(++idx);
+ newFile = new File(newName);
+ }
+ backupFile.renameTo(newFile);
+ }
copyFile(projectFile, backupFile);
}

original_message: issue 42 - Don't overwrite .bak file


message: issue 44 - Confirm Exit Dialog when user presses windows X button

diff:
@@ -31,6 +31,8 @@ import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -208,6 +210,17 @@ public class Builder extends JDesktopPane {
SwingUtilities.updateComponentTreeUI(frame);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
}
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent we) {
+ String title = "Confirm Dialog";
+ String message = "You're about to quit the application -- are you sure?";
+ int answer = JOptionPane.showConfirmDialog(null,message,title, JOptionPane.YES_NO_OPTION);
+ if(answer == JOptionPane.YES_OPTION)
+ {
+ System.exit(0);
+ }
+ }
+ });
frame.setVisible(true);
}
});


message: enum numbering error

diff:
@@ -95,24 +95,24 @@ public class WidgetFactory {
widget = new BoxWidget(x, y);
model = (BoxModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
}
break;
case "CheckBox":
widget = new CheckBoxWidget(x, y);
model = (CheckBoxModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
}
break;
case "Graph":
widget = new GraphWidget(x, y);
model = (GraphModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
ref = GraphModel.ELEMENTREF_NAME;
strKey = model.getKey();
n = strKey.indexOf("$");
@@ -125,24 +125,24 @@ public class WidgetFactory {
widget = new ImageWidget();
model = (ImageModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
}
break;
case "ImageButton":
widget = new ImgButtonWidget();
model = (ImgButtonModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
}
break;
case "ProgressBar":
widget = new ProgressBarWidget(x, y);
model = (ProgressBarModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
ref = ProgressBarModel.ELEMENTREF_NAME;
strKey = model.getKey();
n = strKey.indexOf("$");
@@ -155,16 +155,16 @@ public class WidgetFactory {
widget = new RadioButtonWidget(x, y);
model = (RadioButtonModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
}
break;
case "Slider":
widget = new SliderWidget(x, y);
model = (SliderModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
ref = SliderModel.ELEMENTREF_NAME;
strKey = model.getKey();
n = strKey.indexOf("$");
@@ -185,8 +185,8 @@ public class WidgetFactory {
widget = new TextBoxWidget(x, y);
model = (TextBoxModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
ref = TextBoxModel.ELEMENTREF_NAME;
strKey = model.getKey();
n = strKey.indexOf("$");
@@ -199,8 +199,8 @@ public class WidgetFactory {
widget = new TxtButtonWidget(x, y);
model = (TxtButtonModel) widget.getModel();
if (widget != null) {
- model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
model.setKey(EnumFactory.getInstance().createKey(widgetType));
+ model.setEnum(EnumFactory.getInstance().createEnum(widgetType));
}
break;
default:

original_message: enum numbering error


message: issue 50 - Delete not active on new blank page

diff:
@@ -408,7 +408,7 @@ public class Controller extends JInternalFrame
if (list.size() < 1) { // could be a widget or page selected in TreeView
// ask tree view if anyone selected?
String selected = TreeView.getInstance().getSelectedWidget();
- if (selected != null) {
+ if (selected != null && !selected.isEmpty()) {
if (selected.startsWith("Page")) {
PagePane p = findPage(selected);
if (p != null) {
@@ -423,6 +423,7 @@ public class Controller extends JInternalFrame
return;
}
}
+
} else { // widget removal
delWidget(list);
return;

diff:
@@ -401,13 +401,6 @@ public class PagePane extends JPanel implements iSubscriber {
w.unSelect();
doSelectedCount(w);
toolBar.setEditButtons(selectedCnt, selectedGroupCnt);
- if (selectedCnt == 0) {
- MsgEvent ev = new MsgEvent();
- ev.message ="";
- ev.parent = getKey();
- ev.code = MsgEvent.OBJECT_UNSELECT_PAGEPANE;
- MsgBoard.getInstance().publish(ev);
- }
}
/**
@@ -429,6 +422,13 @@ public class PagePane extends JPanel implements iSubscriber {
}
if (selectedCnt > 0) selectedCnt--;
}
+ if (selectedCnt == 0) {
+ MsgEvent ev = new MsgEvent();
+ ev.message ="";
+ ev.parent = getKey();
+ ev.code = MsgEvent.OBJECT_UNSELECT_PAGEPANE;
+ MsgBoard.getInstance().publish(ev);
+ }
}
/**
@@ -675,6 +675,12 @@ public class PagePane extends JPanel implements iSubscriber {
selectNone();
if (w == null) {
bMultiSelectionBox = true;
+ toolBar.setEditButtons(selectedCnt, selectedGroupCnt);
+ MsgEvent ev = new MsgEvent();
+ ev.message ="";
+ ev.parent = getKey();
+ ev.code = MsgEvent.OBJECT_UNSELECT_PAGEPANE;
+ MsgBoard.getInstance().publish(ev);
} else {
selectWidget(w);
MsgEvent ev = new MsgEvent();

diff:
@@ -135,7 +135,10 @@ public class ToolBar extends JToolBar {
add(btn_redo);
btn_delete = new JButton(new ImageIcon(Builder.class.getResource("/resources/icons/delete.png")));
- btn_delete.setDisabledIcon(new ImageIcon(Builder.class.getResource("/resources/icons/disable_delete.png")));
+/* The builder's pagepane doesn't know if its selected or not and so we can't
+ * dynamically turn Delete button on/off. Symptoms: Users can't delete empty page
+ * btn_delete.setDisabledIcon(new ImageIcon(Builder.class.getResource("/resources/icons/disable_delete.png")));
+ */
btn_delete.setToolTipText("Delete Widget");
btn_delete.setActionCommand("delete");
add(btn_delete);
@@ -323,7 +326,6 @@ public class ToolBar extends JToolBar {
btn_aligncenter.setEnabled(true);
btn_alignleft.setEnabled(true);
btn_alignright.setEnabled(true);
- btn_delete.setEnabled(true);
}
public void disableSingleEdits() {
@@ -336,7 +338,6 @@ public class ToolBar extends JToolBar {
btn_alignvspace.setEnabled(false);
btn_alignwidth.setEnabled(false);
btn_alignheight.setEnabled(false);
- btn_delete.setEnabled(false);
}
public void enableMultiEdits() {
@@ -349,7 +350,6 @@ public class ToolBar extends JToolBar {
btn_alignvspace.setEnabled(true);
btn_alignwidth.setEnabled(true);
btn_alignheight.setEnabled(true);
- btn_delete.setEnabled(true);
}
public void disableMultiEdits() {


message: update user guide for import

diff:
**Publication date and software version**
-Published January, 2019. Based on GUIslice API Library 0.11.5
+Published february, 2019. Based on GUIslice API Library 0.11.5
**Copyright**
@@ -596,6 +596,8 @@ The following lists GUIsliceBuilder UI Widgets that are supported along with the
- gslc_ElemXGraphCreate
- gslc_ElemXGraphSetStyle
- gslc_ElemSetCol
+- gslc_PageFindElemById
+- m_pElemXXX = pElemRef; // Save for quick access
## 5.4 PROGRESS BAR
@@ -604,6 +606,8 @@ The following lists GUIsliceBuilder UI Widgets that are supported along with the
- gslc_ElemSetCol
- gslc_ElemXGaugeSetIndicator
- gslc_ElemXGaugeSetTicks
+- gslc_PageFindElemById
+- m_pElemXXX = pElemRef; // Save for quick access
-----------------------------------------------

@@ -614,6 +618,8 @@ The following lists GUIsliceBuilder UI Widgets that are supported along with the
- gslc_ElemXSliderCreate_P
- gslc_ElemSetCol
- gslc_ElemXSliderSetStyle
+- gslc_PageFindElemById
+- m_pElemXXX = pElemRef; // Save for quick access
## 5.6 TEXT
@@ -624,6 +630,9 @@ The following lists GUIsliceBuilder UI Widgets that are supported along with the
- gslc_ElemSetTxtCol
- gslc_ElemSetTxtAlign
- gslc_ElemSetFillEn
+- gslc_FontAdd
+- gslc_PageFindElemById
+- m_pElemXXX = pElemRef; // Save for quick access
## 5.7 TEXT BUTTON
@@ -631,21 +640,66 @@ The following lists GUIsliceBuilder UI Widgets that are supported along with the
- gslc_ElemCreateBtnTxt_P
- gslc_ElemSetCol
- gslc_ElemSetTxtCol
+- gslc_FontAdd
## 5.8 TEXT BOX
- gslc_ElemXTextboxCreate
- gslc_ElemSetCol
- gslc_ElemXTextboxWrapSet
+- gslc_FontAdd
+- gslc_PageFindElemById
+- m_pElemXXX = pElemRef; // Save for quick access
-## 5.9 UI Widgets not supported by import
+-----------------------------------------------
+

+
+## 5.9 Not supported by import
+
+### 5.9.1 IMAGES
- IMAGE
- IMAGE BUTTON
-Images are problematic due to complexity of parsing the source code and gaining access to the images from the builders platform.
+### 5.9.2 C Language Issues
+
+Since the Builder has a simple parser not a full C Language preprocessor certain constructs will cause import issues.
+The most common causes are things like:
+
+Usuage of #ifdef and #endif pairs
+
+```
+ #ifdef USE_EXTRA_FONTS
+ // Demonstrate the use of additional fonts (must have #include)
+ if (!gslc_FontAdd(&m_gui,E_FONT_BTN,GSLC_FONTREF_PTR,&FreeSansBold12pt7b,1))
+ { return; }
+ #else
+ // Use default font
+ if (!gslc_FontAdd(&m_gui,E_FONT_BTN,GSLC_FONTREF_PTR,NULL,1))
+ { return; }
+ #endif
+```
+
+Likewise using Variable Names instead of constants like:
+
+```
+ pElemRef = gslc_ElemXCheckboxCreate(&m_gui,E_ELEM_CHECK2,E_PG_EXTRA,&m_asXCheck[1],
+ (gslc_tsRect){60,nPosY,20,20},
+ false,GSLCX_CHECKBOX_STYLE_X,GSLC_COL_RED_LT2,false);
+```
+
+Will cause a parsing error on nPosY.
+
+Doing arithmetic with constants like:
+
+```
+ pElemRef = gslc_ElemCreateTxt(&m_gui,GSLC_ID_AUTO,E_PG_MAIN,
+ (gslc_tsRect){9,57,177,80-57}, "Now Playing",0,E_FONT_HEAD);
+```
+Causes an parsing error on '-57'.
+All of these can easily be corrected by hand editing the file and re-doing the import.
-----------------------------------------------

diff: Binary files a/builder/docs/user_guide.pdf and b/builder/docs/user_guide.pdf differ

diff:
@@ -1544,6 +1544,18 @@ public class Parser {
} else parseError("graph style");
parse_EOS();
return true;
+ } else if (token.getType() == Parser.WORD) {
+ // scan for something like: m_pElemCnt = pElemRef;
+ String strElemRef = token.getToken();
+ token = tokenizer.nextToken();
+ if (token.getType() == Parser.EQUALS) {
+ token = tokenizer.nextToken();
+ if (token.getType() == Parser.WORD && token.getToken().equals("pElemRef")) {
+ node.setElementRef(strElemRef);
+ parse_EOS();
+ return true;
+ }
+ }
}
tokenizer.pushToken();
return false;
@@ -1975,6 +1987,9 @@ public class Parser {
} else if (a.getType() == ApiNode.TXTBUTTON) {
if (((TxtButtonNode) a).getFontDisplayName() == null)
((TxtButtonNode) a).setFontDisplayName(strFontRef);
+ } else if (a.getType() == ApiNode.TEXTBOX) {
+ if (((TextBoxNode) a).getFontDisplayName() == null)
+ ((TextBoxNode) a).setFontDisplayName(strFontRef);
}
}
@@ -1995,6 +2010,8 @@ public class Parser {
((SliderNode) a).setElementRef(strElemRef);
} else if (a.getType() == ApiNode.GRAPH) {
((GraphNode) a).setElementRef(strElemRef);
+ } else if (a.getType() == ApiNode.TEXTBOX) {
+ ((TextBoxNode) a).setElementRef(strElemRef);
}
}

original_message: update user guide for import


message: fix delay() hang

diff:
@@ -694,7 +694,13 @@ public class CodeGenerator {
String tmp = fileName.substring(0,n);
String skeletonName = new String(folder + System.getProperty("file.separator") + tmp + fileExtension);
projectFile = new File(skeletonName);
+ backupName = null;
+ backupFile = null;
+ if(projectFile.exists()) {
+ // Make a backup copy of projectFile
+ backupName = new String(skeletonName + ".bak");
CommonUtil.getInstance().backupFile(projectFile);
+ }
try {
// Here we are either going to use a previously generated file as input
// or we are generating a brand new file from one of our templates.

diff:
@@ -130,7 +130,7 @@ public class TextBoxModel extends WidgetModel {
*/
@Override
public void changeValueAt(Object value, int row) {
- boolean bChangeFontEnum = true;
+ boolean bChangeFontEnum = false;
// The test for Integer supports copy and paste from clipboard.
// Otherwise we get a can't cast class String to Integer fault
if ( (getClassAt(row) == Integer.class) && (value instanceof String)) {
@@ -138,7 +138,7 @@ public class TextBoxModel extends WidgetModel {
} else {
if (row == PROP_FONT) {
// check to see if user defined this font enum, if so we won't change it
- if (!ff.getFontEnum((String)value).equals(getFontEnum())) bChangeFontEnum=false;
+ if (!ff.getFontEnum((String)value).equals(getFontEnum())) bChangeFontEnum=true;
}
data[row][PROP_VAL_VALUE] = value;
}

diff:
@@ -186,7 +186,7 @@ public class TextModel extends WidgetModel {
*/
@Override
public void changeValueAt(Object value, int row) {
- boolean bChangeFontEnum = true;
+ boolean bChangeFontEnum = false;
// The test for Integer supports copy and paste from clipboard.
// Otherwise we get a can't cast class String to Integer fault
if ( (getClassAt(row) == Integer.class) && (value instanceof String)) {
@@ -194,7 +194,7 @@ public class TextModel extends WidgetModel {
} else {
if (row == PROP_FONT) {
// check to see if user defined this font enum, if so we won't change it
- if (!ff.getFontEnum((String)value).equals(getFontEnum())) bChangeFontEnum=false;
+ if (!ff.getFontEnum((String)value).equals(getFontEnum())) bChangeFontEnum=true;
}
data[row][PROP_VAL_VALUE] = value;
}

diff:
@@ -130,7 +130,7 @@ public class TxtButtonModel extends WidgetModel {
*/
@Override
public void changeValueAt(Object value, int row) {
- boolean bChangeFontEnum = true;
+ boolean bChangeFontEnum = false;
// The test for Integer supports copy and paste from clipboard.
// Otherwise we get a can't cast class String to Integer fault
if ( (getClassAt(row) == Integer.class) && (value instanceof String)) {
@@ -138,7 +138,7 @@ public class TxtButtonModel extends WidgetModel {
} else {
if (row == PROP_FONT) {
// check to see if user defined this font enum, if so we won't change it
- if (!ff.getFontEnum((String)value).equals(getFontEnum())) bChangeFontEnum=false;
+ if (!ff.getFontEnum((String)value).equals(getFontEnum())) bChangeFontEnum=true;
}
data[row][PROP_VAL_VALUE] = value;
}

diff:
@@ -92,9 +92,8 @@ void setup()
// ------------------------------------------------
Serial.begin(9600);
// Wait for USB Serial
- while (!Serial) {
- yield();
- }
+ //delay(1000); // NOTE: Some devices require a delay after Serial.begin() before serial port can be used
+
gslc_InitDebug(&DebugOut);
if (!gslc_Init(&m_gui,&m_drv,m_asPage,MAX_PAGE,m_asFont,MAX_FONT)) { return; }

diff:
@@ -91,10 +91,8 @@ void setup()
// Initialize
// ------------------------------------------------
Serial.begin(9600);
- // Wait for USB Serial
- while (!Serial) {
- yield();
- }
+ //delay(1000); // NOTE: Some devices require a delay after Serial.begin() before serial port can be used
+
gslc_InitDebug(&DebugOut);
if (!gslc_Init(&m_gui,&m_drv,m_asPage,MAX_PAGE,m_asFont,MAX_FONT)) { return; }

original_message: fix delay() hang


message: add color background for images

diff:
@@ -86,7 +86,6 @@ public class ImageModel extends WidgetModel {
* Instantiates a new image model.
*/
public ImageModel() {
- cf = ColorFactory.getInstance();
generalModel = (GeneralModel) GeneralEditor.getInstance().getModel();
initProperties();
}
@@ -114,9 +113,9 @@ public class ImageModel extends WidgetModel {
initProp(PROP_ELEMENTREF, String.class, "TXT-206", Boolean.FALSE,"ElementRef","");
initProp(PROP_DEFAULT_COLORS, Boolean.class, "COL-300", Boolean.FALSE,"Use Default Colors?",Boolean.TRUE);
- initProp(PROP_FRAME_COLOR, Color.class, "COL-302", Boolean.TRUE,"Frame Color",cf.getDefFrameCol());
- initProp(PROP_FILL_COLOR, Color.class, "COL-303", Boolean.TRUE,"Fill Color",cf.getDefFillCol());
- initProp(PROP_SELECTED_COLOR, Color.class, "COL-304", Boolean.TRUE,"Selected Color",cf.getDefGlowCol());
+ initProp(PROP_FRAME_COLOR, Color.class, "COL-302", Boolean.TRUE,"Frame Color",Color.WHITE);
+ initProp(PROP_FILL_COLOR, Color.class, "COL-303", Boolean.TRUE,"Fill Color",Color.WHITE);
+ initProp(PROP_SELECTED_COLOR, Color.class, "COL-304", Boolean.TRUE,"Selected Color",Color.WHITE);
}
/**
@@ -137,9 +136,9 @@ public class ImageModel extends WidgetModel {
if (row == PROP_DEFAULT_COLORS) {
// check for switching back and forth
if (useDefaultColors()) {
- data[PROP_FRAME_COLOR][PROP_VAL_VALUE]=cf.getDefFrameCol();
- data[PROP_FILL_COLOR][PROP_VAL_VALUE]=cf.getDefFillCol();
- data[PROP_SELECTED_COLOR][PROP_VAL_VALUE]=cf.getDefGlowCol();
+ data[PROP_FRAME_COLOR][PROP_VAL_VALUE]=Color.WHITE;
+ data[PROP_FILL_COLOR][PROP_VAL_VALUE]=Color.WHITE;
+ data[PROP_SELECTED_COLOR][PROP_VAL_VALUE]=Color.WHITE;
data[PROP_FRAME_COLOR][PROP_VAL_READONLY]=Boolean.TRUE;
data[PROP_FILL_COLOR][PROP_VAL_READONLY]=Boolean.TRUE;
data[PROP_SELECTED_COLOR][PROP_VAL_READONLY]=Boolean.TRUE;

diff:
@@ -105,7 +105,6 @@ public class ImgButtonModel extends WidgetModel {
* Instantiates a new img button model.
*/
public ImgButtonModel() {
- cf = ColorFactory.getInstance();
generalModel = (GeneralModel) GeneralEditor.getInstance().getModel();
initProperties();
}
@@ -136,9 +135,9 @@ public class ImgButtonModel extends WidgetModel {
initProp(PROP_ELEMENTREF, String.class, "TXT-206", Boolean.FALSE,"ElementRef","");
initProp(PROP_DEFAULT_COLORS, Boolean.class, "COL-300", Boolean.FALSE,"Use Default Colors?",Boolean.TRUE);
- initProp(PROP_FRAME_COLOR, Color.class, "COL-302", Boolean.TRUE,"Frame Color",cf.getDefFrameCol());
- initProp(PROP_FILL_COLOR, Color.class, "COL-303", Boolean.TRUE,"Fill Color",cf.getDefFillCol());
- initProp(PROP_SELECTED_COLOR, Color.class, "COL-304", Boolean.TRUE,"Selected Color",cf.getDefGlowCol());
+ initProp(PROP_FRAME_COLOR, Color.class, "COL-302", Boolean.TRUE,"Frame Color",Color.WHITE);
+ initProp(PROP_FILL_COLOR, Color.class, "COL-303", Boolean.TRUE,"Fill Color",Color.WHITE);
+ initProp(PROP_SELECTED_COLOR, Color.class, "COL-304", Boolean.TRUE,"Selected Color",Color.WHITE);
}
@@ -262,9 +261,9 @@ public class ImgButtonModel extends WidgetModel {
if (row == PROP_DEFAULT_COLORS) {
// check for switching back and forth
if (useDefaultColors()) {
- data[PROP_FRAME_COLOR][PROP_VAL_VALUE]=cf.getDefFrameCol();
- data[PROP_FILL_COLOR][PROP_VAL_VALUE]=cf.getDefFillCol();
- data[PROP_SELECTED_COLOR][PROP_VAL_VALUE]=cf.getDefGlowCol();
+ data[PROP_FRAME_COLOR][PROP_VAL_VALUE]=Color.WHITE;
+ data[PROP_FILL_COLOR][PROP_VAL_VALUE]=Color.WHITE;
+ data[PROP_SELECTED_COLOR][PROP_VAL_VALUE]=Color.WHITE;
data[PROP_FRAME_COLOR][PROP_VAL_READONLY]=Boolean.TRUE;
data[PROP_FILL_COLOR][PROP_VAL_READONLY]=Boolean.TRUE;
data[PROP_SELECTED_COLOR][PROP_VAL_READONLY]=Boolean.TRUE;

original_message: add color background for images


message: fix for images with null pElemRef

diff:
@@ -1309,22 +1309,52 @@ public class CodeGenerator {
// save page enum for our quick access code generation section
// quick access may be needed for progressbars, sliders, and text that is changed dynamically at runtime.
+ String ref = null;
for (PagePane p : pages) {
for (Widget w : p.getWidgets()) {
if (w.getType().equals(EnumFactory.TEXT)) {
- if (((TextModel)w.getModel()).getTextStorage() > 0) {
+ ref = ((TextModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
refList.add(w.getModel());
w.getModel().setPageEnum(p.getEnum());
}
- } else if (w.getType().equals(EnumFactory.PROGRESSBAR) ||
- w.getType().equals(EnumFactory.TEXTBOX) ||
- w.getType().equals(EnumFactory.GRAPH) ||
- w.getType().equals(EnumFactory.IMAGE) ||
- w.getType().equals(EnumFactory.IMAGEBUTTON) ||
- w.getType().equals(EnumFactory.SLIDER)) {
+ } else if (w.getType().equals(EnumFactory.PROGRESSBAR)) {
+ ref = ((ProgressBarModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
refList.add(w.getModel());
w.getModel().setPageEnum(p.getEnum());
}
+ } else if (w.getType().equals(EnumFactory.TEXTBOX)) {
+ ref = ((GraphModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
+ refList.add(w.getModel());
+ w.getModel().setPageEnum(p.getEnum());
+ }
+ } else if (w.getType().equals(EnumFactory.GRAPH)) {
+ ref = ((TextModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
+ refList.add(w.getModel());
+ w.getModel().setPageEnum(p.getEnum());
+ }
+ } else if (w.getType().equals(EnumFactory.IMAGE)) {
+ ref = ((ImageModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
+ refList.add(w.getModel());
+ w.getModel().setPageEnum(p.getEnum());
+ }
+ } else if (w.getType().equals(EnumFactory.IMAGEBUTTON)) {
+ ref = ((ImgButtonModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
+ refList.add(w.getModel());
+ w.getModel().setPageEnum(p.getEnum());
+ }
+ } else if (w.getType().equals(EnumFactory.SLIDER)) {
+ ref = ((SliderModel)w.getModel()).getElementRef();
+ if (ref != null && !ref.isEmpty()) {
+ refList.add(w.getModel());
+ w.getModel().setPageEnum(p.getEnum());
+ }
+ }
}
}
if (refList.size() > 0) {
@@ -1334,7 +1364,6 @@ public class CodeGenerator {
return one.getKey().compareTo(other.getKey());
}
});
- String ref = "";
for (WidgetModel m : refList) {
if (m.getType().equals(EnumFactory.TEXT)) {
ref = ((TextModel) m).getElementRef();

diff:
@@ -34,7 +34,6 @@ import java.io.ObjectOutputStream;
import javax.imageio.ImageIO;
-import builder.common.ColorFactory;
import builder.common.CommonUtil;
import builder.common.EnumFactory;
import builder.events.MsgBoard;

original_message: fix for images with null pElemRef


message: issue - GH#93: Add scrollbar to design canvas

diff:
@@ -108,6 +108,12 @@ public class Builder extends JDesktopPane {
/** The Constant NEW_PROJECT. */
public static final String NEW_PROJECT = " - unnamed project";
+ /** The canvas width */
+ public static int CANVAS_WIDTH;
+
+ /** The canvas height */
+ public static int CANVAS_HEIGHT;
+
/** The frame. */
private JFrame frame;
@@ -315,7 +321,14 @@ public class Builder extends JDesktopPane {
int height = Math.max(GeneralEditor.getInstance().getHeight()+40, 700);
frame.setPreferredSize(new Dimension(width, height));
frame.pack();
- CommonUtil.getInstance().setWinOffsets(controller.getPanel().getSize(),
+
+ // setup our canvas offsets
+ // NOTE: we can't use controller.getPanel().getSize()
+ // since its a scrollpane thats much larger than actual screen size
+ CANVAS_WIDTH = GeneralEditor.getInstance().getWidth()+205;
+ CANVAS_HEIGHT = GeneralEditor.getInstance().getHeight()+235;
+ Dimension canvasSz = new Dimension(CANVAS_WIDTH, CANVAS_HEIGHT);
+ CommonUtil.getInstance().setWinOffsets(canvasSz,
GeneralEditor.getInstance().getWidth(),
GeneralEditor.getInstance().getHeight());
frame.setLocationRelativeTo(null);

diff:
@@ -58,6 +58,7 @@ import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
@@ -192,7 +193,9 @@ public class Controller extends JInternalFrame
MsgBoard.getInstance().subscribe(this);
layout = new CardLayout();
cards = new JPanel(layout);
- this.add(cards);
+ JScrollPane scrollPane = new JScrollPane(cards);
+
+ this.add(scrollPane);
this.setTitle(title);
createFirstPage();
this.setVisible(true);
@@ -853,28 +856,9 @@ public class Controller extends JInternalFrame
*/
@Override
public Dimension getPreferredSize() {
- return new Dimension(generalEditor.getWidth(), generalEditor.getHeight());
+ return new Dimension(1200,1200);
}
- /**
- * getMaximumSize
- *
- * @see javax.swing.JComponent#getMaximumSize()
- */
- @Override
- public Dimension getMaximumSize() {
- return new Dimension(generalEditor.getWidth(), generalEditor.getHeight());
- }
-
- /**
- * getMinimumSize
- *
- * @see javax.swing.JComponent#getMinimumSize()
- */
- @Override
- public Dimension getMinimumSize() {
- return new Dimension(generalEditor.getWidth(), generalEditor.getHeight());
- }
/**
* updateEvent
@@ -1322,15 +1306,26 @@ public class Controller extends JInternalFrame
generalEditor.getHeight() != displayHeight) {
displayWidth = generalEditor.getWidth();
displayHeight = generalEditor.getHeight();
- getPanel().setPreferredSize(new Dimension(displayWidth, displayHeight));
+// getPanel().setPreferredSize(new Dimension(displayWidth, displayHeight));
int width = Math.max(displayWidth + 600, 700);
int height = Math.max(displayHeight + 40, 700);
Dimension d = new Dimension(width, height);
topFrame.setPreferredSize(d);
topFrame.setMaximumSize(d);
topFrame.setMinimumSize(d);
+ Builder.CANVAS_WIDTH = GeneralEditor.getInstance().getWidth()+205;
+ Builder.CANVAS_HEIGHT = GeneralEditor.getInstance().getHeight()+235;
+ Dimension canvasSz = new Dimension(Builder.CANVAS_WIDTH, Builder.CANVAS_HEIGHT);
+ CommonUtil.getInstance().setWinOffsets(canvasSz,
+ GeneralEditor.getInstance().getWidth(),
+ GeneralEditor.getInstance().getHeight());
+
topFrame.revalidate();
- CommonUtil.getInstance().setWinOffsets(getPanel().getSize(), displayWidth, displayHeight);
+ MsgEvent ev = new MsgEvent();
+ ev.message ="";
+ ev.parent = "";
+ ev.code = MsgEvent.CANVAS_MODEL_CHANGE;
+ MsgBoard.getInstance().publish(ev);
topFrame.repaint();
}
refreshView(); // refresh view no matter what changed.

diff:
@@ -51,6 +51,7 @@ import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
+import builder.Builder;
import builder.commands.Command;
import builder.commands.DragWidgetCommand;
import builder.commands.History;
@@ -153,6 +154,12 @@ public class PagePane extends JPanel implements iSubscriber {
/** The inverse AffineTransform at. */
private AffineTransform inv_at;
+ /** The canvas width */
+ int canvasWidth;
+
+ /** The canvas height */
+ int canvasHeight;
+
/**
* Instantiates a new page pane.
*/
@@ -165,6 +172,8 @@ public class PagePane extends JPanel implements iSubscriber {
gridModel = (GridModel) GridEditor.getInstance().getModel();
model = new PageModel();
mousePt = new Point(generalModel.getWidth() / 2, generalModel.getHeight() / 2);
+ canvasWidth = Builder.CANVAS_WIDTH;
+ canvasHeight = Builder.CANVAS_HEIGHT;
this.addMouseListener(new MouseHandler());
this.addMouseMotionListener(new MouseMotionHandler());
this.addKeyListener(new DeleteKeyListener());
@@ -208,13 +217,14 @@ public class PagePane extends JPanel implements iSubscriber {
Graphics2D g2d = (Graphics2D) g.create();
if (bZoom) {
at = new AffineTransform();
- Dimension d = this.getSize();
+ Dimension d = new Dimension(canvasWidth, canvasHeight);
double xRel = ((double)d.getWidth() - (double)gridModel.getWidth()) / 2.0;
double yRel = ((double)d.getHeight() - (double)gridModel.getHeight()) / 2.0;;
double zoomDiv = zoomFactor / prevZoomFactor;
xOffset = (zoomDiv) * (xOffset) + (1 - zoomDiv) * xRel;
+
yOffset = (zoomDiv) * (yOffset) + (1 - zoomDiv) * yRel;
at.translate(xOffset, yOffset);
at.scale(zoomFactor, zoomFactor);
@@ -260,6 +270,13 @@ public class PagePane extends JPanel implements iSubscriber {
zoomFactor *= 1.1;
bZoom = true;
ToolBar.getInstance().btn_zoom_out.setEnabled(true);
+ canvasWidth = (int)(Builder.CANVAS_WIDTH * zoomFactor);
+ canvasHeight = (int)(Builder.CANVAS_HEIGHT * zoomFactor);
+ System.out.println("in: " + zoomFactor + " zw: " + canvasWidth + " zh: " + canvasHeight);
+ Dimension canvasSz = new Dimension((int)canvasWidth, (int)canvasHeight);
+ CommonUtil.getInstance().setWinOffsets(canvasSz,
+ GeneralEditor.getInstance().getWidth(),
+ GeneralEditor.getInstance().getHeight());
repaint();
}
@@ -271,6 +288,13 @@ public class PagePane extends JPanel implements iSubscriber {
if (zoomFactor < 1.1)
ToolBar.getInstance().btn_zoom_out.setEnabled(false);
bZoom = true;
+ canvasWidth = (int)(Builder.CANVAS_WIDTH * zoomFactor);
+ canvasHeight = (int)(Builder.CANVAS_HEIGHT * zoomFactor);
+ System.out.println("out: " + zoomFactor + " zw: " + canvasWidth + " zh: " + canvasHeight);
+ Dimension canvasSz = new Dimension((int)canvasWidth, (int)canvasHeight);
+ CommonUtil.getInstance().setWinOffsets(canvasSz,
+ GeneralEditor.getInstance().getWidth(),
+ GeneralEditor.getInstance().getHeight());
repaint();
}
@@ -777,29 +801,8 @@ public class PagePane extends JPanel implements iSubscriber {
*/
@Override
public Dimension getPreferredSize() {
- return new Dimension(gridModel.getWidth(), gridModel.getHeight());
- }
-
- /**
- * getMaximumSize.
- *
- * @return the maximum size
- * @see javax.swing.JComponent#getMaximumSize()
- */
- @Override
- public Dimension getMaximumSize() {
- return new Dimension(gridModel.getWidth(), gridModel.getHeight());
- }
-
- /**
- * getMinimumSize.
- *
- * @return the minimum size
- * @see javax.swing.JComponent#getMinimumSize()
- */
- @Override
- public Dimension getMinimumSize() {
- return new Dimension(gridModel.getWidth(), gridModel.getHeight());
+// return new Dimension(gridModel.getWidth(), gridModel.getHeight());
+ return new Dimension(1200, 1200);
}
/**
@@ -849,7 +852,9 @@ public class PagePane extends JPanel implements iSubscriber {
selectNone();
repaint();
} else if (e.code == MsgEvent.CANVAS_MODEL_CHANGE) {
- CommonUtil.getInstance().setWinOffsets(this.getSize(),
+ canvasWidth = (int)(Builder.CANVAS_WIDTH * zoomFactor);
+ canvasHeight = (int)(Builder.CANVAS_HEIGHT * zoomFactor);
+ CommonUtil.getInstance().setWinOffsets(new Dimension(canvasWidth, canvasHeight),
generalModel.getWidth(),
generalModel.getHeight());
repaint();

original_message: issue #39 - GH#93: Add scrollbar to design canvas


message: On 64-bit systems use program files not (x86)

diff:
@@ -148,8 +148,8 @@ task packageWinDistrib(type: Zip) {
dependsOn buildWinInstall
group = "build"
description = "windows package distribution"
- from "${buildDir}/innosetup/builder-" + "win64-" + version + ".exe"
- archiveName = "builder-" + "win64-" + version + ".zip"
+ from "${buildDir}/innosetup/builder-" + "win-" + version + ".exe"
+ archiveName = "builder-" + "win-" + version + ".zip"
destinationDir = file("${buildDir}/disp")
}
@@ -166,7 +166,7 @@ task packageLinuxDistrib(type: Tar) {
include ("**/*.sh")
fileMode 0755
}
- baseName = "builder-" + "linux64"
+ baseName = "builder-" + "linux"
destinationDir = file("${buildDir}/disp")
extension = "tar.gz"
compression = Compression.GZIP

diff:
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+ArchitecturesInstallIn64BitMode=x64 ia64
AppId={{D2C2D2DF-35CC-4921-9F51-2F31B8C0E3C5}
AppName=GUIsliceBuilder
AppVersion=${applicationVersion}
@@ -33,7 +34,7 @@ DisableWelcomePage=no
DisableProgramGroupPage=yes
LicenseFile=..\\..\\docs\\LICENSE.txt
OutputDir=.
-OutputBaseFilename=builder-win64-${applicationVersion}
+OutputBaseFilename=builder-win-${applicationVersion}
SetupIconFile=..\\tmp\\windows\\GUIsliceBuilder\\guislicebuilder.ico
Compression=lzma
SolidCompression=yes


message: support 32-bit windows install

diff:
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
-ArchitecturesInstallIn64BitMode=x64 ia64
+; Right now we are not setting 64 bit mode
+;ArchitecturesInstallIn64BitMode=x64 ia64
AppId={{D2C2D2DF-35CC-4921-9F51-2F31B8C0E3C5}
AppName=GUIsliceBuilder
AppVersion=${applicationVersion}

original_message: support 32-bit windows install


message: fix for shell scripts

old_path: .gitattributes

new_path: .gitattributes

diff:
# Auto detect text files and perform LF normalization
* text=auto
+# Explicitly declare text files you want to always be normalized and converted
+# to native line endings on checkout.
+*.sh text eol=lf
+
# Custom for Visual Studio
*.cs diff=csharp

original_message: fix for shell scripts


message: issue 59 - TextBox columns and rows not correctly calculated, col always 0

diff:
@@ -280,9 +280,7 @@ public class TextBoxModel extends WidgetModel {
int nCols = (getWidth() - 33) / nChSz.width;
// rows must be greater than actual or the scroll bar will be disabled
int nRows = ((getHeight() - 18) / nChSz.height) + 1;
- if (nCols > getNumTextColumns())
data[PROP_ROWS][PROP_VAL_VALUE]= Integer.valueOf(nRows);
- if (nRows > getNumTextRows())
data[PROP_COLS][PROP_VAL_VALUE]=Integer.valueOf(nCols);
}


message: issue 60 - TextBox crashes during code gen

diff:
@@ -15,7 +15,7 @@ apply plugin: 'org.junit.platform.gradle.plugin'
mainClassName = "builder.Builder"
applicationName = "GUIslice"
archivesBaseName = 'builder'
-version = '0.11.0-rc1'
+version = '0.11.0-rc2'
repositories {
mavenCentral()

diff:
@@ -1409,7 +1409,7 @@ public class CodeGenerator {
w.getModel().setPageEnum(p.getEnum());
}
} else if (w.getType().equals(EnumFactory.TEXTBOX)) {
- ref = ((GraphModel)w.getModel()).getElementRef();
+ ref = ((TextBoxModel)w.getModel()).getElementRef();
if (ref != null && !ref.isEmpty()) {
refList.add(w.getModel());
w.getModel().setPageEnum(p.getEnum());

diff:
@@ -1053,7 +1053,7 @@ public class Controller extends JInternalFrame
// System.out.println("command: " + command);
switch(command) {
case "about":
- JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc1", "About", JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc2", "About", JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(null, "GUIsliceBuider ver SNAPSHOT", "About", JOptionPane.INFORMATION_MESSAGE);
break;


message: issue 61 - TextBox Code gen incorrectly outputs &m_sXGauge[0] instead of &m_sXSlider[0]

diff:
@@ -222,7 +222,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
// Create vertical scrollbar for textbox
- pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXGauge[$<COUNT>],
+ pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXSlider[$<COUNT>],
(gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,100,0,5,true);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);

diff:
@@ -230,7 +230,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
// Create vertical scrollbar for textbox
- pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXGauge[$<COUNT>],
+ pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXSlider[$<COUNT>],
(gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,100,0,5,true);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);


message: issue 63-Text Height and Width incorrectly calculated

diff:
@@ -27,6 +27,7 @@ package builder.models;
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Font;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -35,6 +36,7 @@ import javax.swing.JTextField;
import builder.common.ColorFactory;
import builder.common.EnumFactory;
import builder.common.FontFactory;
+import builder.common.FontItem;
import builder.events.MsgBoard;
import builder.events.MsgEvent;
import builder.prefs.GeneralEditor;
@@ -276,10 +278,33 @@ public class TextBoxModel extends WidgetModel {
* Calc sizes.
*/
private void calcSizes() {
- Dimension nChSz = ff.measureChar(getFontDisplayName());
- int nCols = (getWidth() - 33) / nChSz.width;
- // rows must be greater than actual or the scroll bar will be disabled
- int nRows = ((getHeight() - 18) / nChSz.height) + 1;
+ int nCols;
+ int nRows;
+ String name = getFontDisplayName();
+ FontItem item = ff.getFontItem(name);
+ if (!item.getDisplayName().equals(name)) {
+ data[PROP_FONT][PROP_VAL_VALUE] = item.getDisplayName();
+ data[PROP_FONT_ENUM][PROP_VAL_VALUE] = item.getFontId();
+ }
+ Font font = ff.getFont(item.getDisplayName());
+ // calculate the real sizes of our display font
+ String strText = "AaBbCcDd%$";
+ // now figure out the rect size needed on the target platform
+ // that we show to our user and also push out during code generation.
+ if (getFontDisplayName().startsWith("BuiltIn")) {
+ Dimension nChSz = ff.measureAdafruitText(strText,getFontDisplayName());
+ nCols = (getWidth() - 33) / (nChSz.width / 10);
+ nRows = ((getHeight() - 10) / nChSz.height) + 1;
+ System.out.println("getWidth(): " + getWidth() + " nChSz.width: " + nChSz.width);
+ System.out.println("getHeight(): " + getHeight() + " nChSz.height: " + nChSz.height);
+ } else {
+ // if font is not one of the built-in fonts than actual size is correct even though font is scaled.
+ Dimension d = ff.measureText(strText, font);
+ nCols = (getWidth() - 33) / (d.width / 10);
+ nRows = (getHeight() / d.height) + 10;
+ System.out.println("getWidth(): " + getWidth() + " d.width: " + d.width);
+ System.out.println("getHeight(): " + getHeight() + " d.height: " + d.height);
+ }
data[PROP_ROWS][PROP_VAL_VALUE]= Integer.valueOf(nRows);
data[PROP_COLS][PROP_VAL_VALUE]=Integer.valueOf(nCols);
}

diff:
@@ -518,12 +518,12 @@ public class TextModel extends WidgetModel {
// that we show to our user and also push out during code generation.
if (getFontDisplayName().startsWith("BuiltIn")) {
Dimension nChSz = ff.measureAdafruitText(getText(),getFontDisplayName());
- if (nChSz.width > getWidth()) setWidth(nChSz.width);
- if (nChSz.height > getHeight()) setHeight(nChSz.height);
+ if (nChSz.width > getTargetWidth()) setWidth(nChSz.width);
+ if (nChSz.height > getTargetHeight()) setHeight(nChSz.height);
} else {
// if font is not one of the built-in fonts than actual size is correct even though font is scaled.
- if (d.width > getWidth()) setWidth(d.width);
- if (d.height > getHeight()) setHeight(d.height);
+ if (d.width > getTargetWidth()) setWidth(d.width);
+ if (d.height > getTargetHeight()) setHeight(d.height);
}
if (fireUpdates) {
fireTableCellUpdated(PROP_WIDTH, COLUMN_VALUE);

diff:
@@ -217,7 +217,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create textbox
pElemRef = gslc_ElemXTextboxCreate(&m_gui,$<WIDGET_ENUM>,$<PAGE_ENUM>,&m_sTextbox$<ID>,
- (gslc_tsRect){$<X>+2,$<Y>+4,$<WIDTH>-23,$<HEIGHT>-8},$<FONT_ID>,(char*)&m_acTextboxBuf$<ID>,$<ROWS>,$<COLS>);
+ (gslc_tsRect){$<X>+2,$<Y>+4,$<WIDTH>-23,$<HEIGHT>-5},$<FONT_ID>,(char*)&m_acTextboxBuf$<ID>,$<ROWS>,$<COLS>);
gslc_ElemXTextboxWrapSet(&m_gui,pElemRef,$<CHECKED>);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);

diff:
@@ -226,7 +226,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create textbox $<WIDGET_ENUM>
// - NOTE: XTextbox does not have a FLASH-based version yet (ElemXTextboxCreate_P)
pElemRef = gslc_ElemXTextboxCreate(&m_gui,$<WIDGET_ENUM>,$<PAGE_ENUM>,&m_sTextbox$<ID>,
- (gslc_tsRect){$<X>+2,$<Y>+4,$<WIDTH>-23,$<HEIGHT>-8},$<FONT_ID>,(char*)&m_acTextboxBuf$<ID>,$<ROWS>,$<COLS>);
+ (gslc_tsRect){$<X>+2,$<Y>+4,$<WIDTH>-23,$<HEIGHT>-5},$<FONT_ID>,(char*)&m_acTextboxBuf$<ID>,$<ROWS>,$<COLS>);
gslc_ElemXTextboxWrapSet(&m_gui,pElemRef,$<CHECKED>);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<FILL_COLOR>);

diff:
@@ -225,7 +225,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create textbox
pElemRef = gslc_ElemXTextboxCreate(&m_gui,$<WIDGET_ENUM>,$<PAGE_ENUM>,&m_sTextbox$<ID>,
- (gslc_tsRect){$<X>+2,$<Y>+4,$<WIDTH>-23,$<HEIGHT>-8},$<FONT_ID>,(char*)&m_acTextboxBuf$<ID>,$<ROWS>,$<COLS>);
+ (gslc_tsRect){$<X>+2,$<Y>+4,$<WIDTH>-23,$<HEIGHT>-5},$<FONT_ID>,(char*)&m_acTextboxBuf$<ID>,$<ROWS>,$<COLS>);
gslc_ElemXTextboxWrapSet(&m_gui,pElemRef,$<CHECKED>);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);


message: b#67 install.sh for linux is broken

diff:
@@ -15,12 +15,6 @@ SCRIPT_PATH=$( cd $(dirname $0) ; pwd )
cd "${SCRIPT_PATH}"
export PATH=.:$PATH
-platform='linux'
-unamestr=`uname`
-if [[ "$unamestr" == 'Darwin' ]]; then
- platform='darwin'
-fi
-
# Default mode is to install.
UNINSTALL=false
@@ -37,14 +31,12 @@ install_files() {
printf "If you have more then one Java version installed\n"
printf "you need to identify what directory has Java 8.\n"
printf "You can exit this script with ^c and use this command to find it.\n\n"
- if [[ $platform == 'linux' ]]; then
+
printf "sudo update-alternatives --config java \n\n"
printf "If Arduino IDE is installed you can use the Arduino built in Java\n"
- printf "Example:\n"
+ printf "Examples:\n"
+ printf "/usr/lib/jvm/java-8-openjdk-amd64/jre\n"
printf "$HOME/arduino-1.8.7/java\n\n"
- else
- printf "/usr/libexec/java_home -v 1.8 \n\n"
- fi
# Ask user where we can find Java - loop until a valid answer is given
JAVA_PATH=""
@@ -70,7 +62,6 @@ install_files() {
chmod +x "${SCRIPT_PATH}/GUIslice.sh"
- if [[ $platform == 'linux' ]]; then
# Create a temp folder for the install
mkdir tmp
@@ -88,14 +79,12 @@ install_files() {
# Clean up temp dir
rm "${SCRIPT_PATH}/tmp/guislice.desktop"
rmdir "${SCRIPT_PATH}/tmp"
- fi
printf "Install Completed!\n"
}
# Uninstall by simply removing desktop files
uninstall_files() {
- if [[ $platform == 'linux' ]]; then
printf "Removing desktop shortcut for GUIsliceBuilder\n"
if [ -f "${SCRIPT_PATH}/GUIslice.sh" ]; then
rm "${SCRIPT_PATH}/GUIslice.sh"
@@ -105,9 +94,6 @@ uninstall_files() {
rm "${HOME}/Desktop/guislice.desktop"
fi
printf "Uninstall Completed!\n"
- else
- printf "Can't Uninstall on OS/X you need to move app to trash!\n"
- fi
}
# Check for provided arguments
@@ -130,6 +116,7 @@ done
if [ ${UNINSTALL} = true ]; then
uninstall_files
else
+ uninstall_files
install_files
fi

original_message: b#67 install.sh for linux is broken


message: b#66 - XTextBox bad values sent to the gslc_ElemXSliderCreate()

diff:
@@ -223,7 +223,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create vertical scrollbar for textbox
pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXSlider[$<COUNT>],
- (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,100,0,5,true);
+ (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,$<ROWS>,0,5,true);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
<STOP>

diff:
@@ -232,7 +232,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create vertical scrollbar for textbox
gslc_ElemXSliderCreate_P(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8,
- 0,100,0,5,true,$<FRAME_COLOR>,$<FILL_COLOR>);
+ 0,$<ROWS>,0,5,true,$<FRAME_COLOR>,$<FILL_COLOR>);
pElemRef = gslc_PageFindElemById(&m_gui,E_PG_MAIN,E_SCROLLBAR$<ID>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
<STOP>

diff:
@@ -231,7 +231,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create vertical scrollbar for textbox
pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXSlider[$<COUNT>],
- (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,100,0,5,true);
+ (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,$<ROWS>,0,5,true);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
<STOP>


message: b#63 - TextBox Rows and Columns incorrect

diff:
@@ -78,6 +78,12 @@ public class FontFactory {
/** The linux CVS. */
private static String linuxCVS;
+ /** Free Mono Font Sizes */
+ private static Dimension[] MonoPlainSizes = new Dimension[4];
+ private static Dimension[] MonoBoldSizes = new Dimension[4];
+ private static Dimension[] MonoItalicSizes = new Dimension[4];
+ private static Dimension[] MonoBoldItalicSizes = new Dimension[4];
+
/**
* Gets the single instance of FontFactory.
*
@@ -97,6 +103,23 @@ public class FontFactory {
linuxMap = new HashMap<String, Integer>(128);
instance.readFonts(linuxCVS,linuxFonts,linuxMap);
+ // setup mono font tables
+ MonoPlainSizes[0] = new Dimension(9,14);
+ MonoPlainSizes[1] = new Dimension(13,19);
+ MonoPlainSizes[2] = new Dimension(19,30);
+ MonoPlainSizes[3] = new Dimension(26,39);
+ MonoBoldSizes[0] = new Dimension(11,16);
+ MonoBoldSizes[1] = new Dimension(14,22);
+ MonoBoldSizes[2] = new Dimension(21,31);
+ MonoBoldSizes[3] = new Dimension(28,41);
+ MonoItalicSizes[0] = new Dimension(10,14);
+ MonoItalicSizes[1] = new Dimension(13,20);
+ MonoItalicSizes[2] = new Dimension(17,30);
+ MonoItalicSizes[3] = new Dimension(25,39);
+ MonoBoldItalicSizes[0] = new Dimension(11,16);
+ MonoBoldItalicSizes[1] = new Dimension(14,22);
+ MonoBoldItalicSizes[2] = new Dimension(21,31);
+ MonoBoldItalicSizes[3] = new Dimension(28,41);
}
return instance;
}
@@ -315,17 +338,55 @@ public class FontFactory {
*/
public Dimension measureChar(String fontName) {
FontItem item = getFontItem(fontName);
- if (fontName.startsWith("BuiltIn")) {
Dimension nChSz = new Dimension();
+ if (fontName.startsWith("BuiltIn")) {
int size = Integer.parseInt(item.getFontSz());
nChSz.width = (6 * size);
nChSz.height = 8 * size;
- return nChSz;
} else {
- String acMono = "%";
- Font tmpFont = createFont("Monospaced", item.getScaledSize(), "PLAIN");
- return (measureText(acMono, tmpFont));
+ int idx = -1;
+ switch (item.getLogicalSize()) {
+ case "9":
+ idx = 0;
+ break;
+ case "12":
+ idx = 1;
+ break;
+ case "18":
+ idx = 2;
+ break;
+ case "24":
+ idx = 3;
+ break;
+ default:
+ break;
}
+ if (idx >= 0) {
+ switch (item.getLogicalStyle()) {
+ case "BOLD":
+ nChSz = MonoBoldSizes[idx];
+ break;
+ case "ITALIC":
+ nChSz = MonoItalicSizes[idx];
+ break;
+ case "BOLD+ITALIC":
+ nChSz = MonoBoldItalicSizes[idx];
+ break;
+ default:
+ nChSz = MonoPlainSizes[idx];
+ break;
+ }
+ } else {
+ String acHeight = "a";
+ String acWidth = "W";
+ Font tmpFont = createFont("Monospaced", item.getLogicalSize(), item.getLogicalStyle());
+ Dimension txtHeight = measureText(acHeight, tmpFont);
+ Dimension txtWidth = measureText(acWidth, tmpFont);
+ nChSz.width = txtWidth.width-4;
+ nChSz.height = txtHeight.height;
+ }
+ }
+ return nChSz;
}
/**

diff:
@@ -27,7 +27,6 @@ package builder.models;
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.Font;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -286,25 +285,9 @@ public class TextBoxModel extends WidgetModel {
data[PROP_FONT][PROP_VAL_VALUE] = item.getDisplayName();
data[PROP_FONT_ENUM][PROP_VAL_VALUE] = item.getFontId();
}
- Font font = ff.getFont(item.getDisplayName());
- // calculate the real sizes of our display font
- String strText = "AaBbCcDd%$";
- // now figure out the rect size needed on the target platform
- // that we show to our user and also push out during code generation.
- if (getFontDisplayName().startsWith("BuiltIn")) {
- Dimension nChSz = ff.measureAdafruitText(strText,getFontDisplayName());
- nCols = (getWidth() - 33) / (nChSz.width / 10);
- nRows = ((getHeight() - 10) / nChSz.height) + 1;
- System.out.println("getWidth(): " + getWidth() + " nChSz.width: " + nChSz.width);
- System.out.println("getHeight(): " + getHeight() + " nChSz.height: " + nChSz.height);
- } else {
- // if font is not one of the built-in fonts than actual size is correct even though font is scaled.
- Dimension d = ff.measureText(strText, font);
- nCols = (getWidth() - 33) / (d.width / 10);
- nRows = (getHeight() / d.height) + 10;
- System.out.println("getWidth(): " + getWidth() + " d.width: " + d.width);
- System.out.println("getHeight(): " + getHeight() + " d.height: " + d.height);
- }
+ Dimension nChSz = ff.measureChar(getFontDisplayName());
+ nCols = (getWidth() - 33) / nChSz.width;
+ nRows = (getHeight() - 15) / nChSz.height;
data[PROP_ROWS][PROP_VAL_VALUE]= Integer.valueOf(nRows);
data[PROP_COLS][PROP_VAL_VALUE]=Integer.valueOf(nCols);
}


message: update version # to rc3

diff:
@@ -15,7 +15,7 @@ apply plugin: 'org.junit.platform.gradle.plugin'
mainClassName = "builder.Builder"
applicationName = "GUIslice"
archivesBaseName = 'builder'
-version = '0.11.0-rc2'
+version = '0.11.0-rc3'
repositories {
mavenCentral()

diff:
@@ -1053,7 +1053,7 @@ public class Controller extends JInternalFrame
// System.out.println("command: " + command);
switch(command) {
case "about":
- JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc2", "About", JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc3", "About", JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(null, "GUIsliceBuider ver SNAPSHOT", "About", JOptionPane.INFORMATION_MESSAGE);
break;

original_message: update version # to rc3


message: 66 - XTextBox bad values sent to the gslc_ElemXSliderCreate()

diff:
@@ -15,7 +15,7 @@ apply plugin: 'org.junit.platform.gradle.plugin'
mainClassName = "builder.Builder"
applicationName = "GUIslice"
archivesBaseName = 'builder'
-version = '0.11.0-rc3'
+version = '0.11.0-rc4'
repositories {
mavenCentral()

diff:
@@ -104,18 +104,18 @@ public class FontFactory {
instance.readFonts(linuxCVS,linuxFonts,linuxMap);
// setup mono font tables
- MonoPlainSizes[0] = new Dimension(9,14);
- MonoPlainSizes[1] = new Dimension(13,19);
- MonoPlainSizes[2] = new Dimension(19,30);
- MonoPlainSizes[3] = new Dimension(26,39);
+ MonoPlainSizes[0] = new Dimension(11,14);
+ MonoPlainSizes[1] = new Dimension(14,19);
+ MonoPlainSizes[2] = new Dimension(21,30);
+ MonoPlainSizes[3] = new Dimension(28,39);
MonoBoldSizes[0] = new Dimension(11,16);
MonoBoldSizes[1] = new Dimension(14,22);
MonoBoldSizes[2] = new Dimension(21,31);
MonoBoldSizes[3] = new Dimension(28,41);
- MonoItalicSizes[0] = new Dimension(10,14);
- MonoItalicSizes[1] = new Dimension(13,20);
- MonoItalicSizes[2] = new Dimension(17,30);
- MonoItalicSizes[3] = new Dimension(25,39);
+ MonoItalicSizes[0] = new Dimension(11,14);
+ MonoItalicSizes[1] = new Dimension(14,20);
+ MonoItalicSizes[2] = new Dimension(21,30);
+ MonoItalicSizes[3] = new Dimension(28,39);
MonoBoldItalicSizes[0] = new Dimension(11,16);
MonoBoldItalicSizes[1] = new Dimension(14,22);
MonoBoldItalicSizes[2] = new Dimension(21,31);
@@ -377,9 +377,9 @@ public class FontFactory {
break;
}
} else {
- String acHeight = "a";
+ String acHeight = "p$";
String acWidth = "W";
- Font tmpFont = createFont("Monospaced", item.getLogicalSize(), item.getLogicalStyle());
+ Font tmpFont = createFont(item.getLogicalName(), item.getLogicalSize(), item.getLogicalStyle());
Dimension txtHeight = measureText(acHeight, tmpFont);
Dimension txtWidth = measureText(acWidth, tmpFont);
nChSz.width = txtWidth.width-4;

diff:
@@ -223,7 +223,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create vertical scrollbar for textbox
pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXSlider[$<COUNT>],
- (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,$<ROWS>,0,5,true);
+ (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,100,0,5,true);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
<STOP>

diff:
@@ -232,7 +232,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create vertical scrollbar for textbox
gslc_ElemXSliderCreate_P(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8,
- 0,$<ROWS>,0,5,true,$<FRAME_COLOR>,$<FILL_COLOR>);
+ 0,100,0,5,true,$<FRAME_COLOR>,$<FILL_COLOR>);
pElemRef = gslc_PageFindElemById(&m_gui,E_PG_MAIN,E_SCROLLBAR$<ID>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
<STOP>

diff:
@@ -231,7 +231,7 @@ bool CbSlidePos(void* pvGui,void* pvElemRef,int16_t nPos)
// Create vertical scrollbar for textbox
pElemRef = gslc_ElemXSliderCreate(&m_gui,E_SCROLLBAR$<ID>,$<PAGE_ENUM>,&m_sXSlider[$<COUNT>],
- (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,$<ROWS>,0,5,true);
+ (gslc_tsRect){$<X>+$<WIDTH>-21,$<Y>+4,20,$<HEIGHT>-8},0,100,0,5,true);
gslc_ElemSetCol(&m_gui,pElemRef,$<FRAME_COLOR>,$<FILL_COLOR>,$<GLOW_COLOR>);
gslc_ElemXSliderSetPosFunc(&m_gui,pElemRef,&CbSlidePos);
<STOP>


message: b#68 - Regenerating code increments m_sX* array indices in ElemX*Create()

diff:
@@ -689,6 +689,9 @@ public class CodeGenerator {
@SuppressWarnings("unchecked")
public String generateCode(String folder, String fileName, List<PagePane> pages) {
this.pages = pages;
+ countCheckBoxes = 0;
+ countGauges = 0;
+ countSliders = 0;
GeneralModel generalModel = (GeneralModel) GeneralEditor.getInstance().getModel();
screenWidth = generalModel.getWidth();
screenHeight = generalModel.getHeight();
@@ -777,6 +780,9 @@ public class CodeGenerator {
throws TestException, IOException {
target = testPlatform;
this.pages = pages;
+ countCheckBoxes = 0;
+ countGauges = 0;
+ countSliders = 0;
background = Color.GRAY;
maxstr_len = 100;
listOfTemplates = new ArrayList[32];

diff:
@@ -1053,7 +1053,7 @@ public class Controller extends JInternalFrame
// System.out.println("command: " + command);
switch(command) {
case "about":
- JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc3", "About", JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(null, "GUIsliceBuider ver 0.11.0-rc4", "About", JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(null, "GUIsliceBuider ver SNAPSHOT", "About", JOptionPane.INFORMATION_MESSAGE);
break;


message: Aded BLIT support for load BMP from RAM

diff:
@@ -1593,6 +1593,12 @@ void gslc_DrvDrawBmp24FromMem(gslc_tsGui* pGui,int16_t nDstX, int16_t nDstY,cons
#if defined(DBG_DRIVER)
GSLC_DEBUG_PRINT("DBG: DrvDrawBmp24FromMem() w=%d h=%d\n", w, h);
#endif
+ #if defined(DRV_HAS_DRAW_BMP_MEM)
+ if (!bProgMem) {
+ m_disp.drawRGBBitmap(nDstX, nDstY, (uint16_t*) pImage,w, h);
+ return;
+ }
+ #endif
int row, col;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...

diff:
@@ -99,6 +99,7 @@ extern "C" {
#define DRV_HAS_DRAW_POINT 1 ///< Support gslc_DrvDrawPoint()
#define DRV_HAS_DRAW_POINTS 0 ///< Support gslc_DrvDrawPoints()
+#define DRV_HAS_DRAW_BMP_MEM 1 ///< Support gslc_DrvDrawBmp24FromMem()
#define DRV_HAS_DRAW_LINE 1 ///< Support gslc_DrvDrawLine()
#define DRV_HAS_DRAW_RECT_FRAME 1 ///< Support gslc_DrvDrawFrameRect()
#define DRV_HAS_DRAW_RECT_FILL 1 ///< Support gslc_DrvDrawFillRect()

original_message: Aded BLIT support for load BMP from RAM


message: issue XSpinner support for optional up/down characters

diff:
@@ -120,6 +120,7 @@ gslc_tsElemRef* gslc_ElemXSpinnerCreate(gslc_tsGui* pGui, int16_t nElemId, int16
pXData->nIncr = nIncr;
pXData->pfuncXInput = cbInput;
+
// Initialize the collection of sub-elements within the compound element
// - XSELNUM_COMP_CNT defines the maximum number of sub-elements we have allocated space for
// - Note that this example shows RAM being used for storage
@@ -161,20 +162,22 @@ gslc_tsElemRef* gslc_ElemXSpinnerCreate(gslc_tsGui* pGui, int16_t nElemId, int16
gslc_tsRect rSubElem;
// Create button sub-element
+ strcpy(pXData->acIncr,"\030");
rSubElem = (gslc_tsRect) { nOffsetX+nTxtBoxW, nBtnPosY, nButtonSz, nButtonSz };
rSubElem = gslc_ExpandRect(rSubElem, -1, -1);
pElemRefTmp = gslc_ElemCreateBtnTxt(pGui, SPINNER_ID_BTN_INC, GSLC_PAGE_NONE,
- rSubElem, "\030", 0, nFontId, &gslc_ElemXSpinnerClick);
+ rSubElem, pXData->acIncr, 2, nFontId, &gslc_ElemXSpinnerClick);
gslc_ElemSetCol(pGui, pElemRefTmp, (gslc_tsColor) { 0, 0, 192 }, (gslc_tsColor) { 0, 0, 128 }, (gslc_tsColor) { 0, 0, 224 });
gslc_ElemSetTxtCol(pGui, pElemRefTmp, GSLC_COL_WHITE);
pElemTmp = gslc_GetElemFromRef(pGui, pElemRefTmp);
gslc_CollectElemAdd(pGui, &pXData->sCollect, pElemTmp, GSLC_ELEMREF_DEFAULT);
// Create button sub-element
+ strcpy(pXData->acDecr,"\031");
rSubElem = (gslc_tsRect) { nOffsetX+nTxtBoxW+nButtonSz, nBtnPosY, nButtonSz, nButtonSz };
rSubElem = gslc_ExpandRect(rSubElem, -1, -1);
pElemRefTmp = gslc_ElemCreateBtnTxt(pGui, SPINNER_ID_BTN_DEC, GSLC_PAGE_NONE,
- rSubElem, "\031", 0, nFontId, &gslc_ElemXSpinnerClick);
+ rSubElem, pXData->acDecr, 2, nFontId, &gslc_ElemXSpinnerClick);
gslc_ElemSetCol(pGui, pElemRefTmp, (gslc_tsColor) { 0, 0, 192 }, (gslc_tsColor) { 0, 0, 128 }, (gslc_tsColor) { 0, 0, 224 });
gslc_ElemSetTxtCol(pGui, pElemRefTmp, GSLC_COL_WHITE);
pElemTmp = gslc_GetElemFromRef(pGui, pElemRefTmp);
@@ -222,6 +225,24 @@ gslc_tsElemRef* gslc_ElemXSpinnerCreate(gslc_tsGui* pGui, int16_t nElemId, int16
}
+bool gslc_ElemXSpinnerSetChars(void* pvGui,gslc_tsElemRef* pElemRef,uint8_t cIncr, uint8_t cDecr)
+{
+ gslc_tsGui* pGui = (gslc_tsGui*)(pvGui);
+ gslc_tsElem* pElem = gslc_GetElemFromRefD(pGui, pElemRef, __LINE__);
+ if (!pElem) return false;
+ gslc_tsXSpinner* pSpinner = (gslc_tsXSpinner*)gslc_GetXDataFromRef(pGui, pElemRef, GSLC_TYPEX_SPINNER, __LINE__);
+ if (!pSpinner) return false;
+
+ char acIncr[2] = { cIncr, '\0'};
+ char acDecr[2] = { cDecr, '\0'};
+ gslc_tsElemRef* pElemRefUp = gslc_CollectFindElemById(pGui,&pSpinner->sCollect,SPINNER_ID_BTN_INC);
+ gslc_ElemSetTxtStr(pGui,pElemRefUp,acIncr);
+ gslc_tsElemRef* pElemRefDown = gslc_CollectFindElemById(pGui,&pSpinner->sCollect,SPINNER_ID_BTN_DEC);
+ gslc_ElemSetTxtStr(pGui,pElemRefDown,acDecr);
+
+ return true;
+}
+
// Redraw the compound element
// - When drawing a compound element, we clear the background

diff:
@@ -85,6 +85,8 @@ typedef struct {
// Provide storage for any dynamic text elements
// Simple example here uses fixed-length character array
char acElemTxt[1][XSPINNER_STR_LEN]; ///< Storage for strings
+ char acIncr[2]; ///< Increment character string
+ char acDecr[2]; ///< Decrement character string
} gslc_tsXSpinner;
@@ -114,6 +116,20 @@ gslc_tsElemRef* gslc_ElemXSpinnerCreate(gslc_tsGui* pGui, int16_t nElemId, int16
int8_t nFontId, int8_t nButtonSz, GSLC_CB_INPUT cbInput);
+///
+/// Set Up and Down characters for the Spinner element
+/// - Called during redraw
+///
+/// \param[in] pvGui: Void ptr to GUI (typecast to gslc_tsGui*)
+/// \param[in] pElemRef: ptr to ElementRef
+/// \param[in] cIncrement: Character to use to indicate incrementing the spinner
+/// \param[in] cDecrement: Character to use to indicate decrementing the spinner
+///
+/// \return true if success, false otherwise
+///
+bool gslc_ElemXSpinnerSetChars(void* pvGui,gslc_tsElemRef* pElemRef,uint8_t cIncr, uint8_t cDecr);
+
+
///
/// Draw a Spinner element on the screen
/// - Called during redraw
@@ -126,7 +142,6 @@ gslc_tsElemRef* gslc_ElemXSpinnerCreate(gslc_tsGui* pGui, int16_t nElemId, int16
///
bool gslc_ElemXSpinnerDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw);
-
///
/// Get the current counter associated with Spinner
///

original_message: issue #199 XSpinner support for optional up/down characters


message: moved ex44 to builder and updated comments inside it

change_type: RENAME

diff:
// https://github.com/ImpulseAdventure/GUIslice
//
//<File !End!>
+// GUIslice Builder Examples
+// - Paul Conti
+// - Example 44 SPIFFS (ESP8266/ESP32):
+// - Access Jpeg Images and Icons from SPIFFS file system.
+// A Popup page with a text, text button, and a text box is
+// also demonstrated when the QUIT button is touched.
//
-// ARDUINO NOTES:
-// - GUIslice_config.h must be edited to match the pinout connections
-// between the Arduino CPU and the display controller (see ADAGFX_PIN_*).
+// - NOTE: This Example demonstrates access with the TFT_eSPI, TFT_eFEX,
+// and JPEGDecoder libraries.
+//
+// Instructions using Arduino IDE:
+// ---
+// You must start by uploading the images inside the folder
+// GUIslice\examples\builder\ex44_bld_spiffs\data to your
+// SPIFFS data partition. They take up only about 82.2kb.
+// ---
+// You use the "Tools" "ESP32" (or ESP8266) "Sketch Data Upload"
+// menu option in the IDE.
+// ---
+// To add this option follow instructions here for the ESP8266:
+// https://github.com/esp8266/arduino-esp8266fs-plugin
+// or for the ESP32:
+// https://github.com/me-no-dev/arduino-esp32fs-plugin
+// Close the IDE and open again to see the new menu option.
+// ---
+// Now you may upload the images and icons to SPIFFS using the
+// "Sketch Data Upload" menu option in the IDE.
//
// ------------------------------------------------


message: added error msg for when GSLC_SPIFFS_EN!=1

diff:
@@ -207,7 +207,6 @@ bool gslc_DrvInit(gslc_tsGui* pGui)
GSLC_DEBUG_PRINT("ERROR: DrvInit() SD init failed\n", 0);
return false;
}
-// GSLC_DEBUG_PRINT("- Init SD File System OK\n", 0);
#endif
#if (GSLC_SPIFFS_EN)
@@ -215,7 +214,6 @@ bool gslc_DrvInit(gslc_tsGui* pGui)
if (!SPIFFS.begin()) {
GSLC_DEBUG_PRINT("ERROR: DrvInit() SPIFFS init failed\n", 0);
}
-// GSLC_DEBUG_PRINT("- Init SPIFFS File System OK\n", 0);
#endif
}
return true;
@@ -960,8 +958,9 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
if (sImgRef.eImgFlags == GSLC_IMGREF_NONE) {
return true; // Nothing to do
-#if (GSLC_SPIFFS_EN)
} else if ((sImgRef.eImgFlags & GSLC_IMGREF_SRC) == GSLC_IMGREF_SRC_FILE) {
+ // Load image from SPIFFS
+ #if (GSLC_SPIFFS_EN)
if ((sImgRef.eImgFlags & GSLC_IMGREF_FMT) == GSLC_IMGREF_FMT_JPG) {
// Draw Jpeg from SPIFFS file system
gslc_DrvDrawJpegFromFile(pGui,nDstX,nDstY,sImgRef);
@@ -973,6 +972,9 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
} else {
return false; // TODO: not yet supported
}
+ #else
+ GSLC_DEBUG_PRINT("ERROR: GetImageFromSD() not supported as Config:GSLC_SPIFFS_EN=0", 0);
+ return false; // TODO: not yet supported
#endif // end GSLC_SPIFFS_EN
} else if ((sImgRef.eImgFlags & GSLC_IMGREF_SRC) == GSLC_IMGREF_SRC_RAM) {
if ((sImgRef.eImgFlags & GSLC_IMGREF_FMT) == GSLC_IMGREF_FMT_RAW1) {
@@ -1017,12 +1019,13 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
}
#else
// SD card access not enabled
+ GSLC_DEBUG_PRINT("ERROR: GSLC_SD_EN must be set to 1 to access SD Card\n", 0);
return false;
#endif
} else {
// Unsupported source
- GSLC_DEBUG2_PRINT("DBG: DrvDrawImage() unsupported source eImgFlags=%d\n", sImgRef.eImgFlags);
+ GSLC_DEBUG_PRINT("DBG: DrvDrawImage() unsupported source eImgFlags=%d\n", sImgRef.eImgFlags);
return false;
}
}
@@ -1042,8 +1045,7 @@ bool gslc_DrvDrawJpegFromFile(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_
{
const char* pStrFname = sImgRef.pFname;
- // Load Jpeg image from SPIFFS file system
-
+ // Load Jpeg image from file system
#if defined(ESP32)
// use optimized ESP32 native decoder
fex.drawJpgFile(SPIFFS, pStrFname, nDstX, nDstY);


message: correct SPIFFS error msg

diff:
@@ -957,7 +957,6 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
// we to handle the loading now (when rendering).
if (sImgRef.eImgFlags == GSLC_IMGREF_NONE) {
return true; // Nothing to do
-
} else if ((sImgRef.eImgFlags & GSLC_IMGREF_SRC) == GSLC_IMGREF_SRC_FILE) {
// Load image from SPIFFS
#if (GSLC_SPIFFS_EN)
@@ -973,7 +972,7 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
return false; // TODO: not yet supported
}
#else
- GSLC_DEBUG_PRINT("ERROR: GetImageFromSD() not supported as Config:GSLC_SPIFFS_EN=0", 0);
+ GSLC_DEBUG_PRINT("ERROR: GetImageFromFile() not supported as Config:GSLC_SPIFFS_EN=0", 0);
return false; // TODO: not yet supported
#endif // end GSLC_SPIFFS_EN
} else if ((sImgRef.eImgFlags & GSLC_IMGREF_SRC) == GSLC_IMGREF_SRC_RAM) {

original_message: correct SPIFFS error msg


message: removed SD not enabled msg since we never reach it

diff:
@@ -1018,7 +1018,6 @@ bool gslc_DrvDrawImage(gslc_tsGui* pGui,int16_t nDstX,int16_t nDstY,gslc_tsImgRe
}
#else
// SD card access not enabled
- GSLC_DEBUG_PRINT("ERROR: GSLC_SD_EN must be set to 1 to access SD Card\n", 0);
return false;
#endif


message: fix for tick color when vertical

diff:
@@ -393,7 +393,7 @@ bool gslc_ElemXSeekbarDraw(void* pvGui,void* pvElemRef,gslc_teRedrawType eRedraw
nX0+nTickOffset+nMargin,nYMid+(nTickLen/2),colTick);
} else {
gslc_DrawLine(pGui,nXMid+(nTickLen/2),nY0+nTickOffset+nMargin,nXMid-(nTickLen/2),
- nY0+nTickOffset+nMargin,GSLC_COL_BLACK);
+ nY0+nTickOffset+nMargin,colTick);
}
}
}

original_message: fix for tick color when vertical