Skip to content

Commit 8a6c03d

Browse files
committed
Multiline tooltips.
1 parent 5a0789b commit 8a6c03d

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

src/gui.gloa

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export SPACING_LARGE :: 10
5050
local BUTTON_RADIUS :: 3
5151
local BUTTON_PADDING_Y :: 2
5252

53-
local SCROLLABLE_PADDING :: 5 -- Vertical.
54-
local SCROLLBAR_WIDTH :: 8
55-
local SCROLLBAR_MIN_LENGTH :: 30
53+
export SCROLLABLE_PADDING :: 5 -- Vertical.
54+
export SCROLLBAR_WIDTH :: 8
55+
export SCROLLBAR_MIN_LENGTH :: 16
5656

5757
local SECTION_LABEL_WIDTH :: 100
5858

@@ -1294,8 +1294,9 @@ export onMouseWheel :: (state:State, dx,dy:int) -> (handled:bool) {
12941294

12951295
if el ~= NULL {
12961296
local scrollable = cast(Scrollable) el
1297+
local maxDy = math.max(scrollable.layoutHeight - 2 * (SCROLLABLE_PADDING + SPACING), 10)
12971298
scrollable.scrollSource = scrollable.scroll
1298-
scrollable.scrollTarget = scrollable.scrollTarget + 50*dy
1299+
scrollable.scrollTarget = scrollable.scrollTarget + math.clamp(50*dy, -maxDy, maxDy)
12991300
limitScroll(scrollable)
13001301
return true
13011302
}
@@ -1798,7 +1799,7 @@ local drawElement :: (state:State, el:Element) {
17981799

17991800
-- Shadow.
18001801
do {
1801-
local shadowH = scrollable.scroll ? 30 : 10
1802+
local shadowH = math.min((scrollable.scroll ? 30 : 10), math.round(.4*scrollable.layoutHeight))
18021803
local iw, ih = imageGradient.getDimensions!()
18031804
local sx = shadowH / ih
18041805
local sy = (w + SPACING - SCROLLBAR_WIDTH) / iw
@@ -2476,10 +2477,13 @@ export draw :: (state:State) {
24762477
local a = math.clamp01(((LT.getTime() - state.tooltipTime) - .30) / 0.20)
24772478

24782479
if a > 0 {
2479-
local w = fontNormal.getWidth!(state.currentTooltip) + 2*SPACING
2480-
local h = fontNormal.getHeight!() + 2*BUTTON_PADDING_Y
2481-
local x = math.max(math.min(state.tooltipX, ww-w), 0)
2482-
local y = state.tooltipY1 - h - 1
2480+
local w, lines = fontNormal.getWrap!(state.currentTooltip, 100_000)
2481+
local fontH = fontNormal.getHeight!()
2482+
2483+
w += 2*SPACING
2484+
local h = fontH + math.ceil((#lines-1)*fontH*fontNormal.getLineHeight!()) + 2*BUTTON_PADDING_Y
2485+
local x = math.max(math.min(state.tooltipX, ww-w), 0)
2486+
local y = state.tooltipY1 - h - 1
24832487

24842488
if y < 0 y = state.tooltipY2 + 1
24852489

src/guiSetup.gloa

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
--=
1010
--============================================================]]
1111

12+
export MAIN_PANEL_WIDTH :: 450
13+
export DIALOG_WIDTH :: 400
14+
export DIALOG_WIDTH_LOG :: 700
15+
export DIALOG_WIDTH_EXPORT :: 550
16+
1217
local BIG_BUTTON_HEIGHT :: 40
1318
local MEDIUM_BUTTON_HEIGHT :: 16
1419

@@ -376,7 +381,7 @@ export setupGuiFrames :: () {
376381
}),
377382
}),
378383

379-
guiState.frame!({ name="exportProject", width=DIALOG_WIDTH, modal=true, layout=gui.Layout.FLOATING, active=false,
384+
guiState.frame!({ name="exportProject", width=DIALOG_WIDTH_EXPORT, modal=true, layout=gui.Layout.FLOATING, active=false,
380385
guiState.text!({ text="Export", size=3 }),
381386

382387
guiState.separator!({ thick=false }),
@@ -412,7 +417,9 @@ export setupGuiFrames :: () {
412417
}),
413418
guiState.inputText!({ name="exportProject_textures_directory", labelLeft="output folder", tooltip="Absolute path, or relative to base folder" }),
414419
guiState.hbox!({ labelLeft="resulting paths",
415-
guiState.text!({ name="exportProject_textures_pathResults", weight=1 }),
420+
guiState.scrollable!({ height=fontNormal.getHeight!()+2*(gui.SCROLLABLE_PADDING+gui.SPACING), weight=1,
421+
guiState.text!({ name="exportProject_textures_pathResults" }),
422+
}),
416423
guiState.buttons!({ name="exportProject_textures_pathResultsInfo", buttons={{image="iconEye"}} }),
417424
}),
418425
}),
@@ -456,7 +463,7 @@ export setupGuiFrames :: () {
456463
guiState.buttons!({ height=BIG_BUTTON_HEIGHT, buttons={{name="util_popPanel",label="Close"}} }),
457464
}),
458465

459-
guiState.frame!({ name="log", width=LOG_DIALOG_WIDTH, modal=true, layout=gui.Layout.FLOATING, active=false,
466+
guiState.frame!({ name="log", width=DIALOG_WIDTH_LOG, modal=true, layout=gui.Layout.FLOATING, active=false,
460467
guiState.text!({ text="Log", size=3 }),
461468

462469
guiState.separator!({ thick=false }),
@@ -515,13 +522,13 @@ export pushPanel :: (name:string) {
515522
insert(panelStack, name)
516523
}
517524

518-
export pushTempChoiceDialog :: (title:string, text:string, buttonList:[]gui.Button, cb:(choice:int), submitIndex=0, extraContent:gui.Element=NULL) {
525+
export pushTempChoiceDialog :: (title:string, text:string, buttonList:[]gui.Button, cb:(choice:int), submitIndex=0, extraContent:gui.Element=NULL, width=DIALOG_WIDTH) {
519526
static tempN = 0 ; tempN += 1
520527

521528
local name = format("temp%d", tempN)
522529
local nameButtons = name.."_buttons"
523530

524-
local frame = guiState.frame!({ name=name, temp=true, layout=gui.Layout.FLOATING, modal=true, width=DIALOG_WIDTH, active=false })
531+
local frame = guiState.frame!({ name=name, temp=true, layout=gui.Layout.FLOATING, modal=true, width=width, active=false })
525532
insert(guiState.frames, frame)
526533

527534
if title {
@@ -2523,7 +2530,7 @@ export setupGuiCallbacks :: () {
25232530
}
25242531
}
25252532

2526-
textEl.text = concatinate(paths, ", ")
2533+
textEl.text = concatinate(paths, "\n")
25272534
}
25282535
guiState.onRefresh.exportProject_textures_pathResultsInfo = (buttons:gui.Buttons) {
25292536
buttons.tooltip = guiState.getElement!("exportProject_textures_pathResults", gui.Text).text
@@ -2662,11 +2669,11 @@ export setupGuiCallbacks :: () {
26622669
)
26632670

26642671
local buttonList: []gui.Button
2665-
for filesToConfirmOverwrite insert(buttonList, cast(gui.Button){ label=it })
2672+
for filesToConfirmOverwrite insert(buttonList, cast(gui.Button){ label=it, tooltip=it })
26662673

26672674
local fileListEl = guiState.buttons!({ vertical=true, align=gui.Alignment.LEFT, style=gui.Style.LIST, buttons=buttonList })
26682675

2669-
pushTempChoiceDialog("Confirm export", text, BUTTONS, submitIndex=1, extraContent=fileListEl, [writeExportFiles] (choice:int) {
2676+
pushTempChoiceDialog("Confirm export", text, BUTTONS, submitIndex=1, extraContent=fileListEl, width=DIALOG_WIDTH_EXPORT, [writeExportFiles] (choice:int) {
26702677
if choice ~= 1 return
26712678

26722679
writeExportFiles()
@@ -3379,7 +3386,7 @@ export setupGuiCallbacks :: () {
33793386

33803387
guiState.onRefresh.log_text = (textEl:gui.Text) {
33813388
local s = concatinate(logStrings, "\n")
3382-
local _, lines = fontNormal.getWrap!(s, LOG_DIALOG_WIDTH-20) -- @Ugly
3389+
local _, lines = fontNormal.getWrap!(s, DIALOG_WIDTH_LOG-20) -- @Ugly
33833390
textEl.text = concatinate(lines, "\n")
33843391
}
33853392

src/main.gloa

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
local GIF_RECORDING_MODE :: DEV and 1==0
99
local GIF_FRAME_DELAY :: 2 -- 100th of a second. (Using 1 here seem troublesome and may make the GIF play very slowly for some reason.)
1010

11-
export APP_VERSION_STRING :: !run (getReleaseVersion())
12-
13-
export MAIN_PANEL_WIDTH :: 450
14-
export DIALOG_WIDTH :: 400
15-
export LOG_DIALOG_WIDTH :: 700
11+
export APP_VERSION_STRING :: !run (getReleaseVersion())
1612
export WORKSPACE_SAVE_DELAY :: 1.00
17-
18-
export WINDOW_TITLE :: !run format("Hot Particles %s%s", APP_VERSION_STRING, (DEV ? " [DEBUG]" : ""))
13+
export WINDOW_TITLE :: !run format("Hot Particles %s%s", APP_VERSION_STRING, (DEV ? " [DEBUG]" : ""))
1914

2015

2116

@@ -63,12 +58,12 @@ export LW :: love.window
6358
local LE :: love.event
6459

6560
export !self
61+
export !load "src/guiSetup"
6662
export !load "src/misc"
6763
export !load "src/workspace"
6864

6965
export gui :: !load "src/gui"
7066

71-
!load "src/guiSetup"
7267
!load "src/shared"
7368

7469

0 commit comments

Comments
 (0)