1 module windows.layerlist; 2 3 import PixelPerfectEngine.concrete.window; 4 import app; 5 import std.utf : toUTF32; 6 import std.conv : to; 7 import PixelPerfectEngine.graphics.layers; 8 import PixelPerfectEngine.map.mapformat : LayerInfo; 9 10 public class LayerList : Window { 11 //ListBox listBox_layers; 12 ListView listView_layers; 13 SmallButton[] buttons; 14 15 //CheckBox CheckBox_Visible; 16 public this(int x, int y, void delegate() onClose){ 17 //super(Coordinate(0 + x, 16 + y, 98 + x, 213 + y), "Layers"d); 18 super(Coordinate(0 + x, 0 + y, 129 + x, 213 + y), "Layers"d); 19 this.onClose = onClose; 20 //StyleSheet ss = getStyleSheet(); 21 /+listBox_layers = new ListBox("listBox0", Coordinate(1, 17, 129, 180), [], new ListBoxHeader(["Pri"d ,"Type"d, "Name"d], 22 [24, 24, 96]));+/ 23 listView_layers = new ListView( 24 new ListViewHeader(16, [24, 24, 96], ["Pri"d ,"Type"d, "Name"d]), null, "listView_layers", Box(1, 17, 128, 179) 25 ); 26 addElement(listView_layers); 27 listView_layers.onItemSelect = &listBox_layers_onItemSelect; 28 { 29 SmallButton sb = new SmallButton("trashButtonB", "trashButtonA", "trash", Box(113, 197, 129, 213)); 30 sb.onMouseLClick = &button_trash_onClick; 31 buttons ~= sb; 32 } 33 { 34 SmallButton sb = new SmallButton("settingsButtonB", "settingsButtonA", "editMat", Box(97, 197, 113, 213)); 35 //sb.onMouseLClickRel = &button_trash_onClick; 36 buttons ~= sb; 37 } 38 { 39 SmallButton sb = new SmallButton("newTileLayerButtonB", "newTileLayerButtonA", "newTileLayer", 40 Coordinate(1, 181, 16, 196)); 41 sb.onMouseLClick = &button_newTileLayer_onClick; 42 buttons ~= sb; 43 } 44 { 45 SmallButton sb = new SmallButton("newSpriteLayerButtonB", "newSpriteLayerButtonA", "newSpriteLayer", 46 Coordinate(17, 181, 32, 196)); 47 sb.onMouseLClick = &button_newSpriteLayer_onClick; 48 buttons ~= sb; 49 } 50 { 51 SmallButton sb = new SmallButton("newTransformableTileLayerButtonB", "newTransformableTileLayerButtonA", 52 "newTransformableTileLayer", Coordinate(33, 181, 48, 196)); 53 sb.onMouseLClick = &button_newTransformableTileLayer_onClick; 54 buttons ~= sb; 55 } 56 { 57 SmallButton sb = new SmallButton("importMaterialDataButtonB", "importMaterialDataButtonA", "importMat", 58 Coordinate(97, 181, 113, 196)); 59 sb.onMouseLClick = &button_importMaterialData_onClick; 60 buttons ~= sb; 61 } 62 { 63 SmallButton sb = new SmallButton("importLayerDataButtonB", "importLayerDataButtonA", "importLayer", 64 Coordinate(113, 181, 129, 196)); 65 sb.onMouseLClick = &button_importLayerData_onClick; 66 buttons ~= sb; 67 } 68 { 69 SmallButton sb = new SmallButton("upArrowB", "upArrowA", "moveLayerUp", Coordinate(1, 197, 16, 212)); 70 sb.onMouseLClick = &button_moveLayerUp_onClick; 71 buttons ~= sb; 72 } 73 { 74 SmallButton sb = new SmallButton("downArrowB", "downArrowA", "moveLayerDown", Coordinate(17, 197, 32, 212)); 75 sb.onMouseLClick = &button_moveLayerDown_onClick; 76 buttons ~= sb; 77 } 78 foreach(sb ; buttons){ 79 addElement(sb); 80 } 81 //CheckBox_Visible = new CheckBox("Visible"d, "CheckBox0", Coordinate(1, 180, 97, 196)); 82 } 83 private void listBox_layers_onItemSelect(Event ev){ 84 if (prg.selDoc !is null) { 85 ListViewItem lbi = cast(ListViewItem)ev.aux; 86 const int selectedLayer = to!int(lbi.fields[0].text.text); 87 prg.selDoc.selectedLayer = selectedLayer; 88 } 89 } 90 private void button_trash_onClick(Event ev){ 91 92 } 93 private void button_newTileLayer_onClick(Event ev){ 94 prg.initNewTileLayer; 95 } 96 private void button_newSpriteLayer_onClick(Event ev){ 97 98 } 99 private void button_newTransformableTileLayer_onClick(Event ev){ 100 101 } 102 private void button_importMaterialData_onClick(Event ev){ 103 104 } 105 private void button_importLayerData_onClick(Event ev){ 106 107 } 108 private void button_moveLayerUp_onClick(Event ev){ 109 110 } 111 private void button_moveLayerDown_onClick(Event ev){ 112 113 } 114 public void updateLayerList(LayerInfo[] items) { 115 //ListViewItem[] list; 116 listView_layers.clear(); 117 foreach (i ; items) { 118 //list ~= new ListViewItem(16, [to!dstring(i.pri), to!dstring(i.type), toUTF32(i.name)]); 119 listView_layers ~= new ListViewItem(16, [to!dstring(i.pri), to!dstring(i.type), toUTF32(i.name)]); 120 } 121 listView_layers.refresh; 122 //listView_layers.(list); 123 } 124 public override void close(){ 125 if(onClose !is null){ 126 onClose(); 127 } 128 super.close; 129 } 130 }