11package gui ;
2- import java .awt .Dimension ;
3- import java .awt .Font ;
4- import java .awt .GridLayout ;
5- import java .awt .Toolkit ;
6- import java .awt .event .WindowAdapter ;
7- import java .awt .event .WindowEvent ;
8- import java .io .File ;
9- import java .io .FileNotFoundException ;
10- import java .io .PrintStream ;
11- import java .util .ArrayList ;
2+
3+ import java .awt .*;
4+ import java .awt .event .*;
5+ import java .io .*;
6+ import java .util .*;
127import java .util .regex .Pattern ;
138
14- import javax .swing .BoxLayout ;
15- import javax .swing .JCheckBoxMenuItem ;
16- import javax .swing .JDialog ;
17- import javax .swing .JFrame ;
18- import javax .swing .JPanel ;
19- import javax .swing .JScrollPane ;
20- import javax .swing .ScrollPaneConstants ;
21- import javax .swing .SwingUtilities ;
22- import javax .swing .UIManager ;
23- import javax .swing .WindowConstants ;
9+ import javax .swing .*;
2410
25- import edit .CellEditDialog ;
26- import edit .SectionManagerDialog ;
27- import logic .FileOperations ;
28- import logic .Hotkeys ;
29- import logic .LiveSplitConnection ;
30- import logic .MouseAdapters ;
31- import logic .Section ;
32- import logic .Updates ;
11+ import edit .*;
12+ import logic .*;
3313
3414public class MainGui {
3515 public static Font font = new Font ("Serif" , Font .PLAIN , 20 );
@@ -39,6 +19,7 @@ public class MainGui {
3919 public static CellEditDialog cellEditDialog ;
4020
4121 public static JFrame window ;
22+ //public static JFrame content_window;
4223 public static JScrollPane scrollPane ;
4324 public static JPanel mainPanel ;
4425
@@ -52,7 +33,11 @@ public class MainGui {
5233
5334 public static Dimension screensize ;
5435
55- public static String currentVersionTag = "v3.3" ;
36+ public static String currentVersionTag = "v3.4" ;
37+
38+ public final static int moveToSectionAbove = -1 ;
39+ public final static int removeSection = 0 ;
40+ public final static int moveToSectionBelow = 1 ;
5641
5742 private static void prepareGui ()
5843 {
@@ -66,15 +51,41 @@ private static void prepareGui()
6651 ScrollPaneConstants .VERTICAL_SCROLLBAR_AS_NEEDED ,
6752 ScrollPaneConstants .HORIZONTAL_SCROLLBAR_AS_NEEDED );
6853
69- window = new JFrame ();
54+ JPanel colorPanel = new JPanel ();
55+ colorPanel .setBackground (ColorSettings .getBackgroundColor () );
56+ colorPanel .setBorder (GuiHelper .getEmptyBorder () );
57+
58+ window = new JFrame () /*{
59+ private static final long serialVersionUID = -1303115076804508497L;
60+
61+ @Override
62+ public Insets getInsets()
63+ {
64+ return new Insets(0, 0, 0, 0);
65+ }
66+ }//*/ ;
7067 window .setJMenuBar (MenuItems .createMenuBar () );
7168 window .setLayout (new BoxLayout (window .getContentPane (), BoxLayout .Y_AXIS ) );
7269 window .add (scrollPane );
70+ //window.setContentPane(colorPanel);
7371 window .setDefaultCloseOperation (WindowConstants .DO_NOTHING_ON_CLOSE );
7472 window .addWindowListener (MouseAdapters .windowOnCloseAdapter );
7573 window .setTitle ("" );
7674 window .pack ();
7775 window .setVisible (true );
76+
77+ /*
78+ content_window = new JFrame();
79+ content_window.setUndecorated(true);
80+ content_window.setLayout(new BoxLayout(content_window.getContentPane(), BoxLayout.Y_AXIS) );
81+ content_window.add(scrollPane);
82+ content_window.setTitle("Notes-creator-capture-frame");
83+ content_window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
84+ content_window.addWindowListener(MouseAdapters.windowOnCloseAdapter);
85+ content_window.pack();
86+ content_window.setVisible(true);
87+ System.out.println("Main:" + window.getInsets() + ", content:" + content_window.getInsets() );
88+ //*/
7889 }
7990
8091 public static void arrangeContent ()
@@ -90,12 +101,15 @@ public static void arrangeContent()
90101 if (inEditMode ) sectionManagerDialog .updateSectionManagerDialog ();
91102
92103 window .remove (scrollPane );
104+ //content_window.remove(scrollPane);
93105 window .setPreferredSize (null );
106+ //content_window.setPreferredSize(null);
94107 window .setTitle (FileOperations .getWindowTitle () );
95108
96109 mainPanel = new JPanel ();
97110 mainPanel .setLayout (new BoxLayout (mainPanel , BoxLayout .Y_AXIS ) );
98111 mainPanel .setBackground (ColorSettings .getBackgroundColor () );
112+ mainPanel .setOpaque (false );
99113
100114 for (Section section : sectionsList )
101115 mainPanel .add (section );
@@ -104,12 +118,20 @@ public static void arrangeContent()
104118 ScrollPaneConstants .VERTICAL_SCROLLBAR_AS_NEEDED ,
105119 ScrollPaneConstants .HORIZONTAL_SCROLLBAR_AS_NEEDED );
106120 scrollPane .getVerticalScrollBar ().setUnitIncrement (16 );
121+ //scrollPane.getViewport().setOpaque(false);
122+ //scrollPane.setOpaque(false);
123+ scrollPane .getViewport ().setBackground (ColorSettings .getBackgroundColor () );
107124
108125 window .add (scrollPane );
126+ //content_window.add(scrollPane);
127+ //content_window.setBackground(new Color(0, 0, 0, 0) );
109128 window .pack ();
129+ //content_window.pack();
110130 window .setVisible (true );
131+ //content_window.setVisible(true);
111132 resizeWindow ();
112133 window .pack ();
134+ //content_window.pack();
113135
114136 sectionsList .forEach (section -> section .setLocation () );
115137 }
@@ -133,6 +155,7 @@ private static void resizeWindow()
133155 height = window .getHeight ();
134156 if (window .getWidth () < width )
135157 width = window .getWidth ();
158+ //content_window.setPreferredSize(new Dimension(width + 100, height) );
136159 window .setPreferredSize (new Dimension (width + 100 , height ) );
137160 }
138161
@@ -154,6 +177,10 @@ public static void spaceColums()
154177 window .setVisible (true );
155178 window .repaint ();
156179 window .setMaximumSize (screensize );
180+ //content_window.pack();
181+ //content_window.setVisible(true);
182+ //content_window.repaint();
183+ //content_window.setMaximumSize(screensize);
157184
158185 // determining the maximal width for each column
159186 Section .maxWidths = new int [FileOperations .numberOfColumns + 2 ];
@@ -165,6 +192,7 @@ public static void spaceColums()
165192 scrollPane .setPreferredSize (new Dimension (scrollPane .getWidth () + 100 , keepGuiSize ? height : scrollPane .getHeight () ) );
166193
167194 window .pack ();
195+ //content_window.pack();
168196 scrollPane .getVerticalScrollBar ().setValue (scrollValue );
169197
170198 keepGuiSize = true ;
@@ -200,6 +228,7 @@ public void run()
200228 try
201229 {
202230 e .printStackTrace (new PrintStream (new File ("log.txt" ) ) );
231+ e .printStackTrace ();
203232 } catch (FileNotFoundException e1 )
204233 {
205234 // TODO Auto-generated catch block
@@ -252,8 +281,27 @@ public static void addSection(int section_index, Section new_section)
252281 sectionManagerDialog .updateSectionManagerDialog ();
253282 }
254283
255- public static void removeSection (int section_index )
284+ public static void removeSection (int section_index , int moveContent )
256285 {
286+ if (moveContent < -1 || moveContent > 1 )
287+ throw new IllegalArgumentException ("moveContent has to be between -1 and 1, got " + moveContent );
288+
289+ if (moveContent == removeSection )
290+ sectionsList .remove (section_index );
291+ else
292+ {
293+ ArrayList <Row > rows = sectionsList .remove (section_index ).getRows ();
294+ rows .remove (rows .size () - 1 );
295+
296+ try
297+ {
298+ if (moveContent == moveToSectionAbove )
299+ sectionsList .get (section_index - 1 ).addRowsAtEnd (rows );
300+ else if (moveContent == moveToSectionBelow )
301+ sectionsList .get (section_index ).addRowsAtStart (rows ); // the section was already removed, so the next section has the same index as the one that was removed.
302+ } catch (IndexOutOfBoundsException e )
303+ { return ; }
304+ }
257305 arrangeContent ();
258306 spaceColums ();
259307 sectionManagerDialog .updateSectionManagerDialog ();
0 commit comments