- 候选窗:深色 #2C2C2C 底、#383838 选中底、#E183D9 紫色选中条,序号与候选同字号, 横排每项最小 4.35em、间距 0.28em(换行的行间同样隔 0.28em);尺寸均按字号缩放 - 翻页:默认开启,实心圆角三角,与候选行等高,横排前加分隔线 - 悬浮工具栏沿用默认页面,拖拽条改为紫色 - ui:PagerArrows 新增 Glyph::Triangle 与分隔线,三角用单一路径填充,半透明时不出现描边重叠; CandidateList 新增 minItemWidth 与 selectedBarInside - 设置页新增皮肤卡片与预览;更新内置皮肤列表、文档与配置注释,补充测试
87 lines
3.0 KiB
C++
87 lines
3.0 KiB
C++
#include "tests/includes/test_framework.h"
|
|
|
|
#include "msimeui/Controls.h"
|
|
#include "msimeui/Layout.h"
|
|
|
|
#include <cmath>
|
|
#include <memory>
|
|
|
|
using namespace msimeui;
|
|
|
|
namespace
|
|
{
|
|
std::shared_ptr<PagerArrows> MakePager()
|
|
{
|
|
auto pager = std::make_shared<PagerArrows>();
|
|
PagerArrows::Appearance appearance;
|
|
appearance.buttonWidth = 10.0f;
|
|
appearance.buttonHeight = 12.0f;
|
|
appearance.gap = 2.0f;
|
|
pager->SetAppearance(appearance);
|
|
return pager;
|
|
}
|
|
} // namespace
|
|
|
|
TEST_CASE(PagerArrowsMeasuresTwoButtonsAndGap)
|
|
{
|
|
auto pager = MakePager();
|
|
const SizeF measured = pager->MeasureInLayout({500.0f, 500.0f});
|
|
REQUIRE_NEAR(measured.width, 22.0f);
|
|
REQUIRE_NEAR(measured.height, 12.0f);
|
|
}
|
|
|
|
TEST_CASE(PagerArrowsKeepButtonsInTrailingBottomCorner)
|
|
{
|
|
auto pager = MakePager();
|
|
pager->MeasureInLayout({500.0f, 500.0f});
|
|
// A slot larger than the buttons, as a stretched list row would hand it.
|
|
pager->Arrange({100.0f, 50.0f, 40.0f, 30.0f});
|
|
|
|
const RectF next = pager->GetPartBounds(PagerArrows::Part::Next);
|
|
const RectF previous = pager->GetPartBounds(PagerArrows::Part::Previous);
|
|
REQUIRE_NEAR(next.x, 130.0f);
|
|
REQUIRE_NEAR(next.y, 68.0f);
|
|
REQUIRE_NEAR(previous.x, 118.0f);
|
|
REQUIRE_NEAR(previous.y, 68.0f);
|
|
|
|
REQUIRE(pager->HitTestPart({135.0f, 74.0f}) == PagerArrows::Part::Next);
|
|
REQUIRE(pager->HitTestPart({121.0f, 74.0f}) == PagerArrows::Part::Previous);
|
|
// The gap between the buttons and the empty rest of the slot are not buttons.
|
|
REQUIRE(pager->HitTestPart({129.0f, 74.0f}) == PagerArrows::Part::None);
|
|
REQUIRE(pager->HitTestPart({105.0f, 55.0f}) == PagerArrows::Part::None);
|
|
REQUIRE(!pager->HitTest({105.0f, 55.0f}));
|
|
}
|
|
|
|
TEST_CASE(PagerArrowsDividerTakesRoomBeforeButtons)
|
|
{
|
|
auto pager = std::make_shared<PagerArrows>();
|
|
PagerArrows::Appearance appearance;
|
|
appearance.buttonWidth = 10.0f;
|
|
appearance.buttonHeight = 12.0f;
|
|
appearance.glyph = PagerArrows::Glyph::Triangle;
|
|
appearance.glyphSize = 10.0f;
|
|
appearance.dividerWidth = 1.0f;
|
|
appearance.dividerGap = 3.0f;
|
|
pager->SetAppearance(appearance);
|
|
const SizeF measured = pager->MeasureInLayout({500.0f, 500.0f});
|
|
REQUIRE_NEAR(measured.width, 24.0f);
|
|
REQUIRE_NEAR(measured.height, 12.0f);
|
|
REQUIRE_NEAR(appearance.GlyphWidth(), 8.4f);
|
|
|
|
// The divider is drawn left of the buttons, so the buttons still sit in the trailing corner.
|
|
pager->Arrange({0.0f, 0.0f, 24.0f, 12.0f});
|
|
REQUIRE_NEAR(pager->GetPartBounds(PagerArrows::Part::Previous).x, 4.0f);
|
|
REQUIRE(pager->HitTestPart({2.0f, 6.0f}) == PagerArrows::Part::None);
|
|
}
|
|
|
|
TEST_CASE(PagerArrowsTrackEnabledParts)
|
|
{
|
|
auto pager = MakePager();
|
|
REQUIRE(pager->IsPartEnabled(PagerArrows::Part::Previous));
|
|
REQUIRE(pager->IsPartEnabled(PagerArrows::Part::Next));
|
|
pager->SetEnabled(false, true);
|
|
REQUIRE(!pager->IsPartEnabled(PagerArrows::Part::Previous));
|
|
REQUIRE(pager->IsPartEnabled(PagerArrows::Part::Next));
|
|
REQUIRE(!pager->IsPartEnabled(PagerArrows::Part::None));
|
|
}
|