Logic insert line button (from foo's client)
This commit is contained in:
@@ -131,6 +131,10 @@ public class LCanvas extends Table{
|
|||||||
statements.addChild(new StatementElem(statement));
|
statements.addChild(new StatementElem(statement));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAt(int at, LStatement statement){
|
||||||
|
statements.addChildAt(at, new StatementElem(statement));
|
||||||
|
}
|
||||||
|
|
||||||
public String save(){
|
public String save(){
|
||||||
Seq<LStatement> st = statements.getChildren().<StatementElem>as().map(s -> s.st);
|
Seq<LStatement> st = statements.getChildren().<StatementElem>as().map(s -> s.st);
|
||||||
st.each(LStatement::saveUI);
|
st.each(LStatement::saveUI);
|
||||||
@@ -433,6 +437,10 @@ public class LCanvas extends Table{
|
|||||||
|
|
||||||
addressLabel = t.add(index + "").style(Styles.outlineLabel).color(color).padRight(8).get();
|
addressLabel = t.add(index + "").style(Styles.outlineLabel).color(color).padRight(8).get();
|
||||||
|
|
||||||
|
//taken from foo's client
|
||||||
|
t.button(Icon.add, Styles.logici, () -> Vars.ui.logic.showAddDialog(statements.insertPosition + 1))
|
||||||
|
.disabled(b -> canvas.statements.getChildren().size >= LExecutor.maxInstructions).size(24f).padRight(6);
|
||||||
|
|
||||||
t.button(Icon.copy, Styles.logici, () -> {
|
t.button(Icon.copy, Styles.logici, () -> {
|
||||||
}).size(24f).padRight(6).get().tapped(this::copy);
|
}).size(24f).padRight(6).get().tapped(this::copy);
|
||||||
|
|
||||||
@@ -447,6 +455,8 @@ public class LCanvas extends Table{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||||
|
//don't start dragging when pressing the menu buttons
|
||||||
|
if(event.targetActor instanceof Image) return false;
|
||||||
|
|
||||||
if(button == KeyCode.mouseMiddle){
|
if(button == KeyCode.mouseMiddle){
|
||||||
copy();
|
copy();
|
||||||
|
|||||||
@@ -254,6 +254,10 @@ public class LogicDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showAddDialog(){
|
public void showAddDialog(){
|
||||||
|
showAddDialog(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showAddDialog(int position){
|
||||||
BaseDialog dialog = new BaseDialog("@add");
|
BaseDialog dialog = new BaseDialog("@add");
|
||||||
dialog.cont.table(table -> {
|
dialog.cont.table(table -> {
|
||||||
String[] searchText = {""};
|
String[] searchText = {""};
|
||||||
@@ -326,7 +330,7 @@ public class LogicDialog extends BaseDialog{
|
|||||||
style.font = Fonts.outline;
|
style.font = Fonts.outline;
|
||||||
|
|
||||||
cat.button(example.name(), style, () -> {
|
cat.button(example.name(), style, () -> {
|
||||||
canvas.add(prov.get());
|
canvas.addAt(position == -1 ? canvas.statements.getChildren().size : position, prov.get());
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
}).size(130f, 50f).self(c -> tooltip(c, "lst." + example.name())).top().left();
|
}).size(130f, 50f).self(c -> tooltip(c, "lst." + example.name())).top().left();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user