37 const char TU_ReaderSettingUI[]{u8R
"NPL(root
38 ($type "TabControl")($bounds "8 24 240 160")
42 ($type "Button")($bounds "12 12 80 22"))
44 ($type "Button")($bounds "148 12 80 22"))
46 ($type "Button")($bounds "12 44 80 22"))
48 ($type "Button")($bounds "148 44 80 22"))
50 ($type "Button")($bounds "12 76 80 22"))
52 ($type "DropDownList")($bounds "148 76 80 22"))
57 ($type "DropDownList")($bounds "12 12 192 22"))
62 ($type "CheckButton")($bounds "12 12 72 18"))
64 ($type "DropDownList")($bounds "84 12 128 22"))
72 using std::chrono::milliseconds;
81 return String(
to_string(pr.first) +
": ") + pr.second;
90 lblAreaUp({20, 12, 216, 72}), lblAreaDown({20, 108, 216, 72}),
91 boxColor(
Point(4, 80)), pColor(), current_encoding(),
92 scroll_duration(), smooth_scroll_duration()
95 auto& node(dynWgts.WidgetNode);
97 auto& node_pnlPage1(AccessWidgetNode(node, "pnlPage1"));
98 auto& node_pnlPage2(AccessWidgetNode(node, "pnlPage2"));
99 auto& node_pnlPage3(AccessWidgetNode(node, "pnlPage3"));
109 const auto set_font_size([this](
FontSize size){
110 lblAreaUp.Font.SetSize(size),
111 lblAreaDown.Font.SetSize(size);
120 root.UpdateTabPages();
121 for(
const auto& p_pnl : root.GetPages())
126 SetVisibleOf(boxColor,
false),
132 root.Background =
nullptr,
133 btnFontSizeDecrease.Text = u
"减小字体",
134 btnFontSizeIncrease.Text = u
"增大字体",
135 btnSetUpBack.Text = u
"上屏颜色...",
136 btnSetDownBack.Text = u
"下屏颜色...",
137 btnTextColor.Text = u
"文字颜色...",
138 cbSmoothScroll.Text = u
"平滑滚屏",
143 FetchEvent<KeyDown>(*
this) += OnEvent_StopRouting<KeyEventArgs>,
144 FetchEvent<KeyHeld>(*
this) += OnEvent_StopRouting<KeyEventArgs>,
145 FetchEvent<Click>(btnFontSizeDecrease) += [
this, set_font_size]{
146 auto size(lblAreaUp.Font.GetSize());
148 if(YB_LIKELY(size > Font::MinimalSize))
149 set_font_size(--size);
151 FetchEvent<Click>(btnFontSizeIncrease) += [
this, set_font_size]{
152 auto size(lblAreaUp.Font.GetSize());
154 if(YB_LIKELY(size < Font::MaximalSize))
155 set_font_size(++size);
157 FetchEvent<Click>(btnTextColor) += [
this]{
158 boxColor.SetColor(*(pColor = &lblAreaUp.ForeColor));
161 FetchEvent<Click>(btnSetUpBack) += [
this]{
163 *(pColor = &lblAreaUp.Background.target<SolidBrush>()->Color));
166 FetchEvent<Click>(btnSetDownBack) += [
this]{
168 *(pColor = &lblAreaDown.Background.target<SolidBrush>()->Color));
171 ddlFont.GetConfirmed() += [&,
this]{
173 .GetFontFamilyPtr(ddlFont.Text.GetMBCS().c_str()))
175 lblAreaUp.Font = Font(*p, lblAreaUp.Font.GetSize());
176 lblAreaDown.Font = lblAreaUp.Font;
189 static yconstexpr auto fetch_scroll_durations([](
bool is_smooth)
191 const auto postfix(is_smooth ? u
"毫秒/像素行" : u
"毫秒/文本行");
192 auto& lst(*
new TextList::ListType(20U));
193 const u16 delta(is_smooth ? 10 : 100);
196 std::generate(lst.begin(), lst.end(), [&, is_smooth, delta]{
197 return String(
to_string(t += delta)) + postfix;
202 ddlScrollTiming.SetList(e.Value ? get_init<true>(fetch_scroll_durations,
203 true) : get_init<false>(fetch_scroll_durations,
false));
204 ddlScrollTiming.Text = ddlScrollTiming.GetList()[(e.Value
205 ? smooth_scroll_duration.count() / 10U : scroll_duration.count()
210 if(cbSmoothScroll.IsTicked())
211 smooth_scroll_duration = milliseconds((e.Value + 1U) * 10);
213 scroll_duration = milliseconds((e.Value + 1U) * 100);
216 FetchEvent<Click>(boxColor.btnOK) += [
this]{
220 *pColor = boxColor.GetColor();
221 lblAreaDown.ForeColor = lblAreaUp.ForeColor;
243 ddlFont.Text = s.
Font.GetFamilyName(),
248 : CheckBox::Unchecked);
std::chrono::milliseconds ScrollDuration
滚屏间隔。
typename ListType::size_type IndexType
索引类型。
GValueEventArgs< MTextList::IndexType > IndexEventArgs
索引事件。
yconstexpr EncodingInfoItem Encodings[]
编码信息。
size_t arrlen(_type(&)[_vN])
计算指定数组类型对象的长度。
YF_API void Invalidate(IWidget &, const Rect &)
无效化:使相对于部件的指定区域在直接和间接的窗口缓冲区中无效。
Label lblAreaUp
标签:文本区域示例。
MSelector::SelectedArgs TickedArgs
选择框选中状态参数类型。
std::shared_ptr< _type > share_raw(const _pSrc &p)
YF_API void OnTouchHeld_Dragging(CursorEventArgs &&)
处理屏幕接触移动事件:拖放按下部件。
yconstexpr EventPriority BoundaryPriority(0x60)
YF_API shared_ptr< UI::TextList::ListType > FetchFontFamilyNames()
取字型家族名称。
SettingPanel & operator<<(const ReaderSetting &)
读取设置。
void AddWidgets(_tCon &con, _tWidgets &...wgts)
向部件容器添加子部件。
std::chrono::milliseconds smooth_scroll_duration
平滑滚屏间隔。
#define DeclDynWidgetN(_t, _n,...)
声明指定节点下的按相同名称访问的动态部件。
const second_tag get_value
YSLib 标准字符串(使用 UCS-2 作为内部编码)。
GBinaryGroup< SPos > Point
屏幕二维点(直角坐标表示)。
#define yunseq
无序列依赖表达式组求值。
WidgetLoader & FetchWidgetLoader()
YF_API Drawing::FontCache & FetchDefaultFontCache()
取默认字体缓存。
#define DeclDynWidget(_t, _n,...)
声明动态部件。
auto get_init(_fInit &&f, _tParams &&...args) -> decltype(f(std::forward< decltype(args)>(args)...))&
取类型标识和初始化调用指定的对象。
std::string to_string(unsigned char val)
转换为字符串。
String FetchEncodingString(MTextList::IndexType)
取编码字符串。
std::chrono::milliseconds SmoothScrollDuration
平滑滚屏间隔。
#define yconstexpr
指定编译时常量表达式。
void AddButtonToTabBar(TabControl &, const ValueNode &, const string &, const String &, SDst=64)
向标签栏和节点添加按钮。
std::chrono::milliseconds scroll_duration
滚屏间隔。
#define DeclDynWidgetNode(_t, _n)
声明名称为 node 的节点下的按相同名称访问的动态部件。
SettingPanel & operator>>(ReaderSetting &)
保存设置。