Updated block deletion behavior

This commit is contained in:
Cavallium 2018-10-04 09:52:14 +02:00
parent 658c5669f0
commit a9395277c9
13 changed files with 71 additions and 14 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ font_gputest4.png
font_gputest4.xcf
manager2/
VBO_Example.java
math-rules-cache.zip
/target/
!/target/*.jar

View File

@ -40,7 +40,9 @@ public abstract class Block implements TreeBlock, GraphicalElement {
* Used only to get inner blocks when deleting the parent block.
* @return every block of every inner container, or null if empty
*/
public abstract ObjectArrayList<Block> getAllInnerBlocks();
public abstract ObjectArrayList<Block> getInnerBlocks();
public abstract int getInnerContainersCount();
@Override
public abstract void recomputeDimensions();

View File

@ -67,8 +67,13 @@ public class BlockChar extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return null;
}
@Override
public int getInnerContainersCount() {
return 0;
}
}

View File

@ -219,9 +219,12 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
final int deltaCaret = caret.getRemaining();
removed = removed | b.delBlock(caret);
if (caret.getRemaining() == 0 || removed == false && deltaCaret >= 0 && caret.getRemaining() < 0) {
ObjectArrayList<Block> blocks = this.getBlockAt(pos - 1).get().getAllInnerBlocks();
ObjectArrayList<Block> blocks = this.getBlockAt(pos - 1).get().getInnerBlocks();
int innerContainersCount = this.getBlockAt(pos - 1).get().getInnerContainersCount();
if (innerContainersCount > 0) {
innerContainersCount--;
}
removeAt(pos - 1);
caret.setPosition(caret.getPosition() - deltaCaret);
if (blocks != null) {
ObjectListIterator<Block> blocksIterator = blocks.iterator();
int blockNum = 0;
@ -231,6 +234,7 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
blockNum++;
}
}
caret.setPosition(caret.getPosition() - innerContainersCount);
removed = true;
}
}

View File

@ -122,9 +122,14 @@ public class BlockDivision extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
ObjectArrayList<Block> output = containerUp.getContent();
output.addAll(containerDown.getContent());
return output;
}
@Override
public int getInnerContainersCount() {
return 2;
}
}

View File

@ -161,10 +161,15 @@ public class BlockLogarithm extends Block implements IParenthesis {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
ObjectArrayList<Block> output = containerBase.getContent();
output.addAll(containerNumber.getContent());
return output;
}
@Override
public int getInnerContainersCount() {
return 2;
}
}

View File

@ -21,8 +21,13 @@ public class BlockParenthesis extends BlockParenthesisAbstract {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return getNumberContainer().getContent();
}
@Override
public int getInnerContainersCount() {
return 1;
}
}

View File

@ -117,8 +117,13 @@ public abstract class BlockParenthesisAbstract extends Block implements IParenth
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return containerNumber.getContent();
}
@Override
public int getInnerContainersCount() {
return 1;
}
}

View File

@ -83,7 +83,12 @@ public class BlockPower extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return this.containerExponent.getContent();
}
@Override
public int getInnerContainersCount() {
return 1;
}
}

View File

@ -89,7 +89,12 @@ public class BlockPower2 extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return containerExponent.getContent();
}
@Override
public int getInnerContainersCount() {
return 1;
}
}

View File

@ -98,9 +98,14 @@ public class BlockSquareRoot extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
ObjectArrayList<Block> output = containerNumber.getContent();
// output.addAll();
return output;
}
@Override
public int getInnerContainersCount() {
return 1; //2
}
}

View File

@ -61,8 +61,13 @@ public class BlockUndefined extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return null;
}
@Override
public int getInnerContainersCount() {
return 0;
}
}

View File

@ -258,7 +258,12 @@ public class BlockVariable extends Block {
}
@Override
public ObjectArrayList<Block> getAllInnerBlocks() {
public ObjectArrayList<Block> getInnerBlocks() {
return null;
}
@Override
public int getInnerContainersCount() {
return 0;
}
}