当前位置: 首页 > news >正文

【Rust GUI开发入门】编写一个本地音乐播放器(10. 拼装UI组件)

本系列教程对应的代码已开源在 Github zeedle

将前文写的零散的UI组件(歌曲列表/播放控制面板/歌词面板/设置面板)拼装起来,组成最终的音乐播放器UI,用TabWidget分成多标签页,每一个标签页分担不同的功能:

player.png

export component MainWindow inherits Window {preferred-width: 850px;preferred-height: 500px;min-width: 850px;min-height: 500px;title: "Zeedle";icon: @image-url("cover.svg");callback toggle_play();callback play(SongInfo, TriggerSource);callback play_next();callback play_prev();callback change_progress(float);callback switch_mode(PlayMode);callback refresh_song_list(string);callback sort_song_list(SortKey, bool);callback set_lang(string);pure callback format_duration(float) -> string;public function set_light_theme(yes: bool) {UIState.light_ui = yes;if (yes) {Palette.color-scheme = ColorScheme.light;} else {Palette.color-scheme = ColorScheme.dark;}}tabs := TabWidget {Tab {title: @tr("Gallery");VerticalLayout {SongListView {ascending <=> UIState.sort_ascending;sort-key <=> UIState.sort_key;last-sort-key <=> UIState.last_sort_key;song-list <=> UIState.song_list;sort-songs(key, asc) => {root.sort_song_list(key, asc);}play-song(info, src) => {root.play(info, src);}}ControlPanel {max-height: 80px;min-height: 50px;preferred-height: 60px;progress <=> UIState.progress;duration <=> UIState.duration;paused <=> UIState.paused;dragging <=> UIState.dragging;play_mode <=> UIState.play_mode;current_song <=> UIState.current_song;album_image <=> UIState.album_image;change-progress(p) => {root.change_progress(p);root.focus();}toggle-play() => {root.toggle_play();}play-next() => {root.play_next();}play-prev() => {root.play_prev();}switch-mode(m) => {root.switch_mode(m);}double-clicked() => {tabs.current-index = 1; // 切换到歌词页}format-duration(d) => {return root.format_duration(d);}}}}Tab {title: @tr("Lyrics");Rectangle {width: 100%;height: 100%;z: -5;TouchArea {double-clicked => {tabs.current-index = 0; // 切换到歌曲列表页}}}LyricsPanel {width: 100%;height: 100%;album_image <=> UIState.album_image;current_song <=> UIState.current_song;lyrics <=> UIState.lyrics;progress <=> UIState.progress;lyric_viewport_y <=> UIState.lyric_viewport_y;}}Tab {title: @tr("Settings");SettingsPanel {width: 100%;height: 100%;song_dir <=> UIState.song_dir;lang <=> UIState.lang;light_ui <=> UIState.light_ui;refresh_song_list(p) => {root.refresh_song_list(p);}set_lang(l) => {root.set_lang(l);}set_light_theme(yes) => {root.set_light_theme(yes);}}}Tab {title: @tr("About");Text {width: 100%;height: 100%;font-size: 16px;text: UIState.about_info;horizontal-alignment: center;vertical-alignment: center;}}}
}
http://www.dtcms.com/a/426991.html

相关文章:

  • 【区块链】Fiat24 深度解读(含 Flutter 集成与 SDK 骨架)
  • 下载站推广谷歌搜索引擎网页版入口
  • Linux任务迁移函数和空闲负载均衡函数的实现
  • Web接入层的“铁三角”---防盗链、反向代理,负载均衡(nginx)
  • 精读 C++20 设计模式:行为型设计模式 — 访问者模式
  • 哪里可以做网站啊网站上传照片 传不上去
  • 鸿蒙NEXT NearLink Kit入门指南:重新定义短距无线通信
  • 微服务架构:基于Spring Cloud ,构建同城生活服务平台
  • 青岛网站推WordPress主题ao破解版
  • 做网站运营的简历网站开发补充协议 违约
  • Java-Spring入门指南(十三)SpringMVC基本概念与核心流程详解
  • Java Web实战 - 实现用户登录功能
  • 设计模式详解——工厂模式
  • 【大模型】KNighter: 内容审查 漏洞分析
  • WampServer下载安装教程(附安装包,图文并茂)
  • 基于matlab的直流电机调速系统仿真分析-一套
  • MVC 简介
  • c#设计模式—访问者模式
  • 【大数据实战】如何从0到1构建用户画像系统(案例+数据仓库+Airflow调度)
  • 打破数据枷锁:在AWS上解锁Oracle数据库的无限潜能
  • 广州网站推广公司wordpress备份恢复阿里云
  • 不用装专业软件!reaConverter:PSD 转 JPG、PDF 转图片
  • 大模型训练流程及GPU内存解析(110)
  • 学习Python中Selenium模块的基本用法(18:使用ActionChains操作鼠标)
  • 从UI到UE:企业级软件如何做出“高端感”的桌面端界面设计
  • 服务专业的建网站公司电话新站优化案例
  • QCustomPlot 核心功能与图表设置(下)——高级功能实现
  • 莱芜网站排名价格珠海高端网站建设
  • 运营商数据安全的垂直破局:技术适配与场景深耕的双重进化
  • 《Local_Pdf_Chat_RAG 深度学习笔记:PDF 本地化对话的 RAG 原理与实践》