Removed/Added window controls based on if "showWindowControls" option

was on/off. Removed reliance on the overlay mode for this.
master
sigonasr2 6 years ago
parent bd7a76a06f
commit 3ebdd94951
  1. BIN
      sigIRCv2.jar
  2. 36
      src/sig/Module.java
  3. 193
      src/sig/modules/ControllerModule.java
  4. 2
      src/sig/sigIRC.java

Binary file not shown.

@ -53,7 +53,7 @@ public class Module {
}
private void enableWindowDrag(int mouseX, int mouseY) {
if (!sigIRC.overlayMode && !dragging && inDragBounds(mouseX,mouseY) && !DRAGGING) {
if (sigIRC.showWindowControls && !dragging && inDragBounds(mouseX,mouseY) && !DRAGGING) {
//Enable dragging.
dragOffset = new Point((int)position.getX() - mouseX,(int)position.getY()-mouseY);
dragging=DRAGGING=true;
@ -104,21 +104,23 @@ public class Module {
}
private void dragWindow() {
if (dragging) {
//sigIRC.panel.repaint(getDrawBounds().getBounds());
int mouseX = sigIRC.panel.lastMouseX+(int)dragOffset.getX();
int mouseY = sigIRC.panel.lastMouseY+(int)dragOffset.getY();
int oldX = (int)position.getX();
int oldY = (int)position.getY();
position = new Rectangle((int)Math.min(Math.max(0,mouseX),sigIRC.window.getWidth()-position.getWidth()), (int)Math.min(Math.max(titleHeight,mouseY),sigIRC.window.getHeight()-position.getHeight()-titleHeight*2),(int)position.getWidth(),(int)position.getHeight());
//System.out.println(sigIRC.panel.lastMouseX+","+sigIRC.panel.lastMouseY);
ModuleDragEvent(oldX,oldY,mouseX,mouseY);
}
if (inDragBounds(sigIRC.panel.lastMouseX,sigIRC.panel.lastMouseY)) {
inDragZone=true;
//System.out.println("In Drag Zone for Module "+name);
//sigIRC.panel.setCursor(new Cursor(Cursor.MOVE_CURSOR));
} /*else
if (sigIRC.showWindowControls) {
if (dragging) {
//sigIRC.panel.repaint(getDrawBounds().getBounds());
int mouseX = sigIRC.panel.lastMouseX+(int)dragOffset.getX();
int mouseY = sigIRC.panel.lastMouseY+(int)dragOffset.getY();
int oldX = (int)position.getX();
int oldY = (int)position.getY();
position = new Rectangle((int)Math.min(Math.max(0,mouseX),sigIRC.window.getWidth()-position.getWidth()), (int)Math.min(Math.max(titleHeight,mouseY),sigIRC.window.getHeight()-position.getHeight()-titleHeight*2),(int)position.getWidth(),(int)position.getHeight());
//System.out.println(sigIRC.panel.lastMouseX+","+sigIRC.panel.lastMouseY);
ModuleDragEvent(oldX,oldY,mouseX,mouseY);
}
if (inDragBounds(sigIRC.panel.lastMouseX,sigIRC.panel.lastMouseY)) {
inDragZone=true;
//System.out.println("In Drag Zone for Module "+name);
//sigIRC.panel.setCursor(new Cursor(Cursor.MOVE_CURSOR));
}
}/*else
if (sigIRC.panel.getCursor().getType()==Cursor.MOVE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}*/
@ -141,7 +143,7 @@ public class Module {
}
private void drawModuleHeader(Graphics g) {
if (!sigIRC.overlayMode) {
if (sigIRC.showWindowControls) {
g.drawImage(Module.IMG_DRAGBAR,
(int)position.getX()+2,
(int)position.getY()-Module.IMG_DRAGBAR.getHeight(),

@ -103,8 +103,11 @@ public class ControllerModule extends Module{
}
//buttons.add(new Button(0.1,0.05,0.1,0.05,controllers.get(0),Identifier.Button._3,Color.RED,this));
LoadButtonAndAxisData();
click_buttons.add(new AddClickableButton(new Rectangle(
0,(int)position.getHeight()-21,96,20),"Add Button",this));
if (sigIRC.showWindowControls) {
click_buttons.add(new AddClickableButton(new Rectangle(
0,(int)position.getHeight()-21,96,20),"Add Button",this));
}
}
public List<Controller> getControllers() {
@ -382,106 +385,108 @@ public class ControllerModule extends Module{
public void run() {
Point mouse_position = new Point((int)(sigIRC.panel.lastMouseX-getPosition().getX()),(int)(sigIRC.panel.lastMouseY-getPosition().getY()));
if (resizing) {
PerformResize(mouse_position);
setConstraints();
}
if (dragging) {
selectedElement.setBounds(new Rectangle2D.Double((mouse_position.getX()+xoffset)/controller_img.getWidth(sigIRC.panel),
(mouse_position.getY()+yoffset)/controller_img.getHeight(sigIRC.panel),
selectedElement.getBounds().getWidth(),
selectedElement.getBounds().getHeight()));
setConstraints();
}
if (!inDragZone && selectedElement==null) {
if (findMouseoverElement(mouse_position)!=null) {
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.HAND_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
} else {
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.DEFAULT_CURSOR &&
!inDragZone) {
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
if (sigIRC.showWindowControls) {
if (resizing) {
PerformResize(mouse_position);
setConstraints();
}
}
if (selectedElement!=null && extendBoundaries(selectedElement.getPixelBounds(controller_img),3).contains(mouse_position)) {
if (!resizing) {
resizing_direction=0;
if (mouse_position.getY()-selectedElement.getPixelBounds(controller_img).getY()<=RESIZE_BORDER &&
mouse_position.getY()-selectedElement.getPixelBounds(controller_img).getY()>=-RESIZE_BORDER) {
resizing_direction+=1;
} else
if (mouse_position.getY()-(selectedElement.getPixelBounds(controller_img).getY()+selectedElement.getPixelBounds(controller_img).getHeight())<=RESIZE_BORDER &&
mouse_position.getY()-(selectedElement.getPixelBounds(controller_img).getY()+selectedElement.getPixelBounds(controller_img).getHeight())>=-RESIZE_BORDER) {
resizing_direction+=4;
}
if (mouse_position.getX()-selectedElement.getPixelBounds(controller_img).getX()<=RESIZE_BORDER &&
mouse_position.getX()-selectedElement.getPixelBounds(controller_img).getX()>=-RESIZE_BORDER) {
resizing_direction+=8;
} else
if (mouse_position.getX()-(selectedElement.getPixelBounds(controller_img).getX()+selectedElement.getPixelBounds(controller_img).getWidth())<=RESIZE_BORDER &&
mouse_position.getX()-(selectedElement.getPixelBounds(controller_img).getX()+selectedElement.getPixelBounds(controller_img).getWidth())>=-RESIZE_BORDER) {
resizing_direction+=2;
}
if (dragging) {
selectedElement.setBounds(new Rectangle2D.Double((mouse_position.getX()+xoffset)/controller_img.getWidth(sigIRC.panel),
(mouse_position.getY()+yoffset)/controller_img.getHeight(sigIRC.panel),
selectedElement.getBounds().getWidth(),
selectedElement.getBounds().getHeight()));
setConstraints();
}
switch (resizing_direction) {
case 1:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.N_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
}
}break;
case 2:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.E_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
}
}break;
case 3:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.NE_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR));
}
}break;
case 6:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.SE_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
}
}break;
case 4:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.S_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR));
}
}break;
case 12:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.SW_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR));
}
}break;
case 8:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.W_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
}
}break;
case 9:{
if (!inDragZone && selectedElement==null) {
if (findMouseoverElement(mouse_position)!=null) {
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.NW_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));
if (cursortype!=Cursor.HAND_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
}break;
default:
} else {
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.DEFAULT_CURSOR &&
if (cursortype!=Cursor.DEFAULT_CURSOR &&
!inDragZone) {
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
}
if (selectedElement!=null && extendBoundaries(selectedElement.getPixelBounds(controller_img),3).contains(mouse_position)) {
if (!resizing) {
resizing_direction=0;
if (mouse_position.getY()-selectedElement.getPixelBounds(controller_img).getY()<=RESIZE_BORDER &&
mouse_position.getY()-selectedElement.getPixelBounds(controller_img).getY()>=-RESIZE_BORDER) {
resizing_direction+=1;
} else
if (mouse_position.getY()-(selectedElement.getPixelBounds(controller_img).getY()+selectedElement.getPixelBounds(controller_img).getHeight())<=RESIZE_BORDER &&
mouse_position.getY()-(selectedElement.getPixelBounds(controller_img).getY()+selectedElement.getPixelBounds(controller_img).getHeight())>=-RESIZE_BORDER) {
resizing_direction+=4;
}
if (mouse_position.getX()-selectedElement.getPixelBounds(controller_img).getX()<=RESIZE_BORDER &&
mouse_position.getX()-selectedElement.getPixelBounds(controller_img).getX()>=-RESIZE_BORDER) {
resizing_direction+=8;
} else
if (mouse_position.getX()-(selectedElement.getPixelBounds(controller_img).getX()+selectedElement.getPixelBounds(controller_img).getWidth())<=RESIZE_BORDER &&
mouse_position.getX()-(selectedElement.getPixelBounds(controller_img).getX()+selectedElement.getPixelBounds(controller_img).getWidth())>=-RESIZE_BORDER) {
resizing_direction+=2;
}
}
switch (resizing_direction) {
case 1:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.N_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR));
}
}break;
case 2:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.E_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.E_RESIZE_CURSOR));
}
}break;
case 3:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.NE_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.NE_RESIZE_CURSOR));
}
}break;
case 6:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.SE_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
}
}break;
case 4:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.S_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.S_RESIZE_CURSOR));
}
}break;
case 12:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.SW_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.SW_RESIZE_CURSOR));
}
}break;
case 8:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.W_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.W_RESIZE_CURSOR));
}
}break;
case 9:{
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.NW_RESIZE_CURSOR) {
sigIRC.panel.setCursor(new Cursor(Cursor.NW_RESIZE_CURSOR));
}
}break;
default:
int cursortype = sigIRC.panel.getCursor().getType();
if (cursortype!=Cursor.DEFAULT_CURSOR &&
!inDragZone) {
sigIRC.panel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
}
}
for (Controller c : controllers) {

@ -100,7 +100,7 @@ public class sigIRC{
public static BackgroundColorButton button;
public static JFrame window;
static boolean overlayMode=false;
static boolean showWindowControls=false;
public static boolean showWindowControls=false;
static int windowX=0;
static int windowY=0;
static int windowWidth=0;

Loading…
Cancel
Save