gdx-studio
git clone https://git.pyrossh.dev/gdx-studio
An IDE for creating Games using libgdx and Java supported on all platforms Android, iOS, Desktop
src/gdxstudio/panel/WidgetPanel.java
| a9b2a64 | 1 | package gdxstudio.panel; |
| a62d533 | 2 | import java.awt.Dimension; |
| a62d533 | 3 | import java.awt.datatransfer.StringSelection; |
| a62d533 | 4 | import java.awt.dnd.DnDConstants; |
| a62d533 | 5 | import java.awt.dnd.DragGestureEvent; |
| a62d533 | 6 | import java.awt.dnd.DragGestureListener; |
| a62d533 | 7 | import java.awt.dnd.DragSource; |
| a62d533 | 8 | import java.awt.dnd.DragSourceDragEvent; |
| a62d533 | 9 | import java.awt.dnd.DragSourceDropEvent; |
| a62d533 | 10 | import java.awt.dnd.DragSourceEvent; |
| a62d533 | 11 | import java.awt.dnd.DragSourceListener; |
| a62d533 | 12 | import java.awt.event.ActionEvent; |
| a62d533 | 13 | |
| a9b2a64 | 14 | import javax.swing.JList; |
| a9b2a64 | 15 | import javax.swing.JPanel; |
| a62d533 | 16 | import javax.swing.event.ListSelectionEvent; |
| a62d533 | 17 | |
| a9b2a64 | 18 | import web.laf.lite.layout.HorizontalFlowLayout; |
| a9b2a64 | 19 | import web.laf.lite.utils.UIUtils; |
| a9b2a64 | 20 | |
| a62d533 | 21 | public class WidgetPanel extends BaseList implements DragSourceListener, DragGestureListener {
|
| a62d533 | 22 | private static final long serialVersionUID = 1L; |
| a62d533 | 23 | |
| a62d533 | 24 | DragSource dragSource = new DragSource(); |
| a62d533 | 25 | String[] btns = new String[]{
|
| a62d533 | 26 | "New Widget", "new","Delete", "trash" |
| a62d533 | 27 | }; |
| a9b2a64 | 28 | private JPanel hbox = new JPanel(new HorizontalFlowLayout()); |
| a9b2a64 | 29 | StyleList sl = new StyleList(); |
| a9b2a64 | 30 | StyleTable st = new StyleTable(); |
| a9b2a64 | 31 | |
| a62d533 | 32 | |
| a62d533 | 33 | public WidgetPanel(){
|
| a62d533 | 34 | super("Widgets", "Label","Image", "Sprite", "Button","TextButton", "CheckBox",
|
| a62d533 | 35 | "List", "SelectBox", "Slider", "TextField", |
| a9b2a64 | 36 | "Table", "Dialog", "Touchpad", "Model"); |
| a9b2a64 | 37 | list.setLayoutOrientation(JList.HORIZONTAL_WRAP); |
| a62d533 | 38 | dragSource.addDragSourceListener(this); |
| a62d533 | 39 | dragSource.createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_MOVE, this); |
| a9b2a64 | 40 | hbox.add(list); |
| a9b2a64 | 41 | hbox.add(sl); |
| a9b2a64 | 42 | hbox.add(st); |
| a9b2a64 | 43 | //this.remove(scrollPane); |
| a9b2a64 | 44 | UIUtils.setDrawBorder(scrollPane, true); |
| a9b2a64 | 45 | scrollPane.setPreferredSize(new Dimension(200, 150)); |
| a9b2a64 | 46 | scrollPane.setViewportView(hbox); |
| a9b2a64 | 47 | add(scrollPane); |
| a62d533 | 48 | } |
| a62d533 | 49 | |
| a62d533 | 50 | @Override |
| a62d533 | 51 | public void dragDropEnd(DragSourceDropEvent arg0) {
|
| a62d533 | 52 | } |
| a62d533 | 53 | |
| a62d533 | 54 | |
| a62d533 | 55 | @Override |
| a62d533 | 56 | public void dragEnter(DragSourceDragEvent arg0) {
|
| a62d533 | 57 | } |
| a62d533 | 58 | |
| a62d533 | 59 | |
| a62d533 | 60 | @Override |
| a62d533 | 61 | public void dragExit(DragSourceEvent arg0) {
|
| a62d533 | 62 | } |
| a62d533 | 63 | |
| a62d533 | 64 | |
| a62d533 | 65 | @Override |
| a62d533 | 66 | public void dragOver(DragSourceDragEvent arg0) {
|
| a62d533 | 67 | } |
| a62d533 | 68 | |
| a62d533 | 69 | |
| a62d533 | 70 | @Override |
| a62d533 | 71 | public void dropActionChanged(DragSourceDragEvent arg0) {
|
| a62d533 | 72 | } |
| a62d533 | 73 | |
| a62d533 | 74 | @Override |
| a62d533 | 75 | public void dragGestureRecognized(DragGestureEvent event) {
|
| a62d533 | 76 | StringSelection text = new StringSelection(list.getSelectedValue()); |
| a62d533 | 77 | dragSource.startDrag(event, DragSource.DefaultMoveDrop, text, this); |
| a62d533 | 78 | } |
| a62d533 | 79 | |
| a62d533 | 80 | @Override |
| a62d533 | 81 | public void valueChanged(ListSelectionEvent arg0) {
|
| a62d533 | 82 | } |
| a62d533 | 83 | |
| a62d533 | 84 | @Override |
| a62d533 | 85 | public void actionPerformed(ActionEvent arg0) {
|
| a62d533 | 86 | } |
| a62d533 | 87 | } |
| a9b2a64 | 88 | |
| a9b2a64 | 89 | class StyleList extends BaseList {
|
| a9b2a64 | 90 | private static final long serialVersionUID = 1L; |
| a9b2a64 | 91 | |
| a9b2a64 | 92 | public StyleList(){
|
| a9b2a64 | 93 | super("Styles", "LabelStyle", "ButtonStyle");
|
| a9b2a64 | 94 | } |
| a9b2a64 | 95 | |
| a9b2a64 | 96 | @Override |
| a9b2a64 | 97 | public void valueChanged(ListSelectionEvent arg0) {
|
| a9b2a64 | 98 | } |
| a9b2a64 | 99 | } |
| a9b2a64 | 100 | |
| a9b2a64 | 101 | class StyleTable extends BaseTable {
|
| a9b2a64 | 102 | private static final long serialVersionUID = 1L; |
| a9b2a64 | 103 | |
| a9b2a64 | 104 | public StyleTable(){
|
| a9b2a64 | 105 | super("Properties");
|
| a9b2a64 | 106 | } |
| a9b2a64 | 107 | |
| a9b2a64 | 108 | @Override |
| a9b2a64 | 109 | public void clear(String... items){
|
| a9b2a64 | 110 | super.clear("StyleName", "", "", "", "");
|
| a9b2a64 | 111 | } |
| a9b2a64 | 112 | } |