Changes scrollable tabs forward/backward icons if new message is received and the tab is not in the visible list of opened chat tabs, a problem where user can miss messages if too many open tabs exist.

cusax-fix 4834
Damian Minkov 12 years ago
parent 3bc2321407
commit 1460e91541

@ -40,6 +40,8 @@ service.gui.icons.FONT_ICON=resources/images/impl/gui/buttons/fontIcon.png
service.gui.icons.ADD_CONTACT_CHAT_ICON=resources/images/impl/gui/buttons/addContactChatIcon.png
service.gui.icons.CHAT_CONFIGURE_ICON=resources/images/impl/gui/buttons/chatConfigureIcon.png
service.gui.icons.WARNING_ICON=resources/images/impl/gui/common/warning.png
service.gui.icons.TAB_UNREAD_FORWARD_ICON=resources/images/impl/gui/common/tabForward.png
service.gui.icons.TAB_UNREAD_BACKWARD_ICON=resources/images/impl/gui/common/tabBackward.png
service.gui.icons.ERROR_ICON=resources/images/impl/gui/common/error.png
service.gui.icons.INFO_ICON=resources/images/impl/gui/common/info.png
service.gui.icons.SEND_MESSAGE_16x16_ICON=resources/images/impl/gui/common/sendMessage16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -412,17 +412,96 @@ public void paint(Graphics g)
// Draw the arrow
size = Math.min((h - 4) / 3, (w - 4) / 3);
size = Math.max(size, 2);
paintTriangle(g, (w - size) / 2, (h - size) / 2, size, direction,
isEnabled);
boolean highlight = false;
if(!highlightedTabs.isEmpty() &&
((direction == WEST
&& tabScroller.scrollBackwardButton.isEnabled())
|| (direction == EAST
&& tabScroller.scrollForwardButton.isEnabled())))
{
Rectangle viewRect = tabScroller.viewport.getViewRect();
if(direction == WEST)
{
int leadingTabIndex = getClosestTab(viewRect.x, viewRect.y);
for(int i = 0; i < leadingTabIndex; i++)
{
if(highlightedTabs.contains(i)
&& !isScrollTabVisible(i))
{
highlight = true;
break;
}
}
}
else
{
int leadingTabIndex =
getClosestTab(viewRect.x + viewRect.y, viewRect.y);
for(int i = leadingTabIndex; i < tabPane.getTabCount(); i++)
{
if(highlightedTabs.contains(i)
&& !isScrollTabVisible(i))
{
highlight = true;
break;
}
}
}
if(highlight)
{
Image img = DesktopUtilActivator.getImage(
direction == WEST ?
"service.gui.icons.TAB_UNREAD_BACKWARD_ICON"
: "service.gui.icons.TAB_UNREAD_FORWARD_ICON");
int wi = img.getWidth(null);
g.drawImage(img,
(w - wi)/2,
(h - size) / 2 - 2/* 2 borders 1px width*/,
null);
}
}
if(!highlight)
paintTriangle(g, (w - size) / 2, (h - size) / 2,
size, direction, isEnabled);
// Reset the Graphics back to it's original settings
if (isPressed) {
g.translate(-1, -1);
}
g.setColor(origColor);
}
}
/**
* Checks whether the <tt>tabIndex</tt> is visible in the scrollable
* tabs list.
*
* @param tabIndex the tab index to check.
* @return whether <tt>tabIndex</tt> is visible in the list of scrollable
* tabs.
*/
private boolean isScrollTabVisible(int tabIndex)
{
Rectangle tabRect = rects[tabIndex];
Rectangle viewRect = tabScroller.viewport.getViewRect();
if ((tabRect.x + tabRect.width - BUTTONSIZE < viewRect.x)
|| (tabRect.x + BUTTONSIZE > viewRect.x + viewRect.width))
{
return false;
}
else
{
return true;
}
}
@Override

@ -863,7 +863,7 @@ public int getOverTabIndex()
* Returns the index of the tab closest to the passed in location, note that
* the returned tab may not contain the location x,y.
*/
private int getClosestTab(int x, int y)
protected int getClosestTab(int x, int y)
{
int min = 0;
int tabCount = Math.min(rects.length, tabPane.getTabCount());
@ -1358,7 +1358,7 @@ protected void calculateTabRects(int tabPlacement, int tabCount)
}
}
private class ScrollableTabSupport implements ChangeListener
protected class ScrollableTabSupport implements ChangeListener
{
public ScrollableTabViewport viewport;
@ -1471,7 +1471,7 @@ public String toString()
}
private static class ScrollableTabViewport
protected static class ScrollableTabViewport
extends JViewport
implements UIResource
{

Loading…
Cancel
Save