feat(D.2b): UiScrollbar (Type 11) — promote the generic chat scrollbar (widget-generalization Task 2)
- git mv UiChatScrollbar.cs → UiScrollbar.cs; rename class + update doc summary to "Generic scrollbar. Ports retail UIElement_Scrollbar (RegisterElementClass(0xb) @ acclient_2013_pseudo_c.txt:124137); thumb size = trackLen * ThumbRatio (min 8px); step ±1 line." - git mv UiChatScrollbarTests.cs → UiScrollbarTests.cs; rename test class + replace every UiChatScrollbar reference with UiScrollbar (bodies unchanged). - DatWidgetFactory: register Type 11 → new UiScrollbar() before the _ fallback case. - ChatWindowController: change Scrollbar property type to UiScrollbar; replace the old "construct-remove-add" block with a "find factory-built UiScrollbar and bind in place" block (no RemoveChild/AddChild); keep `var track` assignment in scope so the Max/Min block's track.Left/track.Width reads still compile against UiElement?. - AP-41 divergence register: update file:line to UiScrollbar.cs:35; narrow wording to "fallback only — single-tile drawn only when cap ids are unset; the chat controller passes all three cap ids so the 3-slice path is the active code path." - Update inline UiChatScrollbar doc-comment references in UiScrollable.cs + UiChatView.cs. - Full suite: 399 passed, 2 skipped (dat/tower fixture skips), 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d1b13a7dbf
commit
3593d6623d
8 changed files with 49 additions and 50 deletions
|
|
@ -97,6 +97,15 @@ public class DatWidgetFactoryTests
|
|||
Assert.Null(DatWidgetFactory.Create(noMedia, NoTex, null));
|
||||
}
|
||||
|
||||
// ── Test 5b: Type 11 → UiScrollbar ──────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void Type11_Scrollbar_MakesUiScrollbar()
|
||||
{
|
||||
var e = DatWidgetFactory.Create(new ElementInfo { Type = 11, Width = 16, Height = 68 }, NoTex, null);
|
||||
Assert.IsType<UiScrollbar>(e);
|
||||
}
|
||||
|
||||
// ── Test 6: Meter slice extraction (the important one) ───────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ using Xunit;
|
|||
namespace AcDream.App.Tests.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Pure unit tests for <see cref="UiChatScrollbar.ThumbRect"/> — no GL dependency.
|
||||
/// Pure unit tests for <see cref="UiScrollbar.ThumbRect"/> — no GL dependency.
|
||||
/// </summary>
|
||||
public class UiChatScrollbarTests
|
||||
public class UiScrollbarTests
|
||||
{
|
||||
// Model: content=400, view=100, trackLen=200.
|
||||
// ThumbRatio = 100/400 = 0.25 → thumbH = max(8, 200*0.25) = 50.
|
||||
|
|
@ -17,7 +17,7 @@ public class UiChatScrollbarTests
|
|||
{
|
||||
var m = new UiScrollable { ContentHeight = 400, ViewHeight = 100 };
|
||||
// PositionRatio = 0 (start).
|
||||
var (y, h) = UiChatScrollbar.ThumbRect(m, trackTop: 0f, trackLen: 200f);
|
||||
var (y, h) = UiScrollbar.ThumbRect(m, trackTop: 0f, trackLen: 200f);
|
||||
Assert.Equal(50f, h, 3f);
|
||||
Assert.Equal(0f, y, 3f);
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ public class UiChatScrollbarTests
|
|||
var m = new UiScrollable { ContentHeight = 400, ViewHeight = 100 };
|
||||
m.ScrollToEnd(); // PositionRatio = 1.
|
||||
float trackTop = 16f, trackLen = 200f;
|
||||
var (y, h) = UiChatScrollbar.ThumbRect(m, trackTop, trackLen);
|
||||
var (y, h) = UiScrollbar.ThumbRect(m, trackTop, trackLen);
|
||||
Assert.Equal(50f, h, 3f);
|
||||
// y = trackTop + travel * 1 = 16 + 150 = 166.
|
||||
Assert.Equal(166f, y, 3f);
|
||||
|
|
@ -41,7 +41,7 @@ public class UiChatScrollbarTests
|
|||
// thumbH=50; travel=150; y = trackTop + 150 = trackTop + 150.
|
||||
var m = new UiScrollable { ContentHeight = 400, ViewHeight = 100 };
|
||||
m.ScrollToEnd();
|
||||
var (y, h) = UiChatScrollbar.ThumbRect(m, trackTop: 16f, trackLen: 200f);
|
||||
var (y, h) = UiScrollbar.ThumbRect(m, trackTop: 16f, trackLen: 200f);
|
||||
Assert.Equal(50f, h, 3f);
|
||||
Assert.Equal(166f, y, 3f); // 16 + 150
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ public class UiChatScrollbarTests
|
|||
m.SetScrollY(150);
|
||||
Assert.Equal(0.5f, m.PositionRatio, 3);
|
||||
|
||||
var (y, h) = UiChatScrollbar.ThumbRect(m, trackTop: 0f, trackLen: 200f);
|
||||
var (y, h) = UiScrollbar.ThumbRect(m, trackTop: 0f, trackLen: 200f);
|
||||
Assert.Equal(50f, h, 3f);
|
||||
// y = 0 + 150 * 0.5 = 75.
|
||||
Assert.Equal(75f, y, 3f);
|
||||
|
|
@ -65,7 +65,7 @@ public class UiChatScrollbarTests
|
|||
{
|
||||
// content=1000, view=10, trackLen=200 → ThumbRatio=0.01 → raw=2 < 8 → clamp to 8.
|
||||
var m = new UiScrollable { ContentHeight = 1000, ViewHeight = 10 };
|
||||
var (_, h) = UiChatScrollbar.ThumbRect(m, trackTop: 0f, trackLen: 200f);
|
||||
var (_, h) = UiScrollbar.ThumbRect(m, trackTop: 0f, trackLen: 200f);
|
||||
Assert.Equal(8f, h, 3f);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public class UiChatScrollbarTests
|
|||
{
|
||||
// content <= view → ThumbRatio = 1 → thumbH = trackLen.
|
||||
var m = new UiScrollable { ContentHeight = 50, ViewHeight = 100 };
|
||||
var (y, h) = UiChatScrollbar.ThumbRect(m, trackTop: 16f, trackLen: 100f);
|
||||
var (y, h) = UiScrollbar.ThumbRect(m, trackTop: 16f, trackLen: 100f);
|
||||
Assert.Equal(100f, h, 3f);
|
||||
Assert.Equal(16f, y, 3f); // travel = 0 → y = trackTop
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue