[raiguard][1.1.49] Multi-line labels cause strange behavior with scroll panes and stretching

Post Reply
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

[raiguard][1.1.49] Multi-line labels cause strange behavior with scroll panes and stretching

Post by raiguard »



To reproduce

1. Download Task List (requires the Factorio library)
2. Create a task with a very long description (lorem ipsum works nicely)
3. Observe the above effects

I attempted to reproduce this with a simple test mod, but failed. Something in the combination of elements and layouts in Task List is causing this, but I haven't been able to figure out exactly what. Here is the layout of a task item in the mod's code.

Bug 1: Scroll pane height

As you can see, the added height of the multi-line label is not communicated to the scroll pane at all, so rather than stretching until it hits max height (which in this case is 900), it immediately initiates scrolling. The expected behavior is that it would stretch like it normally does until it his max height, and only then would it start scrolling.

Bug 2: horizontally_stretchable

The content of the scroll pane uses horizontally_stretchable with a twelve-pixel padding on the scroll pane's content flow. However, when the label wraps, the stretching is reduced to the width of the label itself. You can see this in the above video by comparing looking at the distance between the expand button and the scroll bar - it is much more than twelve pixels. It also happens to line up perfectly with the width of the description label.

Then, if you scroll down, the subtasks are going all the way right, and the padding is gone for them. You cannot click the expand buttons because they're outside of the scroll pane's content flow.

The expected behavior is that it would stretch until it hits the twelve-pixel padding on the scroll pane.
Attachments
scroll pane height.mp4
(59.9 KiB) Downloaded 167 times
Don't forget, you're here forever.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: [raiguard][1.1.49] Multi-line labels cause strange behavior with scroll panes and stretching

Post by raiguard »

Bug 2 was inadvertantly fixed by 102254! Bug 1 is still present though.
Don't forget, you're here forever.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: [raiguard][1.1.49] Multi-line labels cause strange behavior with scroll panes and stretching

Post by raiguard »

Simple reproduction of bug 1:

Code: Select all

local long_caption =
  "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in blandit sapien. Nulla suscipit hendrerit consectetur."

--- @param e EventData.on_player_created
local function on_player_created(e)
  local player = game.get_player(e.player_index)
  if not player then
    return
  end
  if player.gui.screen.test_window then
    return
  end

  local window = player.gui.screen.add({ type = "frame", name = "test_window" })
  window.style.size = 300
  window.force_auto_center()

  local content_frame = window.add({
    type = "frame",
    style = "inside_shallow_frame",
  })
  content_frame.style.vertically_stretchable = true

  local scroll_pane = content_frame.add({
    type = "scroll-pane",
    style = "only_inner_shadow_scroll_pane",
  })
  scroll_pane.style.padding = 8

  local string = scroll_pane.add({ type = "label", caption = long_caption })
  string.style.single_line = false
end

script.on_event(defines.events.on_player_created, on_player_created)
image.png
image.png (235.19 KiB) Viewed 830 times
Don't forget, you're here forever.

Post Reply

Return to “Assigned”