mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Hide overflowing address with ellipsis
This commit is contained in:
parent
2653a9f6a1
commit
d4665a5146
@ -6,6 +6,7 @@ import ocelot.desktop.graphics.Graphics
|
|||||||
import ocelot.desktop.ui.event.{KeyEvent, MouseEvent, ScrollEvent}
|
import ocelot.desktop.ui.event.{KeyEvent, MouseEvent, ScrollEvent}
|
||||||
import ocelot.desktop.ui.{MouseEvents, UiHandler}
|
import ocelot.desktop.ui.{MouseEvents, UiHandler}
|
||||||
import ocelot.desktop.util.{DrawUtils, Logging}
|
import ocelot.desktop.util.{DrawUtils, Logging}
|
||||||
|
import org.apache.commons.lang3.StringUtils
|
||||||
import totoro.ocelot.brain.entity.Screen
|
import totoro.ocelot.brain.entity.Screen
|
||||||
import totoro.ocelot.brain.user.User
|
import totoro.ocelot.brain.user.User
|
||||||
import totoro.ocelot.brain.util.PackedColor
|
import totoro.ocelot.brain.util.PackedColor
|
||||||
@ -125,7 +126,15 @@ class ScreenWindow(screen: Screen) extends BasicWindow with Logging {
|
|||||||
val col = (backgroundAlpha * 110).toShort
|
val col = (backgroundAlpha * 110).toShort
|
||||||
val alpha = (backgroundAlpha * 255).toShort
|
val alpha = (backgroundAlpha * 255).toShort
|
||||||
g.foreground = RGBAColor(col, col, col, alpha)
|
g.foreground = RGBAColor(col, col, col, alpha)
|
||||||
g.text(sx - 4, sy - 14, screen.node.address)
|
|
||||||
|
val freeSpace = ((w - 15) / 8).toInt
|
||||||
|
val addr = screen.node.address
|
||||||
|
val text = if (addr.length <= freeSpace)
|
||||||
|
addr
|
||||||
|
else
|
||||||
|
StringUtils.substring(addr, 0, (freeSpace - 1).max(0).min(addr.length)) + "…"
|
||||||
|
|
||||||
|
g.text(sx - 4, sy - 14, text)
|
||||||
g.setNormalFont()
|
g.setNormalFont()
|
||||||
|
|
||||||
g.sprite("window/CloseButton", sx + w - 7, sy - 13, 7, 6,
|
g.sprite("window/CloseButton", sx + w - 7, sy - 13, 7, 6,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user