Add API to create new widgets
This commit is contained in:
@@ -52,4 +52,12 @@ public final class ScriptID
|
||||
* </ul>
|
||||
*/
|
||||
public static final int RUNELITE_CHATBOX_INPUT_INIT = 10001;
|
||||
|
||||
/**
|
||||
* Does nothing
|
||||
*
|
||||
* This is used to eat events when you want a menu action attached to it
|
||||
* because you need an op listener attached to it for it to work
|
||||
*/
|
||||
public static final int NULL = 10003;
|
||||
}
|
||||
|
||||
30
runelite-api/src/main/java/net/runelite/api/WidgetType.java
Normal file
30
runelite-api/src/main/java/net/runelite/api/WidgetType.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.api;
|
||||
|
||||
public final class WidgetType
|
||||
{
|
||||
public static final int GRAPHIC = 5;
|
||||
}
|
||||
@@ -267,6 +267,11 @@ public interface Widget
|
||||
*/
|
||||
void setHidden(boolean hidden);
|
||||
|
||||
/**
|
||||
* The index of this widget in it's parent's children array
|
||||
*/
|
||||
int getIndex();
|
||||
|
||||
/**
|
||||
* Gets the location the widget is being drawn on the canvas.
|
||||
* <p>
|
||||
@@ -354,14 +359,46 @@ public interface Widget
|
||||
*/
|
||||
boolean contains(Point point);
|
||||
|
||||
/**
|
||||
* Gets the amount of pixels the widget is scrolled in the X axis
|
||||
*/
|
||||
int getScrollX();
|
||||
|
||||
/**
|
||||
* Sets the amount of pixels the widget is scrolled in the X axis
|
||||
*/
|
||||
void setScrollX(int scrollX);
|
||||
|
||||
/**
|
||||
* Gets the amount of pixels the widget is scrolled in the Y axis
|
||||
*/
|
||||
int getScrollY();
|
||||
|
||||
/**
|
||||
* sets the amount of pixels the widget is scrolled in the Y axis
|
||||
*/
|
||||
void setScrollY(int scrollY);
|
||||
|
||||
/**
|
||||
* Gets the size of the widget's viewport in the X axis
|
||||
*/
|
||||
int getScrollWidth();
|
||||
|
||||
/**
|
||||
* Sets the size of the widget's viewport in the X axis
|
||||
*/
|
||||
void setScrollWidth(int width);
|
||||
|
||||
/**
|
||||
* Gets the size of the widget's viewport in the Y axis
|
||||
*/
|
||||
int getScrollHeight();
|
||||
|
||||
/**
|
||||
* Sets the size of the widget's viewport in the Y axis
|
||||
*/
|
||||
void setScrollHeight(int height);
|
||||
|
||||
/**
|
||||
* Gets the original x-axis coordinate.
|
||||
*
|
||||
@@ -452,4 +489,53 @@ public interface Widget
|
||||
* @return the actions
|
||||
*/
|
||||
String[] getActions();
|
||||
|
||||
/**
|
||||
* Creates a dynamic widget child
|
||||
*
|
||||
* @param index the index of the new widget in the children list or -1 to append to the back
|
||||
* @param type the type of the widget
|
||||
*/
|
||||
Widget createChild(int index, int type);
|
||||
|
||||
/**
|
||||
* Creates a menu action on the widget
|
||||
*
|
||||
* @param index The index of the menu
|
||||
* @param action The string to be displayed next to the widget's name in the context menu
|
||||
*/
|
||||
void setAction(int index, String action);
|
||||
|
||||
/**
|
||||
* Sets a script to be ran when the a menu action is clicked.
|
||||
* hasListener must be true for this to take effect
|
||||
*
|
||||
* @param args A ScriptID, then the args for the script
|
||||
*/
|
||||
void setOnOpListener(Object ...args);
|
||||
|
||||
/**
|
||||
* If this widget has any listeners on it
|
||||
*/
|
||||
boolean hasListener();
|
||||
|
||||
/**
|
||||
* Sets if the widget has any listeners. This should be called whenever a setXListener function is called
|
||||
*/
|
||||
void setHasListener(boolean hasListener);
|
||||
|
||||
/**
|
||||
* This is true if the widget is from an if3 interface, or is dynamically created
|
||||
*/
|
||||
boolean isIf3();
|
||||
|
||||
/**
|
||||
* Recomputes this widget's x/y/w/h, excluding scroll
|
||||
*/
|
||||
void revalidate();
|
||||
|
||||
/**
|
||||
* Recomputes this widget's group's x/y/w/h including scroll
|
||||
*/
|
||||
void revalidateScroll();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user