changeset 112:9bf9fd26bb33

TabOptions: Started on visual representations of categories, checkboxes and actions
author Fox
date Thu, 15 Jun 2023 03:49:56 +0200
parents b93c6236c6cb
children 5c74293fb41a
files src/junotu/TabOptions.java
diffstat 1 files changed, 92 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/TabOptions.java	Thu Jun 15 00:53:55 2023 +0200
+++ b/src/junotu/TabOptions.java	Thu Jun 15 03:49:56 2023 +0200
@@ -7,6 +7,8 @@
 import javax.swing.Box;
 import javax.swing.JScrollPane;
 import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JCheckBox;
 
 import java.awt.BorderLayout;
 import java.awt.FlowLayout;
@@ -21,12 +23,12 @@
 import junotu.Card;
 
 public class TabOptions extends JPanel implements ActionListener, TabInterface {
-
+	
 	private static final String ACTION_PATH_BUTTON = "path_button";
-
+	
 	private static class Option extends JPanel implements ActionListener {
 		TabOptions events;
-
+		
 		@Override
 		public void actionPerformed( ActionEvent e )
 		{
@@ -35,34 +37,102 @@
 			}
 		}
 	}
-
+	
 	private static class OptionFolder extends Option {
-	
-		OptionTree.OptionFolder folder;
 		
-		public OptionFolder( TabOptions events_, OptionTree.OptionFolder folder_ )
+		OptionTree.OptionFolder option;
+		
+		public OptionFolder( TabOptions events_, OptionTree.OptionFolder option_ )
 		{
 			setLayout( new BoxLayout( this, BoxLayout.X_AXIS ) );
 			events = events_;
-			folder = folder_;
+			option = option_;
 			
-			JButton button = new JButton( folder.brief );
+			JButton button = new JButton( option.brief );
 			
 			this.add(button);
 			
-			if( folder.hint.length() > 0 ) {
-				button.setToolTipText( folder.hint );
+			if( option.hint.length() > 0 ) {
+				button.setToolTipText( option.hint );
 			}
 			
 			button.addActionListener(this);
 		}
 	}
-	private static class OptionCategory extends Option {}
-	private static class OptionCheckbox extends Option {}
+	
+	private static class OptionCategory extends Option {
+		
+		OptionTree.OptionCategory option;
+		
+		public OptionCategory( TabOptions events_, OptionTree.OptionCategory option_ )
+		{
+			setLayout( new BoxLayout( this, BoxLayout.X_AXIS ) );
+			events = events_;
+			option = option_;
+			
+			JLabel label = new JLabel( option.brief );
+			
+			this.add(label);
+			
+			if( option.hint.length() > 0 ) {
+				label.setToolTipText( option.hint );
+			}
+			
+		}
+		
+	}
+	
+	private static class OptionCheckbox extends Option {
+		
+		OptionTree.OptionCheckbox option;
+		
+		public OptionCheckbox( TabOptions events_, OptionTree.OptionCheckbox option_ )
+		{
+			setLayout( new BoxLayout( this, BoxLayout.X_AXIS ) );
+			events = events_;
+			option = option_;
+			
+			JCheckBox checkbox = new JCheckBox( option.brief, option.default_value );
+			
+			this.add(checkbox);
+			
+			if( option.hint.length() > 0 ) {
+				checkbox.setToolTipText( option.hint );
+			}
+			
+			checkbox.addActionListener(this);
+			
+		}
+		
+	}
+	
 	private static class OptionSlider extends Option {}
 	private static class OptionNumberCounter extends Option {}
 	private static class OptionString extends Option {}
-	private static class OptionAction extends Option {}
+	
+	private static class OptionAction extends Option {
+		
+		OptionTree.OptionAction option;
+		
+		public OptionAction( TabOptions events_, OptionTree.OptionAction option_ )
+		{
+			setLayout( new BoxLayout( this, BoxLayout.X_AXIS ) );
+			events = events_;
+			option = option_;
+			
+			JButton button = new JButton( option.brief );
+			
+			this.add(button);
+			
+			if( option.hint.length() > 0 ) {
+				button.setToolTipText( option.hint );
+			}
+			
+			button.addActionListener(this);
+			
+		}
+		
+	}
 
 	static public final OptionTree OPTION_TREE;
 	static {
@@ -149,8 +219,14 @@
 			OptionTree.Option<?> option = page.options.get(i);
 			if( option instanceof OptionTree.OptionFolder ) {
 				optionList.add( new OptionFolder( this, (OptionTree.OptionFolder)option ) );
+			} else if( option instanceof OptionTree.OptionCategory ) {
+				optionList.add( new OptionCategory( this, (OptionTree.OptionCategory)option ) );
+			} else if( option instanceof OptionTree.OptionCheckbox ) {
+				optionList.add( new OptionCheckbox( this, (OptionTree.OptionCheckbox)option ) );
+			} else if( option instanceof OptionTree.OptionAction ) {
+				optionList.add( new OptionAction( this, (OptionTree.OptionAction)option ) );
 			} else {
-				System.out.print( "TabOptions, generate: Unknown option type '"+option.getClass().getName()+"', cannot create interface.\n" );
+				System.out.print( "TabOptions, generate: Unknown option type '"+option.getClass().getName()+"', cannot create interface element.\n" );
 			}
 		}
 		optionList.add( Box.createVerticalGlue() );
@@ -189,7 +265,7 @@
 
 		if( source instanceof OptionFolder ) {
 			OptionFolder clicked = (OptionFolder)source;
-			path.add( clicked.folder );
+			path.add( clicked.option );
 			generate();
 		}
 	}