Keep center stage the widest pane on wide monitors
The stage had a fixed preferred width, so on a big monitor the panes beside it shared the leftover and grew wider than the chat on stage. The stage is now at least 1.5 times as wide as each other column.
This commit is contained in:
@@ -16,13 +16,19 @@ const double chatCenterStageWidth =
|
||||
/// and a vertical title.
|
||||
const double chatCenterStageStripMinimumWidth = 56;
|
||||
|
||||
/// How much wider than each pane beside it the stage is at least, so the
|
||||
/// stage stays the biggest pane on a wide monitor.
|
||||
const double chatCenterStageLeadFactor = 1.5;
|
||||
|
||||
/// The gap between the stage and each pane beside it.
|
||||
const double chatCenterStageGap = chatPaneDividerExtent;
|
||||
|
||||
/// Where every pane sits while one chat is on center stage. Panes keep their
|
||||
/// split-tree order left to right; the stage takes the full height and its
|
||||
/// preferred width (capped by the workspace), and the others share the rest
|
||||
/// as columns. A column narrower than a usable pane is shown as a strip.
|
||||
/// preferred width (capped by the workspace), widened when the workspace is
|
||||
/// so wide that the others would outgrow it: it is always at least
|
||||
/// [chatCenterStageLeadFactor] times as wide as each other column, which share
|
||||
/// the rest. A column narrower than a usable pane is shown as a strip.
|
||||
class ChatCenterStageLayout {
|
||||
ChatCenterStageLayout._(this.rects, this.strips, this.stageId);
|
||||
|
||||
@@ -45,8 +51,15 @@ class ChatCenterStageLayout {
|
||||
}
|
||||
final others = order.length - 1;
|
||||
final available = size.width - chatCenterStageGap * others;
|
||||
final leading =
|
||||
available *
|
||||
chatCenterStageLeadFactor /
|
||||
(others + chatCenterStageLeadFactor);
|
||||
final stage = math.min(
|
||||
chatCenterStageWidth + (paneExtraWidths?[activeId] ?? 0),
|
||||
math.max(
|
||||
chatCenterStageWidth + (paneExtraWidths?[activeId] ?? 0),
|
||||
leading,
|
||||
),
|
||||
available - others * chatCenterStageStripMinimumWidth,
|
||||
);
|
||||
if (stage < chatPaneMinimumWidth) return null;
|
||||
|
||||
@@ -200,15 +200,30 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('a very wide workspace keeps the stage and shows live columns', () {
|
||||
test('a very wide workspace keeps the stage the biggest pane', () {
|
||||
final layout = ChatCenterStageLayout.of(
|
||||
const Size(2560, 800),
|
||||
['a', 'b'],
|
||||
'a',
|
||||
null,
|
||||
)!;
|
||||
expect(layout.rects['a']!.width, 950);
|
||||
// 2548 usable: the stage takes 1.5 parts, the other pane 1.
|
||||
expect(layout.rects['a']!.width, closeTo(2548 * 1.5 / 2.5, 0.001));
|
||||
expect(layout.rects['b']!.width, closeTo(2548 / 2.5, 0.001));
|
||||
expect(layout.rects['b']!.right, 2560);
|
||||
expect(layout.strips, isEmpty);
|
||||
final three = ChatCenterStageLayout.of(
|
||||
const Size(3840, 800),
|
||||
['a', 'b', 'c'],
|
||||
'c',
|
||||
null,
|
||||
)!;
|
||||
for (final other in ['a', 'b']) {
|
||||
expect(
|
||||
three.rects['c']!.width,
|
||||
closeTo(three.rects[other]!.width * chatCenterStageLeadFactor, 0.001),
|
||||
);
|
||||
}
|
||||
expect(
|
||||
ChatCenterStageLayout.of(const Size(2560, 800), ['a'], 'a', null),
|
||||
isNull,
|
||||
@@ -233,7 +248,8 @@ void main() {
|
||||
'a',
|
||||
{'b': 300},
|
||||
)!;
|
||||
expect(switched.rects['a']!.width, chatCenterStageWidth);
|
||||
// 1588 usable: 1.5 parts of 2.5 just exceed the preferred width.
|
||||
expect(switched.rects['a']!.width, closeTo(1588 * 1.5 / 2.5, 0.001));
|
||||
|
||||
final closed = ChatCenterStageLayout.of(
|
||||
const Size(1600, 800),
|
||||
@@ -241,7 +257,7 @@ void main() {
|
||||
'b',
|
||||
null,
|
||||
)!;
|
||||
expect(closed.rects['b']!.width, chatCenterStageWidth);
|
||||
expect(closed.rects['b']!.width, closeTo(1588 * 1.5 / 2.5, 0.001));
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -378,12 +394,13 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
final staged = widthOf(tester, 'three');
|
||||
expect(staged, greaterThan(widthOf(tester, 'one')));
|
||||
await tester.tap(find.byKey(const ValueKey('action-one')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(workspace.activePane?.sessionId, 'three');
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
expect(widthOf(tester, 'three'), staged);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('input-one')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
Reference in New Issue
Block a user