Hide overlayed messages when mouse is moved on top of them to allow
clicks.
This commit is contained in:
parent
992be31560
commit
91c0d907ae
BIN
sigIRCv2.jar
BIN
sigIRCv2.jar
Binary file not shown.
@ -13,6 +13,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import java.awt.event.MouseWheelListener;
|
import java.awt.event.MouseWheelListener;
|
||||||
|
|
||||||
@ -26,6 +27,8 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
|
|||||||
final public static Font programFont = new Font(sigIRC.messageFont,0,24);
|
final public static Font programFont = new Font(sigIRC.messageFont,0,24);
|
||||||
final public static Font userFont = new Font(sigIRC.usernameFont,0,16);
|
final public static Font userFont = new Font(sigIRC.usernameFont,0,16);
|
||||||
final public static Font smallFont = new Font(sigIRC.touhoumotherConsoleFont,0,12);
|
final public static Font smallFont = new Font(sigIRC.touhoumotherConsoleFont,0,12);
|
||||||
|
int lastMouseX = 0;
|
||||||
|
int lastMouseY = 0;
|
||||||
|
|
||||||
public MyPanel() {
|
public MyPanel() {
|
||||||
//setBorder(BorderFactory.createLineBorder(Color.black));
|
//setBorder(BorderFactory.createLineBorder(Color.black));
|
||||||
@ -45,15 +48,26 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo
|
|||||||
// Draw Text
|
// Draw Text
|
||||||
//int counter=18;
|
//int counter=18;
|
||||||
for (int i=0;i<sigIRC.twitchemoticons.size();i++) {
|
for (int i=0;i<sigIRC.twitchemoticons.size();i++) {
|
||||||
if (sigIRC.twitchemoticons.get(i).isActive()) {
|
if (sigIRC.twitchemoticons.get(i).isActive() &&
|
||||||
|
sigIRC.twitchemoticons.get(i).textRefIsVisible()) {
|
||||||
sigIRC.twitchemoticons.get(i).draw(g);
|
sigIRC.twitchemoticons.get(i).draw(g);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (sigIRC.window!=null && sigIRC.window.getMousePosition(true)!=null && sigIRC.overlayMode) {
|
||||||
|
lastMouseX = (int)sigIRC.window.getMousePosition(true).getX();
|
||||||
|
lastMouseY = (int)sigIRC.window.getMousePosition(true).getY();
|
||||||
|
}
|
||||||
|
//System.out.println("("+lastMouseX+","+lastMouseY+")");
|
||||||
for (int i=0;i<sigIRC.textobj.size();i++) {
|
for (int i=0;i<sigIRC.textobj.size();i++) {
|
||||||
if (sigIRC.textobj.get(i).isActive()) {
|
if (sigIRC.textobj.get(i).isActive() && sigIRC.overlayMode) {
|
||||||
|
if (!sigIRC.textobj.get(i).intersects(lastMouseX,lastMouseY)) {
|
||||||
|
sigIRC.textobj.get(i).setVisible(true);
|
||||||
sigIRC.textobj.get(i).draw(g);
|
sigIRC.textobj.get(i).draw(g);
|
||||||
|
} else {
|
||||||
|
sigIRC.textobj.get(i).setVisible(false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ public class ScrollingText {
|
|||||||
private boolean isAlive=true;
|
private boolean isAlive=true;
|
||||||
private Color userColor;
|
private Color userColor;
|
||||||
private TextRow myRow;
|
private TextRow myRow;
|
||||||
|
private int textMaxWidth;
|
||||||
|
private int textMaxHeight;
|
||||||
|
private boolean visible=true;
|
||||||
|
|
||||||
public void setX(double x) {
|
public void setX(double x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -63,6 +66,10 @@ public class ScrollingText {
|
|||||||
return stringHeight;
|
return stringHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVisible() {
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
|
|
||||||
private int userstringWidth;
|
private int userstringWidth;
|
||||||
private int shadowSize;
|
private int shadowSize;
|
||||||
|
|
||||||
@ -149,6 +156,10 @@ public class ScrollingText {
|
|||||||
return isAlive;
|
return isAlive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVisible(boolean isVisible) {
|
||||||
|
this.visible=visible;
|
||||||
|
}
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
if (isAlive && WithinBounds(x,y,Math.max(TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth(), TextUtils.calculateStringBoundsFont(message, MyPanel.programFont).getWidth()),Math.max(TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getHeight(), TextUtils.calculateStringBoundsFont(message, MyPanel.programFont).getHeight()))) {
|
if (isAlive && WithinBounds(x,y,Math.max(TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getWidth(), TextUtils.calculateStringBoundsFont(message, MyPanel.programFont).getWidth()),Math.max(TextUtils.calculateStringBoundsFont(username, MyPanel.userFont).getHeight(), TextUtils.calculateStringBoundsFont(message, MyPanel.programFont).getHeight()))) {
|
||||||
//DrawUtils.drawTextFont(g, MyPanel.userFont, x+8, y+stringHeight-20, Color.GREEN, username);
|
//DrawUtils.drawTextFont(g, MyPanel.userFont, x+8, y+stringHeight-20, Color.GREEN, username);
|
||||||
@ -232,6 +243,8 @@ public class ScrollingText {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
textMaxWidth = (int)TextUtils.calculateStringBoundsFont(basemsg, sigIRC.panel.programFont).getWidth();
|
||||||
|
textMaxHeight = Math.max(textMaxHeight,(int)TextUtils.calculateStringBoundsFont(basemsg, sigIRC.panel.programFont).getHeight());
|
||||||
return basemsg;
|
return basemsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,9 +261,16 @@ public class ScrollingText {
|
|||||||
double width = TextUtils.calculateStringBoundsFont(cutstring, sigIRC.panel.programFont).getWidth();
|
double width = TextUtils.calculateStringBoundsFont(cutstring, sigIRC.panel.programFont).getWidth();
|
||||||
//System.out.println("Width of '"+cutstring+"' is "+width);
|
//System.out.println("Width of '"+cutstring+"' is "+width);
|
||||||
sigIRC.createEmoticon(e, this, (int)(width), 0);
|
sigIRC.createEmoticon(e, this, (int)(width), 0);
|
||||||
|
textMaxHeight = Math.max(textMaxHeight, e.getImage().getHeight());
|
||||||
|
//textMaxWidth = (int)(width + e.getImage().getWidth()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String GetUsername(String msg) {
|
private String GetUsername(String msg) {
|
||||||
return msg.substring(0,msg.indexOf(":"));
|
return msg.substring(0,msg.indexOf(":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean intersects(int x, int y) {
|
||||||
|
return (x>=this.x && x<=this.x+this.textMaxWidth &&
|
||||||
|
y>=this.y && y<=this.y+this.textMaxHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,8 @@ public class TwitchEmote {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean textRefIsVisible() {
|
||||||
|
return text.isVisible();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,6 +315,7 @@ public class sigIRC{
|
|||||||
f.setVisible(true);
|
f.setVisible(true);
|
||||||
f.setLocation(windowX, windowY);
|
f.setLocation(windowX, windowY);
|
||||||
f.setSize(windowWidth, windowHeight);
|
f.setSize(windowWidth, windowHeight);
|
||||||
|
|
||||||
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,64+rowobj.size()*rowSpacing);
|
button = new BackgroundColorButton(new File(sigIRC.BASEDIR+"backcolor.png"),panel.getX()+panel.getWidth()-96,64+rowobj.size()*rowSpacing);
|
||||||
if (sigIRC.overlayMode) {
|
if (sigIRC.overlayMode) {
|
||||||
f.setBackground(new Color(0,0,0,0));
|
f.setBackground(new Color(0,0,0,0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user