Skip to content

Commit

Permalink
Improved input area interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Nov 7, 2021
1 parent fab4824 commit 4aef5d4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ dependencies {
implementation group: 'com.formdev', name: 'flatlaf', version: '0.45'
implementation group: 'com.fifesoft', name: 'rsyntaxtextarea', version: '3.1.1'
implementation group: 'com.github.weisj', name: 'darklaf-core', version: '2.5.5'

implementation group: 'com.jidesoft', name: 'jide-oss', version: '3.6.18'

implementation 'com.github.APN-Pucky:GitJarUpdate:0.0.7'
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/TeXCalc/gui/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import TeXCalc.latex.wrap.math.Equation;
import TeXCalc.mathematica.Mathematica;
import TeXCalc.python.Python;
import TeXCalc.util.StringUtils;
import lombok.Getter;
import lombok.Setter;

Expand Down Expand Up @@ -113,10 +114,13 @@ public Cell(@JsonProperty("text") String stext, Latex latex) {
text.setLineWrap(true);
// text.setPreferredSize(new Dimension(150,100));
// text.setLineWrap(true);
Cell t = this;
text.addKeyListener((new KeyListener() {

@Override
public void keyTyped(KeyEvent e) {
text.setRows(StringUtils.count(text.getText(), '\n', 0)+3);
list.re();
queueUpdate();
}

Expand All @@ -131,7 +135,6 @@ public void keyPressed(KeyEvent e) {
}));
queueUpdate();
}

public String getText() {
return text.getText();
}
Expand Down Expand Up @@ -220,7 +223,6 @@ else if (Config.current.getMath().getExecuteSubsequent().getValue() && (environm
){
// queue updates on cells after this
list.updateFrom(this);

}
}
}
Expand Down
76 changes: 46 additions & 30 deletions src/main/java/TeXCalc/gui/CellList.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
package TeXCalc.gui;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Group;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import TeXCalc.latex.Latex;
Expand All @@ -35,6 +30,10 @@ public class CellList
@JsonIgnore
@Getter
private JPanel panel;
@JsonIgnore
@Getter
private GroupLayout layout;
private Group hg,vg,hg1,hg2;
//@JsonValue
//@JsonProperty("property")
@JsonSerialize(as=ArrayList.class, contentAs=Cell.class)
Expand Down Expand Up @@ -80,7 +79,20 @@ public CellList() {
public CellList(int number) {
panel = new JPanel();
latex = new Latex();
panel.setLayout(new GridBagLayout());
layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
hg = layout.createSequentialGroup();
hg1 = layout.createParallelGroup();
hg2 = layout.createParallelGroup();
vg = layout.createSequentialGroup();
hg.addGroup(hg1);
hg.addGroup(hg2);

layout.setHorizontalGroup(hg);
layout.setVerticalGroup(vg);
System.out.println("max" + layout.maximumLayoutSize(panel));
for ( int i = 0 ; i < number ; ++i)
{
increase();
Expand Down Expand Up @@ -120,31 +132,35 @@ public void link(int index) {

GridBagConstraints c = new GridBagConstraints();

c.fill = GridBagConstraints.NONE;
c.weightx = 0.01;
c.weighty = 0.1;
c.gridx = 0;
c.gridy = index;
//panel.add(tools, c);

JPanel tmpp = new JPanel();
JPanel tmpp = new JPanel(layout);
tmpp.setLayout(new BoxLayout(tmpp, BoxLayout.Y_AXIS));
tmpp.add(tools);
tmpp.add(new JScrollPane(cell.text));
c.fill = GridBagConstraints.NONE;
c.weightx = 0.3;
c.weighty = 0.1;
c.gridx = 1;
c.gridy = index;
panel.add(tmpp, c);

//tmpp.add(cell.text);
///*



tmpp.add(new JScrollPane(cell.text
,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
));
//*/

ParallelGroup p = layout.createParallelGroup(GroupLayout.Alignment.CENTER);
vg.addGroup(p);
p.addComponent(tmpp);
p.addComponent(cell.icon);
hg1.addComponent(tmpp);
hg2.addComponent(cell.icon);

//panel.add(tmpp, c);

c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 0.7;
c.weighty = 0.1;
c.gridx = 2;
c.gridy = index;
//c.fill = GridBagConstraints.HORIZONTAL;
//GUI.log.m(cell.getText()+ (cell.getLatex()==null));
panel.add(cell.icon, c);
//panel.add(cell.icon, c);
//panel.setPreferredSize(new Dimension(1000,200));
barmap.put(cell, tmpp);

}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/TeXCalc/gui/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package TeXCalc.gui;

import java.awt.BorderLayout;
import java.awt.ScrollPane;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -99,7 +100,10 @@ public Main() {
private void refreshTabs() {
if(tp!=null)jframe.remove(tp);
tp= new JTabbedPane();
tp.addTab("Notebook",null,jsp =new JScrollPane(celllist.getPanel()),"");
tp.addTab("Notebook",null,jsp =new JScrollPane(celllist.getPanel()
,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
),"");
jsp.getVerticalScrollBar().setUnitIncrement(20);
tp.addTab("Settings",null,jsp =new JScrollPane(celllist.getLatex().getPanel()),"");
jsp.getVerticalScrollBar().setUnitIncrement(20);
Expand Down

0 comments on commit 4aef5d4

Please sign in to comment.