PixelPaint: Draw layers from bottom of panel, adjust spacing

If we don't have enough layers to be able to scroll, the layers
are pushed to be at the top of the layer list. This doesn't make
much sense now that we are correctly drawing the layers in the
right order, so now we draw them justified towards the bottom.

Previously we were also clipping the bottom gadget slightly when
there were enough layers to scroll. Now, I'm adding some offset to
the total height to account for this and give equivalent spacing
from the top and bottom layers.
This commit is contained in:
Mustafa Quraish 2021-09-02 05:09:30 -04:00 committed by Andreas Kling
parent 339f0d5bca
commit 0c56f06994
Notes: sideshowbarker 2024-07-18 04:51:07 +09:00

View file

@ -316,7 +316,8 @@ void LayerListWidget::cycle_through_selection(int delta)
void LayerListWidget::relayout_gadgets()
{
int y = 0;
auto total_gadget_height = static_cast<int>(m_gadgets.size()) * vertical_step + 6;
int y = max(0, height() - total_gadget_height);
Optional<size_t> hole_index;
if (is_moving_gadget())
@ -333,7 +334,6 @@ void LayerListWidget::relayout_gadgets()
++index;
}
auto total_gadget_height = static_cast<int>(m_gadgets.size()) * vertical_step;
set_content_size({ widget_inner_rect().width(), total_gadget_height });
vertical_scrollbar().set_range(0, max(total_gadget_height - height(), 0));
update();