diff --git a/.gitignore b/.gitignore index 0069d4f8bd248ac6423bd52923ecbb83c1234897..5324a23f88f18531068b28b77312adb8052b7e5c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,11 @@ install/x86_64 install/x86_32 install/arm_64 install/arm_32 +install/build_x86_64 +install/build_x86_32 +install/build_arm_64 +install/build_arm_32 +install/build install/system CMakeFiles/ .cmake/ @@ -14,25 +19,25 @@ cmake_install.cmake CMakeCache.txt Makefile CMakeCache.txt-0 -examples/TpGUI/tpSlider/slider -examples/TpGUI/tpAnimation/animation +examples/TpGUI/TpSlider/slider +examples/TpGUI/TpAnimation/animation examples/TpGUI/deleteLaterTest/test examples/TpGUI/fixsrceen/fixscreen examples/TpGUI/layout/layout examples/TpGUI/link/link examples/TpGUI/listwidget/listwidget -examples/TpGUI/tpLine/line -examples/TpGUI/tpLineEdit/lineedit -examples/TpGUI/tpListCheckBoxGroup/listCheckBoxGroup -examples/TpGUI/tpMediaTileButton/button -examples/TpGUI/tpMenu/menu -examples/TpGUI/tpMenuPanelWidget/menuPanelWidget -examples/TpGUI/tpMessgaeBox/tpMessgaeBox -examples/TpGUI/tpPercentProgressBar/progressBar -examples/TpGUI/tpProgressBar/progress -examples/TpGUI/tpRadioButton/radiobutton -examples/TpGUI/tpTabWidget/tabWidget -examples/TpGUI/tpVirtualKeyboard/virtualKeyboard +examples/TpGUI/TpLine/line +examples/TpGUI/TpLineEdit/lineedit +examples/TpGUI/TpListCheckBoxGroup/listCheckBoxGroup +examples/TpGUI/TpMediaTileButton/button +examples/TpGUI/TpMenu/menu +examples/TpGUI/TpMenuPanelWidget/menuPanelWidget +examples/TpGUI/TpMessgaeBox/TpMessgaeBox +examples/TpGUI/TpPercentProgressBar/progressBar +examples/TpGUI/TpProgressBar/progress +examples/TpGUI/TpRadioButton/radiobutton +examples/TpGUI/TpTabWidget/tabWidget +examples/TpGUI/TpVirtualKeyboard/virtualKeyboard examples/TpGUI/treewidget/treewidget TpUtils/cmake_install.cmake @@ -55,28 +60,25 @@ TpWM/cmake_install.cmake TpWM/Makefile TpWM/CMakeFiles/ -examples/TpUtils/tpThreadPool/threadPool +examples/TpUtils/TpThreadPool/threadPool examples/TpUtils/cssParser/cssParser examples/TpUtils/cssParser/main examples/TpUtils/fileDirTest/fileTest examples/TpUtils/jsonParser/jsonParser -examples/TpUtils/tpGateway/client1 -examples/TpUtils/tpGateway/client1Main -examples/TpUtils/tpGateway/client2 -examples/TpUtils/tpInputMethod/inputMethod -examples/TpUtils/tpProcess/process -examples/TpUtils/tpString/tpString +examples/TpUtils/TpInputMethod/inputMethod +examples/TpUtils/TpProcess/process +examples/TpUtils/TpString/TpString examples/TpUtils/variant/variant -examples/TpGUI/tpButton/button +examples/TpGUI/TpButton/button install_manifest.txt examples/TpGUI/scroll/scroll examples/TpGUI/scrollpanel/scrollpanel -examples/TpGUI/tpCheckBox/checkbox -examples/TpGUI/tpLabel/label +examples/TpGUI/TpCheckBox/checkbox +examples/TpGUI/TpLabel/label examplesApp/bin/examplesApp -examples/TpGUI/tpBattery/battery +examples/TpGUI/TpBattery/battery examples/TpGUI/thorVGTest/thorVGTest -examples/TpGUI/tpDialog/dialog +examples/TpGUI/TpDialog/dialog examples/TpGUI/TpLottieAnimation/lottieAnimation TpGUI/TpGUI_symlink.cmake TpService/TpService_symlink.cmake @@ -104,3 +106,8 @@ examples/TpGUI/TpGradient/gradient examples/TpGUI/TpGraphicsEffect/graphics TpWM/TpWM_symlink.cmake examples/TpGUI/TpTemperatureWidget/temp +examples/TpUtils/TpGateway/client1 +examples/TpUtils/TpGateway/client2 +examples/TpGUI/TpMessgaeBox/messgaeBox +examples/TpUtils/TpGateway/PubSub/client2 +examples/TpUtils/TpGateway/REP/repClient diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a063013a91a5951d3465d8d0c8a2f8097e2f8d6e..2ff2e3eda1f199473677ce897850ef8af1bc1d2e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -53,6 +53,7 @@ "-lTpUtils", "-lTpGUI", "-lTpExtUtils", + "-lTpWMEngine", "-lrime", "" ], diff --git a/3rdparty/nanomsg b/3rdparty/nanomsg index 90501fe490a923a61dc1097dabff1ecba3b79f13..5c0a5cb7926a7cab6abd99bc658d03b270a9c687 160000 --- a/3rdparty/nanomsg +++ b/3rdparty/nanomsg @@ -1 +1 @@ -Subproject commit 90501fe490a923a61dc1097dabff1ecba3b79f13 +Subproject commit 5c0a5cb7926a7cab6abd99bc658d03b270a9c687 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b527f6d9a2a6fa0958bcd910efb62a9c9e12c3e..ef52550755f291268acff4c8ecda2fe08f19fe80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,10 +49,6 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/res DESTINATION ${INSTALL_PACK install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/data/ DESTINATION ${INSTALL_DATA_DIR}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/data DESTINATION ${INSTALL_PACKAGE_ROOT_PATH}) -# 安装bin文件 -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/bin/ DESTINATION ${INSTALL_BIN_DIR}) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/bin DESTINATION ${INSTALL_PACKAGE_ROOT_PATH}) - # 安装TpWM的system文件 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/system/ DESTINATION ${INSTALL_SYSTEM_DIR}) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/system/ DESTINATION ${INSTALL_PACKAGE_ROOT_PATH}/../system) diff --git a/README.md b/README.md index 991da7b152480fbbb06254398e6f3e2bbe5d723f..8700455db03369966aa0923af0497f32b64d7f04 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ TinyPiXOS的诞生标志着我们从零起步,完成了基础技术栈的完 TpWM是 TinyPiXOS 的窗口管理引擎,是 TinyPiXOS 的核心支撑要件。整个引擎设计以精简接口为切入点,摒弃复杂冗余的接口设计理念,结合类似RISC精简指令集的设计思想,为窗口设计人员提供任意组装和拼接的高效途径,可以打造出千变万化的自定义产品。 +## TpService + +TpService 是 ​​TiniPiXOS​​ 框架的后台服务模块,基于 ​​nanomsg​​ 实现高效通信,目前主要提供 ​​进程间通信(IPC)​​ 和 ​​局域网设备间通信​​ 功能,并计划逐步扩展为更强大的系统服务节点。 + ## TpGUI TpGUI 库为 TinyPiXOS 应用程序提供了核心 GUI 框架,实现了一个全面的基于小部件的用户界面系统,具有 CSS 样式、事件处理和动画功能。该库是在 TinyPiXOS 平台上构建图形应用程序的基础。 @@ -119,11 +123,11 @@ TinyPiXOS整体架构图 ### 源码下载 -拉取代码,可以使用Github地址直接下拉,或者使用Gitee同步仓库拉取 +拉取代码,可以使用Gitee地址直接下拉,或者使用同步仓库Github拉取 ```bash -git clone https://github.com/TinyPiXOS/TinyPiXOS.git -# git clone https://gitee.com/tinypixos/TinyPiXOS.git +# git clone https://github.com/TinyPiXOS/TinyPiXOS.git +git clone https://gitee.com/tinypixos/TinyPiXOS.git ``` ### 依赖库清单 @@ -149,17 +153,11 @@ git clone https://github.com/TinyPiXOS/TinyPiXOS.git ### 构建安装 -- ​**安装 TpWM 基础库** - -```bash -# 需要先安装完成 TpWM 相关依赖;参考官网 TpWM 安装教程 -``` - - ​**安装 依赖环境** ```bash sudo apt install \ - libcairo2-dev libpango1.0-dev libglib2.0-dev \ + libsdl2-dev libcairo2-dev libpango1.0-dev libglib2.0-dev \ libpangocairo-1.0-0 libfontconfig-dev libfreetype-dev \ libgbm-dev libgles2 libegl-dev \ libasound2-dev libjson-c-dev libssl-dev libavcodec-dev libavformat-dev \ @@ -216,6 +214,8 @@ make install `/usr/res/TinyPiX` - ​**数据文件安装路径**​ `/usr/data/TinyPiX` +- ​**系统支持文件安装路径**​ + `/System` #### 应用程序库引入 @@ -236,6 +236,36 @@ link_directories("/usr/lib") target_link_libraries(你的应用程序名称 TpExtUtils) ``` +#### 配置文件解析 + +### 2. 配置文件解析 + +配置文件路径:`/System/conf/tinyPiX.conf` + +示例配置,请勿复制注释至tinyPiX.conf: + +```ini +[display-setting] +width = 1080 # 屏幕宽度(建议保持默认) +height = 720 # 屏幕高度(建议保持默认) +format = 32 # 颜色深度(不建议修改) + +[attribute-setting] +daemon = 0 # 0=前台运行,1=后台运行 +acclerate = 1 # 0=禁用硬件加速,1=启用 +brightness = 255 # 屏幕亮度(0-255) +sharemem = 0 # 0=硬盘空间;1=内存空间 +shareone = 1 # 0=多应用不使用共享内存;1=使用共享内存 + +[system-setting] +simulator = 1 +quitwait = 15 + +[mode-setting] +startdir = /opt/project-main/tinyPiXApp/Application/deskTop/bin/ +startapp = TpDesktop +``` + ## 贡献代码 - **提交问题**:在开源仓库的 Issues 页面提交问题或改进建议。 @@ -303,3 +333,9 @@ TinyPiXOS开发者服务邮箱
核心团队
+ +## 支持作者 + +
+核心团队 +
diff --git a/TpGUI/CMakeLists.txt b/TpGUI/CMakeLists.txt index f007bd399db745ff608603c710af1a58123481c4..843e934e17065261d6a924a95e22d72ed2a255ba 100644 --- a/TpGUI/CMakeLists.txt +++ b/TpGUI/CMakeLists.txt @@ -75,6 +75,7 @@ set(SOURCE_FILES ${SOURCE_PATH}/src/TpGUI/Widgets/TpLottieAnimation.cpp ${SOURCE_PATH}/src_p/TpGUI/Core/TpObjectStack.cpp ${SOURCE_PATH}/src_p/TpGUI/Core/TpAutoObject.cpp + ${SOURCE_PATH}/src_p/TpGUI/Screen/TpFixScreen.cpp ) include_directories(/usr/include/cairo) @@ -90,6 +91,7 @@ include_directories(${SOURCE_PATH}/include_p) include_directories(${SOURCE_PATH}/include_p/TpGUI) include_directories(${SOURCE_PATH}/include_p/TpGUI/Widgets) include_directories(${SOURCE_PATH}/include_p/TpGUI/Core) +include_directories(${SOURCE_PATH}/include_p/TpGUI/Screen) include_directories(${SOURCE_PATH}/include_p/TpUtils) # 添加动态库目标 diff --git a/TpService/CMakeLists.txt b/TpService/CMakeLists.txt index e5b5b88002e1ced9e25d3e58dbcc901d230981de..13b15b0e54fd6774608238f0761a026a363b4087 100644 --- a/TpService/CMakeLists.txt +++ b/TpService/CMakeLists.txt @@ -15,7 +15,8 @@ set(SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../src") # 定义源码路径宏 set(SOURCE_FILES ${SOURCE_PATH}/src/TpService/main.cpp - ${SOURCE_PATH}/src/TpService/TpGatewayServer.cpp + ${SOURCE_PATH}/src/TpService/TpGatewayServerPUBSUB.cpp + ${SOURCE_PATH}/src/TpService/TpGatewayServerREP.cpp ) include_directories(${SOURCE_PATH}/include) @@ -39,7 +40,7 @@ target_link_libraries(TpService ${NANOMSG_STATIC_LIB} dl pthread - TpWMEngine + ${DEPEND_DYNAMIC_LIB_PATH}/libTpWMEngine.so TpGUI TpUtils TpExtUtils diff --git a/TpUtils/CMakeLists.txt b/TpUtils/CMakeLists.txt index 7f1ecd7b93ada3e89843c8482bc2b00a1c9526d8..5317348130b3aa9acc0c00b4753d67fbb59a582b 100644 --- a/TpUtils/CMakeLists.txt +++ b/TpUtils/CMakeLists.txt @@ -146,6 +146,8 @@ include_directories(${SOURCE_PATH}/include_p) include_directories(${SOURCE_PATH}/include_p/TpExtUtils/SystemLib) include_directories(${SOURCE_PATH}/include_p/TpUtils) include_directories(${SOURCE_PATH}/include_p/TpGUI) +include_directories(${SOURCE_PATH}/include_p/TpGUI/Core) +include_directories(${SOURCE_PATH}/include_p/TpGUI/Screen) include_directories(${SOURCE_PATH}/include_p/TpUtils/CSSParser) include_directories(${SOURCE_PATH}/include_p/TpUtils/CSSParser/Applicability) include_directories(${SOURCE_PATH}/include_p/TpUtils/CSSParser/Vendor) diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake index f22118e21fe2c44a4bda0ccbfab31995ef09f906..3703b680407d6c8a3365332a177e72970c99487c 100644 --- a/cmake/GlobalConfig.cmake +++ b/cmake/GlobalConfig.cmake @@ -1,11 +1,6 @@ # 设置构建生成的根目录 set(CMAKE_BINARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build") -# 设置不同类型的目标文件的输出目录 -# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/lib") -# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/lib") -# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/bin") - # 安装系统底层依赖 set(INSTALL_SYSTEM_DIR "/System") diff --git a/examples/TpExtUtils/App/readme b/examples/TpExtUtils/App/readme index 295a481a00e03f336bc3412159b2b5fbc0b3b62c..091ebde18d3a7c82643d631e3f83e6ef8aff72f7 100644 --- a/examples/TpExtUtils/App/readme +++ b/examples/TpExtUtils/App/readme @@ -25,7 +25,7 @@ INC = -I/usr/include \ #引用的库 #LIB = -lpthread -lpcap -ltparchive LIB = -L/usr/lib \ - -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lTpGUI -lPiXExternUtils + -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lTpGUI -lPiXExternUtils #伪目标:需要依赖的目标 .PHONY:Install Dopack Remove#即使该目标存在也重新生成 all:Install Dopack Remove clean# diff --git a/examples/TpExtUtils/bluetooth/rfcomm.cpp b/examples/TpExtUtils/bluetooth/rfcomm.cpp index 2be9d32d00d218676a3b44effdf31b27e4657020..ae4b2d5ea51c825ac89cc6826d88bb86e51dc7d7 100644 --- a/examples/TpExtUtils/bluetooth/rfcomm.cpp +++ b/examples/TpExtUtils/bluetooth/rfcomm.cpp @@ -35,8 +35,8 @@ int example_socket_client(int32_t argc, char *argv[],const TpString& adapter) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + tpUInt8 buff[10]="senddata\n"; @@ -82,8 +82,8 @@ int example_socket_server(int32_t argc, char *argv[],const TpString& adapter) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + TpBluetoothServer bt_server(adapter,TpBluetoothService::TP_BLUET_RFCOMM_PROTOCOL); bt_server.listen(TpBluetoothAddress::any(),1); diff --git a/examples/TpExtUtils/bluetooth/sdp.cpp b/examples/TpExtUtils/bluetooth/sdp.cpp index 22065bf2a17d71f0e8ea3c88bd529f3d1b48e067..a8a6a2837e21102e8d5fd1edf393b7ae9371eb6f 100644 --- a/examples/TpExtUtils/bluetooth/sdp.cpp +++ b/examples/TpExtUtils/bluetooth/sdp.cpp @@ -443,8 +443,8 @@ int main(int argc,char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + // example_service(); // testServiceDescriptorPrinting(); // example_bluet_uuid(); diff --git a/examples/TpExtUtils/diskManage/cross b/examples/TpExtUtils/diskManage/cross index 33cc45dd7a98314588633de22dd08df79b40d32b..f0ab11215f87517e92e758f5675b6b354f61614f 100755 --- a/examples/TpExtUtils/diskManage/cross +++ b/examples/TpExtUtils/diskManage/cross @@ -1 +1 @@ -g++ main.cpp -o diskManage -I//usr/include/TpWM -I/usr/include -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpExtUtils -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lPiXExternUtils +g++ main.cpp -o diskManage -I//usr/include/TpWM -I/usr/include -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpExtUtils -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lPiXExternUtils diff --git a/examples/TpExtUtils/diskManage/main.cpp b/examples/TpExtUtils/diskManage/main.cpp index 5210940391bda67c753d21bed1dcbf573c9fb6a2..0d440c9a1e2b825046ec85a27548fe17506ab294 100644 --- a/examples/TpExtUtils/diskManage/main.cpp +++ b/examples/TpExtUtils/diskManage/main.cpp @@ -10,8 +10,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + TpDiskManage diskManager(TP_TRUE,500); std::cout << "-------------------------------" << std::endl; diff --git a/examples/TpExtUtils/gpio/cross b/examples/TpExtUtils/gpio/cross index 23f1df222dcbb44cc5e14c58c534d49254a225f3..eab6b499d3627edf89d07feec432b77035b1389e 100755 --- a/examples/TpExtUtils/gpio/cross +++ b/examples/TpExtUtils/gpio/cross @@ -1 +1 @@ -g++ gpio.cpp -o Gpio -I/usr/include/TinyPiX/TpWM -I/usr/include -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpExtUtils -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lPiXExternUtils -lTpGUI +g++ gpio.cpp -o Gpio -I/usr/include/TinyPiX/TpWM -I/usr/include -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpExtUtils -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lPiXExternUtils -lTpGUI diff --git a/examples/TpExtUtils/hardwareDevice/ap3216/readme b/examples/TpExtUtils/hardwareDevice/ap3216/readme index 5a23e70732e6d94102a2a787e97ef5eac338ec72..249682c76ab712b422014c15769ab51e550e4776 100644 --- a/examples/TpExtUtils/hardwareDevice/ap3216/readme +++ b/examples/TpExtUtils/hardwareDevice/ap3216/readme @@ -25,7 +25,7 @@ INC = -I/usr/include \ #引用的库 #LIB = -lpthread -lpcap -ltparchive LIB = -L/usr/lib \ - -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lPiXExternUtils -lTpGUI + -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lPiXExternUtils -lTpGUI #伪目标:需要依赖的目标 #.PHONY:Audio Video Hard Record#即使该目标存在也重新生成 #all:Audio Video Hard Record clean# diff --git a/examples/TpExtUtils/hardwareDevice/sht20/readme b/examples/TpExtUtils/hardwareDevice/sht20/readme index 7aac069711b86518a7bb891fdad410e0e08d6876..d4f6681572e518daffa78e92079a4f47a9c44350 100644 --- a/examples/TpExtUtils/hardwareDevice/sht20/readme +++ b/examples/TpExtUtils/hardwareDevice/sht20/readme @@ -25,7 +25,7 @@ INC = -I/usr/include \ #引用的库 #LIB = -lpthread -lpcap -ltparchive LIB = -L/usr/lib \ - -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lPiXExternUtils -lTpGUI + -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lPiXExternUtils -lTpGUI #伪目标:需要依赖的目标 #.PHONY:Audio Video Hard Record#即使该目标存在也重新生成 #all:Audio Video Hard Record clean# diff --git a/examples/TpExtUtils/media/readme b/examples/TpExtUtils/media/readme index 0f1808f9ae05ae7cee7c0d1c68dca17e487bdeaa..eb0deebc89a6e14bbe8b17b1de73b43ea62e0df5 100644 --- a/examples/TpExtUtils/media/readme +++ b/examples/TpExtUtils/media/readme @@ -25,7 +25,7 @@ INC = -I/usr/include \ #引用的库 #LIB = -lpthread -lpcap -ltparchive LIB = -L/usr/lib \ - -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lTpGUI -lPiXExternUtils + -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lTpGUI -lPiXExternUtils #伪目标:需要依赖的目标 .PHONY:Audio Video Hard Record#即使该目标存在也重新生成 all:Audio Video Hard Record clean# diff --git a/examples/TpExtUtils/serial/serial.cpp b/examples/TpExtUtils/serial/serial.cpp index 0daf6271440206e2735208befd6e393f53089725..42112550bf5469b4836ae17a3518819346b68d9d 100644 --- a/examples/TpExtUtils/serial/serial.cpp +++ b/examples/TpExtUtils/serial/serial.cpp @@ -8,8 +8,8 @@ int main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + TpSerialPort tty("/dev/ttyUSB0"); if(!tty.open()) diff --git a/examples/TpGUI/TpAnimation/cross b/examples/TpGUI/TpAnimation/cross index 037dc3089730ae584ac25c81445e1b3708ea9c1f..e66b66fb88cdb72fe5dd2eec230e9fc0f3741bde 100755 --- a/examples/TpGUI/TpAnimation/cross +++ b/examples/TpGUI/TpAnimation/cross @@ -1 +1 @@ -g++ main.cpp -o animation -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o animation -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpAnimation/main.cpp b/examples/TpGUI/TpAnimation/main.cpp index 0a695df194f498287e97b4d82d2bef19f4a7739c..ac2b61baf5cf194f85f9dbf6c3c0298a39b6646f 100644 --- a/examples/TpGUI/TpAnimation/main.cpp +++ b/examples/TpGUI/TpAnimation/main.cpp @@ -10,8 +10,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + // 效果展示窗体 TpDialog *exampleWidget = new TpDialog(); diff --git a/examples/TpGUI/TpBattery/cross b/examples/TpGUI/TpBattery/cross index 0ebb73c431d12c3889c6b5e3075707c70e7a1ec6..a45544e919aae00bbb2909b80caefe63d0d18bf8 100755 --- a/examples/TpGUI/TpBattery/cross +++ b/examples/TpGUI/TpBattery/cross @@ -1 +1 @@ -g++ main.cpp -o battery -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o battery -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpBattery/main.cpp b/examples/TpGUI/TpBattery/main.cpp index faee31e1f425035cc1946319dea5b82bbd3df33a..f8ba9fc566ab1429c2ec60ccb137381051fa29ea 100644 --- a/examples/TpGUI/TpBattery/main.cpp +++ b/examples/TpGUI/TpBattery/main.cpp @@ -8,8 +8,6 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); TpBattery *battertWidget = new TpBattery(vScreen); battertWidget->setValue(50); diff --git a/examples/TpGUI/TpButton/main.cpp b/examples/TpGUI/TpButton/main.cpp index 2209df3ebaa7168b958563e8f4f1e052bf0a29e4..741e885ceb86cef2131e58a62b6ae420eb9611aa 100644 --- a/examples/TpGUI/TpButton/main.cpp +++ b/examples/TpGUI/TpButton/main.cpp @@ -10,7 +10,7 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - app.bindVScreen(vScreen); + TpButton *button1 = new TpButton("北京市", vScreen); button1->setProperty("type", "ControlPanelPowerButton"); diff --git a/examples/TpGUI/TpCarouselButton/cross b/examples/TpGUI/TpCarouselButton/cross index 0ababc7db73903c1f4ebeca2a615bed11f32c143..3befbe5b0397e37ae55ef02e35b4e21aec4cbc96 100644 --- a/examples/TpGUI/TpCarouselButton/cross +++ b/examples/TpGUI/TpCarouselButton/cross @@ -1 +1 @@ -g++ main.cpp -o button -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o button -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpCarouselButton/main.cpp b/examples/TpGUI/TpCarouselButton/main.cpp index 06afbf00b1109143e11d50029459b44c8420b13f..7059909a7584686787ef432f5b1036e320ffb1f9 100644 --- a/examples/TpGUI/TpCarouselButton/main.cpp +++ b/examples/TpGUI/TpCarouselButton/main.cpp @@ -7,8 +7,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpCarouselButton* carouselButton = new TpCarouselButton(vScreen); carouselButton->setCount(3); diff --git a/examples/TpGUI/TpCheckBox/cross b/examples/TpGUI/TpCheckBox/cross index 273db14644a2e438b65343f702b14661363b1d8d..ec30b3ed5bbaa5350e6a9d257626f6e7f67f9a3b 100755 --- a/examples/TpGUI/TpCheckBox/cross +++ b/examples/TpGUI/TpCheckBox/cross @@ -1 +1 @@ -g++ main.cpp -o checkbox -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o checkbox -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpCheckBox/main.cpp b/examples/TpGUI/TpCheckBox/main.cpp index 436fd27e1bdbd9c7424e36c5febd9adcc964fac2..f87e4ff9e5f3b985077627e074577f23d63e061a 100644 --- a/examples/TpGUI/TpCheckBox/main.cpp +++ b/examples/TpGUI/TpCheckBox/main.cpp @@ -10,7 +10,7 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); vScreen->setVisible(true);//vScreen setvisible will be update display - app.bindVScreen(vScreen); + TpCheckBox *checkBox1 = new TpCheckBox(vScreen); checkBox1->setText("CheckBox1"); diff --git a/examples/TpGUI/TpCollapsibleFileWidget/cross b/examples/TpGUI/TpCollapsibleFileWidget/cross index 706f7b071abce0a582b57772864bd12dfc9597d6..bad52ac318f9998a74ec0e7f7121eec423a46ea5 100644 --- a/examples/TpGUI/TpCollapsibleFileWidget/cross +++ b/examples/TpGUI/TpCollapsibleFileWidget/cross @@ -1 +1 @@ -g++ main.cpp -o fileWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o fileWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpCollapsibleFileWidget/main.cpp b/examples/TpGUI/TpCollapsibleFileWidget/main.cpp index 8654beb27122dd35dd608f7ad9cf64b474446abc..32a999852abb8fd7a0cded92a370cc802833fc1c 100644 --- a/examples/TpGUI/TpCollapsibleFileWidget/main.cpp +++ b/examples/TpGUI/TpCollapsibleFileWidget/main.cpp @@ -8,8 +8,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpCollapsibleFileWidget *testFileWidget = new TpCollapsibleFileWidget(vScreen); testFileWidget->setTitle("今天"); diff --git a/examples/TpGUI/TpComBox/cross b/examples/TpGUI/TpComBox/cross index a606429119b5606f62983f21323c84c76174b69d..8375bc27d434abcd4a64a82c0bda69e7471b5d03 100755 --- a/examples/TpGUI/TpComBox/cross +++ b/examples/TpGUI/TpComBox/cross @@ -1 +1 @@ -g++ main.cpp -o comBox -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o comBox -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpComBox/main.cpp b/examples/TpGUI/TpComBox/main.cpp index 13b3e5684a7c454c22a3b882778a6cc59a7cea5d..09f99a1bbc3f1f679333b1985efb78704d5736d4 100644 --- a/examples/TpGUI/TpComBox/main.cpp +++ b/examples/TpGUI/TpComBox/main.cpp @@ -8,8 +8,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpComBox* listCombox = new TpComBox(vScreen); listCombox->setTitle("视图模式"); diff --git a/examples/TpGUI/TpDialog/cross b/examples/TpGUI/TpDialog/cross index a41808dc5b91ef1d7a30db4520a3639aef80b9c3..d85409cfd41c4a114497197d9f5d240cdf035d60 100755 --- a/examples/TpGUI/TpDialog/cross +++ b/examples/TpGUI/TpDialog/cross @@ -1 +1 @@ -g++ main.cpp -o dialog -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o dialog -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpDialog/main.cpp b/examples/TpGUI/TpDialog/main.cpp index 6834804c7f26c2cd9d4358ef467652330cf551ad..c3c5614230c9a83d01d82a22a9f175b471c4fde3 100644 --- a/examples/TpGUI/TpDialog/main.cpp +++ b/examples/TpGUI/TpDialog/main.cpp @@ -7,14 +7,13 @@ int32_t main(int32_t argc, char *argv[]) { TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); - vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); + vScreen->setBackGroundColor(_RGB(128, 128, 128)); vScreen->setVisible(true);//vScreen setvisible will be update display - app.bindVScreen(vScreen); TpDialog *dia = new TpDialog(); - dia->setBackGroundColor(_RGBA(243, 243, 243, 100)); + dia->setBackGroundColor(_RGB(243, 243, 243)); dia->setRect(0, 0, 300, 300); - dia->setAlpha(128); + dia->setWindowOpacity(0.1); dia->setRoundCorners(50); dia->setVisible(true); dia->setBeMoved(true); diff --git a/examples/TpGUI/TpFilePathWidget/cross b/examples/TpGUI/TpFilePathWidget/cross index 9f558ea4ae8dd0d7b2f45cd5c851cb15765c99bf..1186527d50b07fdc672912bd57d9e416ff1da4bb 100644 --- a/examples/TpGUI/TpFilePathWidget/cross +++ b/examples/TpGUI/TpFilePathWidget/cross @@ -1 +1 @@ -g++ main.cpp -o filePathWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o filePathWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpFilePathWidget/main.cpp b/examples/TpGUI/TpFilePathWidget/main.cpp index 52b8fc8d12b97ad749638f487dfcbf51d594db58..dafb600a93d9eac141dfa0871fc57e4352c517d1 100644 --- a/examples/TpGUI/TpFilePathWidget/main.cpp +++ b/examples/TpGUI/TpFilePathWidget/main.cpp @@ -7,8 +7,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpFilePathWidget* testWidget = new TpFilePathWidget(vScreen); diff --git a/examples/TpGUI/TpFlexLayout/cross b/examples/TpGUI/TpFlexLayout/cross index ff25059e9e7e9172e5933e2c8b3104ec5c7c681b..d13f1c84e15a517de945b1869b2ad5b4b977e134 100644 --- a/examples/TpGUI/TpFlexLayout/cross +++ b/examples/TpGUI/TpFlexLayout/cross @@ -1 +1 @@ -g++ main.cpp -o flexLayout -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o flexLayout -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpFlexLayout/main.cpp b/examples/TpGUI/TpFlexLayout/main.cpp index d91ccf9dc3f1e3e9990858578143d2ef31271918..49f065fa37d6ad5d051ccdede9310d39ed5bf0d8 100644 --- a/examples/TpGUI/TpFlexLayout/main.cpp +++ b/examples/TpGUI/TpFlexLayout/main.cpp @@ -9,8 +9,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpFlexLayout *flexLayout = new TpFlexLayout(); diff --git a/examples/TpGUI/TpGradient/main.cpp b/examples/TpGUI/TpGradient/main.cpp index c0872c1323f2ab1b0991650ee861383de789d570..71213500f03b7b27b5f14118a2a8b226ab1296d0 100644 --- a/examples/TpGUI/TpGradient/main.cpp +++ b/examples/TpGUI/TpGradient/main.cpp @@ -10,7 +10,6 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - app.bindVScreen(vScreen); TpLabel *lineGradientText = new TpLabel("线性渐变:", vScreen); lineGradientText->setRect(30, 30, 100, 50); @@ -37,27 +36,40 @@ int32_t main(int32_t argc, char *argv[]) TpLabel *radialGradientText = new TpLabel("径向渐变:", vScreen); radialGradientText->setRect(30, 150, 100, 50); - TpRadialGradient radialGradient; - radialGradient.setColorAt(0, _RGB(255, 0, 0)); - radialGradient.setColorAt(0.1, _RGB(252, 107, 1)); - radialGradient.setColorAt(0.2, _RGB(252, 226, 1)); - radialGradient.setColorAt(0.3, _RGB(158, 252, 1)); - radialGradient.setColorAt(0.4, _RGB(1, 252, 33)); - radialGradient.setColorAt(0.5, _RGB(2, 251, 201)); - radialGradient.setColorAt(0.6, _RGB(2, 139, 251)); - radialGradient.setColorAt(0.7, _RGB(1, 45, 252)); - radialGradient.setColorAt(0.8, _RGB(120, 1, 252)); - radialGradient.setColorAt(0.9, _RGB(252, 1, 252)); - radialGradient.setColorAt(1, _RGB(252, 1, 455)); - radialGradient.setCenter(110, 110); - radialGradient.setCenterRadius(110); - radialGradient.setFocalPoint(110, 110); - radialGradient.setFocalRadius(0); + TpBrush tmpBrush; + { + { + TpRadialGradient radialGradient; + radialGradient.setColorAt(0, _RGB(255, 0, 0)); + radialGradient.setColorAt(0.1, _RGB(252, 107, 1)); + radialGradient.setColorAt(0.2, _RGB(252, 226, 1)); + radialGradient.setColorAt(0.3, _RGB(158, 252, 1)); + radialGradient.setColorAt(0.4, _RGB(1, 252, 33)); + radialGradient.setColorAt(0.5, _RGB(2, 251, 201)); + radialGradient.setColorAt(0.6, _RGB(2, 139, 251)); + radialGradient.setColorAt(0.7, _RGB(1, 45, 252)); + radialGradient.setColorAt(0.8, _RGB(120, 1, 252)); + radialGradient.setColorAt(0.9, _RGB(252, 1, 252)); + radialGradient.setColorAt(1, _RGB(252, 1, 455)); + radialGradient.setCenter(110, 110); + radialGradient.setCenterRadius(110); + radialGradient.setFocalPoint(110, 110); + radialGradient.setFocalRadius(0); - TpLabel *radialGradientColor = new TpLabel(vScreen); - radialGradientColor->setRect(150, 150, 220, 220); - radialGradientColor->setRoundCorners(110); - radialGradientColor->setBackGroundColor(TpBrush(&radialGradient)); + // TpLabel *radialGradientColor = new TpLabel(vScreen); + // radialGradientColor->setRect(150, 150, 220, 220); + // radialGradientColor->setRoundCorners(110); + // radialGradientColor->setBackGroundColor(TpBrush(&radialGradient)); + + TpBrush testBrush(&radialGradient); + tmpBrush = testBrush; + } + + TpLabel *radialGradientColor = new TpLabel(vScreen); + radialGradientColor->setRect(150, 150, 220, 220); + radialGradientColor->setRoundCorners(110); + radialGradientColor->setBackGroundColor(tmpBrush); + } vScreen->update(); return app.run(); diff --git a/examples/TpGUI/TpGraphicsEffect/main.cpp b/examples/TpGUI/TpGraphicsEffect/main.cpp index 383e55fceef63686ad45d805e7d07b1345defe48..7488a4f317e9aa1bb0e108cc152527645e81033a 100644 --- a/examples/TpGUI/TpGraphicsEffect/main.cpp +++ b/examples/TpGUI/TpGraphicsEffect/main.cpp @@ -10,7 +10,7 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - app.bindVScreen(vScreen); + TpLabel *imgLabel = new TpLabel(vScreen); imgLabel->setRect(30, 30, 500, 500); diff --git a/examples/TpGUI/TpLabel/cross b/examples/TpGUI/TpLabel/cross index 90165b1d1124d9e2776fbd26c1528a76800f732b..8fc38766ea7748b9c3697a1f8cf8d97d55b8399d 100755 --- a/examples/TpGUI/TpLabel/cross +++ b/examples/TpGUI/TpLabel/cross @@ -1 +1 @@ -g++ main.cpp -o label -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o label -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpLabel/main.cpp b/examples/TpGUI/TpLabel/main.cpp index c1f6fcd0ce7a6fe1a5ec6ca5f0f6fe2828df2d1a..9510a62520342036fd22313732c319166ca39195 100644 --- a/examples/TpGUI/TpLabel/main.cpp +++ b/examples/TpGUI/TpLabel/main.cpp @@ -11,7 +11,7 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(226, 226, 226, 255)); - app.bindVScreen(vScreen); + vScreen->update(); #if 0 diff --git a/examples/TpGUI/TpLayout/cross b/examples/TpGUI/TpLayout/cross index 0070ca24e7e6ce1621f43610f0473e2cf4b82631..eecdaa3aad82cb05162df3c2f862a31a4639b45d 100644 --- a/examples/TpGUI/TpLayout/cross +++ b/examples/TpGUI/TpLayout/cross @@ -1 +1 @@ -g++ main.cpp -o layout -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o layout -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpLayout/main.cpp b/examples/TpGUI/TpLayout/main.cpp index 716d0074af2491d592877cebc28124ddffcced27..8c9dcc7df7151a85ccb5242b5a274908d98961be 100644 --- a/examples/TpGUI/TpLayout/main.cpp +++ b/examples/TpGUI/TpLayout/main.cpp @@ -11,18 +11,18 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 200)); - app.bindVScreen(vScreen); + TpDialog *floatScreenH = new TpDialog(); floatScreenH->setBackGroundColor(_RGBA(255, 255, 255, 200)); floatScreenH->setRect(0, 0, 900, 600); - floatScreenH->setAlpha(128); + floatScreenH->setWindowOpacity(0.5); floatScreenH->setBeMoved(true); TpDialog *floatScreenV = new TpDialog(); floatScreenV->setBackGroundColor(_RGBA(255, 255, 255, 200)); floatScreenV->setRect(10, 100, 400, 650); - floatScreenV->setAlpha(128); + floatScreenV->setWindowOpacity(0.5); floatScreenV->setBeMoved(true); TpHBoxLayout *hLayout = new TpHBoxLayout(); diff --git a/examples/TpGUI/TpLine/cross b/examples/TpGUI/TpLine/cross index cea675f7a65b83fe6ea84f71ec8a407256da4580..57ac78be64e3a1b36f50e4a2b39389c7c83827e2 100644 --- a/examples/TpGUI/TpLine/cross +++ b/examples/TpGUI/TpLine/cross @@ -1 +1 @@ -g++ main.cpp -o line -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o line -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpLine/main.cpp b/examples/TpGUI/TpLine/main.cpp index 21ba4b10ab6bf2874086a33e92e3273dffb1ceed..a35e47ffd68d5eec28a5dfe731ec21fb2d0ff193 100644 --- a/examples/TpGUI/TpLine/main.cpp +++ b/examples/TpGUI/TpLine/main.cpp @@ -7,8 +7,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpLine* hLine = new TpLine(vScreen); hLine->setLineType(TpLine::HLine); diff --git a/examples/TpGUI/TpLineEdit/cross b/examples/TpGUI/TpLineEdit/cross index a8a863e4b034f149331dfcc41a3bd4c5860e0c2e..045cd3793004a446fa0e14e6e3a6a842b407d2e4 100755 --- a/examples/TpGUI/TpLineEdit/cross +++ b/examples/TpGUI/TpLineEdit/cross @@ -1 +1 @@ -g++ main.cpp -o lineedit -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o lineedit -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpLineEdit/main.cpp b/examples/TpGUI/TpLineEdit/main.cpp index 29be83289dee583bea828afd820707a3d0d40d60..b8797e7215533ed344770cffd9b099bd01f8cf13 100644 --- a/examples/TpGUI/TpLineEdit/main.cpp +++ b/examples/TpGUI/TpLineEdit/main.cpp @@ -11,8 +11,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + vScreen->update(); TpLineEdit *edit = new TpLineEdit(vScreen); diff --git a/examples/TpGUI/TpListWidhet/cross b/examples/TpGUI/TpListWidhet/cross index 66d4086a33504d154c8b8da21199d58cbb5101ab..cc525a263f7a34767a2cce4adaa70f714e8301fd 100755 --- a/examples/TpGUI/TpListWidhet/cross +++ b/examples/TpGUI/TpListWidhet/cross @@ -1 +1 @@ -g++ main.cpp -o listWidhet -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o listWidhet -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpListWidhet/main.cpp b/examples/TpGUI/TpListWidhet/main.cpp index aa5195b8b7213d102055b8cdfd6b21532990f440..699a5c3fe9cb2183bf72a851f2eccb8563e68768 100644 --- a/examples/TpGUI/TpListWidhet/main.cpp +++ b/examples/TpGUI/TpListWidhet/main.cpp @@ -7,8 +7,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpListWidget* checkBoxGroup = new TpListWidget(vScreen); diff --git a/examples/TpGUI/TpLottieAnimation/cross b/examples/TpGUI/TpLottieAnimation/cross index 043ac37524579c2e9a4a1f51e833fbffa7cf8bc8..a8b0373326913c76ba973c45cbc29eb123912629 100755 --- a/examples/TpGUI/TpLottieAnimation/cross +++ b/examples/TpGUI/TpLottieAnimation/cross @@ -1 +1 @@ -g++ main.cpp -o lottieAnimation -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o lottieAnimation -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpLottieAnimation/main.cpp b/examples/TpGUI/TpLottieAnimation/main.cpp index 89f6d737b82a8cc4a8be92f52062803393a5a09e..18f42470d19ec1bd49b7994767fdf43b10c1823e 100644 --- a/examples/TpGUI/TpLottieAnimation/main.cpp +++ b/examples/TpGUI/TpLottieAnimation/main.cpp @@ -9,8 +9,8 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpLottieAnimation *lottieAnimation1 = new TpLottieAnimation(vScreen); // lottieAnimation1->setBackGroundColor(_RGB(100, 255, 100)); diff --git a/examples/TpGUI/TpMediaTileButton/cross b/examples/TpGUI/TpMediaTileButton/cross index 0ababc7db73903c1f4ebeca2a615bed11f32c143..3befbe5b0397e37ae55ef02e35b4e21aec4cbc96 100755 --- a/examples/TpGUI/TpMediaTileButton/cross +++ b/examples/TpGUI/TpMediaTileButton/cross @@ -1 +1 @@ -g++ main.cpp -o button -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o button -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpMediaTileButton/main.cpp b/examples/TpGUI/TpMediaTileButton/main.cpp index e853108ab0c22ea2e4ba84fca09d4769e193f108..85a3b7dde56b8ba29ca675849e2d3724a200982e 100644 --- a/examples/TpGUI/TpMediaTileButton/main.cpp +++ b/examples/TpGUI/TpMediaTileButton/main.cpp @@ -7,8 +7,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpMediaTileButton* pictureTileBtn = new TpMediaTileButton(vScreen); pictureTileBtn->setText("图片"); diff --git a/examples/TpGUI/TpMenu/cross b/examples/TpGUI/TpMenu/cross old mode 100644 new mode 100755 index 1166ab385d31cd529f9f3cf116db0d7784c580c8..cb6145d6f4c252d5e917d44558b3dd1157b7a0db --- a/examples/TpGUI/TpMenu/cross +++ b/examples/TpGUI/TpMenu/cross @@ -1 +1 @@ -g++ main.cpp -o menu -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o menu -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpMenu/main.cpp b/examples/TpGUI/TpMenu/main.cpp index e7b0f7a148b2af3b142060b44c7b5fe16595fd91..4bbb1f10fee7fdfd4a9996fb205602e120974c1c 100644 --- a/examples/TpGUI/TpMenu/main.cpp +++ b/examples/TpGUI/TpMenu/main.cpp @@ -6,27 +6,25 @@ int32_t main(int32_t argc, char *argv[]) { - TpApp app(argc, argv); + TpApp app(argc, argv); - TpMainWindow *vScreen = new TpMainWindow(); - vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + TpMainWindow *vScreen = new TpMainWindow(); + vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - TpMenu *menu = new TpMenu(); - menu->addItem("Item1"); - menu->addItem("Item2"); - menu->addItem("Item3"); + TpMenu *menu = new TpMenu(); + menu->addItem("Item11111"); + menu->addItem("Item22222"); + menu->addItem("Item33333"); - TpButton *showMenuBtn = new TpButton(vScreen); - showMenuBtn->setText("显示弹出菜单"); - showMenuBtn->setProperty("type", "ControlPanelPowerButton"); - showMenuBtn->setSize(300, 64); - showMenuBtn->move(20, 20); - connect(showMenuBtn, onClicked, [&](bool) - { menu->exec(330, 20); }); + TpButton *showMenuBtn = new TpButton(vScreen); + showMenuBtn->setText("显示弹出菜单"); + showMenuBtn->setProperty("type", "ControlPanelPowerButton"); + showMenuBtn->setSize(300, 64); + showMenuBtn->move(20, 20); + connect(showMenuBtn, onClicked, [&](bool) + { menu->exec(330, 20); }); - vScreen->update(); + vScreen->update(); - return app.run(); + return app.run(); } diff --git a/examples/TpGUI/TpMenuPanelWidget/cross b/examples/TpGUI/TpMenuPanelWidget/cross index 5699121270e8fed951f15ed98e7d8ecef1c89d1a..5e6898c933de8d141d040ca5d7459e9d7344ba00 100644 --- a/examples/TpGUI/TpMenuPanelWidget/cross +++ b/examples/TpGUI/TpMenuPanelWidget/cross @@ -1 +1 @@ -g++ main.cpp -o menuPanelWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o menuPanelWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpMenuPanelWidget/main.cpp b/examples/TpGUI/TpMenuPanelWidget/main.cpp index 780b3338518ad1c490ae7e9711164decaf9f6cc7..11c2b853dbd67198ff87545585200e571948ebf8 100644 --- a/examples/TpGUI/TpMenuPanelWidget/main.cpp +++ b/examples/TpGUI/TpMenuPanelWidget/main.cpp @@ -8,8 +8,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + TpMenuPanelWidget *menuPanelWidget = new TpMenuPanelWidget(vScreen); connect(menuPanelWidget, onClicked, [=](TpMenuPanelItem *) diff --git a/examples/TpGUI/TpMessgaeBox/cross b/examples/TpGUI/TpMessgaeBox/cross index 8124e872a501fb729f3b8879554854523c5bff6b..f3bcbb31d1bc38e7cc85f5c9d5ddbde2d3e42bc3 100755 --- a/examples/TpGUI/TpMessgaeBox/cross +++ b/examples/TpGUI/TpMessgaeBox/cross @@ -1 +1 @@ -g++ main.cpp -o messgaeBox -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o messgaeBox -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpMessgaeBox/main.cpp b/examples/TpGUI/TpMessgaeBox/main.cpp index 5d5fa288602ad700568f76b6ac8ae7c7aa16d5ca..cfe6b28e3b0cd528777f87b73b74c986ed6d09cf 100644 --- a/examples/TpGUI/TpMessgaeBox/main.cpp +++ b/examples/TpGUI/TpMessgaeBox/main.cpp @@ -5,32 +5,34 @@ int32_t main(int32_t argc, char *argv[]) { - TpApp app(argc, argv); - TpMainWindow *vScreen = new TpMainWindow(); - vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + TpApp app(argc, argv); + TpMainWindow *vScreen = new TpMainWindow(); + vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - TpButton *button1 = new TpButton("消息框", vScreen); - button1->setRect(20, 20, 100, 50); - connect(button1, onClicked, [=](bool) - { TpMessageBox::information("消息弹出框"); }); + TpMessageBox infoMsg("消息弹出框"); + TpButton *button1 = new TpButton("消息框", vScreen); + button1->setRect(20, 20, 100, 50); + connect(button1, onClicked, [&](bool) + { infoMsg.exec(); }); - TpButton *button2 = new TpButton("警告框", vScreen); - button2->setRect(20, 80, 100, 50); - connect(button2, onClicked, [=](bool) - { TpMessageBox::warning("警告弹出框"); }); + TpMessageBox warningMsg("警告弹出框", TpMessageBox::Warning); + TpButton *button2 = new TpButton("警告框", vScreen); + button2->setRect(20, 80, 100, 50); + connect(button2, onClicked, [&](bool) + { warningMsg.exec(); }); - TpButton *button3 = new TpButton("询问框", vScreen); - button3->setRect(20, 140, 100, 50); - connect(button3, onClicked, [=](bool) - { TpMessageBox::question("询问弹出框"); }); + TpMessageBox questiongMsg("询问弹出框", TpMessageBox::Question); + TpButton *button3 = new TpButton("询问框", vScreen); + button3->setRect(20, 140, 100, 50); + connect(button3, onClicked, [&](bool) + { questiongMsg.exec(); }); - TpButton *button4 = new TpButton("错误框", vScreen); - button4->setRect(20, 200, 100, 50); - connect(button4, onClicked, [=](bool) - { TpMessageBox::error("错误弹出框"); }); + TpMessageBox errorMsg("错误弹出框", TpMessageBox::Error); + TpButton *button4 = new TpButton("错误框", vScreen); + button4->setRect(20, 200, 100, 50); + connect(button4, onClicked, [&](bool) + { errorMsg.exec(); }); - vScreen->update(); - return app.run(); + vScreen->update(); + return app.run(); } diff --git a/examples/TpGUI/TpOnOffButton/cross b/examples/TpGUI/TpOnOffButton/cross index c6544aece8d53ba16c738f0e2fa9f751bc084f24..c4a98bac63b78b87954fc4c559ce1bed6bd2e910 100755 --- a/examples/TpGUI/TpOnOffButton/cross +++ b/examples/TpGUI/TpOnOffButton/cross @@ -1 +1 @@ -g++ main.cpp -o onoff -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o onoff -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpOnOffButton/main.cpp b/examples/TpGUI/TpOnOffButton/main.cpp index 21bc396a7664791001fa371ed58eaf909c441f69..2b535986c123edf488eebec260138c4fab604789 100644 --- a/examples/TpGUI/TpOnOffButton/main.cpp +++ b/examples/TpGUI/TpOnOffButton/main.cpp @@ -12,7 +12,7 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - app.bindVScreen(vScreen); + TpOnOffButton *onOffBtn1 = new TpOnOffButton(vScreen, TpOnOffButton::TP_HORIZONTAL); onOffBtn1->setRect(120, 120, 150, 75); diff --git a/examples/TpGUI/TpPainterPath/cross b/examples/TpGUI/TpPainterPath/cross index 03942687132e43bca864804df848cc394c27773d..3f241330e928fc841d5650e8f1d7c723590cb242 100755 --- a/examples/TpGUI/TpPainterPath/cross +++ b/examples/TpGUI/TpPainterPath/cross @@ -1 +1 @@ -g++ main.cpp -o paintPath -I/usr/include/TinyPiX/GUIFramework -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o paintPath -I/usr/include/TinyPiX/GUIFramework -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpPainterPath/main.cpp b/examples/TpGUI/TpPainterPath/main.cpp index 54523cdb7d9b6a38615a4b3c12854f4161835911..d07716373fc5548f7752344c89d427e075fd3635 100644 --- a/examples/TpGUI/TpPainterPath/main.cpp +++ b/examples/TpGUI/TpPainterPath/main.cpp @@ -138,8 +138,8 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + PaintPathWidget *thorVGPaint = new PaintPathWidget(vScreen); thorVGPaint->setRect(100, 100, 500, 500); diff --git a/examples/TpGUI/TpPercentProgressBar/cross b/examples/TpGUI/TpPercentProgressBar/cross index 4ef928de2feb03d3f42225bacea929f1be1b21f7..6a8d7dfdc4cc4b428a39022bbac46db10c447a4b 100644 --- a/examples/TpGUI/TpPercentProgressBar/cross +++ b/examples/TpGUI/TpPercentProgressBar/cross @@ -1 +1 @@ -g++ main.cpp -o progressBar -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o progressBar -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpPercentProgressBar/main.cpp b/examples/TpGUI/TpPercentProgressBar/main.cpp index 704f4224c1c7ac36b9caa8ff1b6a4ef6568557df..42da6b9db851651b1626fe5033dc73113cdadab7 100644 --- a/examples/TpGUI/TpPercentProgressBar/main.cpp +++ b/examples/TpGUI/TpPercentProgressBar/main.cpp @@ -7,8 +7,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpPercentProgressBar *progress = new TpPercentProgressBar(vScreen); progress->setWidth(700); diff --git a/examples/TpGUI/TpProgressBar/cross b/examples/TpGUI/TpProgressBar/cross index 6387b3e385d75d6b54ac879a459aff7021fe7163..3d5696582e6ea8a58b8edc1ff4e197664a445d60 100755 --- a/examples/TpGUI/TpProgressBar/cross +++ b/examples/TpGUI/TpProgressBar/cross @@ -1 +1 @@ -g++ main.cpp -o progress -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o progress -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpProgressBar/main.cpp b/examples/TpGUI/TpProgressBar/main.cpp index f1dedfb8cd3b5b96ef5e48d4c157415ae6176251..a04b9db4fa5fab1224512b605528ee5e338f5fd8 100644 --- a/examples/TpGUI/TpProgressBar/main.cpp +++ b/examples/TpGUI/TpProgressBar/main.cpp @@ -10,7 +10,7 @@ int32_t main(int32_t argc, char *argv[]) vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); vScreen->setVisible(true); // vScreen setvisible will be update display1234567498 - app.bindVScreen(vScreen); + vScreen->update(); TpButton *button1 = new TpButton(vScreen); diff --git a/examples/TpGUI/TpRadioButton/cross b/examples/TpGUI/TpRadioButton/cross index c7952b9bbb3fc76b8f22a657a54c8a68547c95bb..d8fa052693e429f8e54862564f7de4ea4572b31e 100755 --- a/examples/TpGUI/TpRadioButton/cross +++ b/examples/TpGUI/TpRadioButton/cross @@ -1 +1 @@ -g++ main.cpp -o radiobutton -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o radiobutton -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpRadioButton/main.cpp b/examples/TpGUI/TpRadioButton/main.cpp index 67d7015fce7765caab1a4c8ad69d220d680bc84f..f20a00970b6550a5b69c66e7fa49998287db3841 100644 --- a/examples/TpGUI/TpRadioButton/main.cpp +++ b/examples/TpGUI/TpRadioButton/main.cpp @@ -12,7 +12,7 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); vScreen->setVisible(true); - app.bindVScreen(vScreen); + TpRadioButton *RadioButton1 = new TpRadioButton(vScreen); RadioButton1->font()->setFontSize(50); diff --git a/examples/TpGUI/TpScrollPanel/cross b/examples/TpGUI/TpScrollPanel/cross index 6dbf15a7a955b140af44252309a114b5f4a7b762..4fe68575e8be77e721011b54f1d1316778eacd25 100755 --- a/examples/TpGUI/TpScrollPanel/cross +++ b/examples/TpGUI/TpScrollPanel/cross @@ -1 +1 @@ -g++ main.cpp -o scrollpanel -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o scrollpanel -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpScrollPanel/main.cpp b/examples/TpGUI/TpScrollPanel/main.cpp index 4f8af411f2f3d8bbdd4b31aa03f48a0a3570ebaa..955fd4e257d6d8bb1ac2252d933e88d8cc1d38cc 100644 --- a/examples/TpGUI/TpScrollPanel/main.cpp +++ b/examples/TpGUI/TpScrollPanel/main.cpp @@ -14,8 +14,8 @@ int32_t main(int32_t argc, char *argv[]) app.setDisableEventType(TpApp::TP_DIS_KEYBOARD); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + vScreen->update(); // TpScrollPanel *spanel = new TpScrollPanel(vScreen); diff --git a/examples/TpGUI/TpSlider/cross b/examples/TpGUI/TpSlider/cross index 8376b71bb301107f0db7db813882ba7608be18db..675a873e0e2c355f5d488dfabec84f466744459d 100755 --- a/examples/TpGUI/TpSlider/cross +++ b/examples/TpGUI/TpSlider/cross @@ -1 +1 @@ -g++ main.cpp -o slider -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o slider -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpSlider/main.cpp b/examples/TpGUI/TpSlider/main.cpp index 3d8524b9d41fc40a3c47117a29fdbc257c7024f2..eae8e1794b4b97e1aca4dfdd3cbf75ead1ff5d17 100644 --- a/examples/TpGUI/TpSlider/main.cpp +++ b/examples/TpGUI/TpSlider/main.cpp @@ -9,22 +9,20 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); - - // TpLabel *valueText = new TpLabel(vScreen); - // valueText->setText(TpString::number(50)); - // valueText->setAlign(Tp::AlignCenter); - // valueText->font()->setFontColor(_RGB(255, 255, 255),_RGB(255, 255, 255)); - // valueText->font()->setFontSize(30); - // valueText->setWidth(600); - // valueText->setHeight(400); - // valueText->move(20, 200); - - // TpSlider *slider = new TpSlider(vScreen); - // slider->setValue(50); - // slider->setSize(500, 10); - // slider->move(20, 20); + + TpLabel *valueText = new TpLabel(vScreen); + valueText->setText(TpString::number(50)); + valueText->setAlign(Tp::AlignCenter); + valueText->font()->setFontColor(_RGB(255, 255, 255),_RGB(255, 255, 255)); + valueText->font()->setFontSize(30); + valueText->setWidth(600); + valueText->setHeight(400); + valueText->move(20, 200); + + TpSlider *slider = new TpSlider(vScreen); + slider->setValue(50); + slider->setSize(500, 10); + slider->move(20, 20); TpSlider *vSlider = new TpSlider(vScreen); vSlider->setDirection(TpSlider::Vertical); @@ -32,13 +30,13 @@ int32_t main(int32_t argc, char *argv[]) vSlider->setSize(10, 500); vSlider->move(650, 20); - // connect(slider, valueChanged, [=](int32_t value) - // { valueText->setText(TpString::number(value)); - // vSlider->setValue(value); }); + connect(slider, valueChanged, [=](int32_t value) + { valueText->setText(TpString::number(value)); + vSlider->setValue(value); }); - // connect(vSlider, valueChanged, [=](int32_t value) - // { valueText->setText(TpString::number(value)); - // slider->setValue(value); }); + connect(vSlider, valueChanged, [=](int32_t value) + { valueText->setText(TpString::number(value)); + slider->setValue(value); }); vScreen->update(); diff --git a/examples/TpGUI/TpTabWidget/cross b/examples/TpGUI/TpTabWidget/cross index ed3f727694089caaf4139f3068a14d42ea60230c..d0e47383776f8e5440594ac472b96a00fae22267 100644 --- a/examples/TpGUI/TpTabWidget/cross +++ b/examples/TpGUI/TpTabWidget/cross @@ -1 +1 @@ -g++ main.cpp -o tabWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o tabWidget -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpTabWidget/main.cpp b/examples/TpGUI/TpTabWidget/main.cpp index c918560150e297e1c44716c325b3222074a8ecbf..2dc1c84075dcd212eb955c8b38b43776046477f9 100644 --- a/examples/TpGUI/TpTabWidget/main.cpp +++ b/examples/TpGUI/TpTabWidget/main.cpp @@ -18,7 +18,7 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); vScreen->setVisible(true);//vScreen setvisible will be update display - app.bindVScreen(vScreen); + TpTabWidget *tabWidget = new TpTabWidget(vScreen); tabWidget->addTab(new TpWidget(), "Tab1"); diff --git a/examples/TpGUI/TpTemperatureWidget/cross b/examples/TpGUI/TpTemperatureWidget/cross index 5cc872ccd9902b140943495382f3a96c6d649a0d..1e06e7d9c456650ef47b867db5a15b3e9a3a4436 100755 --- a/examples/TpGUI/TpTemperatureWidget/cross +++ b/examples/TpGUI/TpTemperatureWidget/cross @@ -1 +1 @@ -g++ main.cpp -o temp -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o temp -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpTemperatureWidget/main.cpp b/examples/TpGUI/TpTemperatureWidget/main.cpp index c758730455bd3ce709890d306e481b0553bae399..41361197017a7ea53dc79d560d6def618d69c1d9 100644 --- a/examples/TpGUI/TpTemperatureWidget/main.cpp +++ b/examples/TpGUI/TpTemperatureWidget/main.cpp @@ -8,7 +8,7 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(226, 226, 226, 255)); - app.bindVScreen(vScreen); + vScreen->update(); TpTemperatureWidget *temperatureWidget_ = new TpTemperatureWidget(vScreen); diff --git a/examples/TpGUI/TpVirtualKeyboard/cross b/examples/TpGUI/TpVirtualKeyboard/cross index 51e5ed7e34bb3e7e0b35953b5536999803ad72ba..82686f77978ba3fcaab34654d0da0b5eff017bc8 100755 --- a/examples/TpGUI/TpVirtualKeyboard/cross +++ b/examples/TpGUI/TpVirtualKeyboard/cross @@ -1 +1 @@ -g++ main.cpp -o virtualKeyboard -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lPiXExternUtils -lTpUtils -lrime -lTpGUI +g++ main.cpp -o virtualKeyboard -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lPiXExternUtils -lTpUtils -lrime -lTpGUI diff --git a/examples/TpGUI/TpVirtualKeyboard/main.cpp b/examples/TpGUI/TpVirtualKeyboard/main.cpp index 7c56fc272f8b1f8a1b795119d4de70360200a85d..9455e2ac0c360384f49caf7da0bd428d73304390 100644 --- a/examples/TpGUI/TpVirtualKeyboard/main.cpp +++ b/examples/TpGUI/TpVirtualKeyboard/main.cpp @@ -10,8 +10,8 @@ int32_t main(int32_t argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display weekly - app.bindVScreen(vScreen); + weekly + TpLineEdit *testEdit = new TpLineEdit(vScreen); diff --git a/examples/TpGUI/test/cross b/examples/TpGUI/test/cross index 6364cb5035ea08e69e0d2c12ef081b6a28cd4e8a..618450a417b0ef6a14c8b5882c4da9648118412f 100755 --- a/examples/TpGUI/test/cross +++ b/examples/TpGUI/test/cross @@ -1 +1 @@ -g++ main.cpp -o test -I/usr/include/TinyPiX/TpWM -I/usr/include/TinyPiX/GUIFramework -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lTpWMEngine -lpng +g++ main.cpp -o test -I/usr/include/TinyPiX/TpWM -I/usr/include/TinyPiX/GUIFramework -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lTpWMEngine -lpng diff --git a/examples/TpGUI/test/main.cpp b/examples/TpGUI/test/main.cpp index 19fe8d7606f62c96856d344b1aae42dad13ad42c..ab826ee0ace9e5bf78a505146ef2d4dff39f4516 100644 --- a/examples/TpGUI/test/main.cpp +++ b/examples/TpGUI/test/main.cpp @@ -19,6 +19,7 @@ #include "TpSurface.h" #include "png.h" #include "TpMainWindow.h" +#include "Service/TpSystemApi.h" // class ThorVgPaintWidget : public TpWidget class ThorVgPaintWidget : public TpDialog @@ -30,7 +31,6 @@ public: // setBackGroundColor(_RGBA(100, 100, 100, 200)); // setBackGroundImage(TpImage(applicationDirPath() + "/test.svg")); setBackGroundImage(TpImage(applicationDirPath() + "/icon.png")); - // setAlpha(150); testBattery_ = new TpBattery(this); testBattery_->setValue(100); testBattery_->setRect(10, 100, 200, 80); @@ -190,38 +190,72 @@ private: TpBattery *testBattery_; }; +class TestWidget : public TpWidget +{ +public: + TestWidget(TpWidget *parent) : TpWidget(parent) + { + } + ~TestWidget() {} + + virtual bool onMousePressEvent(TpMouseEvent *event) override + { + std::cout << "clickPos : " << event->pos().x() << " , " << event->pos().y() << std::endl; + std::cout << "clickGlobalPos : " << event->globalPos().x() << " , " << event->globalPos().y() << std::endl; + return true; + } + + virtual bool onPaintEvent(TpPaintEvent *event) override + { + TpWidget::onPaintEvent(event); + + TpPainter *painter = event->painter(); + painter->setPen(TpPen(_RGB(255, 165, 255), 3)); + painter->setBrush(TpBrush(_RGB(255, 165, 255))); + painter->drawRect(0, 0, 50, 50); + return true; + } +}; + +IPiSysApiAgent *globalAgent = tinyPiX_sys_create(); + +TpImage getImage() +{ + IPiWFSurface *surfacePtr = tinyPiX_sys_get_process_surface(globalAgent, getpid()); + if (!surfacePtr) + return TpImage(); + + tpShared appDisplayImage = tpMakeShared(surfacePtr); + + TpImage resImage; + resImage.load(appDisplayImage->matrix(), TpSize(appDisplayImage->width(), appDisplayImage->height()), + TpRect(0, 36, appDisplayImage->width(), appDisplayImage->height() - 36)); + + TpImage copyImage = resImage; + + tinyPiX_surface_free(surfacePtr); + + return copyImage; +} + int32_t main(int32_t argc, char *argv[]) { TpApp app(argc, argv); app.setStyle(Tp::SmartDeviceGUIStyle); TpMainWindow *vScreen = new TpMainWindow(); - - // TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - // vScreen->setBackGroundImage(TpImage(applicationDirPath() + "/test.svg")); // vScreen->setBackGroundImage(TpImage(applicationDirPath() + "/icon.png")); - app.bindVScreen(vScreen); - - TpDialog *dia = new TpDialog(); - dia->setBackGroundColor(_RGBA(243, 243, 243, 100)); - dia->setRect(0, 0, 300, 300); - dia->setAlpha(128); - dia->setRoundCorners(50); - dia->setVisible(true); - dia->setBeMoved(true); - - // TpLabel *bgLabel = new TpLabel(vScreen); - // bgLabel->setBackGroundColor(_RGB(200, 80, 80)); - // bgLabel->setRect(300, 50, 500, 500); - - // TestClass *testObj = new TestClass(); - // testObj->setBgLabel(bgLabel); - - // TpButton *testBtn = new TpButton(vScreen); - // testBtn->setText("获取截图"); - // testBtn->setRect(50, 50, 150, 50); - // connect(testBtn, onClicked, testObj, &TestClass::SlotTestFunc); + + TpLabel *bgLabel = new TpLabel(vScreen); + bgLabel->setBorderColor(_RGB(255, 0, 0)); + bgLabel->setRect(250, 50, 450, 450); + + TpButton *testBtn = new TpButton(vScreen); + testBtn->setText("获取当前进程截图"); + testBtn->setRect(50, 50, 150, 50); + connect(testBtn, onClicked, [=](bool) + { bgLabel->setBackGroundImage(getImage()); }); // ThorVgPaintWidget *thorVGPaint = new ThorVgPaintWidget(vScreen); // thorVGPaint->setRect(600, 100, 500, 500); diff --git a/examples/TpUtils/TpConfig/cross b/examples/TpUtils/TpConfig/cross index 7cf84ab2266d7ac370de29a60867818d11f6c0e2..ef1bee06d3a6e68b9bef84e309c7b057047e5628 100755 --- a/examples/TpUtils/TpConfig/cross +++ b/examples/TpUtils/TpConfig/cross @@ -1 +1 @@ -g++ main.cpp -o config -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o config -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpCssParser/cross b/examples/TpUtils/TpCssParser/cross index 5674eb77174eaf8a508ee82819979d4dd6cab2c1..149cfa97c602644ceb4b03d1d1e7e71e86d8e16c 100755 --- a/examples/TpUtils/TpCssParser/cross +++ b/examples/TpUtils/TpCssParser/cross @@ -1 +1 @@ -g++ main.cpp -o cssParser -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o cssParser -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpFileDir/cross b/examples/TpUtils/TpFileDir/cross index fcfa617add9d2f67aa618d24b94c7ae614daad11..403a71fc0edcc9efaf8e4a3d107bddeeac58b82f 100644 --- a/examples/TpUtils/TpFileDir/cross +++ b/examples/TpUtils/TpFileDir/cross @@ -1 +1 @@ -g++ main.cpp -o fileTest -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o fileTest -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpGateway/PubSub/client1 b/examples/TpUtils/TpGateway/PubSub/client1 new file mode 100755 index 0000000000000000000000000000000000000000..d51d276809b5ef86b13a018f07f497744bef82c2 Binary files /dev/null and b/examples/TpUtils/TpGateway/PubSub/client1 differ diff --git a/examples/TpUtils/TpGateway/PubSub/client1Main.cpp b/examples/TpUtils/TpGateway/PubSub/client1Main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..186f9eff342de54ef77540e3239772fc18ed61b9 --- /dev/null +++ b/examples/TpUtils/TpGateway/PubSub/client1Main.cpp @@ -0,0 +1,46 @@ +#include "TpGateway.h" +#include +#include +#include + +std::atomic grunning{true}; +void signalHandler(int signal) +{ + grunning = false; +} + +class TestRecvDataClass : public ITpGatewayHander +{ +public: + virtual void recvData(const char *topic, const void *data, const uint32_t &size) + { + int32_t recvData = *(int32_t *)data; + std::cout << "Topic : " << topic << std::endl; + std::cout << "RecvData : " << recvData << std::endl; + std::cout << "DataSize : " << size << std::endl; + } +}; + +int32_t main(int32_t argc, char *argv[]) +{ + // 注册信号处理 + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + + TestRecvDataClass *recvClass = new TestRecvDataClass(); + + initializeGateway(); + subscribeGatewayData("TestTopic22", recvClass); + + while (grunning) + { + std::cout << "PublishData " << std::endl; + int32_t pubData = 1; + publishGatewayData("TestTopic", &pubData, sizeof(int32_t)); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } + + shutdownGateway(); + + return 0; +} diff --git a/examples/TpUtils/TpGateway/PubSub/client2Main.cpp b/examples/TpUtils/TpGateway/PubSub/client2Main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..47088935908f00c6e9f5ea20eb4ff3c8b45e2a29 --- /dev/null +++ b/examples/TpUtils/TpGateway/PubSub/client2Main.cpp @@ -0,0 +1,46 @@ +#include "TpGateway.h" +#include +#include +#include + +std::atomic grunning{true}; +void signalHandler(int signal) +{ + grunning = false; +} + +class TestRecvDataClass : public ITpGatewayHander +{ +public: + virtual void recvData(const char *topic, const void *data, const uint32_t &size) + { + int32_t recvData = *(int32_t *)data; + std::cout << "Topic : " << topic << std::endl; + std::cout << "RecvData : " << recvData << std::endl; + std::cout << "DataSize : " << size << std::endl; + } +}; + +int32_t main(int32_t argc, char *argv[]) +{ + // 注册信号处理 + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + + TestRecvDataClass *recvClass = new TestRecvDataClass(); + + initializeGateway(); + subscribeGatewayData("TestTopic", recvClass); + + while (grunning) + { + std::cout << "PublishData " << std::endl; + int32_t pubData = 2; + publishGatewayData("TestTopic22", &pubData, sizeof(int32_t)); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + } + + shutdownGateway(); + + return 0; +} diff --git a/examples/TpUtils/tpGateway/cross b/examples/TpUtils/TpGateway/PubSub/cross old mode 100644 new mode 100755 similarity index 73% rename from examples/TpUtils/tpGateway/cross rename to examples/TpUtils/TpGateway/PubSub/cross index 91f2b2b1e147d50f44907f1fc3feea27851e5b02..3c0906bfc63e8cb808de0b3fb46bf0e2541f1a64 --- a/examples/TpUtils/tpGateway/cross +++ b/examples/TpUtils/TpGateway/PubSub/cross @@ -1,2 +1,2 @@ -g++ client1Main.cpp -o client1 -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -g++ client2Main.cpp -o client2 -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ client1Main.cpp -o client1 -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ client2Main.cpp -o client2 -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpGateway/REP/cross b/examples/TpUtils/TpGateway/REP/cross new file mode 100755 index 0000000000000000000000000000000000000000..4c97ea249f455d14e47fa532ec0c45a7010724a9 --- /dev/null +++ b/examples/TpUtils/TpGateway/REP/cross @@ -0,0 +1 @@ +g++ main.cpp -o repClient -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpGateway/REP/main.cpp b/examples/TpUtils/TpGateway/REP/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..60e54d8a08a3d4e2cf68f50524eeb71158677e44 --- /dev/null +++ b/examples/TpUtils/TpGateway/REP/main.cpp @@ -0,0 +1,33 @@ +#include "TpGateway.h" +#include +#include +#include + +std::atomic grunning{true}; +void signalHandler(int signal) +{ + grunning = false; +} + +int32_t main(int32_t argc, char *argv[]) +{ + // 注册信号处理 + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + + TpGatewayClientREQ client; + client.openConnect("ipc:///tmp/gateway_rep.ipc"); + + while (grunning) + { + std::cout << "SendReq " << std::endl; + std::string recvString = client.sendRequest("TestReqKey"); + std::cout << "接收到服务端响应:" << recvString << std::endl; + + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); + } + + client.closeConnect(); + + return 0; +} diff --git a/examples/TpUtils/TpInputMethod/cross b/examples/TpUtils/TpInputMethod/cross index 074de32997ceb1a33ae068b8d452a96215133fbc..2b6f83991caf1d5ca739fff76df7873407e60f73 100644 --- a/examples/TpUtils/TpInputMethod/cross +++ b/examples/TpUtils/TpInputMethod/cross @@ -1 +1 @@ -g++ main.cpp -o inputMethod -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lrime +g++ main.cpp -o inputMethod -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lrime diff --git a/examples/TpUtils/TpJsonParser/cross b/examples/TpUtils/TpJsonParser/cross index 1b25af6120da7a4a1daa7780ae5d57efeabf755a..1f004a101f3deb4c2262932f45c4f186a6737024 100644 --- a/examples/TpUtils/TpJsonParser/cross +++ b/examples/TpUtils/TpJsonParser/cross @@ -1 +1 @@ -g++ main.cpp -o jsonParser -I/usr/include -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpExtUtils -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/app -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lPiXExternUtils +g++ main.cpp -o jsonParser -I/usr/include -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpExtUtils -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/app -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI -lPiXExternUtils diff --git a/examples/TpUtils/TpPipe/cross b/examples/TpUtils/TpPipe/cross index b44679322defcfc397bb37f0e310d0bcc930121f..043426dbf91595a8900dc1d00aa9febe203dca36 100755 --- a/examples/TpUtils/TpPipe/cross +++ b/examples/TpUtils/TpPipe/cross @@ -1 +1 @@ -g++ main.cpp -o pipe -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o pipe -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpProcess/cross b/examples/TpUtils/TpProcess/cross index 2dbf6ed52c6d652e2b8d9cce75193f9e322add62..798470cb500440226a03ab032aa26f9634744a75 100644 --- a/examples/TpUtils/TpProcess/cross +++ b/examples/TpUtils/TpProcess/cross @@ -1 +1 @@ -g++ main.cpp -o process -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o process -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpProcess/main.cpp b/examples/TpUtils/TpProcess/main.cpp index b853b7c27b3e299c26c59b3081a30717731034e7..358ec204f0cf7af6d93a0d18044e9559001e410c 100644 --- a/examples/TpUtils/TpProcess/main.cpp +++ b/examples/TpUtils/TpProcess/main.cpp @@ -11,8 +11,8 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + TpButton *button1 = new TpButton("吉林省1", vScreen); button1->setProperty("type", "ControlPanelPowerButton"); diff --git a/examples/TpUtils/TpShareMemory/cross b/examples/TpUtils/TpShareMemory/cross index 76ef1b7d904eac851f3a9f84fbb4c7f904a928a6..e64743a0bea62e0c1592b9513d52b021d363158e 100755 --- a/examples/TpUtils/TpShareMemory/cross +++ b/examples/TpUtils/TpShareMemory/cross @@ -1 +1 @@ -g++ main.cpp -o send -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o send -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpShareMemory/crossRecv b/examples/TpUtils/TpShareMemory/crossRecv index 369ae043775e445df3694fce92529037efc0c3cf..6e454046755f7ca8d84ee197ecb63546d9fd1bc9 100755 --- a/examples/TpUtils/TpShareMemory/crossRecv +++ b/examples/TpUtils/TpShareMemory/crossRecv @@ -1 +1 @@ -g++ recvMain.cpp -o recvMain -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ recvMain.cpp -o recvMain -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpSignalslot/cross b/examples/TpUtils/TpSignalslot/cross index de2d0721ae1943e1f6a63643a381b1b1e2558987..1d35fc4013095b937c89130101a9a4825a638a65 100755 --- a/examples/TpUtils/TpSignalslot/cross +++ b/examples/TpUtils/TpSignalslot/cross @@ -1 +1 @@ -g++ main.cpp -o signalSlot -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o signalSlot -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpSignalslot/main.cpp b/examples/TpUtils/TpSignalslot/main.cpp index 0fee590bd9497b22ce3fb09823d52f61b9aa4f7a..f1edcf259c23b6f059a231241a780d8a6b06ef6c 100644 --- a/examples/TpUtils/TpSignalslot/main.cpp +++ b/examples/TpUtils/TpSignalslot/main.cpp @@ -24,8 +24,8 @@ int main(int argc, char *argv[]) TpMainWindow *vScreen = new TpMainWindow(); vScreen->setBackGroundColor(_RGBA(128, 128, 128, 255)); - vScreen->setVisible(true); // vScreen setvisible will be update display - app.bindVScreen(vScreen); + + std::thread::id mainThreadId = std::this_thread::get_id(); diff --git a/examples/TpUtils/TpString/cross b/examples/TpUtils/TpString/cross index 0fe6732fae8f5131961082728d759314fc737f00..9388ca7bff790d9b87e634121c95842ed864d29b 100644 --- a/examples/TpUtils/TpString/cross +++ b/examples/TpUtils/TpString/cross @@ -1 +1 @@ -g++ main.cpp -o string -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o string -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpThreadPool/cross b/examples/TpUtils/TpThreadPool/cross index 656008a836136371b73f1cbabf3f4a934aff65a0..082abefc791ddbc87b6a22abc02a8a2a2d31651d 100755 --- a/examples/TpUtils/TpThreadPool/cross +++ b/examples/TpUtils/TpThreadPool/cross @@ -1 +1 @@ -g++ main.cpp -o threadPool -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o threadPool -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpUuid/cross b/examples/TpUtils/TpUuid/cross index f49b7c3db069c87560d926f78fbd5a29824c51dd..0a492bdfc185e654a34f16ac6b40cb2eecb17a71 100755 --- a/examples/TpUtils/TpUuid/cross +++ b/examples/TpUtils/TpUuid/cross @@ -1 +1 @@ -g++ main.cpp -o uuid -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o uuid -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/TpVariant/cross b/examples/TpUtils/TpVariant/cross index ca7b575cd64344d94337d9186e6b00d910506524..c0adb9c61d2c0493ebf0c83c190c3da88d766978 100755 --- a/examples/TpUtils/TpVariant/cross +++ b/examples/TpUtils/TpVariant/cross @@ -1 +1 @@ -g++ main.cpp -o variant -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX/TpUtils -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime \ No newline at end of file +g++ main.cpp -o variant -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX/TpUtils -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime \ No newline at end of file diff --git a/examples/TpUtils/network/cross b/examples/TpUtils/network/cross deleted file mode 100644 index a5656e05207aeffb202def37d4ff8c661f1ea37a..0000000000000000000000000000000000000000 --- a/examples/TpUtils/network/cross +++ /dev/null @@ -1,2 +0,0 @@ -g++ main.cpp -o test -I/usr/include -I/usr/include/SDL2 -I../../../../PiX/include/Utils -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/lib -L/usr/lib/TinyPiX -L../../../../PixSingleGUI/depend_lib -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime - diff --git a/examples/TpUtils/tpDateTime/cross b/examples/TpUtils/tpDateTime/cross index 0fe7b8952595c63862ee7d3370cd6890eed83b71..1d8c093f604b0048cdce7e6671a822a226e1224c 100644 --- a/examples/TpUtils/tpDateTime/cross +++ b/examples/TpUtils/tpDateTime/cross @@ -1 +1 @@ -g++ main.cpp -o dateTime -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lSDL2_image -lSDL2_gfx -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI +g++ main.cpp -o dateTime -I/usr/include -I/usr/include/TinyPiX/TpWM -I/usr/include/SDL2 -I/usr/include/TinyPiX -I/usr/include/TinyPiX/TpUtils -I/usr/include/TinyPiX/TpGUI -I/usr/include/TinyPiX/TpGUI/Core -I/usr/include/TinyPiX/TpGUI/Screen -I/usr/include/TinyPiX/TpGUI/Widgets -I. -I/usr/include/freetype2 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/TinyPiX/TpGUI/Core -L/usr/lib -L/usr/lib/TinyPiX -ldl -lpthread -lSDL2 -lcairo -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lfontconfig -lfreetype -lgbm -lGLESv2 -lEGL -lTpUtils -lrime -lTpGUI diff --git a/examples/TpUtils/tpGateway/client1Main.cpp b/examples/TpUtils/tpGateway/client1Main.cpp deleted file mode 100644 index ad529a696cc370b138e01d514ebb02bed0ea0908..0000000000000000000000000000000000000000 --- a/examples/TpUtils/tpGateway/client1Main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "TpGateway.h" -#include - -class TestRecvDataClass : public TpGateway -{ -public: - virtual void recvData(const char *topic, const void *data, const uint32_t &size) - { - int32_t recvData = *(int32_t*)data; - std::cout << "Topic : " << topic << std::endl; - std::cout << "RecvData : " << recvData << std::endl; - std::cout << "DataSize : " << size << std::endl; - } -}; - -int32_t main(int32_t argc, char *argv[]) -{ - TestRecvDataClass *recvClass = new TestRecvDataClass(); - - initializeGateway(); - subscribeGatewayData("TestTopic22", recvClass); - - while (1) - { - std::cout << "PublishData " << std::endl; - int32_t pubData = 1; - publishGatewayData("TestTopic", &pubData, sizeof(int32_t)); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - } - - shutdownGateway(); - - return 0; -} diff --git a/examples/TpUtils/tpGateway/client2Main.cpp b/examples/TpUtils/tpGateway/client2Main.cpp deleted file mode 100644 index e6680159d6d36b6e02096d24d22a89fc353e3bb6..0000000000000000000000000000000000000000 --- a/examples/TpUtils/tpGateway/client2Main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "TpGateway.h" -#include - -class TestRecvDataClass : public TpGateway -{ -public: - virtual void recvData(const char *topic, const void *data, const uint32_t &size) - { - int32_t recvData = *(int32_t *)data; - std::cout << "Topic : " << topic << std::endl; - std::cout << "RecvData : " << recvData << std::endl; - std::cout << "DataSize : " << size << std::endl; - } -}; - -int32_t main(int32_t argc, char *argv[]) -{ - TestRecvDataClass *recvClass = new TestRecvDataClass(); - - initializeGateway(); - subscribeGatewayData("TestTopic", recvClass); - - while (1) - { - std::cout << "PublishData " << std::endl; - int32_t pubData = 2; - publishGatewayData("TestTopic22", &pubData, sizeof(int32_t)); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - } - - shutdownGateway(); - - return 0; -} diff --git a/examplesApp/CMakeLists.txt b/examplesApp/CMakeLists.txt index a1246f226e9f5fbce77dca6f0462c28ca21f79b7..2c68d6c46370a586137317b7e98b8b0b0398c12d 100644 --- a/examplesApp/CMakeLists.txt +++ b/examplesApp/CMakeLists.txt @@ -27,6 +27,7 @@ set(SOURCE_FILES include_directories(${SOURCE_PATH}) include_directories(/usr/include) include_directories(/usr/include/TinyPiX) +include_directories(/usr/include/TinyPiX/TpWM) include_directories(/usr/include/TinyPiX/TpUtils) include_directories(/usr/include/TinyPiX/TpExtUtils) include_directories(/usr/include/TinyPiX/TpGUI) diff --git a/examplesApp/src/MainWindowService.cpp b/examplesApp/src/MainWindowService.cpp index aaed76eb2a823f751a7663697f0f353c4157b4d4..2874c702aae9a905fa3c4b6f2e70ce099064cb3e 100644 --- a/examplesApp/src/MainWindowService.cpp +++ b/examplesApp/src/MainWindowService.cpp @@ -22,13 +22,6 @@ bool MainWindowService::appChange(int32_t id, int32_t pid, int32_t visible, int3 return true; } -bool MainWindowService::onResizeEvent(TpResizeEvent *event) -{ - std::cout << "mainWindowService::onResizeEvent" << std::endl; - - return true; -} - bool MainWindowService::onActiveEvent(TpActiveEvent *event) { std::cout << "mainWindowService::onActiveEvent" << std::endl; diff --git a/examplesApp/src/MainWindowService.h b/examplesApp/src/MainWindowService.h index 0bc6de15e1d7430e3ac59fadbb07de9c904e1023..74ec112ae3d15d7fe29f588d02661fa30bcac6fb 100644 --- a/examplesApp/src/MainWindowService.h +++ b/examplesApp/src/MainWindowService.h @@ -16,8 +16,6 @@ public: virtual bool appChange(int32_t id, int32_t pid, int32_t visible, int32_t active, int32_t color, uint8_t alpha, int32_t require) override; protected: - virtual bool onResizeEvent(TpResizeEvent *event) override; - virtual bool onActiveEvent(TpActiveEvent *event) override; virtual bool onPaintEvent(TpPaintEvent *event) override; diff --git a/examplesApp/src/main.cpp b/examplesApp/src/main.cpp index 923018dc9944f2a21ba146ae281331fc4962a929..755bf69fa21cfba2e42a04d566c77ef21b1414bf 100644 --- a/examplesApp/src/main.cpp +++ b/examplesApp/src/main.cpp @@ -6,8 +6,6 @@ int32_t main(int32_t argc, char *argv[]) TpApp app(argc, argv); MainWindowService *mainWindow = new MainWindowService(); - app.bindVScreen(mainWindow); - mainWindow->update(); return app.run(); } diff --git a/install/dopack.sh b/install/dopack.sh index db1128abc1d4a351a8dd4754348032b53c566e85..55bb753de7135c8b136b39d426f65b9278588eef 100755 --- a/install/dopack.sh +++ b/install/dopack.sh @@ -7,17 +7,23 @@ TMP_ROOT_DIR="package_build" # 生成的临时文件的名字 KEEP_TMP_DIR=false # 是否保留中间生成的打包源文件 SCRIPTS_DIR="config" # 禁止修改,如果需要修改,需要同步修“改智能安装器“部分的SCRIPTS_DIR -if [ $# -ge 1 ]; then - ARCH="$1" -else - ARCH="auto" # 默认自动检测 +if [ $# -lt 2 ]; then + echo "❌ 错误: 需要提供两个参数" + echo "用法: $0 <架构> <是否在线>" + echo " 架构: x86_64 或 arm_64" + echo " 是否在线: 1 (在线模式) 或 0 (离线模式)" + exit 1 fi +# 获取参数 +ARCH="$1" +ONLINE_MODE="$2" + # 源目录 → 目标路径映射 (完整保留多路径映射) declare -A PATH_MAPPINGS=( # 相对路径会自动转换为绝对路径 # 格式: [源目录]="模式:目标路径" - # 模式支持: overwrite(覆盖) | merge(合并) | update(更新) + # 模式支持: overwrite(覆盖) | merge(合并) | update(更新) | preserve(跳过以有同名文件) ["./{ARCH}/lib"]="overwrite:/usr/lib/TinyPiX" ["./{ARCH}/bin"]="overwrite:/usr/bin/TinyPiX" @@ -34,8 +40,15 @@ declare -A PATH_MAPPINGS=( ["./{ARCH}/res"]="update:/usr/res/TinyPiX" #System - ["./system"]="overwrite:/System" +# ["./system"]="overwrite:/System" + # 系统基本构建环境(必须使用preserve模式) +# ["./build/{ARCH}/lib"]="overwrite:/usr/lib/TinyPiX/build" +# ["./build/{ARCH}/bin"]="overwrite:/usr/bin/TinyPiX/build" +# ["./build/{ARCH}/libexec"]="overwrite:/usr/libexec/TinyPiX/build" +# ["./build/{ARCH}/etc"]="preserve:/usr/etc/TinyPiX" + +# ["./build/{ARCH}/systemd"]="preserve:/usr/lib/TinyPiX/systemd" #这个目录仅用于映射保存,实际安装位置为/usr/lib/systemd/system ) # ===================================================== @@ -148,6 +161,11 @@ echo "===== 开始灵活路径打包 =====" ACTUAL_ARCH=$(resolve_architecture) #拼接输出文件名 OUTPUT_NAME="${BASE_NAME}_${ACTUAL_ARCH}.run" +#打包模式 +PACKAGE_MODE_VALUE="local" # 默认为离线模式 +if [ "$ONLINE_MODE" = "1" ]; then + PACKAGE_MODE_VALUE="online" +fi # 1. 创建临时根目录 echo "▸ 创建临时工作区: $TMP_ROOT_DIR" @@ -181,6 +199,13 @@ declare -A target_groups declare -A mode_map # 存储目标路径到模式的映射 echo "▸ 处理路径映射 (ARCH=$ACTUAL_ARCH)" for src_key in "${!PATH_MAPPINGS[@]}"; do + + #如果是在线模式跳过build目录 + if [ "$PACKAGE_MODE" = "online" ] && [[ "$src_key" == *"build"* ]]; then + echo " ⏭️ 在线模式: 跳过 $src_key" + continue + fi + # 获取原始映射值 mapping_value="${PATH_MAPPINGS[$src_key]}" echo " - 源键: $src_key => 映射值: $mapping_value" @@ -253,6 +278,7 @@ done cat > "$TMP_ROOT_DIR/installer.sh" <<'EOF' #!/bin/bash # TinyPiXOS 智能安装器 (完整覆盖版) +PACKAGE_MODE="$PACKAGE_MODE_VALUE" SCRIPTS_DIR="config" SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) @@ -382,11 +408,13 @@ echo "映射文件: $MAPPING_FILE" echo "▸ 正在检查系统依赖包 (架构: $ARCH)" packages=( libsdl2-dev libdrm-dev libudev-dev - libcairo2-dev libpango1.0-dev libglib2.0-dev - libpangocairo-1.0-0 libfontconfig-dev libfreetype-dev - libgbm-dev libgles2 libegl-dev - librsvg2-dev libssl-dev libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev - bluez-obexd bluez-alsa-utils libasound2-plugin-bluez + libcairo2-dev libpango1.0-dev libglib2.0-dev \ + libpangocairo-1.0-0 libfontconfig-dev libfreetype-dev \ + libgbm-dev libgles2 libegl-dev \ + libasound2-dev libjson-c-dev libssl-dev libavcodec-dev libavformat-dev \ + libavutil-dev libswscale-dev libswresample-dev \ + libavfilter-dev libavdevice-dev librsvg2-dev bluez libbluetooth-dev \ + libdbus-1-dev bluez-alsa-utils libasound2-plugin-bluez bluez-obexd libusb-1.0-0-dev \ libleveldb-dev libmarisa-dev libopencc-dev libyaml-cpp-dev libgoogle-glog-dev ) # 可能已经通过手动安装的库 @@ -405,7 +433,7 @@ check_sdl2_installed() { #网络检查函数 check_network() { - local servers=("google.com" "8.8.8.8" "1.1.1.1") + local servers=("baidu.com" "8.8.8.8" "1.1.1.1") local connected=0 echo "▸ 检查网络连接..." @@ -429,62 +457,55 @@ check_network() { echo "✓ 网络连接正常" return 0 } -check_and_install_packages() { - if ! command -v apt-get >/dev/null; then - echo "[错误] 只支持基于Debian的系统(如Ubuntu)自动安装依赖包" >&2 - echo "请手动安装以下包:${packages[*]}" >&2 - return 1 - fi - # 更新包列表... - echo " 更新包列表..." - if ! apt-get update >/dev/null; then - echo "[错误] 更新包列表失败,请检查软件源配置" >&2 - return 1 - fi - - for pkg in "$@"; do - # 使用 dpkg-query 精确检查 - if dpkg-query -W -f='${Status}' "$pkg" 2>/dev/null | grep -q "install ok installed"; then - echo " ✓ $pkg 已安装" - continue; - fi - # 检查可能通过手动安装的库 - if [[ -n "${LIB_DETECT_FUNCTIONS[$pkg]}" ]]; then - if ${LIB_DETECT_FUNCTIONS[$pkg]}; then - echo " ✓ [$pkg] 检测到手动编译安装" - continue # 跳过安装流程 - fi - fi - #安装 - echo " ▸ 正在安装 $pkg ..." - if ! apt-get install -y "$pkg" >/dev/null; then - echo "[错误] 安装 $pkg 失败,请检查网络连接或软件源配置" >&2 - return 1 - fi - done - - return 0 -} check_and_install_packages() { local has_network=$1 # 接收网络状态参数 shift # 移除第一个参数,剩余参数为包列表 + local packages=("$@") #包列表 - if ! command -v apt-get >/dev/null; then - echo "[错误] 只支持基于Debian的系统(如Ubuntu)自动安装依赖包" >&2 - echo "请手动安装以下包:${packages[*]}" >&2 - exit 1 + # 检测系统可用的包管理工具 + local pkg_manager="" + if command -v apt > /dev/null 2>&1; then + pkg_manager="apt" + elif command -v apt-get > /dev/null 2>&1; then + pkg_manager="apt-get" + else + echo "❌ 当前系统未检测到 apt 或 apt-get 包管理器。" >&2 + echo "📋 需要手动安装的软件包列表: ${packages[*]}" >&2 + echo "💡 请根据您的嵌入式平台文档,通过源码或特定包管理器安装上述软件。" >&2 + return 1 fi - # 更新包索引 - if [ $has_network -eq 0 ]; then - echo "▸ 更新包列表..." - if ! apt-get update >/dev/null; then + if [ $has_network -eq 0 ]; then + echo "▸ 检测到包管理器: $pkg_manager, 开始自动安装流程..." + echo "▸ 更新软件包列表..." + if ! sudo $pkg_manager update > /dev/null 2>&1; then echo "❌ 更新包列表失败" >&2 return 1 fi + + echo "▸ 正在安装软件包: ${packages[*]} ..." + if sudo $pkg_manager install -y "${packages[@]}" > /dev/null 2>&1; then + echo "✓ 所有软件包安装成功。" + return 0 + else + echo "❌ 软件包安装失败,请检查:" >&2 + echo " • 网络连接" >&2 + echo " • 软件源配置" >&2 + echo " • 软件包名称拼写" >&2 + return 1 + fi + + # 4. 有包管理器但无网络:提示手动安装 + else + echo "❌ 检测到包管理器但无网络连接,无法自动安装。" >&2 + echo "📋 需要手动安装的软件包列表: ${packages[*]}" >&2 + echo "💡 请在有网络的环境下执行自动安装,或手动下载上述软件的 .deb 包及其依赖后进行离线安装。" >&2 + return 1 fi + #循环安装所有包 + : ' #按块注释调这部分,改为直接安装 for pkg in "$@"; do # 方法1:使用 dpkg-query 精确检查(推荐) # 使用 dpkg-query 精确检查 @@ -506,24 +527,38 @@ check_and_install_packages() { return 1 fi echo " ▸ 正在安装 $pkg ..." - if ! apt-get install -y "$pkg" >/dev/null; then + if ! $pkg_manager install -y "$pkg" >/dev/null; then echo "[错误] 安装 $pkg 失败,请检查网络连接或软件源配置" >&2 return 1 fi echo " ✓ $pkg 安装成功" done + ' } -if check_network; then - has_network=0 # 有网络 -else - has_network=1 # 无网络 -fi -# 安装依赖包,传递网络状态和包列表 -if ! check_and_install_packages $has_network "${packages[@]}"; then - echo "❌ 依赖包检查/安装失败" >&2 - exit 1 +if [ "$PACKAGE_MODE" = "online" ]; then + if check_network; then + has_network=0 # 有网络 + else + has_network=1 # 无网络 + fi + + # 安装依赖包,传递网络状态和包列表 + # 保存依赖包安装状态 + DEPENDENCY_STATUS=0 + PACKAGES_TO_INSTALL_MANUALLY=() + + # 安装依赖包 + check_and_install_packages $has_network "${packages[@]}" + DEPENDENCY_STATUS=$? + + # 根据状态码记录需要手动安装的包 + if [ $DEPENDENCY_STATUS -ne 0 ]; then + PACKAGES_TO_INSTALL_MANUALLY=("${packages[@]}") + fi +else + echo "💿 离线安装模式 - 使用包内预置的第三方依赖" fi # ====================== 文件复制逻辑 ====================== @@ -534,7 +569,7 @@ while IFS= read -r mapping; do # 跳过空行和注释 [[ "$mapping" == \#* ]] || [[ -z "$mapping" ]] && continue - # 使用两次分割提取三个部分 + # 解析映射行:源路径<|>模式<|>目标路径 part1="${mapping%%<|>*}" rest="${mapping#*<|>}" part2="${rest%%<|>*}" @@ -550,88 +585,106 @@ while IFS= read -r mapping; do mode_part="$part2" dest_part="$part3" - # 调试输出 - echo " - 映射行解析:" - echo " src_part: $src_part" - echo " mode_part: $mode_part" - echo " dest_part: $dest_part" - - # 计算完整源路径 + # 计算完整路径 src_path="${SCRIPT_DIR}/${src_part}" full_dest="${TARGET_DIR}${dest_part}" - # 计算完整源路径 - src_path="${SCRIPT_DIR}/${src_part}" - full_dest="${TARGET_DIR}${dest_part}" - - if [ ! -d "$src_path" ]; then - echo "❌ 错误: 源目录不存在 - $src_path" >&2 - echo " 映射行: $mapping" >&2 - echo " 脚本目录: $SCRIPT_DIR" >&2 - echo " 源路径: $src_path" >&2 + # 验证源路径是否存在 + if [ ! -e "$src_path" ]; then + echo "❌ 错误: 源路径不存在 - $src_path" >&2 continue fi + # 调试信息 + echo " - 处理映射: $src_path => $full_dest (模式: $mode_part)" + if $DRY_RUN; then - echo "🔍 [模拟] $src_path => $full_dest (模式: $mode_part)" + echo " [模拟运行] 跳过实际操作" continue fi - echo "▸ 处理映射: $src_path => $full_dest (模式: $mode_part)" - - # 第一次遇到目标路径时,根据模式处理 - if [ -z "${processed_targets[$full_dest]}" ]; then - case "$mode_part" in - overwrite) - # 覆盖模式:清空目标目录 - echo " 🗑️ 清空目标目录: $full_dest" - rm -rf "$full_dest" 2>/dev/null - ;; - merge|update) - # 合并/更新模式:保留目标目录 - if [ ! -d "$full_dest" ]; then - echo " 📁 创建目标目录: $full_dest" - mkdir -p "$full_dest" + # 根据模式处理目标目录初始化 + case "$mode_part" in + overwrite) + if [ -e "$full_dest" ]; then + echo " 🗑️ 覆盖模式: 清空目标目录" + rm -rf "$full_dest" + fi + ;; + preserve) + echo " 🔒 使用保活模式处理目录: $full_dest" + # 检查目标目录是否已存在 + if [ -e "$full_dest" ] || [ -L "$full_dest" ]; then + echo " ⏭️ 目标目录已存在,为保活用户配置,跳过部署。" + else + echo " ✅ 目标目录不存在,执行初始安装。" + # 递归复制整个目录(包括子目录) + if [ -d "$src_path" ]; then + cp -r "$src_path" "$full_dest" + echo " ✓ 目录初始安装完成。" else - echo " 🔄 保留目标目录内容 (模式: $mode_part)" + cp "$src_path" "$full_dest" + echo " ✓ 文件初始安装完成。" fi - ;; - *) - echo "⚠️ 未知拷贝模式: $mode_part, 使用默认覆盖模式" >&2 - rm -rf "$full_dest" 2>/dev/null - ;; - esac - processed_targets["$full_dest"]=1 - fi + fi + ;; + merge|update) + # 这些模式保留现有内容,如果目录不存在则创建 + if [ ! -d "$full_dest" ]; then + echo " 📁 创建目标目录 (模式: $mode_part)" + mkdir -p "$full_dest" + else + echo " 🔄 保留目标目录内容 (模式: $mode_part)" + fi + ;; + *) + echo "⚠️ 未知模式: $mode_part,使用默认覆盖模式" >&2 + if [ -e "$full_dest" ]; then + rm -rf "$full_dest" + fi + ;; + esac - # 确保目标目录存在 - mkdir -p "$full_dest" + # 确保目标目录存在(对于需要创建的情况) + if [ ! -d "$full_dest" ]; then + mkdir -p "$full_dest" + fi - # 根据拷贝模式执行不同操作 + # 根据模式执行复制操作 case "$mode_part" in overwrite) - # 完全覆盖 - echo " → 完全覆盖: $src_path/ => $full_dest/" + echo " → 执行完全覆盖" rsync -a --delete "$src_path/" "$full_dest/" ;; merge) - # 合并目录(不删除目标目录已有文件) - echo " → 合并内容: $src_path/ => $full_dest/" + echo " → 执行合并(覆盖同名文件)" rsync -a "$src_path/" "$full_dest/" ;; update) - # 只更新较新的文件 - echo " → 更新内容: $src_path/ => $full_dest/ (仅更新)" + echo " → 执行更新(仅更新较新文件)" rsync -a -u "$src_path/" "$full_dest/" ;; + preserve) + # ✅ 统一使用rsync的-n(dry-run)参数进行存在性检查 + echo " → 执行保活安装(仅当目标不存在时)" + # 使用rsync的dry-run模式检查是否有文件需要复制 + if rsync -a -n --include="*/" --include="*" --exclude="*" "$src_path/" "$full_dest/" | grep -q .; then + echo " ✅ 目标目录为空,执行初始安装" + rsync -a "$src_path/" "$full_dest/" + else + echo " ⏭️ 目标目录已存在内容,跳过复制" + fi + ;; *) - # 默认使用覆盖模式 - echo "⚠️ 未知拷贝模式: $mode_part, 使用覆盖模式" >&2 + echo "⚠️ 未知模式,使用默认覆盖模式" >&2 rsync -a --delete "$src_path/" "$full_dest/" ;; - esac + esac || { + echo "❌ 复制操作失败: $src_path => $full_dest" >&2 + continue + } - # 确保所有文件可访问 + # 设置权限(所有模式通用) chmod -R a+rX "$full_dest" done < "$MAPPING_FILE" @@ -659,7 +712,7 @@ safe_create_link() { return 0 } -# ====================== 合并软链接处理 ====================== +# ====================== 合并软链接处理 (对bin,lib,字体创建软链接)====================== create_symlinks() { echo "▸ 创建绝对路径符号链接 (安全替换)" @@ -749,11 +802,206 @@ create_symlinks() { fi } +create_corrected_symlinks() { + echo "▸ 开始处理第三方软链接 " + + local SYSTEM_BIN_DIR="${TARGET_DIR}/usr/bin" + local SYSTEM_LIB_DIR="${TARGET_DIR}/usr/lib" + local TINYPIX_BIN_DIR="${TARGET_DIR}/usr/bin/TinyPiX" + local TINYPIX_LIB_DIR="${TARGET_DIR}/usr/lib/TinyPiX" + + # 1. 处理第三方二进制文件 (位于 build 子目录,智能链接) + if [ -d "${TINYPIX_BIN_DIR}/build" ]; then + echo " → 处理第三方二进制文件 (/build/ 目录,智能链接)" + find "${TINYPIX_BIN_DIR}/build" -maxdepth 1 -type f -executable | while read -r bin; do + local bin_name=$(basename "$bin") + local system_bin_path="${SYSTEM_BIN_DIR}/${bin_name}" + + # 核心逻辑:只有系统路径不存在时才创建链接 + if [ ! -e "$system_bin_path" ] && [ ! -L "$system_bin_path" ]; then + echo " ✅ 创建第三方命令链接: $bin_name -> TinyPiX/build/$bin_name" + if ! $DRY_RUN; then + ln -sf "$bin" "$system_bin_path" + fi + else + echo " ⏭️ 系统已存在命令 '$bin_name',跳过链接" + fi + done + fi + + # 2. 处理第三方库文件 (位于 build 子目录,智能链接) + if [ -d "${TINYPIX_LIB_DIR}/build" ]; then + echo " → 处理第三方库文件 (/build/ 目录,智能链接)" + find "${TINYPIX_LIB_DIR}/build" -type f \( -name "*.so" -o -name "*.so.*" \) | while read -r lib; do + local lib_name=$(basename "$lib") + + # 版本化库处理逻辑 + if [[ "$lib_name" =~ \.so\. ]]; then + local base_name="${lib_name%%.so.*}.so" + local major_version="${lib_name#*.so.}"; major_version="${major_version%%.*}" + + local major_link="${SYSTEM_LIB_DIR}/${base_name}.${major_version}" + local base_link="${SYSTEM_LIB_DIR}/${base_name}" + + # 只创建系统缺失的链接 + if [ ! -e "$major_link" ] && [ ! -L "$major_link" ]; then + echo " ✅ 创建版本库链接: ${base_name}.${major_version} -> TinyPiX/build/$lib_name" + if ! $DRY_RUN; then + ln -sf "$lib" "$major_link" + fi + else + echo " ⏭️ 系统已存在库链接 '${base_name}.${major_version}',跳过" + fi + + if [ ! -e "$base_link" ] && [ ! -L "$base_link" ]; then + echo " ✅ 创建基础库链接: $base_name -> TinyPiX/build/$lib_name" + if ! $DRY_RUN; then + ln -sf "$lib" "$base_link" + fi + else + echo " ⏭️ 系统已存在库链接 '$base_name',跳过" + fi + else + # 非版本化库 + local link_path="${SYSTEM_LIB_DIR}/${lib_name}" + if [ ! -e "$link_path" ] && [ ! -L "$link_path" ]; then + echo " ✅ 创建库链接: $lib_name -> TinyPiX/build/$lib_name" + if ! $DRY_RUN; then + ln -sf "$lib" "$link_path" + fi + else + echo " ⏭️ 系统已存在库 '$lib_name',跳过" + fi + fi + done + fi + echo "✓ 第三方软链接处理完成" +} + +# ====================== service文件安装 ====================== +install_systemd_services() { + local SERVICE_SOURCE_DIR="${TARGET_DIR}/usr/lib/TinyPiX/systemd" + local SYSTEMD_TARGET_DIR="/etc/systemd/system" + + echo "▸ 开始部署 systemd 服务文件 (模式: preserve)..." + + # 1. 检查源目录是否存在 + if [ ! -d "$SERVICE_SOURCE_DIR" ]; then + echo " ℹ️ 未找到服务文件源目录: $SERVICE_SOURCE_DIR" + return 0 + fi + + # 2. 确保目标目录存在 + safe_mkdir "$SYSTEMD_TARGET_DIR" + + # 3. 使用 find 命令递归查找所有 .service 文件(包括子目录) + # 这就是 find 命令应该放置的位置! + find "$SERVICE_SOURCE_DIR" -name "*.service" | while read -r service_file; do + # 计算相对于源目录的相对路径 + local relative_path="${service_file#$SERVICE_SOURCE_DIR/}" + local service_name=$(basename "$service_file") + + # 在目标路径中保持相同的目录结构 + local systemd_dest="${SYSTEMD_TARGET_DIR}/${relative_path}" + local dest_dir=$(dirname "$systemd_dest") + + echo " → 处理服务: $relative_path" + + # 确保目标目录存在 + safe_mkdir "$dest_dir" + + # Preserve 模式核心逻辑:检查目标是否已存在 + if [ -e "$systemd_dest" ] || [ -L "$systemd_dest" ]; then + echo " ⏭️ 系统已存在服务 '$relative_path',为保活现有配置,跳过部署。" + else + echo " ✅ 目标不存在,执行初始安装。" + if ! $DRY_RUN; then + # 复制文件并设置正确权限 + cp "$service_file" "$systemd_dest" + chmod 644 "$systemd_dest" + echo " ✓ 服务文件安装完成。" + fi + fi + done + + # 4. 重新加载 systemd 配置 + if ! $DRY_RUN; then + echo "▸ 重新加载 systemd 配置..." + if systemctl daemon-reload; then + echo " ✅ systemd 配置重载成功。" + else + echo " ⚠️ systemd 配置重载完成(请注意环境)。" + fi + fi + + echo "✓ 服务文件部署完成。" +} + +deploy_etc_configs() { + local ETC_SOURCE_DIR="${TARGET_DIR}/usr/etc/TinyPiX" + local ETC_TARGET_DIR="/etc" + + echo "▸ 开始部署 etc 配置文件 (模式: preserve)..." + + # 1. 检查源目录是否存在 + if [ ! -d "$ETC_SOURCE_DIR" ]; then + echo " ℹ️ 未找到 etc 配置源目录: $ETC_SOURCE_DIR" + return 0 + fi + + # 2. 递归遍历源目录中的所有文件 + find "$ETC_SOURCE_DIR" -type f | while read -r source_file; do + # 计算相对于源目录的相对路径 + local relative_path="${source_file#$ETC_SOURCE_DIR/}" + local dest_file="${ETC_TARGET_DIR}/${relative_path}" + + echo " → 处理配置: $relative_path" + + # Preserve 模式核心逻辑:检查目标是否已存在 + if [ -f "$dest_file" ]; then + echo " ⏭️ 配置文件已存在,为保活用户修改,跳过: $relative_path" + else + echo " ✅ 配置文件不存在,执行初始安装。" + if ! $DRY_RUN; then + # 确保目标文件的目录存在 + safe_mkdir "$(dirname "$dest_file")" + # 复制文件 + cp "$source_file" "$dest_file" + # 建议设置严谨的权限,例如对于敏感配置可设为 600 + chmod 600 "$dest_file" + echo " ✓ 配置文件安装完成。" + fi + fi + done + + echo "✓ etc 配置文件部署完成。" +} + + + #调用脚本执行 run_post_install_scripts -# 在文件复制后调用 +# 在文件复制后调用软链接处理 create_symlinks +create_corrected_symlinks + +#系统服务文件 +install_systemd_services +#etc文件 +deploy_etc_configs + +#在线安装需要输出未成功安装的安装包 +if [ "$PACKAGE_MODE" = "online" ]; then + if [ $DEPENDENCY_STATUS -ne 0 ]; then + echo "" + echo "⚠️ 以下依赖包需要手动安装:" + for pkg in "${packages[@]}"; do + echo " $pkg" + done + echo "" + fi +fi echo -e "\n✅ 安装成功完成" exit 0 diff --git a/src/bin/TpWM b/src/bin/TpWM deleted file mode 100755 index 36daf2a1b4ace377638997c097901d3d5b8d8bdc..0000000000000000000000000000000000000000 Binary files a/src/bin/TpWM and /dev/null differ diff --git a/src/bin/tpDopack b/src/bin/tpDopack deleted file mode 100644 index 1497af62dc9015f55afa84f94aa1c94af4e91ee8..0000000000000000000000000000000000000000 Binary files a/src/bin/tpDopack and /dev/null differ diff --git a/src/bin/tpInstall b/src/bin/tpInstall deleted file mode 100644 index 236a615f6f097e65efb6bacbba233e5519c41de9..0000000000000000000000000000000000000000 Binary files a/src/bin/tpInstall and /dev/null differ diff --git a/src/bin/tpRemove b/src/bin/tpRemove deleted file mode 100644 index a1455fcf63740adf71735087c1a1c78b0cf2d4a9..0000000000000000000000000000000000000000 Binary files a/src/bin/tpRemove and /dev/null differ diff --git a/src/depend_lib/dynamic/arm_64/libTpWMEngine.so b/src/depend_lib/dynamic/arm_64/libTpWMEngine.so index 98cda0a2c44b38946a5929698011601269c8c29a..52c774ba16833005b8d15295c865a854c321ed46 100644 Binary files a/src/depend_lib/dynamic/arm_64/libTpWMEngine.so and b/src/depend_lib/dynamic/arm_64/libTpWMEngine.so differ diff --git a/src/depend_lib/dynamic/arm_64/librime.so.1.5.3 b/src/depend_lib/dynamic/arm_64/librime.so.1.5.3 index 46705dc85babcfe96b3e1866af3c537412368a92..c6e191f12bb68c2866d010e6d5301c7d3a4a3570 100644 Binary files a/src/depend_lib/dynamic/arm_64/librime.so.1.5.3 and b/src/depend_lib/dynamic/arm_64/librime.so.1.5.3 differ diff --git a/src/depend_lib/dynamic/x86_64/libTpWMEngine.so b/src/depend_lib/dynamic/x86_64/libTpWMEngine.so index a6d75e7eb8a5d9281349103bcddcaf4d0e755c02..99de866d8d24eddfaba477f6083d6eb23a8babde 100755 Binary files a/src/depend_lib/dynamic/x86_64/libTpWMEngine.so and b/src/depend_lib/dynamic/x86_64/libTpWMEngine.so differ diff --git a/src/depend_lib/static/arm_64/libnanomsg.a b/src/depend_lib/static/arm_64/libnanomsg.a index b00c38d418c7bc90d0cedc03263ebd33718f5ddd..3ada0ccaf8240f5e6e7fbb95b8eda1912e3ecd6b 100644 Binary files a/src/depend_lib/static/arm_64/libnanomsg.a and b/src/depend_lib/static/arm_64/libnanomsg.a differ diff --git a/src/depend_lib/static/x86_64/libnanomsg.a b/src/depend_lib/static/x86_64/libnanomsg.a index a4263cb4af63430141c956f4b3f0f324f579e4af..880118ea133e76dcbc372087d40736e2d74af73a 100644 Binary files a/src/depend_lib/static/x86_64/libnanomsg.a and b/src/depend_lib/static/x86_64/libnanomsg.a differ diff --git a/src/include/TpGUI/Core/TpApp.h b/src/include/TpGUI/Core/TpApp.h index 6d16063f882b0a2a7afe74e4c3089e0f4caadb2f..20aca807c4c176c3833461722c26223ac655780d 100644 --- a/src/include/TpGUI/Core/TpApp.h +++ b/src/include/TpGUI/Core/TpApp.h @@ -12,7 +12,6 @@ TP_DEF_VOID_TYPE_VAR(ITpAppData); class TpObject; class TpClipboard; class TpWidget; -class TpScreen; class TpCssParser; class TpApp @@ -73,7 +72,11 @@ public: }; public: - TpApp(int32_t argc, char *argv[]); + /// @brief 主事件循环构造函数 + /// @param argc 参数数量 + /// @param argv 入口参数 + /// @param deskTopStrKey 桌面唯一标识;普通应用无需处理 + TpApp(int32_t argc, char *argv[], const TpString& deskStrKey = ""); virtual ~TpApp(); public: @@ -82,20 +85,17 @@ public: static TpApp *Inst(); public: - /// @brief 绑定应用主窗体 - /// @param object 主窗体对象指针 - /// @return 绑定结果 - virtual bool bindVScreen(TpScreen *object); /// @brief 开启tpApp主事件循环 /// @return 启动结果 virtual bool run(); -public: + /// @brief 获取剪切板单例指针 + /// @return 剪切板指针 virtual TpClipboard *clipboard(); - /// @brief 获取当前程序主窗体 - /// @return 主窗体指针 - virtual TpScreen *vScreen(); + /// @brief 获取应用的主窗口;无主窗口则返回nullptr + /// @return 应用主窗口指针 + virtual TpWidget* mainWindow(); /// @brief 获取全局单例CSS解析器 /// @return css解析器智能指针 @@ -109,10 +109,6 @@ public: /// @return 系统主观类型 Tp::SystemTheme style(); - /// @brief 获取当前应用界面抓图;暂未实现 - /// @return 图片资源对象 - TpImage grabWindow(); - /// @brief 唤醒虚拟键盘 /// @return object 唤醒对象;虚拟键盘的输入将会给入该对象 void wakeUpVirtualKeyboard(TpWidget *object); diff --git a/src/include/TpGUI/Core/TpObject.h b/src/include/TpGUI/Core/TpObject.h index 8912bbde609d5e5116c4bcc8a861c32ab83683ec..073846fb7bfea538c4075187a1a2c30a8a07d870 100644 --- a/src/include/TpGUI/Core/TpObject.h +++ b/src/include/TpGUI/Core/TpObject.h @@ -67,7 +67,7 @@ public: virtual bool eventFilter(TpObject *watched, TpEvent *event); public: - virtual Tp::ItpObjectType objectType() { return Tp::TP_UNKOWN_OBJECT; }; + virtual Tp::TpObjectType objectType() { return Tp::TP_UNKOWN_OBJECT; }; virtual int32_t objectID(); virtual bool objectActive() { return false; }; diff --git a/src/include/TpGUI/Core/TpWidget.h b/src/include/TpGUI/Core/TpWidget.h index 7760d98c370e9ee08ccab260f655ae3bf819604a..df7eeca82b6f0e83aeffed3948a94802cfe0b888 100644 --- a/src/include/TpGUI/Core/TpWidget.h +++ b/src/include/TpGUI/Core/TpWidget.h @@ -76,7 +76,7 @@ public: /// @brief 设置widget矩形区域 /// @param rect X、Y、W、H virtual void setRect(const TpRect &rect); - virtual void setRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h); + virtual void setRect(int32_t x, int32_t y, int32_t w, int32_t h); public: /// @brief 获取widget相对于屏幕的矩形区域 @@ -199,12 +199,17 @@ public: virtual const TpPoint pos(); public: - /// @brief 设置窗体透明度,窗体及内部组件均会被影响 - /// @param alpha 透明度值,0-255 - virtual void setAlpha(const uint8_t &alpha = 0xff); - /// @brief 获取窗体当前透明度 - /// @return 当前透明度值 - virtual uint8_t alpha(); + /// @brief 设置窗口的不透明度乘数;当前窗口及所有子窗口都会响应 + /// @param opacity [0,1];0=0%不透明,1=100%不透明 + virtual void setWindowOpacity(float opacity); + /// @brief 获取窗体当前不透明度乘数 + /// @return 当前不透明度乘数 + virtual float windowOpacity(); + + /// @brief 将当前组件调整为父组件下的最顶级组件 + virtual void bringToTop(); + /// @brief 将当前组件调整为父组件下的最底层组件 + virtual void bringToBottom(); public: /// @brief 设置窗体布局,如果已经存在布局则设置失败,需要先释放旧布局指针 @@ -264,7 +269,7 @@ public: /// @brief 设置背景颜色 /// @param color 颜色值 /// @param enable 启动/禁用背景颜色显示 - virtual void setBackGroundColor(TpColors &color, bool enable = true); + virtual void setBackGroundColor(const TpColors &color, bool enable = true); /// @brief 设置背景颜色 /// @param color 颜色值 /// @param enable 启动/禁用背景颜色显示 @@ -273,7 +278,7 @@ public: /// @brief 设置背景填充效果 /// @param bgBrush 填充效果 /// @param enable 启动/禁用背景颜色显示 - virtual void setBackGroundColor(const TpBrush& bgBrush, bool enable = true); + virtual void setBackGroundColor(const TpBrush &bgBrush, bool enable = true); /// @brief 获取当前背景颜色RGBA /// @return RGBA值 @@ -288,7 +293,7 @@ public: /// @brief 设置边框颜色 /// @param color 颜色值 /// @param enable 启动/禁用边框颜色显示 - virtual void setBorderColor(TpColors &color, bool enable = true); + virtual void setBorderColor(const TpColors &color, bool enable = true); /// @brief 设置边框颜色 /// @param color 颜色值 /// @param enable 启动/禁用边框颜色显示 @@ -296,7 +301,7 @@ public: /// @brief 设置边框填充效果;渐变效果等 /// @param bgBrush 填充效果 /// @param enable 启动/禁用边框颜色显示 - virtual void setBorderColor(const TpBrush& borderBrush, bool enable = true); + virtual void setBorderColor(const TpBrush &borderBrush, bool enable = true); /// @brief 获取当前边框颜色RGBA /// @return RGBA值 virtual uint32_t borderColor(); @@ -365,7 +370,7 @@ public: public: /// @brief 获取对象类型,一般禁止重写 /// @return 对象类型 - virtual Tp::ItpObjectType objectType() /*final*/; + virtual Tp::TpObjectType objectType() /*final*/; virtual bool appChange(int32_t id, int32_t pid, int32_t visible, int32_t active, int32_t color, uint8_t alpha, int32_t require) { return true; } @@ -375,7 +380,7 @@ public: public: /// @brief 补充CSS样式,系统内置CSS除非同名否则不会被覆盖 /// @param _styleSheetStr CSS样式字符串或者文件 - void setStyleSheet(const TpString &_styleSheetStr); + virtual void setStyleSheet(const TpString &_styleSheetStr); /// @brief 获取当前系统的CSS样式字符串 /// @return CSS字符串 diff --git a/src/include/TpGUI/Screen/TpDialog.h b/src/include/TpGUI/Screen/TpDialog.h index 28bace9fd47bf4a563678b1e3ee18f59e020e65e..edd2b9cc557e377a5c98f238ed3d7b9cf563dbee 100644 --- a/src/include/TpGUI/Screen/TpDialog.h +++ b/src/include/TpGUI/Screen/TpDialog.h @@ -14,21 +14,22 @@ public: /// @brief 模态显示 /// @return 返回点击ID索引 - virtual uint32_t exec(); + virtual void exec(); /// @brief 关闭窗口 virtual void close() override; + /// @brief 设置窗口显隐 + /// @param visible true显示,false隐藏 + virtual void setVisible(bool visible = true) override; + public: - virtual Tp::ItpObjectType objectType() final; + virtual Tp::TpObjectType objectType() final; /// @brief 组件类名,子类实现,返回子类类名字符串,用于匹配CSS中对应样式 /// @return 类名字符串 virtual TpString pluginType() override { return TO_STRING(TpDialog); } -protected: - virtual bool onPaintEvent(TpPaintEvent *event) override; - private: ItpDialogData *data_; }; diff --git a/src/include/TpGUI/Screen/TpMainWindow.h b/src/include/TpGUI/Screen/TpMainWindow.h index 75b3aa71fc91f61e56f7f1ca0d0245a4fc973fdc..2229402922e11d9b7f751dab2610702675c07c47 100644 --- a/src/include/TpGUI/Screen/TpMainWindow.h +++ b/src/include/TpGUI/Screen/TpMainWindow.h @@ -4,45 +4,48 @@ #include "TpScreen.h" TP_DEF_VOID_TYPE_VAR(ITpMainWindowData); +/// @brief 应用主窗体,每个应用只能拥有一个TpMainWindow class TpMainWindow : public TpScreen { public: - enum - { - ITP_FULL_STYLE, - ITP_POP_STYLE, - }; - -public: - TpMainWindow(const char *type = "tinyPiX_WM_Screen"); + TpMainWindow(const char *type = "tinyPiX_USE_Float"); virtual ~TpMainWindow(); public: - virtual Tp::ItpObjectType objectType() final; + virtual Tp::TpObjectType objectType() final override; -public: - /// @brief 设置桌面颜色,该树形会下发至应用的appchanged - /// @param alpha - /// @param color - /// @param screenAttr - /// @return - virtual int setVScreenAttribute(uint8_t alpha, uint32_t color, int32_t screenAttr); + /// @brief 组件类名,子类实现,返回子类类名字符串,用于匹配CSS中对应样式 + /// @return 类名字符串 + virtual TpString pluginType() override { return TO_STRING(TpMainWindow); } -private: - virtual void setRect(const TpRect &rect) final {}; - virtual void setRect(int32_t x, int32_t y, int32_t w, int32_t h) final {}; + virtual void setBackGroundColor(const TpColors &color, bool enable = true) override; + virtual void setBackGroundColor(int32_t color, bool enable = true) override; + virtual void setBackGroundColor(const TpBrush &bgBrush, bool enable = true) override; + virtual void setEnableBackGroundColor(bool enable) override; + + virtual void setBorderColor(const TpColors &color, bool enable = true) override; + virtual void setBorderColor(int32_t color, bool enable = true) override; + virtual void setBorderColor(const TpBrush &borderBrush, bool enable = true) override; + virtual void setEnabledBorderColor(bool enable) override; + +protected: + /// @brief TpMainWindow无resize事件 + virtual bool onResizeEvent(TpResizeEvent *event) final override { return true; }; private: - virtual void setBeMoved(bool moved = false) final {}; - virtual bool moved() final { return false; }; + virtual void setVisible(bool visible = true) final override {}; + + virtual void setRect(const TpRect &rect) final override {}; + virtual void setRect(int32_t x, int32_t y, int32_t w, int32_t h) final override {}; private: - virtual void setAlpha(const uint8_t &alpha = 0xff) final {}; - virtual uint8_t alpha() final { return 0xff; }; + virtual void setBeMoved(bool moved = false) final override {}; + virtual bool moved() final override { return false; }; -public: - virtual bool onActiveEvent(TpActiveEvent *event); +private: + virtual void setWindowOpacity(float opacity) final override {}; + virtual float windowOpacity() final override { return 1.0; }; private: ITpMainWindowData *data_; diff --git a/src/include/TpGUI/Screen/TpScreen.h b/src/include/TpGUI/Screen/TpScreen.h index 94bd327fbb106c2d5e37bb9abfcaeb7d1b3c3b22..33de67d2b63ba2349c88a6555c93265a857455fd 100644 --- a/src/include/TpGUI/Screen/TpScreen.h +++ b/src/include/TpGUI/Screen/TpScreen.h @@ -21,7 +21,8 @@ public: virtual void setText(const TpString &text); public: - virtual void setRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h) override; + virtual void setRect(const TpRect &rect) override; + virtual void setRect(int32_t x, int32_t y, int32_t w, int32_t h) override; /// @brief 设置窗口宽高 /// @param width @@ -47,19 +48,16 @@ public: virtual bool moved(); public: - virtual void setAlpha(const uint8_t &alpha = 0xff) override; - -public: - virtual void bringToTop(); - virtual void bringToBottom(); + virtual void bringToTop() override; + virtual void bringToBottom() override; public: virtual void update(int32_t x, int32_t y, int32_t w, int32_t h, bool onlyBlit = false) override; virtual void update(bool onlyBlit = false) override; public: - virtual Tp::ItpObjectType objectType(); - virtual Tp::ItpObjectSysLayer objectLayer(); + virtual Tp::TpObjectType objectType(); + virtual Tp::TpObjectSysLayer objectLayer(); virtual int32_t objectSysID(); virtual bool objectActive(); @@ -75,11 +73,6 @@ public: virtual bool returns(); -public: - virtual TpSize screenSize(); - virtual int32_t screenWidth(); - virtual int32_t screenHeight(); - public: /// @brief 外部禁止调用 /// @param event diff --git a/src/include/TpGUI/Widgets/TpAnimation.h b/src/include/TpGUI/Widgets/TpAnimation.h index a76b25579dd7c776ddf354f036bd2a650a43c502..71eb08fcc82c537814e829fc43c82c1d193dad76 100644 --- a/src/include/TpGUI/Widgets/TpAnimation.h +++ b/src/include/TpGUI/Widgets/TpAnimation.h @@ -24,7 +24,7 @@ public: Height, /// @brief 窗体宽度 int32_t Width, - /// @brief 整体透明度​​(0透明,255不透明 int32_t + /// @brief 整体不透明度​​(0透明,1不透明 float WindowOpacity, /// @brief 背景颜色 int32_t BackgroundColor, diff --git a/src/include/TpGUI/Widgets/TpMenu.h b/src/include/TpGUI/Widgets/TpMenu.h index 1a48b9661883e048189d8cb2614655ce7046b96e..b30b157c0086e7271e1a352df8656a940533f35e 100644 --- a/src/include/TpGUI/Widgets/TpMenu.h +++ b/src/include/TpGUI/Widgets/TpMenu.h @@ -34,12 +34,12 @@ public: /// @return 返回按钮ID,当前menu下唯一 uint32_t addItem(const TpString &text, const TpString &iconPath); - /// @brief 添加子菜单 + /// @brief 添加子菜单;暂未实现 /// @param menuName 子菜单名称 /// @param menu 子菜单指针,外部无需释放 void addMenu(const TpString &menuName, TpMenu *menu); - /// @brief 添加子菜单 + /// @brief 添加子菜单;暂未实现 /// @param menuName 子菜单名称 /// @return 返回子菜单指针,子菜单指针,外部无需释放 TpMenu *addMenu(const TpString &menuName); @@ -72,7 +72,6 @@ signals: protected: virtual bool onFocusEvent(TpFocusEvent *event) override; - virtual bool onMousePressEvent(TpMouseEvent *event) override; virtual bool onMouseRleaseEvent(TpMouseEvent *event) override; virtual bool onMouseMoveEvent(TpMouseEvent *event) override; virtual bool onLeaveEvent(TpLeaveEvent *event) override; diff --git a/src/include/TpGUI/Widgets/TpMessageBox.h b/src/include/TpGUI/Widgets/TpMessageBox.h index fee804a34f3b2b5627943ebbbf9c6391a181b551..034614d90596aea02525ca2e7c9449e2d9372bce 100644 --- a/src/include/TpGUI/Widgets/TpMessageBox.h +++ b/src/include/TpGUI/Widgets/TpMessageBox.h @@ -21,48 +21,36 @@ public: }; public: - TpMessageBox(const char *type = "tinyPiX_USE_Float"); - + TpMessageBox(MessageType type = TpMessageBox::Information); + TpMessageBox(const TpString &text, MessageType type = TpMessageBox::Information); virtual ~TpMessageBox(); /// @brief 模态显示消息对话框 /// @return 返回点击ID索引 - uint32_t exec(); - - /// @brief 设置消息框类型 - /// @param type 类型枚举 - void setMessageType(const MessageType &type); - - /// @brief 设置消息框按钮列表,最大最好不要超过四个,否则显示效果受影响 - /// @param buttonList 按钮文本列表 - void setButtonList(const TpVector &buttonList); - -public: - static uint32_t information(const TpString &text, const TpString &btnText = "确认"); - static uint32_t question(const TpString &text, const TpString &yesBtnText = "确认", const TpString &cancleBtnText = "取消"); - static uint32_t error(const TpString &text, const TpString &yesBtnText = "确认"); - static uint32_t warning(const TpString &text, const TpString &yesBtnText = "确认"); + void exec() override; -public: /// @brief 设置按钮文本 /// @param text 文本内容 virtual void setText(const TpString &text); - /// @brief 获取按钮文本字体 - /// @return 字体指针 - virtual TpFont *font(); + /// @brief 设置消息框类型;内部根据类型自动生成交互按钮 + /// @param type 类型枚举 + void setMessageType(MessageType type); + + /// @brief 设置消息框按钮列表,最大最好不要超过四个 + /// @param buttonList 按钮文本列表 + void setButtonList(const TpVector &buttonList); public signals: - -protected: - virtual void setVisible(bool visible = true) override; + /// @brief 消息框关闭信号 + /// @param int32_t 用户点击的交互按钮索引,从0开始 + declare_signal(onClose, int32_t); protected: virtual bool onMouseRleaseEvent(TpMouseEvent *event) override; virtual bool onPaintEvent(TpPaintEvent *event) override; virtual bool onResizeEvent(TpResizeEvent *event) override; - virtual bool eventFilter(TpObject *watched, TpEvent *event) override; protected: diff --git a/src/include/TpGUI/Widgets/TpRadioButton.h b/src/include/TpGUI/Widgets/TpRadioButton.h index 4e831e77a82b2c37cc9ba0c86069520b41a4a927..68da4ffd05ee7283eddadaea5109c0f76a46e060 100644 --- a/src/include/TpGUI/Widgets/TpRadioButton.h +++ b/src/include/TpGUI/Widgets/TpRadioButton.h @@ -13,42 +13,42 @@ class TpString; class TpRadioButton : public TpWidget { public: - TpRadioButton(TpWidget *parent = nullptr); - TpRadioButton(const TpString &text, TpWidget *parent = nullptr); + TpRadioButton(TpWidget *parent = nullptr); + TpRadioButton(const TpString &text, TpWidget *parent = nullptr); - virtual ~TpRadioButton(); + virtual ~TpRadioButton(); public: - /// @brief 根据字体宽度和高度绘制,当设置时对齐将无效 - /// @param enable 是否自动调整 - virtual void setAutoFit(bool enable = false); + /// @brief 根据字体宽度和高度绘制,当设置时对齐将无效 + /// @param enable 是否自动调整 + virtual void setAutoFit(bool enable = false); - /// @brief 设置按钮与文本间距值 - /// @param space 间距 - virtual void setSpacing(uint32_t space = 1); + /// @brief 设置按钮与文本间距值 + /// @param space 间距 + virtual void setSpacing(uint32_t space = 1); - virtual void setRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h) override; + virtual void setRect(int32_t x, int32_t y, int32_t w, int32_t h) override; public: - /// @brief 设置按钮文本 - /// @param text - virtual void setText(const TpString &text); + /// @brief 设置按钮文本 + /// @param text + virtual void setText(const TpString &text); - virtual TpFont *font(); + virtual TpFont *font(); virtual TpString pluginType() override { return TO_STRING(TpRadioButton); } public signals: - declare_signal(onClicked, bool); + declare_signal(onClicked, bool); protected: - virtual bool onMousePressEvent(TpMouseEvent *event) override; - virtual bool onMouseRleaseEvent(TpMouseEvent *event) override; - virtual bool onPaintEvent(TpPaintEvent *event); + virtual bool onMousePressEvent(TpMouseEvent *event) override; + virtual bool onMouseRleaseEvent(TpMouseEvent *event) override; + virtual bool onPaintEvent(TpPaintEvent *event); private: - ItpRadioButtonData *data_; + ItpRadioButtonData *data_; }; #endif diff --git a/src/include/TpGlobal.h b/src/include/TpGlobal.h index 426351dbd998841de7ba0cc49bc8c59b5c03dd1b..eaf426a94ba6586c2be56eda31e4d648aa65de04 100644 --- a/src/include/TpGlobal.h +++ b/src/include/TpGlobal.h @@ -56,15 +56,16 @@ namespace Tp { - enum ItpObjectType + enum TpObjectType { TP_UNKOWN_OBJECT = -1, - TP_TOP_OBJECT, // FixScreen + TP_FIXSCREEN_OBJECT, + TP_MAIN_WINDOW_OBJECT, TP_FLOAT_OBJECT, TP_CHILD_OBJECT, }; - enum ItpObjectSysLayer + enum TpObjectSysLayer { TP_WM_NONE = -1, TP_WM_DESK, diff --git a/src/include/TpUtils/Service/TpWidgetsGateway.h b/src/include/TpUtils/Service/TpWidgetsGateway.h index 995d5a3f076a2022e11c2a2bc1039911b4fa3892..0c6933f936dde722e788adce40984a70f6efb00f 100644 --- a/src/include/TpUtils/Service/TpWidgetsGateway.h +++ b/src/include/TpUtils/Service/TpWidgetsGateway.h @@ -8,8 +8,8 @@ #include "TpNetDataGlobal.h" TP_DEF_VOID_TYPE_VAR(ITpWidgetsGatewayData); -/// @brief 系统组件相关回调接口类;每个小组件只应继承一次该接口类 -class TpWidgetsGateway : public TpGateway +/// @brief 系统组件相关回调接口类;每个小组件只应继承一次该接口类;暂未实现 +class TpWidgetsGateway : public ITpGatewayHander { public: TpWidgetsGateway() = delete; diff --git a/src/include/TpUtils/TpColors.h b/src/include/TpUtils/TpColors.h index d68102a7eb5e90debe24044dca7d54817c242b61..6086b56265e89c14ec1298d1dd1be60fe88b1914 100644 --- a/src/include/TpUtils/TpColors.h +++ b/src/include/TpUtils/TpColors.h @@ -468,40 +468,21 @@ public: }; public: - TpColors() : isNull_(true) - { - this->colorSet_ = _RGBA(0, 0, 0, 255); - } - - TpColors(int32_t colorSet) : isNull_(false) - { - this->colorSet_ = colorSet; - } + TpColors(); + TpColors(int32_t colorSet); + TpColors(const TpColors &color); + TpColors(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); + virtual ~TpColors(); - TpColors(const TpColors &color) : isNull_(false) - { - this->colorSet_ = color.rgba(); - } + inline uint8_t red() const { return _R(data_); } + inline uint8_t green() const { return _G(data_); } + inline uint8_t blue() const { return _B(data_); } + inline uint8_t alpha() const { return _A(data_); } - TpColors(const uint8_t &r, const uint8_t &g, const uint8_t &b, const uint8_t &a = 255) : isNull_(false) - { - this->colorSet_ = _RGBA(r, g, b, a); - } - - uint8_t red() - { - return _R(this->colorSet_); - } - - uint8_t green() - { - return _G(this->colorSet_); - } - - uint8_t blue() - { - return _B(this->colorSet_); - } + void setRed(uint8_t r); + void setGreen(uint8_t g); + void setBlue(uint8_t b); + void setAlpha(uint8_t a); /// @brief 设置颜色为空,重置为黑色 inline void setNull(); @@ -519,54 +500,13 @@ public: /// @brief 获取RGBA值 /// @return 颜色值 - inline int32_t rgba() const { return this->colorSet_; } - -public: - virtual ~TpColors() - { - } - -public: - TpColors operator=(int32_t color) - { - isNull_ = false; - this->colorSet_ = color; - return *this; - } - -public: - static int32_t transColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) - { - return _RGBA(r, g, b, a); - } + inline int32_t rgba() const { return data_; } - static void transColor(int32_t color, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *a) - { - if (r) - { - *r = _R(color); - } - - if (g) - { - *g = _G(color); - } - - if (b) - { - *b = _B(color); - } - - if (a) - { - *a = _A(color); - } - } - -public: - int32_t colorSet_; + TpColors operator=(int32_t color); + TpColors operator=(const TpColors& others); private: + int32_t data_; bool isNull_; }; diff --git a/src/include/TpUtils/TpGateway.h b/src/include/TpUtils/TpGateway.h index a15e23f306567032a5a524d205af1ee86ad7b898..ca9f5b101a63c715ef893c127a7a0b5d4b3d18a5 100644 --- a/src/include/TpUtils/TpGateway.h +++ b/src/include/TpUtils/TpGateway.h @@ -5,11 +5,11 @@ #include /// @brief 网关数据接收接口类 -class TpGateway +class ITpGatewayHander { public: virtual void recvData(const char *topic, const void *data, const uint32_t &size) = 0; - ~TpGateway() {} + ~ITpGatewayHander() {} }; using RecvDataFunc = std::function; @@ -22,11 +22,11 @@ bool initializeGateway(const char *serverAddress = nullptr); bool publishGatewayData(const char *topic, const void *data, const uint32_t &size); /// @brief 订阅接口 -bool subscribeGatewayData(const char *topic, TpGateway *obj); +bool subscribeGatewayData(const char *topic, ITpGatewayHander *obj); bool subscribeGatewayData(const char *topic, RecvDataFunc func); /// @brief 取消订阅 -bool unsubscribeGatewayData(const char *topic, TpGateway *obj); +bool unsubscribeGatewayData(const char *topic, ITpGatewayHander *obj); bool unsubscribeGatewayData(const char *topic, RecvDataFunc func); /// @brief 关闭网关连接 diff --git a/src/include/TpUtils/TpImage.h b/src/include/TpUtils/TpImage.h index e80efa2efae6029bc607ab918cb287bb1f57fb7d..c7aae6e886f27ed61949fd14297b3297755134ce 100644 --- a/src/include/TpUtils/TpImage.h +++ b/src/include/TpUtils/TpImage.h @@ -35,9 +35,10 @@ public: /// @brief 指定资源buffer加载数据;当前仅支持ARGB格式 /// @param martix 数据buffer - /// @param rect 加载数据矩形 + /// @param size 资源图片尺寸 + /// @param rect 裁剪矩形;为空则默认全部加载 /// @return 加载结果 - virtual bool load(void *martix, const TpRect& rect); + virtual bool load(void *martix, const TpSize& size, const TpRect& clipRect = TpRect()); /// @brief 指定size对图片进行缩放 /// @param size 缩放后的尺寸 diff --git a/src/include/TpUtils/TpPainter.h b/src/include/TpUtils/TpPainter.h index 818e04c87453a8fe3f2c5bdd1748499a7fafa1a8..683000598b7f07f36b82255daf74c97c13224f49 100644 --- a/src/include/TpUtils/TpPainter.h +++ b/src/include/TpUtils/TpPainter.h @@ -15,6 +15,7 @@ class TpPainter; class TpSurface; class TpRect; class TpFont; +class TpWidget; /// @brief 绘制镂空遮罩 class TpHollowMask @@ -134,7 +135,7 @@ TP_DEF_VOID_TYPE_VAR(ITpCanvasData); class TpPainter { public: - TpPainter(tpShared surface, int32_t offsetX, int32_t offsetY, int32_t width, int32_t height); + TpPainter(tpShared surface, int32_t offsetX, int32_t offsetY, TpWidget* object); virtual ~TpPainter(); void paintTest(); diff --git a/src/include/TpWM/tinyPiXSys.h b/src/include/TpWM/tinyPiXSys.h index 58e6418d31a542efb13df7c8caa753d7417d20ac..d04946b0bbf4d185fc52f303802b6f74ca63432a 100644 --- a/src/include/TpWM/tinyPiXSys.h +++ b/src/include/TpWM/tinyPiXSys.h @@ -205,6 +205,14 @@ extern DECLSPEC int STDCALL tinyPiX_sys_find_win_main_id_bypid(IPiSysApiAgent *s */ extern DECLSPEC int STDCALL tinyPiX_sys_find_win_pid_byid(IPiSysApiAgent *sysApiagent, int id); +/** +@brief 获取进程应用整体截图 +@param sysApiagent(IPisysApiAgent)系统api的句柄 +@param pid(int)进程id +@return 成功返回表面指针,失败返回NULL +**/ +extern DECLSPEC IPiWFSurface *STDCALL tinyPiX_sys_get_process_surface(IPiSysApiAgent *sysApiagent, int pid); + /** @brief 获取截图 @param sysApiagent(IPiSysApiAgent) 系统api的句柄 diff --git a/src/include_p/TpGUI/Core/TpApp_p.h b/src/include_p/TpGUI/Core/TpApp_p.h index ac0d87f837c10535f16fd2aa90c54ef0cfcd24d7..633f6c772a1d1bee7b076c8e1ceccec86042b4db 100644 --- a/src/include_p/TpGUI/Core/TpApp_p.h +++ b/src/include_p/TpGUI/Core/TpApp_p.h @@ -25,6 +25,9 @@ #include "TpObjectFunction.hpp" #include "TpMainWindow.h" #include "TpShareMemory.h" +#include "TpFixScreen.h" +#include "TpGateway.h" +#include "TpMainWindow.h" #include "thorVG/thorvg.h" #include @@ -44,22 +47,39 @@ #include #include -/// @brief 读取桌面信息;慎重修改,需和桌面保持协议一致 -struct DeskTopBarInfo +#if 1 // 慎重修改,需和桌面保持协议一致 + +/// @brief 应用上线标识;应用启动时发送该主题;桌面会通知应用状态栏信息 +const static TpString DeskApplicationRunTopic = "DeskApplicationRunTopicConfig"; +/// @brief 桌面发布状态栏信息主题 +const static TpString DeskStatusBarInfoTopic = "DeskStatusBarConfig"; +/// @brief 读取桌面状态栏信息;慎重修改,需和桌面保持协议一致 +struct DeskStatusBarInfo { - /// @brief 顶部工具栏宽度值 - int32_t topBarWidth; - /// @brief 顶部工具栏高度值 - int32_t topBarHeight; - /// @brief 顶部工具栏是否显示;true显示,false隐藏 - bool topBarisVislble; - - DeskTopBarInfo() : topBarWidth(0), topBarHeight(0), topBarisVislble(false) + /// @brief 状态栏位置;0=上,1=右,2=下,3=左,其它值=上 + int32_t statusBarLocation; + /// @brief 状态栏宽度值 + int32_t statusBarWidth; + /// @brief 顶状态栏高度值 + int32_t statusBarHeight; + /// @brief 状态栏是否显示;true显示,false隐藏 + bool statusBarVislble; + + DeskStatusBarInfo() : statusBarLocation(0), statusBarWidth(0), statusBarHeight(0), statusBarVislble(false) { } - virtual ~DeskTopBarInfo() {} + virtual ~DeskStatusBarInfo() {} + + bool operator==(const DeskStatusBarInfo &others) + { + return (statusBarLocation == others.statusBarLocation) && + (statusBarWidth == others.statusBarWidth) && + (statusBarHeight == others.statusBarHeight) && + (statusBarVislble == others.statusBarVislble); + } }; +#endif struct ItpProcessInfo { @@ -95,7 +115,10 @@ struct TpAppData std::mutex gMutex; - TpScreen *vScreen; + // 物理屏幕窗口 + TpFixScreen *vScreen; + // 应用主窗口,每个应用只有一个 + TpMainWindow *mainWindow = nullptr; TpClipboard *clipboard; @@ -125,7 +148,7 @@ struct TpAppData // 桌面信息;无桌面则数据无用 bool isDesk = false; - DeskTopBarInfo desktopBarInfo_; + DeskStatusBarInfo deskStatusBarInfo_; }; class appExe : public TpThread @@ -215,9 +238,6 @@ public: set->floatScreenList.remove(*floatFindIter); } - // TpObjectData *vScreenObjDaata = (TpObjectData *)set->vScreen->objectSets(); - // vScreenObjDaata->tmp.deleteObject(object); - if (object == set->vScreen) { goto finished; @@ -226,10 +246,8 @@ public: deleted: set->gMutex.unlock(); - // std::cout << "指针释放 " << std::endl; delete object; object = nullptr; - // set->vScreen->update(); } break; case TpApp::TP_ABORT_ACT: @@ -242,12 +260,16 @@ public: { TpObject *vScreen = set->vScreen; + std::cout << "case TpApp::TP_RETURN_ACT111111: " << std::endl; + if (vScreen == message.user_data0) { TpScreen *screenObj = static_cast(vScreen); + std::cout << "case TpApp::TP_RETURN_ACT2222: " << std::endl; // exclude desktop - if (screenObj->objectLayer() != Tp::TP_WM_DESK) + // if (screenObj->objectLayer() != Tp::TP_WM_DESK) + if (screenObj->objectType() != Tp::TP_MAIN_WINDOW_OBJECT) { if (vScreen) { @@ -337,21 +359,19 @@ static void DownUpdateCommand(std::queue &updateCommandQueue) TpMap pixwmMergeUpdateRect; TpMap mergeUpdateWidget; - // std::pair fixScreenPair; - // fixScreenPair.first = nullptr; while (!updateCommandQueue.empty()) { UpdateCommand task = updateCommandQueue.front(); updateCommandQueue.pop(); - if (task.updateObj->objectType() == Tp::TP_FLOAT_OBJECT || task.updateObj->objectType() == Tp::TP_TOP_OBJECT) + if (task.updateObj->objectType() == Tp::TP_FLOAT_OBJECT || + task.updateObj->objectType() == Tp::TP_FIXSCREEN_OBJECT || + task.updateObj->objectType() == Tp::TP_MAIN_WINDOW_OBJECT) { if (!task.updateObj->objectActive()) continue; } - if (!task.updateObj->visible()) - continue; TpObjectData *updateObjSet = static_cast(task.updateObj->objectSets()); TpObjectData *topScreenSet = static_cast(updateObjSet->top->objectSets()); @@ -367,20 +387,17 @@ static void DownUpdateCommand(std::queue &updateCommandQueue) pixwmMergeUpdateRect[topScreenSet->agent] = TpRect(task.x, task.y, task.w, task.h); } + // 隐藏窗口不处理paint,但要通知TpWM + if (!task.updateObj->visible()) + continue; + // 存在该窗口则更新合并区域 if (mergeUpdateWidget.contains(task.updateObj)) { TpRect taskRect(task.x, task.y, task.w, task.h); - // if (task.updateObj->objectType() == Tp::TP_TOP_OBJECT) - // { - // fixScreenPair.second.updateRect.unions(taskRect); - // } - // else - { - ItpObjectPaintInput &paintInfo = mergeUpdateWidget[task.updateObj]; - paintInfo.updateRect.unions(taskRect); - } + ItpObjectPaintInput &paintInfo = mergeUpdateWidget[task.updateObj]; + paintInfo.updateRect.unions(taskRect); } else { @@ -400,34 +417,10 @@ static void DownUpdateCommand(std::queue &updateCommandQueue) paintInput.updateRect.setWidth(task.w); paintInput.updateRect.setHeight(task.h); - // if (task.updateObj->objectType() == Tp::TP_TOP_OBJECT) - // { - // fixScreenPair.first = task.updateObj; - // fixScreenPair.second = paintInput; - // } - // else - { - - mergeUpdateWidget[task.updateObj] = paintInput; - } + mergeUpdateWidget[task.updateObj] = paintInput; } } - // // 先绘制fixscreen - // if (fixScreenPair.first) - // { - // TpObjectData *updateObjSet = static_cast(fixScreenPair.first->objectSets()); - // TpObjectData *topScreenSet = static_cast(updateObjSet->top->objectSets()); - - // ItpObjectPaintInput paintInput = fixScreenPair.second; - - // tinyPiX_wf_lock_mutex(topScreenSet->agent); - - // drawWidget(paintInput, fixScreenPair.first); - - // tinyPiX_wf_unlock_mutex(topScreenSet->agent); - // } - for (const auto &updateWidgetIter : mergeUpdateWidget) { TpObjectData *updateObjSet = static_cast(updateWidgetIter.first->objectSets()); @@ -456,6 +449,89 @@ static void DownUpdateCommand(std::queue &updateCommandQueue) } } +static bool bindVScreen(TpAppData *appData, TpFixScreen *object) +{ + if (!appData) + return false; + + if (!object) + return false; + + if (object->objectType() != Tp::TP_FIXSCREEN_OBJECT) + { + std::cout << "bind screen type error !" << std::endl; + return false; + } + + if (appData->vScreen) + { + std::cout << "bind screen only once !" << std::endl; + return false; + } + + bool ret = (appData->vScreen != object); + + if (ret) + { + appData->gMutex.lock(); + appData->vScreen = object; + appData->gMutex.unlock(); + } + + appData->thread->start(); + + return ret; +} + +// 桌面工具栏变化,主窗口要刷新尺寸 +static void refreshMainWindow(TpAppData *appData, TpMainWindow *mainWindow, TpObjectData *mainWindowObjData) +{ + // 偏移的XY坐标;和相对于物理屏幕需要裁剪的的宽高值 + int32_t mainWindowX = 0; + int32_t mainWindowY = 0; + int32_t offsetW = 0; + int32_t offsetH = 0; + + if (!appData->isDesk && appData->deskStatusBarInfo_.statusBarVislble) + { + int32_t statusBarLocation = appData->deskStatusBarInfo_.statusBarLocation; + if (statusBarLocation == 0) + { + mainWindowY = appData->deskStatusBarInfo_.statusBarHeight; + offsetH = mainWindowY; + } + else if (statusBarLocation == 1) + { + offsetW = appData->deskStatusBarInfo_.statusBarWidth; + } + else if (statusBarLocation == 2) + { + offsetH = appData->deskStatusBarInfo_.statusBarHeight; + } + else if (statusBarLocation == 3) + { + mainWindowX = appData->deskStatusBarInfo_.statusBarWidth; + offsetW = mainWindowX; + } + else + { + mainWindowY = appData->deskStatusBarInfo_.statusBarHeight; + offsetH = mainWindowY; + } + } + + // 调整窗口大小和坐标 + uint32_t rW = 0, rH = 0; + tinyPiX_wf_get_display_size(mainWindowObjData->agent, &rW, &rH); + tinyPiX_wf_set_rect(mainWindowObjData->agent, mainWindowX, mainWindowY, rW - offsetW, rH - offsetH); + + mainWindowObjData->offsetX = mainWindowX; + mainWindowObjData->offsetY = mainWindowY; + + mainWindowObjData->absoluteRect.setX(mainWindowX); + mainWindowObjData->absoluteRect.setY(mainWindowY); +} + static inline bool holdAppSecondRun(const char *runPath, const char *uuid) { int32_t fd; diff --git a/src/include_p/TpGUI/Core/TpChildWidget_p.h b/src/include_p/TpGUI/Core/TpChildWidget_p.h index 03a83ceca59b6d686aef327bdcf1787cb88ccfa0..620cef45da4d9e39a59e8e03b35e06c28e628e0b 100644 --- a/src/include_p/TpGUI/Core/TpChildWidget_p.h +++ b/src/include_p/TpGUI/Core/TpChildWidget_p.h @@ -49,93 +49,6 @@ struct TpWidgetCssData } }; -#if 0 -// 根据桌面工具栏高度,处理窗体Y坐标 -static int32_t processDeskTopBarY(TpWidget *dealWidget, int32_t originY) -{ - if (!dealWidget) - return originY; - - // 检查当前对象类型 - Tp::ItpObjectType objType = dealWidget->objectType(); - bool isTopOrFloat = (objType == Tp::TP_TOP_OBJECT || objType == Tp::TP_FLOAT_OBJECT); - - // 检查父对象类型 - bool parentIsTop = false; - if (!isTopOrFloat) - { - if (TpWidget *parentPtr = dynamic_cast(dealWidget->parent())) - { - parentIsTop = (parentPtr->objectType() == Tp::TP_TOP_OBJECT); - } - } - - // 合并条件并执行偏移计算 - if (isTopOrFloat || parentIsTop) - { - TpAppData *appData = static_cast(TpApp::Inst()->appObjectSet()); - if (!appData->isDesk && appData->desktopBarInfo_.topBarisVislble) - { - originY += appData->desktopBarInfo_.topBarHeight; - } - } - - return originY; -} - -// 将考虑桌面工具栏的Y坐标转换为原始坐标 -static int32_t processDesktopOriginY(TpWidget *dealWidget, int32_t processY) -{ - if (!dealWidget) - return processY; - - // 检查当前对象类型 - Tp::ItpObjectType objType = dealWidget->objectType(); - bool isTopOrFloat = (objType == Tp::TP_TOP_OBJECT || objType == Tp::TP_FLOAT_OBJECT); - - // 检查父对象类型 - bool parentIsTop = false; - if (!isTopOrFloat) - { - if (TpWidget *parentPtr = dynamic_cast(dealWidget->parent())) - { - parentIsTop = (parentPtr->objectType() == Tp::TP_TOP_OBJECT); - } - } - - // 合并条件并执行偏移计算 - if (isTopOrFloat || parentIsTop) - { - TpAppData *appData = static_cast(TpApp::Inst()->appObjectSet()); - if (!appData->isDesk && appData->desktopBarInfo_.topBarisVislble) - { - processY -= appData->desktopBarInfo_.topBarHeight; - } - } - - return processY; -} - -// 根据桌面工具栏高度,处理窗体高度 -static int32_t processDeskTopBarHeight(TpWidget *dealWidget, int32_t originHeight) -{ - if (!dealWidget) - return originHeight; - - // 检查当前对象类型 - if (dealWidget->objectType() == Tp::TP_TOP_OBJECT) - { - TpAppData *appData = static_cast(TpApp::Inst()->appObjectSet()); - if (!appData->isDesk && appData->desktopBarInfo_.topBarisVislble) - { - originHeight -= appData->desktopBarInfo_.topBarHeight; - } - } - - return originHeight; -} -#endif - // 刷新缓存背景图 static void refreshCacheImage(TpObjectData *set) { @@ -157,10 +70,15 @@ static void refreshCacheImage(TpObjectData *set) static void changeXY(TpWidget *thisPtr, TpObjectData *set, int32_t x, int32_t y) { - if (!set) + if (!thisPtr) return; - // y = processDeskTopBarY(thisPtr, y); + // TpMainWindow不可被移动坐标 + if (thisPtr->pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + + if (!set) + return; int32_t ox = set->logicalRect.x(); int32_t oy = set->logicalRect.y(); @@ -196,6 +114,13 @@ static void changeXY(TpWidget *thisPtr, TpObjectData *set, int32_t x, int32_t y) static void changeWidth(TpWidget *thisPtr, TpObjectData *set, const uint32_t &w) { + if (!thisPtr) + return; + + // TpMainWindow不可被修改尺寸 + if (thisPtr->pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + if (!set) return; @@ -240,6 +165,13 @@ static void changeWidth(TpWidget *thisPtr, TpObjectData *set, const uint32_t &w) static void changeHeight(TpWidget *thisPtr, TpObjectData *set, const uint32_t &h) { + if (!thisPtr) + return; + + // TpMainWindow不可被修改尺寸 + if (thisPtr->pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + if (!set) return; diff --git a/src/include_p/TpGUI/Core/TpObjectFunction.hpp b/src/include_p/TpGUI/Core/TpObjectFunction.hpp index 9e628b8d69d4db08a9013000efe5ed3fb120a2f3..ac1844159d3a1bd30e25ab5df40d856324a35c01 100644 --- a/src/include_p/TpGUI/Core/TpObjectFunction.hpp +++ b/src/include_p/TpGUI/Core/TpObjectFunction.hpp @@ -66,7 +66,8 @@ static inline void broadObjectSetTop(TpObject *object, TpObject *top) // clear t static inline bool addObject(TpObjectData *set, TpObject *object, TpObject *parent) { if (object == nullptr || - object->objectType() == Tp::TP_TOP_OBJECT || + object->objectType() == Tp::TP_FIXSCREEN_OBJECT || + object->objectType() == Tp::TP_MAIN_WINDOW_OBJECT || object->objectType() == Tp::TP_FLOAT_OBJECT) { return false; @@ -291,7 +292,7 @@ static inline void childPaint(TpObjectData *set, TpPaintEvent *events) if (!child->visible()) continue; - if (child->alpha() == 0) + if (tpFuzzyCompare(child->windowOpacity(), 0)) continue; TpObjectData *childSet = (TpObjectData *)child->objectSets(); diff --git a/src/include_p/TpGUI/Screen/TpFixScreen.h b/src/include_p/TpGUI/Screen/TpFixScreen.h new file mode 100644 index 0000000000000000000000000000000000000000..dbbbe3a716cca76d5156989b25a48e6da55d2d91 --- /dev/null +++ b/src/include_p/TpGUI/Screen/TpFixScreen.h @@ -0,0 +1,46 @@ +#ifndef __TP_FIXSCREEN_H +#define __TP_FIXSCREEN_H + +#include "TpScreen.h" + +TP_DEF_VOID_TYPE_VAR(ITpFixScreenData); +/// @brief 物理屏幕 +class TpFixScreen + : public TpScreen +{ +public: + enum + { + ITP_FULL_STYLE, + ITP_POP_STYLE, + }; + +public: + TpFixScreen(const char *type = "tinyPiX_WM_Screen"); + virtual ~TpFixScreen(); + +public: + virtual Tp::TpObjectType objectType() final override; + + virtual int setVScreenAttribute(uint8_t alpha, uint32_t color, int32_t screenAttr); + +protected: + virtual bool onActiveEvent(TpActiveEvent *event) override; + +private: + virtual void setRect(const TpRect &rect) final override {}; + virtual void setRect(int32_t x, int32_t y, int32_t w, int32_t h) final override {}; + +private: + virtual void setBeMoved(bool moved = false) final override {}; + virtual bool moved() final override { return false; }; + +private: + virtual void setWindowOpacity(float opacity) final override {}; + virtual float windowOpacity() final override { return 0xff; }; + +private: + ITpFixScreenData *data_; +}; + +#endif diff --git a/src/include_p/TpGUI/Screen/TpScreen_p.h b/src/include_p/TpGUI/Screen/TpScreen_p.h new file mode 100644 index 0000000000000000000000000000000000000000..46b3deee0f7c24e93129a8c4f0115b22a50dbc16 --- /dev/null +++ b/src/include_p/TpGUI/Screen/TpScreen_p.h @@ -0,0 +1,585 @@ +#ifndef __TP_SCREEN_PRIVATE_H +#define __TP_SCREEN_PRIVATE_H + +#include "TpEvent.h" +#include "TpApp.h" +#include "TpDef.h" +#include "TpLayout.h" +#include "TpObjectStack.h" +#include "TpTimer.h" +#include "TpWidget.h" +#include "TpPainter.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "TpCDef.h" +#include "TpApp.h" + +// 鼠标左键长按回调 +static std::function longPressCallback = [](TpWidget *obj, ItpMouseSet mouseSet) +{ + // std::cout << " onLongPress ***********" << std::endl; + + ItpMouseSet longPressData = mouseSet; + longPressData.type = TpEvent::EVENT_MOUSE_LONG_PRESS_TYPE; + + TpMouseEvent keyEvent; + keyEvent.construct(&longPressData); + + IssueObjEvent(obj, keyEvent, onMouseLongPressEvent, obj->enabled()); +}; + +static std::atomic longPressActive{false}; // 原子标志位 +static std::unique_ptr pressThread; // 线程对象 +static std::mutex pressThreadMutex; // 保护线程状态 + +static inline void timer_delay(unsigned long long usec) +{ + struct timeval tv; + tv.tv_sec = usec / 1000000; + tv.tv_usec = usec % 1000000; + int32_t err; + do + { + err = select(0, NULL, NULL, NULL, &tv); + } while (err < 0 && errno == EINTR); +} + +static inline void generateParentList(TpObject *object, std::list &list) +{ + if (object) + { + TpObject *parent = object->parent(); + TpObject *top = object->topObject(); + + while (parent) + { + list.push_front(parent); + + if (parent == top) + { + break; + } + + parent = parent->parent(); + } + } +} + +static inline void startLongPressCheck(TpWidget *object, const ItpMouseSet &mouseSet) +{ + std::lock_guard lock(pressThreadMutex); + if (pressThread || longPressActive) + return; + + longPressActive = true; + + // 启动异步检测线程 + pressThread = std::unique_ptr(new std::thread([=]() + { + const auto startTime = std::chrono::steady_clock::now(); + + // 分段等待,每100ms检查一次状态 + while (longPressActive) + { + // std::cout << " longPressActive " << longPressActive << std::endl; + + auto elapsed = std::chrono::steady_clock::now() - startTime; + if (elapsed >= std::chrono::seconds(1)) + { + // 触发长按回调 + if (longPressCallback) + longPressCallback(object, mouseSet); + break; + } + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + longPressActive = false; })); +} + +static inline void stopLongPressCheck() +{ + std::lock_guard lock(pressThreadMutex); + longPressActive = false; // 通知线程退出 + + if (pressThread && pressThread->joinable()) + { + // 等待线程结束 + pressThread->join(); + pressThread.reset(); + } +} + +static inline void broadMotion(TpObject *dragObject, TpObject *curMotionObject, std::list &list, ItpEvent *events, TpWidget *pressObject) +{ + TpMouseEvent motionEvent; + ItpMouseSet mInput; + mInput.which = events->mouseMotionEvent.which; + mInput.type = TpEvent::EVENT_MOUSE_MOVE_TYPE; + + std::list::iterator iter = list.begin(); + + TpWidget *childObj = static_cast(dragObject); + if (childObj) + { + // motion, and state = true + mInput.pos.setX(events->mouseMotionEvent.x - childObj->toScreen().x()); + mInput.pos.setY(events->mouseMotionEvent.y - childObj->toScreen().y()); + + mInput.globalPos.setX(events->mouseMotionEvent.x); + mInput.globalPos.setY(events->mouseMotionEvent.y); + + mInput.state = true; + motionEvent.construct(&mInput); + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + // std::cout << "1111++++++++++++Move++++++++++" << mInput.globalPos.x << " , " << mInput.globalPos.y << std::endl; + IssueObjEvent(childObj, motionEvent, onMouseMoveEvent, childObj->enabled()); + } + + TpWidget *childMotionObj = static_cast(curMotionObject); + + if (childMotionObj && curMotionObject != dragObject) + { + // motion, and dragObject is not null, then state = false; otherwise state = true + mInput.pos.setX(events->mouseMotionEvent.x - childMotionObj->toScreen().x()); + mInput.pos.setY(events->mouseMotionEvent.y - childMotionObj->toScreen().y()); + + mInput.globalPos.setX(events->mouseMotionEvent.x); + mInput.globalPos.setY(events->mouseMotionEvent.y); + + mInput.state = dragObject ? false : events->mouseMotionEvent.state; + motionEvent.construct(&mInput); + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + // std::cout << "222++++++++++++Move++++++++++" << mInput.globalPos.x << " , " << mInput.globalPos.y << std::endl; + IssueObjEvent(childMotionObj, motionEvent, onMouseMoveEvent, childMotionObj->enabled()); + + // 如果按下对象后鼠标移动,不再触发长按事件 + if (childMotionObj == pressObject) + { + stopLongPressCheck(); + } + } + + list.clear(); +} + +static inline void broadMouseKey(TpObject *object, std::list &list, ItpEvent *events, TpWidget *pressObject) +{ + ItpMouseSet mInput; + mInput.which = events->mouseButtonEvent.which; + mInput.button = events->mouseButtonEvent.button; + mInput.state = events->mouseButtonEvent.state; + mInput.type = mInput.state ? TpEvent::EVENT_MOUSE_PRESS_TYPE : TpEvent::EVENT_MOUSE_RELEASE_TYPE; + + TpWidget *childObj = static_cast(object); + if (!childObj) + { + list.clear(); + return; + } + + // mouse down and up + mInput.pos.setX(events->mouseButtonEvent.x - childObj->toScreen().x()); + mInput.pos.setY(events->mouseButtonEvent.y - childObj->toScreen().y()); + + mInput.globalPos.setX(events->mouseButtonEvent.x); + mInput.globalPos.setY(events->mouseButtonEvent.y); + + // 滚轮事件 + if (mInput.button == BUTTON_WHEELUP || mInput.button == BUTTON_WHEELDOWN) + { + TpWheelEvent wheelEvent; + mInput.type = TpEvent::EVENT_WHEEL_EVENT; + wheelEvent.construct(&mInput); + + IssueObjEvent(childObj, wheelEvent, onWheelEvent, childObj->enabled()); + + list.clear(); + return; + } + + // 按键事件 + if (mInput.button == BUTTON_LEFT) + { + // 定义双击间隔时间(毫秒) + const int32_t doubleClickInterval = 200; + + if (mInput.state == true) + { + // 记录当前点击时间,减10分钟,确保第一次进入时的判断正确 + static auto lastClickTime = std::chrono::high_resolution_clock::now() - std::chrono::minutes(10); + + auto now = std::chrono::high_resolution_clock::now(); + + auto elapsed = std::chrono::duration_cast(now - lastClickTime).count(); + + // 是双击事件 + if (elapsed < doubleClickInterval) + { + // 如果是双击,触发双击事件 + mInput.type = TpEvent::EVENT_MOUSE_DOUBLE_CLICK_TYPE; + } + + // 重置上一次点击时间 + lastClickTime = std::chrono::high_resolution_clock::now(); + } + } + + TpMouseEvent keyEvent; + keyEvent.construct(&mInput); + + if (mInput.type == TpEvent::EVENT_MOUSE_DOUBLE_CLICK_TYPE) + { + // 终止长按计算线程 + stopLongPressCheck(); + + IssueObjEvent(childObj, keyEvent, onMouseDoubleClickEvent, childObj->enabled()); + } + else + { + // 鼠标按下时直接触发事件,释放时需要判断,鼠标按下后是否滑动,滑动则不触发释放事件 + if (mInput.state) + { + IssueObjEvent(childObj, keyEvent, onMousePressEvent, childObj->enabled()); + + // 计时,判断是否是长按 + startLongPressCheck(childObj, mInput); + } + else + { + // 终止长按计算线程 + stopLongPressCheck(); + + // 无论鼠标在哪,都触发按下对象的释放事件 + if (pressObject) + { + IssueObjEvent(pressObject, keyEvent, onMouseRleaseEvent, pressObject->enabled()); + } + } + } + + list.clear(); +} + +static inline void broadFinger(TpObjectData *set, ItpFingerSet &input, TpObject *object, std::list &list, ItpEvent *events) +{ + TpWidget *childObj = static_cast(object); + if (!childObj) + return; + + uint32_t rW = 0, rH = 0; + tinyPiX_wf_get_display_size(set->agent, &rW, &rH); + TpFingerEvent event; + + input.timestamp = events->fingerEvent.timestamp; + input.fingerID = events->fingerEvent.fingerId; + input.touchID = events->fingerEvent.touchId; + input.pressure = events->fingerEvent.pressure; + + event.construct(&input); + std::list::iterator iter = list.begin(); + + input.x = events->fingerEvent.x * rW - childObj->toScreen().x(); + input.y = events->fingerEvent.y * rH - childObj->toScreen().y(); + event.construct(&input); + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + IssueObjEvent(childObj, event, onFingerEvent, childObj->enabled()); + + list.clear(); +} + +static inline void broaDollar(TpObjectData *set, ItpDollarSet &input, TpObject *object, std::list &list, ItpEvent *events) +{ + TpWidget *childObj = static_cast(object); + if (!childObj) + return; + + uint32_t rW = 0, rH = 0; + tinyPiX_wf_get_display_size(set->agent, &rW, &rH); + TpDollAREvent event; + + input.timestamp = events->dollarEvent.timestamp; + input.touchID = events->dollarEvent.touchid; + input.GestureID = events->dollarEvent.gestureid; + input.numFingers = events->dollarEvent.numfingers; + + event.construct(&input); + + std::list::iterator iter = list.begin(); + + input.x = events->dollarEvent.x * rW - childObj->toScreen().x(); + input.y = events->dollarEvent.y * rH - childObj->toScreen().y(); + event.construct(&input); + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + IssueObjEvent(childObj, event, onDollAREvent, childObj->enabled()); +} + +static inline void broadMultiGesture(TpObjectData *set, ItpMultiGestureSet &input, TpObject *object, std::list &list, ItpEvent *events) +{ + TpWidget *childObj = static_cast(object); + if (!childObj) + return; + + uint32_t rW = 0, rH = 0; + tinyPiX_wf_get_display_size(set->agent, &rW, &rH); + TpMultiGestureEvent event; + + input.timestamp = events->gestrueEvent.timestamp; + input.touchID = events->gestrueEvent.touchid; + input.dtheta = events->gestrueEvent.dtheta; + input.ddist = events->gestrueEvent.ddist; + input.numfingers = events->gestrueEvent.numfingers; + input.padding = events->gestrueEvent.padding; + + event.construct(&input); + + std::list::iterator iter = list.begin(); + + TpWidget *setCurChildObj = static_cast(set->tmp.curObject); + if (setCurChildObj) + { + input.x = events->gestrueEvent.x * rW - setCurChildObj->toScreen().x(); + input.y = events->gestrueEvent.y * rH - setCurChildObj->toScreen().y(); + event.construct(&input); + } + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + IssueObjEvent(childObj, event, onMultiGestureEvent, childObj->enabled()); +} + +static inline bool splitTouchMousePoint(ItpEvent *event, TpPoint *point) +{ + switch (event->type) + { + case TP_MOUSEMOTION: + { + point->setX(event->mouseMotionEvent.x); + point->setY(event->mouseMotionEvent.y); + } + break; + case TP_MOUSEBUTTONDOWN: + case TP_MOUSEBUTTONUP: + { + point->setX(event->mouseButtonEvent.x); + point->setY(event->mouseButtonEvent.y); + } + break; + case TP_FINGERMOTION: + case TP_FINGERUP: + case TP_FINGERDOWN: + { + point->setX(event->fingerEvent.x); + point->setY(event->fingerEvent.y); + } + break; + case TP_DOLLARGESTURE: + case TP_DOLLARRECORD: + { + point->setX(event->dollarEvent.x); + point->setY(event->dollarEvent.y); + } + break; + case TP_MULTIGESTURE: + { + point->setX(event->gestrueEvent.x); + point->setY(event->gestrueEvent.y); + } + break; + default: + { + return false; + } + } + + return true; +} + +static inline void doTransUpdate(void *args) +{ + TpScreen *object = (TpScreen *)args; + TpObjectData *set = (TpObjectData *)object->objectSets(); + int32_t x, y; + uint32_t w, h; + tinyPiX_wf_get_rect(set->agent, &x, &y, &w, &h); + object->update(x, y, w, h, true); +} + +static inline int32_t transferEvent(int32_t id, void *event, void *args) +{ + ItpEvent *events = (ItpEvent *)event; + TpScreen *object = (TpScreen *)args; + + return object->dispatchEvent(events); +} + +static inline int32_t transferFocus(int32_t id, int32_t focused, void *args) +{ + TpWidget *object = (TpWidget *)args; + TpFocusEvent event; + ItpObjectFocusSet input; + input.object = object; + input.focused = focused; + event.construct(&input); + + return object->onFocusEvent(&event); +} + +static inline int32_t transferLeave(int32_t id, int32_t leaved, int mouseX, int mouseY, void *args) +{ + TpWidget *object = (TpWidget *)args; + TpLeaveEvent event; + ItpObjectLeaveSet input; + input.object = nullptr; + input.leaved = leaved; + event.construct(&input); + + if (leaved == false) + { + // notice cur object, leave out + TpObjectData *set = (TpObjectData *)object->objectSets(); + if (set->tmp.curmotion != object) + { + // 如果鼠标坐标没有移出当前对象区域,不触发leve事件 + if (set->tmp.curmotion && (!set->tmp.curmotion->rect().contains(mouseX, mouseY))) + { + // leaveout + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + // std::cout << " LeaveEvent11111111111 " << std::endl; + IssueObjEvent(set->tmp.curmotion, event, onLeaveEvent, set->tmp.curmotion->enabled()); + } + } + } + + // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 + IssueObjEvent(object, event, onLeaveEvent, object->enabled()); + + return true; +} + +static inline int32_t transferResize(int32_t id, uint32_t nw, uint32_t nh, int32_t question, void *args) // only for resolution +{ + TpWidget *object = (TpWidget *)args; + TpResizeEvent event; + ItpObjectResizeSet input; + input.object = object; + input.nw = nw; + input.nh = nh; + input.question = TpResizeEvent::TP_RESOLUTION_CHANGE; + event.construct(&input); + + TpObjectData *set = (TpObjectData *)object->objectSets(); + +#if 1 + set->absoluteRect.setRect(0, 0, nw, nh); + set->logicalRect.setRect(0, 0, nw, nh); +#endif + + if (!set->reserveImage.isNull()) + { + bool ret = (nw > 0 && nh > 0); + if (ret) + { + set->cacheImage = set->reserveImage.scaled(nw, nh); + } + + doTransUpdate(object); + } + + IssueObjEvent(object, event, onResizeEvent, true); + + return true; +} + +static inline int32_t transferVisible(int32_t id, int32_t visible, void *args) +{ + TpWidget *object = (TpWidget *)args; + TpVisibleEvent event; + ItpObjectVisibleSet input; + input.object = object; + input.visible = visible; + event.construct(&input); + + TpObjectData *set = (TpObjectData *)object->objectSets(); + + if (set) + { + set->visible = visible; + } + + object->onVisibleEvent(&event); + doTransUpdate(object); + + return true; +} + +static inline int32_t transferMoved(int32_t id, int32_t nx, int32_t ny, int32_t question, void *args) +{ + TpWidget *object = (TpWidget *)args; + TpMoveEvent event; + ItpObjectMoveSet input; + input.object = object; + input.nx = nx; + input.ny = ny; + event.construct(&input); + + if (object->objectType() == Tp::TP_FLOAT_OBJECT) + { + TpObjectData *set = (TpObjectData *)object->objectSets(); + + set->absoluteRect.setX(nx); + set->absoluteRect.setY(ny); + + object->broadSetTop(); + object->onMoveEvent(&event); + } + + return true; +} + +static inline int32_t transferActive(int32_t id, int32_t actived, void *args) +{ + TpWidget *object = (TpWidget *)args; + TpApp::Inst()->sendActive(object, actived); + + TpActiveEvent event; + ItpObjectActiveSet input; + input.object = object; + input.actived = actived; + event.construct(&input); + + object->onActiveEvent(&event); + doTransUpdate(object); + + return actived; +} + +static inline int32_t transferQuit(int32_t id, int32_t question, void *args) +{ + TpWidget *object = (TpWidget *)args; + object->deleteLater(); + return 1; +} + +static inline int32_t transferReturn(int32_t id, void *args) +{ + TpWidget *object = (TpWidget *)args; + return ((TpScreen *)object)->returns(); +} + +static inline int32_t transferAppState(int32_t id, int32_t pid, int32_t visible, int32_t active, int32_t color, uint8_t alpha, int32_t require, void *args) +{ + TpWidget *object = (TpWidget *)args; + return object->appChange(id, pid, visible, active, color, alpha, require); +} + +#endif diff --git a/src/include_p/TpGUI/TpDef.h b/src/include_p/TpGUI/TpDef.h index aebd67fea89f353c6d88402249afe8168ca79198..3bae4f7febe5fb468777362e6fa60c81882b75dd 100644 --- a/src/include_p/TpGUI/TpDef.h +++ b/src/include_p/TpGUI/TpDef.h @@ -147,7 +147,8 @@ struct TpObjectData // 圆角值,单位px uint32_t round = 0; - uint8_t alpha; + // 窗口不透明度乘数,[0,1],1=完全不透明 + float windowOpacity = 1.0; IPiWFApiAgent *agent = nullptr; std::mutex gMutex; diff --git a/src/include_p/TpUtils/TpPainter_p.h b/src/include_p/TpUtils/TpPainter_p.h index aa38cdcb432de5eb2a7ae385d49f0cea2fdd47b6..ea910eec30e9574e0f17dacf44e6c604b688da51 100644 --- a/src/include_p/TpUtils/TpPainter_p.h +++ b/src/include_p/TpUtils/TpPainter_p.h @@ -19,12 +19,11 @@ struct TpPainterData { tpShared TpSurfacePtr = nullptr; + TpWidget *paintWidget = nullptr; // 当前窗体屏幕坐标和宽高 int32_t offsetX = 0; int32_t offsetY = 0; - int32_t width = 0; - int32_t height = 0; TpRect clipRect; @@ -50,21 +49,16 @@ struct TpPainterData // 重设canvas的target static inline void refreshCanvasTarget(TpPainterData *painterData) { - // static bool test = true; - // if (test) - { - int32_t surfaceWidth = painterData->TpSurfacePtr->width(); - int32_t surfaceHeight = painterData->TpSurfacePtr->height(); + int32_t surfaceWidth = painterData->TpSurfacePtr->width(); + int32_t surfaceHeight = painterData->TpSurfacePtr->height(); - painterData->swCanvas->target((uint32_t *)painterData->TpSurfacePtr->matrix(), surfaceWidth, surfaceWidth, surfaceHeight, tvg::ColorSpace::ARGB8888); + painterData->swCanvas->target((uint32_t *)painterData->TpSurfacePtr->matrix(), surfaceWidth, surfaceWidth, surfaceHeight, tvg::ColorSpace::ARGB8888); - // 限制绘制区域 - painterData->swCanvas->viewport(painterData->clipRect.x(), painterData->clipRect.y(), painterData->clipRect.width(), painterData->clipRect.height()); + // 限制绘制区域 + painterData->swCanvas->viewport(painterData->clipRect.x(), painterData->clipRect.y(), painterData->clipRect.width(), painterData->clipRect.height()); - // std::cout << "裁剪区域: " << painterData->clipRect.x() << " , " << painterData->clipRect.y() - // << " , " << painterData->clipRect.width() << " , " << painterData->clipRect.height() << std::endl; - } - // test = false; + // std::cout << "裁剪区域: " << painterData->clipRect.x() << " , " << painterData->clipRect.y() + // << " , " << painterData->clipRect.width() << " , " << painterData->clipRect.height() << std::endl; } // 根据线性渐变角度 计算线性渐变射线与矩形边界的交点 @@ -177,7 +171,7 @@ static inline tvg::Fill *parseGradientPtr(TpPainterData *painterData) { float lineearAngle = linearGrad->angle(); // 根据角度计算起始点和终止点 - std::pair pointList = calculateRayIntersections(lineearAngle, painterData->width, painterData->height); + std::pair pointList = calculateRayIntersections(lineearAngle, painterData->paintWidget->width(), painterData->paintWidget->height()); linearGradient->linear(painterData->offsetX + pointList.first.x(), painterData->offsetY + pointList.first.y(), painterData->offsetX + pointList.second.x(), painterData->offsetY + pointList.second.y()); @@ -231,7 +225,7 @@ static inline tvg::Fill *parseGradientPtr(TpPainterData *painterData) colorStops[i].r = _R(colorIter.second); colorStops[i].g = _G(colorIter.second); colorStops[i].b = _B(colorIter.second); - colorStops[i].a = _A(colorIter.second); + colorStops[i].a = _A(colorIter.second) * painterData->paintWidget->windowOpacity(); }; resGradientPtr->colorStops(colorStops, colorList.size()); @@ -475,7 +469,7 @@ static inline void renderPoint(TpPainterData *painterData, int32_t x, int32_t y) if (gradientPtr) pixel->fill(gradientPtr); else - pixel->fill(_R(colorRGBA), _G(colorRGBA), _B(colorRGBA), _A(colorRGBA)); + pixel->fill(_R(colorRGBA), _G(colorRGBA), _B(colorRGBA), _A(colorRGBA) * painterData->paintWidget->windowOpacity()); painterData->tvgScene->push(std::move(pixel)); } @@ -505,7 +499,7 @@ static inline void renderLine(TpPainterData *painterData, const TpPoint &point1, else { int32_t colorRGBA = painterData->drawPen.color().rgba(); - line->strokeFill(_R(colorRGBA), _G(colorRGBA), _B(colorRGBA), _A(colorRGBA)); + line->strokeFill(_R(colorRGBA), _G(colorRGBA), _B(colorRGBA), _A(colorRGBA) * painterData->paintWidget->windowOpacity()); } // 线头 @@ -542,7 +536,7 @@ static inline void renderRect(TpPainterData *painterData, const TpRect &rect, in if (gradientPtr) rectShape->strokeFill(gradientPtr); else - rectShape->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor)); + rectShape->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor) * painterData->paintWidget->windowOpacity()); rectShape->strokeWidth(painterData->drawPen.width()); } @@ -551,7 +545,7 @@ static inline void renderRect(TpPainterData *painterData, const TpRect &rect, in if (gradientPtr) rectShape->fill(gradientPtr); else - rectShape->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + rectShape->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(rectShape, rect.x(), rect.y(), hollowMaskData); } @@ -560,7 +554,7 @@ static inline void renderRect(TpPainterData *painterData, const TpRect &rect, in if (gradientPtr) rectShape->fill(gradientPtr); else - rectShape->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + rectShape->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(rectShape, rect.x(), rect.y(), hollowMaskData); } @@ -592,7 +586,7 @@ static inline void renderEllipse(TpPainterData *painterData, const TpPoint ¢ if (gradientPtr) circle->strokeFill(gradientPtr); else - circle->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor)); + circle->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor) * painterData->paintWidget->windowOpacity()); circle->strokeWidth(painterData->drawPen.width()); } @@ -601,7 +595,7 @@ static inline void renderEllipse(TpPainterData *painterData, const TpPoint ¢ if (gradientPtr) circle->fill(gradientPtr); else - circle->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + circle->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(circle, center.x() - rx, center.y() - ry, hollowMaskData); } @@ -610,7 +604,7 @@ static inline void renderEllipse(TpPainterData *painterData, const TpPoint ¢ if (gradientPtr) circle->fill(gradientPtr); else - circle->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + circle->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(circle, center.x() - rx, center.y() - ry, hollowMaskData); } @@ -683,7 +677,7 @@ static inline void renderArc(TpPainterData *painterData, const TpPoint ¢er, if (gradientPtr) arc->strokeFill(gradientPtr); else - arc->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor)); + arc->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor) * painterData->paintWidget->windowOpacity()); arc->strokeWidth(painterData->drawPen.width()); } @@ -692,7 +686,7 @@ static inline void renderArc(TpPainterData *painterData, const TpPoint ¢er, if (gradientPtr) arc->fill(gradientPtr); else - arc->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + arc->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(arc, center.x() - rad, center.y() - rad, hollowMaskData); } @@ -701,7 +695,7 @@ static inline void renderArc(TpPainterData *painterData, const TpPoint ¢er, if (gradientPtr) arc->fill(gradientPtr); else - arc->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + arc->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(arc, center.x() - rad, center.y() - rad, hollowMaskData); } @@ -711,7 +705,7 @@ static inline void renderArc(TpPainterData *painterData, const TpPoint ¢er, if (gradientPtr) arc->strokeFill(gradientPtr); else - arc->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor)); + arc->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor) * painterData->paintWidget->windowOpacity()); arc->strokeWidth(painterData->drawPen.width()); @@ -775,7 +769,7 @@ static inline void renderPolygon(TpPainterData *painterData, const TpVectorstrokeFill(gradientPtr); else - polygon->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor)); + polygon->strokeFill(_R(penColor), _G(penColor), _B(penColor), _A(penColor) * painterData->paintWidget->windowOpacity()); polygon->strokeWidth(painterData->drawPen.width()); } @@ -784,7 +778,7 @@ static inline void renderPolygon(TpPainterData *painterData, const TpVectorfill(gradientPtr); else - polygon->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + polygon->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(polygon, pointList.front().x() + painterData->offsetX, pointList.front().y() + painterData->offsetY, hollowMaskData); } @@ -793,7 +787,7 @@ static inline void renderPolygon(TpPainterData *painterData, const TpVectorfill(gradientPtr); else - polygon->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor)); + polygon->fill(_R(brushColor), _G(brushColor), _B(brushColor), _A(brushColor) * painterData->paintWidget->windowOpacity()); applyHollowMask(polygon, pointList.front().x() + painterData->offsetX, pointList.front().y() + painterData->offsetY, hollowMaskData); } diff --git a/src/include_p/TpWMEngine/base/protocol.h b/src/include_p/TpWMEngine/base/protocol.h index 29838f2dd81ff67d470dbb6f78c5c87f7ba29a9a..5aaa9bcc839a906e63a5843efe050d9369837c4a 100644 --- a/src/include_p/TpWMEngine/base/protocol.h +++ b/src/include_p/TpWMEngine/base/protocol.h @@ -77,6 +77,7 @@ enum{ PIX_FIND_WIN_ID_BYSTRING, PIX_FIND_WIN_ID_BYPID, PIX_FIND_PID_BYID, + PIX_GET_SURF_BYPID, PIX_ALPHA_CHANGE, PIX_KEYBOARD_EVENT, PIX_MOUSE_KEY_EVENT, diff --git a/src/include_p/TpWMEngine/base/utils.h b/src/include_p/TpWMEngine/base/utils.h index 573c110cd28accc6cf4332e97064ecf7fe4f145d..9c1c16871bcce2db785c86ce08f2e1cb6ca5ae2b 100644 --- a/src/include_p/TpWMEngine/base/utils.h +++ b/src/include_p/TpWMEngine/base/utils.h @@ -121,7 +121,7 @@ extern DECLSPEC void STDCALL umount_tmpfs(const tpChar *target); /**set limit**/ extern DECLSPEC void STDCALL set_unlimited_files(); /**check pixwm run**/ -extern DECLSPEC tpBool STDCALL check_pixwm_run(const tpChar *runPath); +extern DECLSPEC tpInt32 STDCALL check_pixwm_run(const tpChar *runPath); /**create deamon**/ extern DECLSPEC void STDCALL daemon_create(); diff --git a/src/src/TpGUI/Core/TpApp.cpp b/src/src/TpGUI/Core/TpApp.cpp index 6ba80f36bbc3a69b866c9120f4d486badaf18f36..6433a8424d7cd1d5dbd6919bd528bc9c94f67e9c 100644 --- a/src/src/TpGUI/Core/TpApp.cpp +++ b/src/src/TpGUI/Core/TpApp.cpp @@ -1,8 +1,11 @@ #include "TpApp.h" #include "TpApp_p.h" -TpApp::TpApp(int32_t argc, char *argv[]) +TpApp::TpApp(int32_t argc, char *argv[], const TpString &deskStrKey) { + // 初始化网关 + bool gatewayInitRes = initializeGateway(); + // // 根据CPU核心数;分配绘图引擎线程数 uint32_t cores = std::thread::hardware_concurrency(); tvg::Initializer::init(cores / 2); @@ -10,11 +13,8 @@ TpApp::TpApp(int32_t argc, char *argv[]) TpAppData *set = new TpAppData(); bool ret = decideRunOnce(argv[0]); - if (ret) - { std::exit(0); - } set->mainThreadId = std::this_thread::get_id(); @@ -43,29 +43,55 @@ TpApp::TpApp(int32_t argc, char *argv[]) } appInst = this; - this->data_ = set; + data_ = set; + + // 绑定物理窗口;判断是否是桌面 + if (deskStrKey.compare("tinyPiX_DeskTop_0x43ef3dc14") == 0) + { + set->isDesk = true; + bindVScreen(set, new TpFixScreen("tinyPiX_DeskTop_0x43ef3dc14")); + } + else + { + bindVScreen(set, new TpFixScreen()); + } // APP创建,解析初始CSS样式 TpString cssFilePath = parseThemeFile(set->systemTheme); set->cssParser_->parseCss(cssFilePath); - // 尝试读取桌面信息;如果没有桌面则读取失败 - try + // 接收桌面工具栏信息 + auto RecvDeskBarFunc = [=](const char *topic, const void *data, uint32_t dataLen) { - // 记录桌面信息要根据topbar的数据,决定应用所有窗体的xy偏移量,和真实可用宽高 - TpShareMemory deskTopBarshare("DeskTopBarConfig", 1024, false); - if (deskTopBarshare.isMapped()) - { - if (deskTopBarshare.readData(&set->desktopBarInfo_, sizeof(set->desktopBarInfo_))) - { - std::cout << "桌面信息:" << set->desktopBarInfo_.topBarWidth << " , " << set->desktopBarInfo_.topBarHeight - << " , " << set->desktopBarInfo_.topBarisVislble << std::endl; - } - } - } - catch (const std::exception &e) + TpAppData *set = static_cast(data_); + DeskStatusBarInfo *recvInfo = (DeskStatusBarInfo *)data; + + // std::cout << "桌面信息:" << recvInfo->statusBarLocation << " , " << recvInfo->statusBarWidth + // << " , " << recvInfo->statusBarHeight << " , " << recvInfo->statusBarVislble << std::endl; + + // 主屏幕根据Bar数据是否变化决定是否刷新主屏 + if (*recvInfo == set->deskStatusBarInfo_) + return; + + set->deskStatusBarInfo_ = *recvInfo; + + // 更新主屏 + if (!set->mainWindow) + return; + + TpObjectData *mainWindowData = static_cast(set->mainWindow->objectSets()); + refreshMainWindow(set, set->mainWindow, mainWindowData); + }; + + // 订阅桌面数据 + subscribeGatewayData(DeskStatusBarInfoTopic.c_str(), RecvDeskBarFunc); + + // 尝试读取桌面信息;如果没有桌面则读取失败 + if (!set->isDesk) { - // 共享内存不存在;无桌面模式 + // 通知桌面应用启动 + bool pubRunData = true; + publishGatewayData(DeskApplicationRunTopic.c_str(), &pubRunData, sizeof(bool)); } } @@ -73,7 +99,7 @@ TpApp::~TpApp() { tvg::Initializer::term(); - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); if (set) { @@ -103,46 +129,9 @@ TpApp *TpApp::Inst() return appInst; } -bool TpApp::bindVScreen(TpScreen *object) -{ - TpAppData *set = static_cast(this->data_); - bool ret = false; - - if (!set) - return false; - - if (!object) - return false; - - // if (object->objectType() != Tp::TP_TOP_OBJECT) - // { - // std::cout << "bind screen type error !" << std::endl; - // return false; - // } - - if (set->vScreen) - { - std::cout << "bind screen only once !" << std::endl; - return false; - } - - ret = (set->vScreen != object); - - if (ret) - { - set->gMutex.lock(); - set->vScreen = object; - set->gMutex.unlock(); - } - - set->thread->start(); - - return ret; -} - bool TpApp::run() { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); if (!set) return set->running; @@ -199,7 +188,7 @@ bool TpApp::run() TpClipboard *TpApp::clipboard() { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); TpClipboard *clipboard = nullptr; if (set) @@ -210,28 +199,21 @@ TpClipboard *TpApp::clipboard() return clipboard; } -TpScreen *TpApp::vScreen() +TpWidget *TpApp::mainWindow() { - TpAppData *set = (TpAppData *)this->data_; - TpScreen *vScreen = nullptr; - - if (set) - { - vScreen = set->vScreen; - } - - return vScreen; + TpAppData *set = static_cast(data_); + return set->mainWindow; } tpShared TpApp::cssParser() { - TpAppData *set = static_cast(this->data_); + TpAppData *set = static_cast(data_); return set->cssParser_; } void TpApp::setStyle(const Tp::SystemTheme &style) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); if (set->systemTheme != style) { @@ -249,25 +231,17 @@ void TpApp::setStyle(const Tp::SystemTheme &style) Tp::SystemTheme TpApp::style() { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); return set->systemTheme; } -TpImage TpApp::grabWindow() -{ - // TpAppData *set = (TpAppData *)this->data_; - - // tinyPiX_sys_capture_screen(); - return TpImage(); -} - void TpApp::wakeUpVirtualKeyboard(TpWidget *object) { if (!object) return; - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); if (set->virtualKeyboard == nullptr) initVirtualKeyboard(set); @@ -278,14 +252,14 @@ void TpApp::wakeUpVirtualKeyboard(TpWidget *object) void TpApp::dormantVirtualKeyboard() { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); set->curInputObj = nullptr; set->virtualKeyboard->close(); } bool TpApp::isExistObject(TpObject *object, bool autoRemove) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); bool ret = false; if (object == nullptr) @@ -318,13 +292,13 @@ bool TpApp::isExistObject(TpObject *object, bool autoRemove) bool TpApp::isMainThread() { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); return std::this_thread::get_id() == set->mainThreadId; } bool TpApp::sendRegister(TpObject *object) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); bool registerObject = false; if (!set) @@ -371,7 +345,7 @@ bool TpApp::sendDelete(TpObject *object) bool TpApp::sendReturn(TpObject *object) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); bool returnAct = false; if (set) @@ -380,7 +354,8 @@ bool TpApp::sendReturn(TpObject *object) if (returnAct) { - if (object->objectType() != Tp::TP_TOP_OBJECT) + if (object->objectType() != Tp::TP_MAIN_WINDOW_OBJECT && + object->objectType() != Tp::TP_FIXSCREEN_OBJECT) { return false; } @@ -398,7 +373,7 @@ bool TpApp::sendReturn(TpObject *object) bool TpApp::sendActive(TpObject *object, bool actived) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); bool beActived = false; if (set) @@ -407,7 +382,7 @@ bool TpApp::sendActive(TpObject *object, bool actived) if (beActived) { - if (object->objectType() != Tp::TP_TOP_OBJECT) + if (object->objectType() != Tp::TP_MAIN_WINDOW_OBJECT && object->objectType() != Tp::TP_FIXSCREEN_OBJECT) { return false; } @@ -426,7 +401,7 @@ bool TpApp::sendActive(TpObject *object, bool actived) bool TpApp::sendAbort(TpObject *object) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); bool abort = false; if (set) @@ -448,7 +423,7 @@ bool TpApp::sendAbort(TpObject *object) void TpApp::setDisableEventType(int32_t type) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); if (set) { @@ -458,12 +433,12 @@ void TpApp::setDisableEventType(int32_t type) ITpAppData *TpApp::appObjectSet() { - return (TpAppData *)this->data_; + return static_cast(data_); } int32_t TpApp::disableEventType() { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); int32_t type = 0; if (set) @@ -476,7 +451,7 @@ int32_t TpApp::disableEventType() void TpApp::postEvent(std::function task) { - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); if (!set->running) return; @@ -492,7 +467,7 @@ void TpApp::postUpdateEvent(TpWidget *updateObj, const int32_t &x, const int32_t if (!updateObj) return; - TpAppData *set = (TpAppData *)this->data_; + TpAppData *set = static_cast(data_); // if (!set->running) // return; diff --git a/src/src/TpGUI/Core/TpEvent.cpp b/src/src/TpGUI/Core/TpEvent.cpp index e5486559edbded0e0a9948fd2af62fcc3e8116be..3b147bb17bcab70a6be8fe31d5a436c38010ddb1 100644 --- a/src/src/TpGUI/Core/TpEvent.cpp +++ b/src/src/TpGUI/Core/TpEvent.cpp @@ -1400,7 +1400,7 @@ bool TpPaintEvent::construct(ItpEventData *inputData) return false; // 缓存频繁使用的计算和属性 - Tp::ItpObjectType type = inputObjectChild->objectType(); + Tp::TpObjectType type = inputObjectChild->objectType(); const TpRect objectAbsRect = inputObjectChild->toScreen(); const int32_t objWidth = inputObjectChild->width(); const int32_t objHeight = inputObjectChild->height(); @@ -1410,7 +1410,7 @@ bool TpPaintEvent::construct(ItpEventData *inputData) eventData->object = inputObjectChild; eventData->surface = input->surface; - if (type == Tp::TP_FLOAT_OBJECT || type == Tp::TP_TOP_OBJECT) + if (type == Tp::TP_FLOAT_OBJECT || type == Tp::TP_MAIN_WINDOW_OBJECT || type == Tp::TP_FIXSCREEN_OBJECT) { eventData->offsetX = 0; eventData->offsetY = 0; @@ -1421,7 +1421,8 @@ bool TpPaintEvent::construct(ItpEventData *inputData) eventData->offsetY = objectAbsRect.y() - offsetYVal; } - eventData->canvas = new TpPainter(eventData->surface, eventData->offsetX, eventData->offsetY, objWidth, objHeight); + // eventData->canvas = new TpPainter(eventData->surface, eventData->offsetX, eventData->offsetY, objWidth, objHeight); + eventData->canvas = new TpPainter(eventData->surface, eventData->offsetX, eventData->offsetY, inputObjectChild); if (eventData->canvas == nullptr) { eventData->surface = nullptr; @@ -1478,7 +1479,7 @@ bool TpPaintEvent::construct(ItpEventData *inputData) } TpObject *top = input->object->topObject(); - if (top && (top != input->object) && top->objectType() == Tp::TP_FLOAT_OBJECT) + if (top && (top != input->object) && (top->objectType() == Tp::TP_FLOAT_OBJECT || top->objectType() == Tp::TP_MAIN_WINDOW_OBJECT)) { clipRect.setX(clipRect.x() - offsetXVal); clipRect.setY(clipRect.y() - offsetYVal); diff --git a/src/src/TpGUI/Core/TpObject.cpp b/src/src/TpGUI/Core/TpObject.cpp index 5fa81435a30bff44a8979ca0325226b18621bd6e..4663fe7bc249fdf9e6a76a34de5b9374c3821adc 100644 --- a/src/src/TpGUI/Core/TpObject.cpp +++ b/src/src/TpGUI/Core/TpObject.cpp @@ -57,7 +57,7 @@ TpObject::TpObject(TpObject *parent) // set->enableColor = TpApp::Inst()->appConfigSet()->enable; set->enableImage = true; - set->alpha = 0xff; + set->windowOpacity = 1.0; set->layout = nullptr; @@ -262,9 +262,9 @@ TpObject *TpObject::topObject() if (!set) return top; - Tp::ItpObjectType type = objectType(); + Tp::TpObjectType type = objectType(); - if (type == Tp::TP_TOP_OBJECT || type == Tp::TP_FLOAT_OBJECT) + if (type == Tp::TP_FIXSCREEN_OBJECT || type == Tp::TP_MAIN_WINDOW_OBJECT || type == Tp::TP_FLOAT_OBJECT) { set->top = this; } @@ -275,9 +275,9 @@ TpObject *TpObject::topObject() pParent = set->parent; while (pParent) { - Tp::ItpObjectType type = pParent->objectType(); + Tp::TpObjectType type = pParent->objectType(); - if (type == Tp::TP_TOP_OBJECT || type == Tp::TP_FLOAT_OBJECT) + if (type == Tp::TP_FIXSCREEN_OBJECT || type == Tp::TP_MAIN_WINDOW_OBJECT || type == Tp::TP_FLOAT_OBJECT) { set->top = pParent; break; diff --git a/src/src/TpGUI/Core/TpWidget.cpp b/src/src/TpGUI/Core/TpWidget.cpp index ed88ff92bb867b51e52e0d24bcbdd17d03e4882c..edbdeed874d1951de54688308639d52d464093c6 100644 --- a/src/src/TpGUI/Core/TpWidget.cpp +++ b/src/src/TpGUI/Core/TpWidget.cpp @@ -223,7 +223,7 @@ void TpWidget::setRect(const TpRect &rect) setRect(rect.x(), rect.y(), rect.width(), rect.height()); } -void TpWidget::setRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h) +void TpWidget::setRect(int32_t x, int32_t y, int32_t w, int32_t h) { TpObjectData *set = static_cast(TpObject::objectSets()); if (!set) @@ -240,10 +240,6 @@ TpRect TpWidget::toScreen() if (!set) return TpRect(); - // TpRect resRect = set->absoluteRect; - // resRect.setY(processDeskTopBarY(this, resRect.y())); - // resRect.setHeight(processDeskTopBarHeight(this, resRect.height())); - return set->absoluteRect; } @@ -514,22 +510,75 @@ const TpPoint TpWidget::pos() return point; } -void TpWidget::setAlpha(const uint8_t &alpha) +void TpWidget::setWindowOpacity(float opacity) { - TpObjectData *set = static_cast(TpObject::objectSets()); - if (!set) + TpObjectData *objData = static_cast(TpObject::objectSets()); + if (!objData) return; - set->alpha = alpha; + if (opacity < 0) + opacity = 0; + if (opacity > 1) + opacity = 1; + + objData->windowOpacity = opacity; + + // 遍历所有子窗口设置Alpha + TpList childList = TpObject::objectList(); + for (const auto &childPtr : childList) + { + TpWidget *childWidget = dynamic_cast(childPtr); + if (!childWidget) + continue; + childWidget->setWindowOpacity(opacity); + } + + update(); } -uint8_t TpWidget::alpha() +float TpWidget::windowOpacity() { - TpObjectData *set = static_cast(TpObject::objectSets()); - if (!set) + TpObjectData *objData = static_cast(TpObject::objectSets()); + if (!objData) return 0; - return set->alpha; + return objData->windowOpacity; +} + +void TpWidget::bringToTop() +{ + TpWidget *parentWidget = dynamic_cast(parent()); + if (!parentWidget) + return; + + // 将本窗体添加至父窗体子节点链表末尾 + TpObjectData *objData = static_cast(parentWidget->objectSets()); + if (objData->objectList.contains(this)) + { + if (objData->objectList.back() != this) + { + objData->objectList.remove(this); + objData->objectList.emplace_back(this); + } + } +} + +void TpWidget::bringToBottom() +{ + TpWidget *parentWidget = dynamic_cast(parent()); + if (!parentWidget) + return; + + // 将本窗体添加至父窗体子节点链表起始 + TpObjectData *objData = static_cast(parentWidget->objectSets()); + if (objData->objectList.contains(this)) + { + if (objData->objectList.front() != this) + { + objData->objectList.remove(this); + objData->objectList.emplace_front(this); + } + } } bool TpWidget::setLayout(TpLayout *layout) @@ -748,7 +797,7 @@ void TpWidget::setEnableBackGroundImage(bool enable) set->enableImage = enable; } -void TpWidget::setBackGroundColor(TpColors &color, bool enable) +void TpWidget::setBackGroundColor(const TpColors &color, bool enable) { setBackGroundColor(color.rgba(), enable); } @@ -762,8 +811,6 @@ void TpWidget::setBackGroundColor(int32_t color, bool enable) set->backColor = color; set->enableColor = enable; - // TpWidgetCssData *childData = static_cast(data_); - // CSS解析完,初始化默认状态下CSS数据对象 enabledCss()->setBackgroundColor(color); pressedCss()->setBackgroundColor(color); @@ -777,6 +824,7 @@ void TpWidget::setBackGroundColor(const TpBrush &bgBrush, bool enable) TpObjectData *set = static_cast(TpObject::objectSets()); if (!set) return; + set->backBrush = bgBrush; set->enableColor = enable; @@ -817,7 +865,7 @@ void TpWidget::setEnableBackGroundColor(bool enable) set->enableColor = enable; } -void TpWidget::setBorderColor(TpColors &color, bool enable) +void TpWidget::setBorderColor(const TpColors &color, bool enable) { setBorderColor(color.rgba(), enable); } @@ -830,6 +878,15 @@ void TpWidget::setBorderColor(int32_t color, bool enable) set->borderColor = color; set->enableBorderColor = enable; + + // CSS解析完,初始化默认状态下CSS数据对象 + enabledCss()->setBorderColor(color); + pressedCss()->setBorderColor(color); + hoveredCss()->setBorderColor(color); + checkedCss()->setBorderColor(color); + disableCss()->setBorderColor(color); + + update(); } void TpWidget::setBorderColor(const TpBrush &borderBrush, bool enable) @@ -1019,8 +1076,6 @@ bool TpWidget::onLeaveEvent(TpLeaveEvent *event) bool TpWidget::onPaintEvent(TpPaintEvent *event) { bool ret = event->isCanDraw(); - uint8_t alpha = 0xff; - if (!ret) return false; @@ -1044,7 +1099,9 @@ bool TpWidget::onPaintEvent(TpPaintEvent *event) { if (objectType() == Tp::TP_FLOAT_OBJECT) { - if ((curCssData->backgroundColor() & 0xff) != 0xff) + int curAlpha = _A(curCssData->backgroundColor()); + curAlpha *= windowOpacity(); + if ((curAlpha & 0xff) != 0xff) { painter->erase(); } @@ -1066,22 +1123,6 @@ bool TpWidget::onPaintEvent(TpPaintEvent *event) painter->setBrush(TpBrush(Tp::NoBrush)); } - if (set->enableBorderColor) - { - painter->pen().setColor(curCssData->borderColor()); - - if (curCssData->borderColorIsGradient()) - { - painter->pen().setBrush(TpBrush(curCssData->borderColorGradiant())); - } - else - { - painter->pen().setBrush(TpBrush(Tp::NoBrush)); - } - - painter->drawRect(0, 0, rect.width(), rect.height(), minRad); - } - if (set->enableImage && !set->cacheImage.isNull()) { int32_t imageX = 0; @@ -1115,6 +1156,21 @@ bool TpWidget::onPaintEvent(TpPaintEvent *event) painter->drawImage(imageX, imageY, set->cacheImage, minRad); } + if (set->enableBorderColor) + { + painter->setPen(curCssData->borderColor()); + painter->setBrush(TpBrush(Tp::NoBrush)); + + // painter->pen().setBrush(TpBrush(Tp::NoBrush)); + + if (curCssData->borderColorIsGradient()) + { + painter->pen().setBrush(TpBrush(curCssData->borderColorGradiant())); + } + + painter->drawRect(0, 0, rect.width(), rect.height(), minRad); + } + // 窗体更新,如果有布局更新布局 if (set->layout) { @@ -1144,7 +1200,7 @@ void TpWidget::onThemeChangeEvent(TpThemeChangeEvent *event) // setRoundCorners(childData->enabledCssData->roundCorners()); } -Tp::ItpObjectType TpWidget::objectType() +Tp::TpObjectType TpWidget::objectType() { return Tp::TP_CHILD_OBJECT; } @@ -1182,7 +1238,7 @@ void TpWidget::setStyleSheet(const TpString &_styleSheetStr) // 解析CSS字符串 TpApp::Inst()->cssParser()->parseCss(_styleSheetStr); - if (objectType() != Tp::TP_TOP_OBJECT) + if (objectType() != Tp::TP_MAIN_WINDOW_OBJECT && objectType() != Tp::TP_FIXSCREEN_OBJECT) refreshBaseCss(); } diff --git a/src/src/TpGUI/Screen/TpDialog.cpp b/src/src/TpGUI/Screen/TpDialog.cpp index f0bd0b497c1ecbed346b04275e33dfcbd1764727..7ef049a65849a7d8a83107dd4e1083963ce1a51b 100644 --- a/src/src/TpGUI/Screen/TpDialog.cpp +++ b/src/src/TpGUI/Screen/TpDialog.cpp @@ -3,6 +3,9 @@ #include "TpDefaultCss.h" #include "TpDef.h" #include +#include "TpMainWindow.h" +#include "TpPainter.h" +#include "thorVG/thorvg.h" class Semaphore { @@ -38,13 +41,26 @@ struct TpDialogData { // 对话框阻塞信号量 Semaphore sema; + + // 遮罩窗体,模态显示时用于遮罩屏幕 + TpWidget *maskWidget = nullptr; + // bool isExec = false; }; -TpDialog::TpDialog(const char *type) : TpScreen(type) +TpDialog::TpDialog(const char *type) + : TpScreen(type) { TpDialogData *dialogData = new TpDialogData(); + + TpWidget *mainScreen = TpApp::Inst()->mainWindow(); + dialogData->maskWidget = new TpWidget(mainScreen); + dialogData->maskWidget->setBackGroundColor(_RGBA(255, 255, 255, 100)); + dialogData->maskWidget->setRect(mainScreen->pos().x(), mainScreen->pos().y(), mainScreen->width(), mainScreen->height()); + dialogData->maskWidget->setVisible(false); + data_ = dialogData; - // TpApp::Inst()->sendRegister(this); + + TpApp::Inst()->sendRegister(this); if (this->objectType() != Tp::TP_FLOAT_OBJECT) { @@ -55,28 +71,39 @@ TpDialog::TpDialog(const char *type) : TpScreen(type) set->top = this->topObject(); refreshBaseCss(); + + setVisible(false); } TpDialog::~TpDialog() { + TpDialogData *dialogData = static_cast(data_); + if (dialogData) + { + delete dialogData; + dialogData = nullptr; + data_ = nullptr; + } } -uint32_t TpDialog::exec() +void TpDialog::exec() { TpDialogData *dialogData = static_cast(data_); if (!dialogData) - return 0; + return; + + dialogData->maskWidget->setVisible(true); + dialogData->maskWidget->bringToTop(); + bringToTop(); // 调整窗口到居中位置 - TpScreen *mainScreen = TpApp::Inst()->vScreen(); - move((mainScreen->width() - width()) / 2.0, (mainScreen->height() - height()) / 2.0); + TpWidget *mainScreen = TpApp::Inst()->mainWindow(); + move((mainScreen->width() - width()) / 2.0, mainScreen->pos().y() + (mainScreen->height() - height()) / 2.0); setVisible(true); update(); // dialogData->sema.wait(); - - return 1; } void TpDialog::close() @@ -85,21 +112,22 @@ void TpDialog::close() if (!dialogData) return; - TpScreen::setVisible(false); - // setVisible(false); + setVisible(false); // update(); - dialogData->sema.post(); + // dialogData->sema.post(); } -Tp::ItpObjectType TpDialog::objectType() +void TpDialog::setVisible(bool visible) { - return Tp::TP_FLOAT_OBJECT; + TpDialogData *dialogData = static_cast(data_); + if (dialogData->maskWidget && (visible == false)) + dialogData->maskWidget->setVisible(false); + + TpScreen::setVisible(visible); } -bool TpDialog::onPaintEvent(TpPaintEvent *event) +Tp::TpObjectType TpDialog::objectType() { - // dialog使用模拟宽高;即每个dialog起始都是全屏的,只是根据设置的尺寸绘制对应的背景 - - return TpScreen::onPaintEvent(event); + return Tp::TP_FLOAT_OBJECT; } diff --git a/src/src/TpGUI/Screen/TpMainWindow.cpp b/src/src/TpGUI/Screen/TpMainWindow.cpp index 29da2765dc65030ac697e7c6ead62e024e21338b..a1e9d4f0d74c8e648427fc7999ef3e7c136ebf31 100644 --- a/src/src/TpGUI/Screen/TpMainWindow.cpp +++ b/src/src/TpGUI/Screen/TpMainWindow.cpp @@ -13,12 +13,7 @@ struct TpMainWindowData { - uint8_t alpha; - uint32_t color; - int32_t attr; - TpMainWindowData() - : alpha(0), color(0), attr(0) { } }; @@ -29,28 +24,31 @@ TpMainWindow::TpMainWindow(const char *type) TpMainWindowData *screenData = new TpMainWindowData(); data_ = screenData; - if (this->objectType() != Tp::TP_TOP_OBJECT) + if (this->objectType() != Tp::TP_MAIN_WINDOW_OBJECT) { TpApp::Inst()->sendDelete(this); + return; } - TpObjectData *set = static_cast(this->objectSets()); - if (set) + // 判断是否已经有mainwindow了 + TpAppData *appData = (TpAppData *)TpApp::Inst()->appObjectSet(); + if (appData->mainWindow) { - uint32_t rW = 0, rH = 0; - tinyPiX_wf_get_display_size(set->agent, &rW, &rH); + TpApp::Inst()->sendDelete(this); + return; + } + appData->mainWindow = this; - set->absoluteRect.setRect(0, 0, rW, rH); - set->logicalRect.setRect(0, 0, rW, rH); + TpObjectData *set = static_cast(TpObject::objectSets()); + set->top = this->topObject(); - screenData->alpha = 0xff; - screenData->color = TpColors::Black; - screenData->attr = TpMainWindow::ITP_POP_STYLE; + // 调整窗口大小 + refreshMainWindow(appData, this, set); - this->setVScreenAttribute(screenData->alpha, screenData->color, screenData->attr); - } + setBackGroundColor(_RGBA(255, 255, 255, 255)); - set->top = this->topObject(); + tinyPiX_wf_set_visible(set->agent, true); + set->visible = true; } TpMainWindow::~TpMainWindow() @@ -64,47 +62,67 @@ TpMainWindow::~TpMainWindow() } } -Tp::ItpObjectType TpMainWindow::objectType() +Tp::TpObjectType TpMainWindow::objectType() { - return Tp::TP_TOP_OBJECT; + return Tp::TP_MAIN_WINDOW_OBJECT; } -int32_t TpMainWindow::setVScreenAttribute(uint8_t alpha, uint32_t color, int32_t screenAttr) +void TpMainWindow::setBackGroundColor(const TpColors &color, bool enable) { - TpMainWindowData *screenData = static_cast(data_); - if (!screenData) - return false; + // TpMainWindow 不能透明,且必须有背景色 + TpColors newColor = color; + newColor.setAlpha(255); + TpScreen::setBackGroundColor(newColor, true); +} - switch (screenAttr) - { - case TpMainWindow::ITP_FULL_STYLE: - case TpMainWindow::ITP_POP_STYLE: +void TpMainWindow::setBackGroundColor(int32_t color, bool enable) +{ + TpScreen::setBackGroundColor(_RGBA(_R(color), _G(color), _B(color), 255), true); +} + +void TpMainWindow::setBackGroundColor(const TpBrush &bgBrush, bool enable) +{ + TpBrush newBrush = bgBrush; + TpColors setColorObj = newBrush.color(); + setColorObj.setAlpha(255); + newBrush.setColor(setColorObj); + + TpGradient *brushGradiwnt = newBrush.gradient(); + if (brushGradiwnt) { - } - break; - default: - return false; + TpList> colorAtList = brushGradiwnt->getColors(); + for (auto &colorAt : colorAtList) + { + colorAt.second = _RGBA(_R(colorAt.second), _G(colorAt.second), _B(colorAt.second), 255); + brushGradiwnt->setColorAt(colorAt.first, colorAt.second); + } } - TpObjectData *set = (TpObjectData *)this->objectSets(); + TpScreen::setBackGroundColor(newBrush, true); +} - if (set) - { - screenData->alpha = alpha; - screenData->color = color; - screenData->attr = screenAttr; +void TpMainWindow::setEnableBackGroundColor(bool enable) +{ + TpScreen::setEnableBackGroundColor(true); +} - return tinyPiX_wf_send_app_state(set->agent, TP_INVALIDATE_VALUE, this->visible(), this->objectActive(), color, alpha, screenAttr); - } +void TpMainWindow::setBorderColor(const TpColors &color, bool enable) +{ + // TpMainWindow没有边框颜色 + TpScreen::setBorderColor(color, false); +} - return false; +void TpMainWindow::setBorderColor(int32_t color, bool enable) +{ + TpScreen::setBorderColor(color, false); } -bool TpMainWindow::onActiveEvent(TpActiveEvent *event) +void TpMainWindow::setBorderColor(const TpBrush &borderBrush, bool enable) { - TpMainWindowData *screenData = static_cast(data_); - if (!screenData) - return false; + TpScreen::setBorderColor(borderBrush, false); +} - return this->setVScreenAttribute(screenData->alpha, screenData->color, screenData->attr); +void TpMainWindow::setEnabledBorderColor(bool enable) +{ + TpScreen::setEnabledBorderColor(false); } diff --git a/src/src/TpGUI/Screen/TpScreen.cpp b/src/src/TpGUI/Screen/TpScreen.cpp index 47f0d446a17021df47ed12f71b1be644d621f0d7..9ac3a7f5378ebe95e107097f98e5dacfc1793e52 100644 --- a/src/src/TpGUI/Screen/TpScreen.cpp +++ b/src/src/TpGUI/Screen/TpScreen.cpp @@ -1,593 +1,6 @@ #include "TpScreen.h" -#include "TpEvent.h" -#include "TpApp.h" -#include "TpDef.h" -#include "TpLayout.h" -#include "TpObjectStack.h" -#include "TpTimer.h" -#include "TpWidget.h" -#include "TpPainter.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "TpCDef.h" -#include "TpApp.h" #include "TpChildWidget_p.h" - -// 记录鼠标按下时的对象,最后鼠标无论在哪释放,都触发按下对象的release -// static TpWidget *pressObject = nullptr; - -// 鼠标左键长按回调 -static std::function longPressCallback = [](TpWidget *obj, ItpMouseSet mouseSet) -{ - // std::cout << " onLongPress ***********" << std::endl; - - ItpMouseSet longPressData = mouseSet; - longPressData.type = TpEvent::EVENT_MOUSE_LONG_PRESS_TYPE; - - TpMouseEvent keyEvent; - keyEvent.construct(&longPressData); - - IssueObjEvent(obj, keyEvent, onMouseLongPressEvent, obj->enabled()); -}; - -static std::atomic longPressActive{false}; // 原子标志位 -static std::unique_ptr pressThread; // 线程对象 -static std::mutex pressThreadMutex; // 保护线程状态 - -static inline void timer_delay(unsigned long long usec) -{ - struct timeval tv; - tv.tv_sec = usec / 1000000; - tv.tv_usec = usec % 1000000; - int32_t err; - do - { - err = select(0, NULL, NULL, NULL, &tv); - } while (err < 0 && errno == EINTR); -} - -static inline void generateParentList(TpObject *object, std::list &list) -{ - if (object) - { - TpObject *parent = object->parent(); - TpObject *top = object->topObject(); - - while (parent) - { - list.push_front(parent); - - if (parent == top) - { - break; - } - - parent = parent->parent(); - } - } -} - -static inline void startLongPressCheck(TpWidget *object, const ItpMouseSet &mouseSet) -{ - std::lock_guard lock(pressThreadMutex); - if (pressThread || longPressActive) - return; - - longPressActive = true; - - // 启动异步检测线程 - pressThread = std::unique_ptr(new std::thread([=]() - { - const auto startTime = std::chrono::steady_clock::now(); - - // 分段等待,每100ms检查一次状态 - while (longPressActive) - { - // std::cout << " longPressActive " << longPressActive << std::endl; - - auto elapsed = std::chrono::steady_clock::now() - startTime; - if (elapsed >= std::chrono::seconds(1)) - { - // 触发长按回调 - if (longPressCallback) - longPressCallback(object, mouseSet); - break; - } - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } - longPressActive = false; })); -} - -static inline void stopLongPressCheck() -{ - std::lock_guard lock(pressThreadMutex); - longPressActive = false; // 通知线程退出 - - if (pressThread && pressThread->joinable()) - { - // 等待线程结束 - pressThread->join(); - pressThread.reset(); - } -} - -static inline void broadMotion(TpObject *dragObject, TpObject *curMotionObject, std::list &list, ItpEvent *events, TpWidget *pressObject) -{ - TpMouseEvent motionEvent; - ItpMouseSet mInput; - mInput.which = events->mouseMotionEvent.which; - mInput.type = TpEvent::EVENT_MOUSE_MOVE_TYPE; - - std::list::iterator iter = list.begin(); - - TpWidget *childObj = static_cast(dragObject); - if (childObj) - { - // motion, and state = true - mInput.pos.setX(events->mouseMotionEvent.x - childObj->toScreen().x()); - mInput.pos.setY(events->mouseMotionEvent.y - childObj->toScreen().y()); - - mInput.globalPos.setX(events->mouseMotionEvent.x); - mInput.globalPos.setY(events->mouseMotionEvent.y); - - mInput.state = true; - motionEvent.construct(&mInput); - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - // std::cout << "1111++++++++++++Move++++++++++" << mInput.globalPos.x << " , " << mInput.globalPos.y << std::endl; - IssueObjEvent(childObj, motionEvent, onMouseMoveEvent, childObj->enabled()); - } - - TpWidget *childMotionObj = static_cast(curMotionObject); - - if (childMotionObj && curMotionObject != dragObject) - { - // motion, and dragObject is not null, then state = false; otherwise state = true - mInput.pos.setX(events->mouseMotionEvent.x - childMotionObj->toScreen().x()); - mInput.pos.setY(events->mouseMotionEvent.y - childMotionObj->toScreen().y()); - - mInput.globalPos.setX(events->mouseMotionEvent.x); - mInput.globalPos.setY(events->mouseMotionEvent.y); - - mInput.state = dragObject ? false : events->mouseMotionEvent.state; - motionEvent.construct(&mInput); - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - // std::cout << "222++++++++++++Move++++++++++" << mInput.globalPos.x << " , " << mInput.globalPos.y << std::endl; - IssueObjEvent(childMotionObj, motionEvent, onMouseMoveEvent, childMotionObj->enabled()); - - // 如果按下对象后鼠标移动,不再触发长按事件 - if (childMotionObj == pressObject) - { - stopLongPressCheck(); - } - } - - list.clear(); -} - -static inline void broadMouseKey(TpObject *object, std::list &list, ItpEvent *events, TpWidget *pressObject) -{ - ItpMouseSet mInput; - mInput.which = events->mouseButtonEvent.which; - mInput.button = events->mouseButtonEvent.button; - mInput.state = events->mouseButtonEvent.state; - mInput.type = mInput.state ? TpEvent::EVENT_MOUSE_PRESS_TYPE : TpEvent::EVENT_MOUSE_RELEASE_TYPE; - - TpWidget *childObj = static_cast(object); - if (!childObj) - { - list.clear(); - return; - } - - // mouse down and up - mInput.pos.setX(events->mouseButtonEvent.x - childObj->toScreen().x()); - mInput.pos.setY(events->mouseButtonEvent.y - childObj->toScreen().y()); - - mInput.globalPos.setX(events->mouseButtonEvent.x); - mInput.globalPos.setY(events->mouseButtonEvent.y); - - // 滚轮事件 - if (mInput.button == BUTTON_WHEELUP || mInput.button == BUTTON_WHEELDOWN) - { - TpWheelEvent wheelEvent; - mInput.type = TpEvent::EVENT_WHEEL_EVENT; - wheelEvent.construct(&mInput); - - IssueObjEvent(childObj, wheelEvent, onWheelEvent, childObj->enabled()); - - list.clear(); - return; - } - - // 按键事件 - if (mInput.button == BUTTON_LEFT) - { - // 定义双击间隔时间(毫秒) - const int32_t doubleClickInterval = 200; - - if (mInput.state == true) - { - // 记录当前点击时间,减10分钟,确保第一次进入时的判断正确 - static auto lastClickTime = std::chrono::high_resolution_clock::now() - std::chrono::minutes(10); - - auto now = std::chrono::high_resolution_clock::now(); - - auto elapsed = std::chrono::duration_cast(now - lastClickTime).count(); - - // 是双击事件 - if (elapsed < doubleClickInterval) - { - // 如果是双击,触发双击事件 - mInput.type = TpEvent::EVENT_MOUSE_DOUBLE_CLICK_TYPE; - } - - // 重置上一次点击时间 - lastClickTime = std::chrono::high_resolution_clock::now(); - } - } - - TpMouseEvent keyEvent; - keyEvent.construct(&mInput); - - if (mInput.type == TpEvent::EVENT_MOUSE_DOUBLE_CLICK_TYPE) - { - // 终止长按计算线程 - stopLongPressCheck(); - - IssueObjEvent(childObj, keyEvent, onMouseDoubleClickEvent, childObj->enabled()); - } - else - { - // 鼠标按下时直接触发事件,释放时需要判断,鼠标按下后是否滑动,滑动则不触发释放事件 - if (mInput.state) - { - IssueObjEvent(childObj, keyEvent, onMousePressEvent, childObj->enabled()); - - // 计时,判断是否是长按 - startLongPressCheck(childObj, mInput); - } - else - { - // 终止长按计算线程 - stopLongPressCheck(); - - // 无论鼠标在哪,都触发按下对象的释放事件 - if (pressObject) - { - IssueObjEvent(pressObject, keyEvent, onMouseRleaseEvent, pressObject->enabled()); - } - } - } - - list.clear(); -} - -static inline void broadFinger(TpObjectData *set, ItpFingerSet &input, TpObject *object, std::list &list, ItpEvent *events) -{ - TpWidget *childObj = static_cast(object); - if (!childObj) - return; - - uint32_t rW = 0, rH = 0; - tinyPiX_wf_get_display_size(set->agent, &rW, &rH); - TpFingerEvent event; - - input.timestamp = events->fingerEvent.timestamp; - input.fingerID = events->fingerEvent.fingerId; - input.touchID = events->fingerEvent.touchId; - input.pressure = events->fingerEvent.pressure; - - event.construct(&input); - std::list::iterator iter = list.begin(); - - input.x = events->fingerEvent.x * rW - childObj->toScreen().x(); - input.y = events->fingerEvent.y * rH - childObj->toScreen().y(); - event.construct(&input); - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - IssueObjEvent(childObj, event, onFingerEvent, childObj->enabled()); - - list.clear(); -} - -static inline void broaDollar(TpObjectData *set, ItpDollarSet &input, TpObject *object, std::list &list, ItpEvent *events) -{ - TpWidget *childObj = static_cast(object); - if (!childObj) - return; - - uint32_t rW = 0, rH = 0; - tinyPiX_wf_get_display_size(set->agent, &rW, &rH); - TpDollAREvent event; - - input.timestamp = events->dollarEvent.timestamp; - input.touchID = events->dollarEvent.touchid; - input.GestureID = events->dollarEvent.gestureid; - input.numFingers = events->dollarEvent.numfingers; - - event.construct(&input); - - std::list::iterator iter = list.begin(); - - input.x = events->dollarEvent.x * rW - childObj->toScreen().x(); - input.y = events->dollarEvent.y * rH - childObj->toScreen().y(); - event.construct(&input); - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - IssueObjEvent(childObj, event, onDollAREvent, childObj->enabled()); -} - -static inline void broadMultiGesture(TpObjectData *set, ItpMultiGestureSet &input, TpObject *object, std::list &list, ItpEvent *events) -{ - TpWidget *childObj = static_cast(object); - if (!childObj) - return; - - uint32_t rW = 0, rH = 0; - tinyPiX_wf_get_display_size(set->agent, &rW, &rH); - TpMultiGestureEvent event; - - input.timestamp = events->gestrueEvent.timestamp; - input.touchID = events->gestrueEvent.touchid; - input.dtheta = events->gestrueEvent.dtheta; - input.ddist = events->gestrueEvent.ddist; - input.numfingers = events->gestrueEvent.numfingers; - input.padding = events->gestrueEvent.padding; - - event.construct(&input); - - std::list::iterator iter = list.begin(); - - TpWidget *setCurChildObj = static_cast(set->tmp.curObject); - if (setCurChildObj) - { - input.x = events->gestrueEvent.x * rW - setCurChildObj->toScreen().x(); - input.y = events->gestrueEvent.y * rH - setCurChildObj->toScreen().y(); - event.construct(&input); - } - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - IssueObjEvent(childObj, event, onMultiGestureEvent, childObj->enabled()); -} - -static inline bool splitTouchMousePoint(ItpEvent *event, TpPoint *point) -{ - switch (event->type) - { - case TP_MOUSEMOTION: - { - point->setX(event->mouseMotionEvent.x); - point->setY(event->mouseMotionEvent.y); - } - break; - case TP_MOUSEBUTTONDOWN: - case TP_MOUSEBUTTONUP: - { - point->setX(event->mouseButtonEvent.x); - point->setY(event->mouseButtonEvent.y); - } - break; - case TP_FINGERMOTION: - case TP_FINGERUP: - case TP_FINGERDOWN: - { - point->setX(event->fingerEvent.x); - point->setY(event->fingerEvent.y); - } - break; - case TP_DOLLARGESTURE: - case TP_DOLLARRECORD: - { - point->setX(event->dollarEvent.x); - point->setY(event->dollarEvent.y); - } - break; - case TP_MULTIGESTURE: - { - point->setX(event->gestrueEvent.x); - point->setY(event->gestrueEvent.y); - } - break; - default: - { - return false; - } - } - - return true; -} - -static inline void doTransUpdate(void *args) -{ - TpScreen *object = (TpScreen *)args; - TpObjectData *set = (TpObjectData *)object->objectSets(); - int32_t x, y; - uint32_t w, h; - tinyPiX_wf_get_rect(set->agent, &x, &y, &w, &h); - object->update(x, y, w, h, true); -} - -static inline int32_t transferEvent(int32_t id, void *event, void *args) -{ - ItpEvent *events = (ItpEvent *)event; - TpScreen *object = (TpScreen *)args; - - return object->dispatchEvent(events); -} - -static inline int32_t transferFocus(int32_t id, int32_t focused, void *args) -{ - TpWidget *object = (TpWidget *)args; - TpFocusEvent event; - ItpObjectFocusSet input; - input.object = object; - input.focused = focused; - event.construct(&input); - - return object->onFocusEvent(&event); -} - -static inline int32_t transferLeave(int32_t id, int32_t leaved, int mouseX, int mouseY, void *args) -{ - TpWidget *object = (TpWidget *)args; - TpLeaveEvent event; - ItpObjectLeaveSet input; - input.object = nullptr; - input.leaved = leaved; - event.construct(&input); - - if (leaved == false) - { - // notice cur object, leave out - TpObjectData *set = (TpObjectData *)object->objectSets(); - if (set->tmp.curmotion != object) - { - // 如果鼠标坐标没有移出当前对象区域,不触发leve事件 - if (set->tmp.curmotion && (!set->tmp.curmotion->rect().contains(mouseX, mouseY))) - { - // leaveout - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - // std::cout << " LeaveEvent11111111111 " << std::endl; - IssueObjEvent(set->tmp.curmotion, event, onLeaveEvent, set->tmp.curmotion->enabled()); - } - } - } - - // 如果该对象安装了事件过滤器,先将事件传给事件过滤器 - IssueObjEvent(object, event, onLeaveEvent, object->enabled()); - - return true; -} - -static inline int32_t transferResize(int32_t id, uint32_t nw, uint32_t nh, int32_t question, void *args) // only for resolution -{ - TpWidget *object = (TpWidget *)args; - TpResizeEvent event; - ItpObjectResizeSet input; - input.object = object; - input.nw = nw; - input.nh = nh; - input.question = TpResizeEvent::TP_RESOLUTION_CHANGE; - event.construct(&input); - - TpObjectData *set = (TpObjectData *)object->objectSets(); - -#if 1 - set->absoluteRect.setRect(0, 0, nw, nh); - set->logicalRect.setRect(0, 0, nw, nh); -#endif - - if (!set->reserveImage.isNull()) - { - bool ret = (nw > 0 && nh > 0); - if (ret) - { - set->cacheImage = set->reserveImage.scaled(nw, nh); - - // if (set->cacheImage) - // { - // set->cacheImage->setAlpha(set->reserveImage->alpha()); - // } - } - - doTransUpdate(object); - } - - IssueObjEvent(object, event, onResizeEvent, true); - - return true; -} - -static inline int32_t transferVisible(int32_t id, int32_t visible, void *args) -{ - TpWidget *object = (TpWidget *)args; - TpVisibleEvent event; - ItpObjectVisibleSet input; - input.object = object; - input.visible = visible; - event.construct(&input); - - TpObjectData *set = (TpObjectData *)object->objectSets(); - - if (set) - { - set->visible = visible; - } - - object->onVisibleEvent(&event); - doTransUpdate(object); - - return true; -} - -static inline int32_t transferMoved(int32_t id, int32_t nx, int32_t ny, int32_t question, void *args) -{ - TpWidget *object = (TpWidget *)args; - TpMoveEvent event; - ItpObjectMoveSet input; - input.object = object; - input.nx = nx; - input.ny = ny; - event.construct(&input); - - if (object->objectType() == Tp::TP_FLOAT_OBJECT) - { - TpObjectData *set = (TpObjectData *)object->objectSets(); - - set->absoluteRect.setX(nx); - set->absoluteRect.setY(ny); - - object->broadSetTop(); - object->onMoveEvent(&event); - } - - return true; -} - -static inline int32_t transferActive(int32_t id, int32_t actived, void *args) -{ - TpWidget *object = (TpWidget *)args; - TpApp::Inst()->sendActive(object, actived); - - TpActiveEvent event; - ItpObjectActiveSet input; - input.object = object; - input.actived = actived; - event.construct(&input); - - object->onActiveEvent(&event); - doTransUpdate(object); - - return actived; -} - -static inline int32_t transferQuit(int32_t id, int32_t question, void *args) -{ - TpWidget *object = (TpWidget *)args; - object->deleteLater(); - return 1; -} - -static inline int32_t transferReturn(int32_t id, void *args) -{ - TpWidget *object = (TpWidget *)args; - return ((TpScreen *)object)->returns(); -} - -static inline int32_t transferAppState(int32_t id, int32_t pid, int32_t visible, int32_t active, int32_t color, uint8_t alpha, int32_t require, void *args) -{ - TpWidget *object = (TpWidget *)args; - return object->appChange(id, pid, visible, active, color, alpha, require); -} +#include "TpScreen_p.h" TpScreen::TpScreen(const char *type, int32_t x, int32_t y, uint32_t w, uint32_t h) : TpWidget(nullptr) @@ -597,22 +10,6 @@ TpScreen::TpScreen(const char *type, int32_t x, int32_t y, uint32_t w, uint32_t return; set->objectType = type; - - TpAppData *appData = (TpAppData *)TpApp::Inst()->appObjectSet(); - if (set->objectType.compare("tinyPiX_DeskTop_0x43ef3dc14") == 0) - { - appData->isDesk = true; - } - - // int32_t fixScreenY = 0; - // if (!appData->isDesk && appData->desktopBarInfo_.topBarisVislble) - // { - // fixScreenY = appData->desktopBarInfo_.topBarHeight; - // } - - // y += fixScreenY; - // h -= fixScreenY; - set->agent = tinyPiX_wf_create(type, x, y, w, h); if (set->agent == nullptr) @@ -648,8 +45,6 @@ TpScreen::TpScreen(const char *type, int32_t x, int32_t y, uint32_t w, uint32_t this->broadSetTop(); } } - - tinyPiX_wf_set_visible(set->agent, true); } TpScreen::~TpScreen() @@ -683,10 +78,10 @@ void TpScreen::setVisible(bool visible) if (visible == false) { - TpWidget *fixedScreen = TpApp::Inst()->vScreen(); - if (fixedScreen) + TpWidget *mainScreen = TpApp::Inst()->mainWindow(); + if (mainScreen) { - fixedScreen->update(); + mainScreen->update(); } } @@ -726,8 +121,17 @@ void TpScreen::setText(const TpString &text) this->setText(text.c_str()); } -void TpScreen::setRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h) +void TpScreen::setRect(const TpRect &rect) { + setRect(rect.x(), rect.y(), rect.width(), rect.height()); +} + +void TpScreen::setRect(int32_t x, int32_t y, int32_t w, int32_t h) +{ + // TpMainWindow不可被调整大小 + if (pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + TpObjectData *set = (TpObjectData *)TpObject::objectSets(); if (!set) @@ -743,6 +147,10 @@ void TpScreen::setRect(const int32_t &x, const int32_t &y, const int32_t &w, con void TpScreen::setSize(const int32_t &width, const int32_t &height) { + // TpMainWindow不可被调整大小 + if (pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + TpObjectData *set = (TpObjectData *)TpObject::objectSets(); if (!set) @@ -755,6 +163,10 @@ void TpScreen::setSize(const int32_t &width, const int32_t &height) void TpScreen::setWidth(const int32_t &width) { + // TpMainWindow不可被调整大小 + if (pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + TpObjectData *set = (TpObjectData *)TpObject::objectSets(); if (!set) @@ -767,6 +179,10 @@ void TpScreen::setWidth(const int32_t &width) void TpScreen::setHeight(const int32_t &height) { + // TpMainWindow不可被调整大小 + if (pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + TpObjectData *set = (TpObjectData *)TpObject::objectSets(); if (!set) @@ -779,38 +195,18 @@ void TpScreen::setHeight(const int32_t &height) void TpScreen::move(int32_t x, int32_t y) { + // TpMainWindow不可被移动坐标 + if (pluginType().compare(TO_STRING(TpMainWindow)) == 0) + return; + TpObjectData *set = (TpObjectData *)TpObject::objectSets(); if (!set) return; - Tp::ItpObjectSysLayer layer = (Tp::ItpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); + Tp::TpObjectSysLayer layer = (Tp::TpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); if (layer >= Tp::TP_WM_USE_FLOAT) { - // 检查当前对象类型 - Tp::ItpObjectType objType = objectType(); - bool isTopOrFloat = (objType == Tp::TP_TOP_OBJECT || objType == Tp::TP_FLOAT_OBJECT); - - // 检查父对象类型 - bool parentIsTop = false; - if (!isTopOrFloat) - { - if (TpWidget *parentPtr = dynamic_cast(parent())) - { - parentIsTop = (parentPtr->objectType() == Tp::TP_TOP_OBJECT); - } - } - - // 合并条件并执行偏移计算 - if (isTopOrFloat || parentIsTop) - { - TpAppData *appData = static_cast(TpApp::Inst()->appObjectSet()); - if (!appData->isDesk && appData->desktopBarInfo_.topBarisVislble) - { - y += appData->desktopBarInfo_.topBarHeight; - } - } - int32_t ox = 0, oy = 0; tinyPiX_wf_get_rect(set->agent, &ox, &oy, nullptr, nullptr); @@ -846,7 +242,7 @@ void TpScreen::setBeMoved(bool moved) if (set) { - Tp::ItpObjectSysLayer layer = (Tp::ItpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); + Tp::TpObjectSysLayer layer = (Tp::TpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); if (layer >= Tp::TP_WM_USE_FLOAT) { @@ -868,35 +264,22 @@ bool TpScreen::moved() return moved; } -void TpScreen::setAlpha(const uint8_t &alpha) -{ - TpObjectData *set = (TpObjectData *)TpObject::objectSets(); - - if (set) - { - tinyPiX_wf_set_alpha(set->agent, alpha); - set->alpha = alpha; - } -} - void TpScreen::bringToTop() { TpObjectData *set = (TpObjectData *)TpObject::objectSets(); + if (!set) + return; - if (set) - { - tinyPiX_wf_bring_to_top(set->agent); - } + tinyPiX_wf_bring_to_top(set->agent); } void TpScreen::bringToBottom() { TpObjectData *set = (TpObjectData *)TpObject::objectSets(); + if (!set) + return; - if (set) - { - tinyPiX_wf_bring_to_bottom(set->agent); - } + tinyPiX_wf_bring_to_bottom(set->agent); } void TpScreen::update(int32_t x, int32_t y, int32_t w, int32_t h, bool onlyBlit) @@ -912,21 +295,21 @@ void TpScreen::update(bool onlyBlit) update(this->toScreen().x(), this->toScreen().y(), this->width(), this->height(), onlyBlit); } -Tp::ItpObjectType TpScreen::objectType() +Tp::TpObjectType TpScreen::objectType() { TpObjectData *set = (TpObjectData *)TpObject::objectSets(); - Tp::ItpObjectType type = Tp::TP_UNKOWN_OBJECT; + Tp::TpObjectType type = Tp::TP_UNKOWN_OBJECT; if (set) { - Tp::ItpObjectSysLayer layer = (Tp::ItpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); + Tp::TpObjectSysLayer layer = (Tp::TpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); switch (layer) { case Tp::TP_WM_DESK: case Tp::TP_WM_WIN: { - type = Tp::TP_TOP_OBJECT; + type = Tp::TP_MAIN_WINDOW_OBJECT; } break; case Tp::TP_WM_USE_FLOAT: @@ -941,14 +324,14 @@ Tp::ItpObjectType TpScreen::objectType() return type; } -Tp::ItpObjectSysLayer TpScreen::objectLayer() +Tp::TpObjectSysLayer TpScreen::objectLayer() { TpObjectData *set = (TpObjectData *)TpObject::objectSets(); - Tp::ItpObjectSysLayer layer = Tp::TP_WM_NONE; + Tp::TpObjectSysLayer layer = Tp::TP_WM_NONE; if (set) { - layer = (Tp::ItpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); + layer = (Tp::TpObjectSysLayer)tinyPiX_wf_get_layer(set->agent); } return layer; @@ -1012,12 +395,18 @@ void TpScreen::deleteLater() switch (this->objectType()) { - case Tp::TP_TOP_OBJECT: + case Tp::TP_FIXSCREEN_OBJECT: { message.type = TpApp::TP_ABORT_ACT; TpApp::Inst()->sendAbort(this); } break; + case Tp::TP_MAIN_WINDOW_OBJECT: + { + message.type = TpApp::TP_DELETE_ACT; + TpApp::Inst()->sendDelete(this); + } + break; case Tp::TP_FLOAT_OBJECT: { message.type = TpApp::TP_DELETE_ACT; @@ -1040,7 +429,8 @@ bool TpScreen::returns() switch (this->objectType()) { - case Tp::TP_TOP_OBJECT: + case Tp::TP_MAIN_WINDOW_OBJECT: + case Tp::TP_FIXSCREEN_OBJECT: { message.type = TpApp::TP_RETURN_ACT; TpApp::Inst()->sendReturn(this); @@ -1054,46 +444,6 @@ bool TpScreen::returns() return returns; } -TpSize TpScreen::screenSize() -{ - TpObjectData *set = (TpObjectData *)TpObject::objectSets(); - uint32_t sWidth = 0; - uint32_t sHeight = 0; - - if (set) - { - tinyPiX_wf_get_display_size(set->agent, &sWidth, &sHeight); - } - - return TpSize(sWidth, sHeight); -} - -int32_t TpScreen::screenWidth() -{ - TpObjectData *set = (TpObjectData *)TpObject::objectSets(); - uint32_t sWidth = 0; - - if (set) - { - tinyPiX_wf_get_display_size(set->agent, &sWidth, nullptr); - } - - return sWidth; -} - -int32_t TpScreen::screenHeight() -{ - TpObjectData *set = (TpObjectData *)TpObject::objectSets(); - uint32_t sHeight = 0; - - if (set) - { - tinyPiX_wf_get_display_size(set->agent, nullptr, &sHeight); - } - - return sHeight; -} - int32_t TpScreen::dispatchEvent(void *events) { ItpEvent *eventPtr = (ItpEvent *)events; @@ -1260,7 +610,7 @@ int32_t TpScreen::dispatchEvent(void *events) return false; } - this->find(point); + // this->find(point); std::list keyList; set->tmp.curfocus = set->tmp.curObject; diff --git a/src/src/TpGUI/Widgets/TpAnimation.cpp b/src/src/TpGUI/Widgets/TpAnimation.cpp index cbd71536c43538f10c556cfe9255141aada7b13a..c19fef1421a996145ee45699bb5f32c545cf81cf 100644 --- a/src/src/TpGUI/Widgets/TpAnimation.cpp +++ b/src/src/TpGUI/Widgets/TpAnimation.cpp @@ -379,10 +379,10 @@ void TpAnimation::AnimationRun() if (startValue.isInt32() && endValue.isInt32()) { const double opacity = lerp( - startValue.toInt32(), - endValue.toInt32(), + startValue.toDouble(), + endValue.toDouble(), keyProgress); - animationData->targetWidget->setAlpha(opacity); + animationData->targetWidget->setWindowOpacity(opacity); } break; } diff --git a/src/src/TpGUI/Widgets/TpBattery.cpp b/src/src/TpGUI/Widgets/TpBattery.cpp index 5ae04585a949aea74584360f8b07656ded5d2ff6..83b30e18d9b05f32704130fae592cd58298a7879 100644 --- a/src/src/TpGUI/Widgets/TpBattery.cpp +++ b/src/src/TpGUI/Widgets/TpBattery.cpp @@ -14,7 +14,7 @@ struct TpBatteryData int32_t alarmValue = 20; int32_t value = 0; - int32_t borderWidth = 1; + int32_t borderWidth = 2; int32_t whiteBorderColor = _RGB(255, 255, 255); int32_t whiteColor = _RGB(255, 255, 255); int32_t blackBorderColor = _RGB(159, 159, 159); @@ -104,9 +104,6 @@ int32_t TpBattery::alamColor() bool TpBattery::onPaintEvent(TpPaintEvent *event) { - static uint64_t paintCount = 0; - // std::cout << "TpBattery::onPaintEvent " << paintCount++ << std::endl; - TpBatteryData *batteryData = static_cast(data_); // TpWidget::onPaintEvent(event); @@ -120,36 +117,37 @@ bool TpBattery::onPaintEvent(TpPaintEvent *event) double headWidth = width() / 12; double batteryWidth = width() - headWidth; - // TpRect batteryRect = TpRect(TpPoint(5, 5), TpPoint(batteryWidth, height() - 5)); - TpRect batteryRect = TpRect(TpPoint(0, 0), TpPoint(batteryWidth, height())); - - // 边框 - double borderRadius = batteryRect.height() * 0.3; + // 起始坐标偏移线宽,保证绘制在区域内 + TpRect batteryRect = TpRect(TpPoint(linew, linew), TpPoint(batteryWidth, height() - linew)); + // 绘制边框 + double borderRadius = batteryRect.height() / 30; painter->pen().setColor(borderColor); painter->pen().setWidth(linew); - - painter->drawRect(batteryRect.x(), batteryRect.y(), batteryRect.width(), batteryRect.height(), borderRadius); + painter->drawRect(batteryRect, borderRadius); // 电量 if (batteryData->value != 0) { int32_t powerColoer = batteryData->value > batteryData->alarmValue ? powerColor : batteryData->alarmColor; - double margin = std::min(width(), height()) * 0.06; + double margin = std::min(width(), height()) / 50.0; margin = std::max(margin, linew); + // margin=0; + + // double linew = 0; - double unit = (batteryRect.width() - (margin * 2) - linew * 2) / 100; - TpPointF topLeft(batteryRect.left() + margin + linew, batteryRect.top() + margin + linew); - TpPointF bottomRight(batteryData->value * unit + margin + linew, batteryRect.bottom() - margin - linew); + double unit = (batteryRect.width() - (margin * 2)) / 100; + TpPointF topLeft(batteryRect.left() + margin, batteryRect.top() + margin); + TpPointF bottomRight(batteryData->value * unit + margin + 2, batteryRect.bottom() - margin); TpRectF rect(topLeft, bottomRight); - double bgRadius = rect.height() * 0.3; + double bgRadius = rect.height() / 30.0; painter->pen().setColor(powerColoer); painter->setBrush(TpBrush(powerColoer)); - painter->drawRect(rect.x(), rect.y(), rect.width(), rect.height(), bgRadius); + painter->drawRect(rect.x(), rect.y(), rect.width(), rect.height(), borderRadius); } // 绘制数值 @@ -157,11 +155,11 @@ bool TpBattery::onPaintEvent(TpPaintEvent *event) TpString text = TpString::number(batteryData->value); // 设置电量文字字体、大小 // TpFont font(DEFAULT_FONT_FAMILY, batteryRect.w / 10); - TpFont font(DEFAULT_FONT_FAMILY, height() / 2); + TpFont font(DEFAULT_FONT_FAMILY, batteryRect.height() * 0.55); font.setText(text); font.setFontColor(fontColor, fontColor); - uint32_t textX = (batteryRect.width() - font.pixelWidth()) / 2.0; - uint32_t textY = (batteryRect.height() - font.pixelHeight()) / 2.0 + 1; + uint32_t textX = batteryRect.left() + (batteryRect.width() - font.pixelWidth()) / 2.0; + uint32_t textY = batteryRect.top() + (batteryRect.height() - font.pixelHeight()) / 2.0 + 1; painter->drawText(font, textX, textY, text); // 绘制头部 diff --git a/src/src/TpGUI/Widgets/TpMenu.cpp b/src/src/TpGUI/Widgets/TpMenu.cpp index cae6d884df36451328553c4563cbdd8746bbf949..f2642cf9b1b904d88ff48425351b3a9e63130443 100644 --- a/src/src/TpGUI/Widgets/TpMenu.cpp +++ b/src/src/TpGUI/Widgets/TpMenu.cpp @@ -4,6 +4,7 @@ #include "TpDef.h" #include "TpImage.h" #include "TpFont.h" +#include "TpApp.h" struct MenuItemData { @@ -84,28 +85,30 @@ void TpMenu::exec(const int32_t &globalPosX, const int32_t &globalPosY) if (!menuData) return; - int32_t width = TpScreen::screenWidth(); - int32_t height = TpScreen::screenHeight(); + TpDialog::exec(); + + uint32_t menuHeight = menuData->itemList.size() * (menuData->itemHeight); + setSize(menuData->itemWidth, menuHeight); + + int32_t mainWindowWidth = TpApp::Inst()->mainWindow()->width(); + int32_t mainWindowHeight = TpApp::Inst()->mainWindow()->height(); int32_t posX = globalPosX; int32_t posY = globalPosY; - if ((posX + this->width()) > width) + if ((posX + width()) > mainWindowWidth) { - posX = posX - this->width(); + posX = posX - width(); } - if ((posY + this->height()) > height) + if ((posY + height()) > mainWindowHeight) { - posY = posY - this->height(); + posY = posY - height(); } - uint32_t menuHeight = menuData->itemList.size() * (menuData->itemHeight); - setSize(menuData->itemWidth, menuHeight); - - this->move(posX, posY); - this->setVisible(true); - this->update(); + move(posX, posY); + setVisible(true); + update(); } uint32_t TpMenu::addItem(const TpString &text) @@ -217,7 +220,7 @@ TpString TpMenu::itemText(const uint32_t &index) bool TpMenu::onFocusEvent(TpFocusEvent *event) { - std::cout << "TpMenu::onFocusEvent " << std::endl; + // std::cout << "TpMenu::onFocusEvent " << std::endl; // if (!event->focused()) // { // close(); @@ -226,14 +229,6 @@ bool TpMenu::onFocusEvent(TpFocusEvent *event) return true; } -bool TpMenu::onMousePressEvent(TpMouseEvent *event) -{ - if (event->button() != BUTTON_LEFT) - return true; - - return true; -} - bool TpMenu::onMouseRleaseEvent(TpMouseEvent *event) { if (event->button() != BUTTON_LEFT) @@ -247,7 +242,6 @@ bool TpMenu::onMouseRleaseEvent(TpMouseEvent *event) onClicked.emit(clickIndex); setVisible(false); - // update(); return true; } diff --git a/src/src/TpGUI/Widgets/TpMessageBox.cpp b/src/src/TpGUI/Widgets/TpMessageBox.cpp index 1139f56491763f7fc4a3f44ae1f23d25c2de3087..acbaf6aa669acd3dcafef3528860e873b6888259 100644 --- a/src/src/TpGUI/Widgets/TpMessageBox.cpp +++ b/src/src/TpGUI/Widgets/TpMessageBox.cpp @@ -7,6 +7,9 @@ static int32_t BtnFontColor = _RGB(38, 38, 38); struct TpMessageBoxData { + uint32_t msgWidth = TpDisplay::dp2Px(430); + uint32_t msgHeight = TpDisplay::dp2Px(160); + TpMessageBox::MessageType type = TpMessageBox::Information; TpVector btnList; @@ -30,8 +33,8 @@ struct TpMessageBoxData } }; -TpMessageBox::TpMessageBox(const char *type) - : TpDialog(type) +TpMessageBox::TpMessageBox(MessageType type) + : TpDialog() { TpMessageBoxData *messageData = new TpMessageBoxData(); @@ -43,97 +46,53 @@ TpMessageBox::TpMessageBox(const char *type) data_ = messageData; - setBackGroundColor(_RGBA(0, 0, 0, 153)); - refreshBaseCss(); -} -TpMessageBox::~TpMessageBox() -{ - TpMessageBoxData *messageData = static_cast(data_); - if (messageData) - { - delete messageData; - messageData = nullptr; - data_ = nullptr; - } -} + setBackGroundColor(_RGBA(255, 255, 255, 230)); + setRoundCorners(25); -uint32_t TpMessageBox::exec() -{ - TpMessageBoxData *messageData = static_cast(data_); - - setSize(TpScreen::screenWidth(), TpScreen::screenHeight()); - - TpDialog::exec(); - - return messageData->clickedIndex; + setMessageType(type); } -void TpMessageBox::setMessageType(const MessageType &type) +TpMessageBox::TpMessageBox(const TpString &text, MessageType type) + : TpDialog() { - TpMessageBoxData *messageData = static_cast(data_); - messageData->type = type; -} - -void TpMessageBox::setButtonList(const TpVector &buttonList) -{ - TpMessageBoxData *messageData = static_cast(data_); - messageData->btnList.clear(); - messageData->btnList = buttonList; -} + TpMessageBoxData *messageData = new TpMessageBoxData(); -uint32_t TpMessageBox::information(const TpString &text, const TpString &btnText) -{ - TpMessageBox msg; - msg.setMessageType(TpMessageBox::Information); - msg.setText(text); + messageData->font->setFontSize(20); + messageData->font->setFontColor(_RGB(38, 38, 38), _RGB(38, 38, 38)); - TpVector btnList; - btnList.emplace_back(btnText); + messageData->btnFont->setFontSize(17); + messageData->btnFont->setFontColor(BtnFontColor, BtnFontColor); - msg.setButtonList(btnList); - return msg.exec(); -} + data_ = messageData; -uint32_t TpMessageBox::question(const TpString &text, const TpString &yesBtnText, const TpString &cancleBtnText) -{ - TpMessageBox msg; - msg.setMessageType(TpMessageBox::Question); - msg.setText(text); + refreshBaseCss(); - TpVector btnList; - btnList.emplace_back(cancleBtnText); - btnList.emplace_back(yesBtnText); + setBackGroundColor(_RGBA(255, 255, 255, 230)); + setRoundCorners(25); - msg.setButtonList(btnList); - return msg.exec(); + setText(text); + setMessageType(type); } -uint32_t TpMessageBox::error(const TpString &text, const TpString &yesBtnText) +TpMessageBox::~TpMessageBox() { - TpMessageBox msg; - msg.setMessageType(TpMessageBox::Error); - msg.setText(text); - - TpVector btnList; - btnList.emplace_back(yesBtnText); - - msg.setButtonList(btnList); - return msg.exec(); + TpMessageBoxData *messageData = static_cast(data_); + if (messageData) + { + delete messageData; + messageData = nullptr; + data_ = nullptr; + } } -uint32_t TpMessageBox::warning(const TpString &text, const TpString &yesBtnText) +void TpMessageBox::exec() { - TpMessageBox msg; - msg.setMessageType(TpMessageBox::Warning); - msg.setText(text); - - TpVector btnList; - btnList.emplace_back(yesBtnText); + TpMessageBoxData *messageData = static_cast(data_); + setSize(messageData->msgWidth, messageData->msgHeight); - msg.setButtonList(btnList); - return msg.exec(); + TpDialog::exec(); } void TpMessageBox::setText(const TpString &text) @@ -143,14 +102,35 @@ void TpMessageBox::setText(const TpString &text) update(); } -TpFont *TpMessageBox::font() +void TpMessageBox::setMessageType(MessageType type) { - return nullptr; + TpMessageBoxData *messageData = static_cast(data_); + messageData->type = type; + + switch (messageData->type) + { + case Information: + setButtonList(TpVector{"确认"}); + break; + case Question: + setButtonList(TpVector{"确认", "取消"}); + break; + case Warning: + setButtonList(TpVector{"确认"}); + break; + case Error: + setButtonList(TpVector{"确认"}); + break; + default: + break; + } } -void TpMessageBox::setVisible(bool visible) +void TpMessageBox::setButtonList(const TpVector &buttonList) { - TpDialog::setVisible(visible); + TpMessageBoxData *messageData = static_cast(data_); + messageData->btnList.clear(); + messageData->btnList = buttonList; } bool TpMessageBox::onMouseRleaseEvent(TpMouseEvent *event) @@ -163,7 +143,9 @@ bool TpMessageBox::onMouseRleaseEvent(TpMouseEvent *event) if (btnRect.contains(event->pos())) { messageData->clickedIndex = btnIndex; + onClose.emit(messageData->clickedIndex); close(); + break; } btnIndex++; @@ -174,34 +156,27 @@ bool TpMessageBox::onMouseRleaseEvent(TpMouseEvent *event) bool TpMessageBox::onPaintEvent(TpPaintEvent *event) { - TpDialog::onPaintEvent(event); - TpMessageBoxData *messageData = static_cast(data_); if (messageData->text.empty()) return true; - TpPainter *paintCanvas = event->painter(); - - uint32_t msgWidth = TpDisplay::dp2Px(450); - uint32_t msgHeight = TpDisplay::dp2Px(160); + TpDialog::onPaintEvent(event); - uint32_t msgX = (width() - msgWidth) / 2.0; - uint32_t msgY = (height() - msgHeight) / 2.0; + TpPainter *painter = event->painter(); - paintCanvas->pen().setColor(_RGBA(255, 255, 255, 230)); - paintCanvas->setBrush(TpBrush(_RGBA(255, 255, 255, 230))); - paintCanvas->drawRect(msgX, msgY, msgWidth, msgHeight, 25); + painter->setPen(backGroundColor()); + painter->setBrush(TpBrush(backGroundColor())); + painter->drawRect(0, 0, width(), height(), roundCorners()); // 分割提示信息 - uint32_t titleHeight = msgHeight * 0.6; - uint32_t btnHeight = msgHeight - titleHeight; - + uint32_t titleHeight = messageData->msgHeight * 0.6; + uint32_t btnHeight = messageData->msgHeight - titleHeight; uint32_t paddingLeftRight = 60; // 绘制标题和按钮分割线 - paintCanvas->pen().setColor(_RGB(190, 196, 202)); - paintCanvas->setBrush(TpBrush(Tp::NoBrush)); - paintCanvas->drawHLine(msgX + paddingLeftRight, msgX + msgWidth - paddingLeftRight, msgY + titleHeight); + painter->pen().setColor(_RGB(190, 196, 202)); + painter->setBrush(TpBrush(Tp::NoBrush)); + painter->drawHLine(paddingLeftRight, messageData->msgWidth - paddingLeftRight, titleHeight); // 文字行间距 uint32_t textGap = 5; @@ -216,31 +191,31 @@ bool TpMessageBox::onPaintEvent(TpPaintEvent *event) { messageData->font->setText(msgTextList.at(i)); - int32_t curLineX = (msgWidth - messageData->font->pixelWidth()) / 2.0; + int32_t curLineX = (messageData->msgWidth - messageData->font->pixelWidth()) / 2.0; - paintCanvas->drawText(*messageData->font, msgX + curLineX, msgY + titleStartY + i * (messageData->font->pixelHeight() + textGap)); + painter->drawText(*messageData->font, curLineX, titleStartY + i * (messageData->font->pixelHeight() + textGap)); } if (messageData->btnList.size() == 0) return true; // 按钮均分窗口宽度 - uint32_t btnWidth = msgWidth / messageData->btnList.size(); + uint32_t btnWidth = messageData->msgWidth / messageData->btnList.size(); // 清空按钮rect messageData->btnRect.clear(); messageData->btnFont->setText("确定"); - int32_t btnTextY = msgY + titleHeight + (btnHeight - messageData->btnFont->pixelHeight()) / 2.0; + int32_t btnTextY = titleHeight + (btnHeight - messageData->btnFont->pixelHeight()) / 2.0; - paintCanvas->pen().setColor(_RGB(190, 196, 202)); - paintCanvas->setBrush(TpBrush(Tp::NoBrush)); + painter->pen().setColor(_RGB(190, 196, 202)); + painter->setBrush(TpBrush(Tp::NoBrush)); for (int i = 0; i < messageData->btnList.size(); ++i) { messageData->btnFont->setText(messageData->btnList.at(i)); - int32_t btnTextX = msgX + btnWidth * i + (btnWidth - messageData->btnFont->pixelWidth()) / 2.0; + int32_t btnTextX = btnWidth * i + (btnWidth - messageData->btnFont->pixelWidth()) / 2.0; // 绘制按钮文本 if ((i == (messageData->btnList.size() - 1)) && messageData->type == TpMessageBox::Question) @@ -251,17 +226,16 @@ bool TpMessageBox::onPaintEvent(TpPaintEvent *event) { messageData->btnFont->setFontColor(BtnFontColor, BtnFontColor); } - paintCanvas->drawText(*messageData->btnFont, btnTextX, btnTextY); + painter->drawText(*messageData->btnFont, btnTextX, btnTextY); // 记录按钮rect - TpRect btnRect(btnTextX, msgY + titleHeight, btnWidth, btnHeight); - + TpRect btnRect(btnWidth * i, titleHeight, btnWidth, btnHeight); messageData->btnRect.emplace_back(btnRect); if (i != (messageData->btnList.size() - 1)) { // 绘制分割线 - paintCanvas->drawVLine(msgX + btnWidth * (i + 1), btnTextY, btnTextY + messageData->btnFont->pixelHeight()); + painter->drawVLine(btnWidth * (i + 1), btnTextY, btnTextY + messageData->btnFont->pixelHeight()); } } diff --git a/src/src/TpGUI/Widgets/TpRadioButton.cpp b/src/src/TpGUI/Widgets/TpRadioButton.cpp index 58da49068814f658194b86cbce8eee294b4511ca..66dc46c96016d7731a82337f9fc44b80b0a76cec 100644 --- a/src/src/TpGUI/Widgets/TpRadioButton.cpp +++ b/src/src/TpGUI/Widgets/TpRadioButton.cpp @@ -110,7 +110,7 @@ void TpRadioButton::setSpacing(uint32_t space) } } -void TpRadioButton::setRect(const int32_t &x, const int32_t &y, const int32_t &w, const int32_t &h) +void TpRadioButton::setRect(int32_t x, int32_t y, int32_t w, int32_t h) { TpRadioButtonData *set = (TpRadioButtonData *)this->data_; diff --git a/src/src/TpGUI/Widgets/TpVirtualKeyboard.cpp b/src/src/TpGUI/Widgets/TpVirtualKeyboard.cpp index 4b2fdddc45923bd5067ca852add337ebd0825b8e..24e15ed779c454bd1b773de809c69b1479f8d602 100644 --- a/src/src/TpGUI/Widgets/TpVirtualKeyboard.cpp +++ b/src/src/TpGUI/Widgets/TpVirtualKeyboard.cpp @@ -7,6 +7,7 @@ #include "TpApp.h" #include "TpPainter.h" #include "TpButton.h" +#include "TpMainWindow.h" #ifndef TOP_MARGIN #define TOP_MARGIN 12 @@ -383,7 +384,7 @@ void TpVirtualKeyboard::show() { TpVirtualKeyboardData *vkData = static_cast(data_); - TpWidget *mainScreen = TpApp::Inst()->vScreen(); + TpWidget *mainScreen = TpApp::Inst()->mainWindow(); setSize(mainScreen->width(), 300); move(0, mainScreen->height() - height()); diff --git a/src/src/TpService/TpGatewayServer.cpp b/src/src/TpService/TpGatewayServerPUBSUB.cpp similarity index 46% rename from src/src/TpService/TpGatewayServer.cpp rename to src/src/TpService/TpGatewayServerPUBSUB.cpp index f6ccf87244196c3eb766aefcb5992409d4152cb7..48b4e311c9dc37ee1301f3065e9475bc8df890da 100644 --- a/src/src/TpService/TpGatewayServer.cpp +++ b/src/src/TpService/TpGatewayServerPUBSUB.cpp @@ -1,4 +1,4 @@ -#include "TpGatewayServer.h" +#include "TpGatewayServerPUBSUB.h" #include "nanomsg/nn.h" #include "nanomsg/pubsub.h" #include @@ -9,6 +9,8 @@ #include #include #include +#include "TpString.h" +#include "TpGatewayServerPUBSUB.h" // 平台特定的IPC地址 #ifdef _WIN32 @@ -20,15 +22,15 @@ // 消息最大尺寸 const uint32_t MAX_MSG_SIZE = 10 * 1024 * 1024; // 10MB -class GatewayServerImpl : public TpGatewayServer +class GatewayServerPUBSUBImpl : public TpGatewayServerPUBSUB { - int32_t pub_socket_ = -1; - int32_t sub_socket_ = -1; + int32_t pubSocket_ = -1; + int32_t subSocket_ = -1; std::atomic running_{false}; - std::atomic message_count_{0}; + std::atomic messageCount_{0}; - std::thread receiver_thread_; - std::thread publisher_thread_; + std::thread receiverThread_; + std::thread publisherThread_; struct Message { @@ -44,24 +46,24 @@ class GatewayServerImpl : public TpGatewayServer } }; - std::queue message_queue_; - std::mutex queue_mutex_; - std::condition_variable queue_cv_; + std::queue messagequeue_; + std::mutex queuemutex_; + std::condition_variable queuecv_; void receiverThread() { while (running_) { char *msg = nullptr; - int32_t bytes = nn_recv(sub_socket_, &msg, NN_MSG, 0); + int32_t bytes = nn_recv(subSocket_, &msg, NN_MSG, 0); if (bytes > 0) { { - std::lock_guard lock(queue_mutex_); - message_queue_.push(Message(msg, bytes)); + std::lock_guard lock(queuemutex_); + messagequeue_.push(Message(msg, bytes)); } - queue_cv_.notify_one(); - message_count_++; + queuecv_.notify_one(); + messageCount_++; } else { @@ -77,17 +79,17 @@ class GatewayServerImpl : public TpGatewayServer { Message msg; { - std::unique_lock lock(queue_mutex_); - queue_cv_.wait(lock, [this] - { return !message_queue_.empty() || !running_; }); + std::unique_lock lock(queuemutex_); + queuecv_.wait(lock, [this] + { return !messagequeue_.empty() || !running_; }); if (!running_) break; - if (!message_queue_.empty()) + if (!messagequeue_.empty()) { - msg = message_queue_.front(); - message_queue_.pop(); + msg = messagequeue_.front(); + messagequeue_.pop(); } else { @@ -97,18 +99,22 @@ class GatewayServerImpl : public TpGatewayServer if (msg.data && msg.size > 0) { + std::cout << "收到发布数据,数据长度:" << msg.size << std::endl; // 处理消息并转发 if (msg.size > 4) { - uint32_t topic_len = *reinterpret_cast(msg.data); - if (topic_len > 0 && topic_len < (msg.size - sizeof(uint32_t))) + uint32_t topicLen = *reinterpret_cast(msg.data); + std::cout << "收到发布数据,主题长度:" << topicLen << std::endl; + + if (topicLen > 0 && topicLen < (msg.size - sizeof(uint32_t))) { const char *topic = msg.data + sizeof(uint32_t); - const char *payload = topic + topic_len; - uint32_t payload_size = msg.size - sizeof(uint32_t) - topic_len; + TpString topicString(topic); + + std::cout << "收到发布数据,主题为:" << topicString << std::endl; // 广播消息 - nn_send(pub_socket_, msg.data, msg.size, 0); + nn_send(pubSocket_, msg.data, msg.size, 0); } } nn_freemsg(msg.data); @@ -116,34 +122,34 @@ class GatewayServerImpl : public TpGatewayServer } // 清理剩余消息 - std::lock_guard lock(queue_mutex_); - while (!message_queue_.empty()) + std::lock_guard lock(queuemutex_); + while (!messagequeue_.empty()) { - auto &msg = message_queue_.front(); + auto &msg = messagequeue_.front(); if (msg.data) nn_freemsg(msg.data); - message_queue_.pop(); + messagequeue_.pop(); } } public: - GatewayServerImpl() = default; + GatewayServerPUBSUBImpl() = default; - ~GatewayServerImpl() override + ~GatewayServerPUBSUBImpl() override { stop(); } - bool start(uint16_t tcp_port) override + bool start(uint16_t tcpPort) override { if (running_) return true; // 创建套接字 - pub_socket_ = nn_socket(AF_SP, NN_PUB); - sub_socket_ = nn_socket(AF_SP, NN_SUB); + pubSocket_ = nn_socket(AF_SP, NN_PUB); + subSocket_ = nn_socket(AF_SP, NN_SUB); - if (pub_socket_ < 0 || sub_socket_ < 0) + if (pubSocket_ < 0 || subSocket_ < 0) { stop(); return false; @@ -151,36 +157,36 @@ public: // 设置接收缓冲区大小 int32_t recv_size = 10 * 1024 * 1024; // 10MB - nn_setsockopt(sub_socket_, NN_SOL_SOCKET, NN_RCVBUF, &recv_size, sizeof(recv_size)); - nn_setsockopt(pub_socket_, NN_SOL_SOCKET, NN_SNDBUF, &recv_size, sizeof(recv_size)); + nn_setsockopt(subSocket_, NN_SOL_SOCKET, NN_RCVBUF, &recv_size, sizeof(recv_size)); + nn_setsockopt(pubSocket_, NN_SOL_SOCKET, NN_SNDBUF, &recv_size, sizeof(recv_size)); // 设置IPC连接 - // if (nn_bind(sub_socket_, IPC_ADDRESS) < 0) + // if (nn_bind(subSocket_, IPC_ADDRESS) < 0) // { - // 允许IPC绑定失败 + // 允许IPC绑定失败 // } // 绑定TCP端口 - // std::string pub_addr = "tcp://*:" + std::to_string(tcp_port); - // std::string sub_addr = "tcp://*:" + std::to_string(tcp_port + 1); + // std::string pub_addr = "tcp://*:" + std::to_string(tcpPort); + // std::string sub_addr = "tcp://*:" + std::to_string(tcpPort + 1); - std::string sub_addr = "tcp://*:" + std::to_string(tcp_port); - std::string pub_addr = "tcp://*:" + std::to_string(tcp_port + 1); + std::string sub_addr = "tcp://*:" + std::to_string(tcpPort); + std::string pub_addr = "tcp://*:" + std::to_string(tcpPort + 1); - if (nn_bind(pub_socket_, pub_addr.c_str()) < 0) + if (nn_bind(pubSocket_, pub_addr.c_str()) < 0) { stop(); return false; } - if (nn_bind(sub_socket_, sub_addr.c_str()) < 0) + if (nn_bind(subSocket_, sub_addr.c_str()) < 0) { stop(); return false; } // 设置订阅所有主题 - if (nn_setsockopt(sub_socket_, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) < 0) + if (nn_setsockopt(subSocket_, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) < 0) { stop(); return false; @@ -188,12 +194,12 @@ public: // 设置接收超时 int32_t timeout = 100; // 100ms - nn_setsockopt(sub_socket_, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(timeout)); + nn_setsockopt(subSocket_, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(timeout)); // 启动工作线程 running_ = true; - receiver_thread_ = std::thread(&GatewayServerImpl::receiverThread, this); - publisher_thread_ = std::thread(&GatewayServerImpl::publisherThread, this); + receiverThread_ = std::thread(&GatewayServerPUBSUBImpl::receiverThread, this); + publisherThread_ = std::thread(&GatewayServerPUBSUBImpl::publisherThread, this); return true; } @@ -201,40 +207,40 @@ public: void stop() override { running_ = false; - queue_cv_.notify_one(); + queuecv_.notify_one(); - if (receiver_thread_.joinable()) + if (receiverThread_.joinable()) { - receiver_thread_.join(); + receiverThread_.join(); } - if (publisher_thread_.joinable()) + if (publisherThread_.joinable()) { - publisher_thread_.join(); + publisherThread_.join(); } - if (pub_socket_ >= 0) + if (pubSocket_ >= 0) { - nn_close(pub_socket_); - pub_socket_ = -1; + nn_close(pubSocket_); + pubSocket_ = -1; } - if (sub_socket_ >= 0) + if (subSocket_ >= 0) { - nn_close(sub_socket_); - sub_socket_ = -1; + nn_close(subSocket_); + subSocket_ = -1; } } size_t getMessageRate() override { - auto count = message_count_.exchange(0); + auto count = messageCount_.exchange(0); return static_cast(count); } }; -// 创建GatewayServer实例 -std::shared_ptr createGatewayServer() +// 创建GatewayServer发布订阅实例 +std::shared_ptr createGatewayServer() { - return std::make_shared(); -} \ No newline at end of file + return std::make_shared(); +} diff --git a/src/src/TpService/TpGatewayServer.h b/src/src/TpService/TpGatewayServerPUBSUB.h similarity index 56% rename from src/src/TpService/TpGatewayServer.h rename to src/src/TpService/TpGatewayServerPUBSUB.h index cb82c6b2905fd7eac675cbe200f1e130caea1e39..a99381d4d390952202fe7f9e8fe62dbc487b6bc9 100644 --- a/src/src/TpService/TpGatewayServer.h +++ b/src/src/TpService/TpGatewayServerPUBSUB.h @@ -1,14 +1,14 @@ -#ifndef GATEWAY_SERVER_H -#define GATEWAY_SERVER_H +#ifndef __GATEWAY_SERVER_PUB_SUB_H +#define __GATEWAY_SERVER_PUB_SUB_H #include #include #include -class TpGatewayServer +class TpGatewayServerPUBSUB { public: - virtual ~TpGatewayServer() = default; + virtual ~TpGatewayServerPUBSUB() = default; virtual bool start(uint16_t tcp_port = 5555) = 0; virtual void stop() = 0; @@ -16,7 +16,6 @@ public: // virtual size_t getClientCount() const = 0; virtual size_t getMessageRate() = 0; }; - -std::shared_ptr createGatewayServer(); +std::shared_ptr createGatewayServer(); #endif // GATEWAY_SERVER_H \ No newline at end of file diff --git a/src/src/TpService/TpGatewayServerREP.cpp b/src/src/TpService/TpGatewayServerREP.cpp new file mode 100644 index 0000000000000000000000000000000000000000..48e4b11bbdccad3de7dd4459feaae989c5fc9bcb --- /dev/null +++ b/src/src/TpService/TpGatewayServerREP.cpp @@ -0,0 +1,200 @@ +#include "TpGatewayServerREP.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "nanomsg/nn.h" +#include "nanomsg/reqrep.h" + +// 平台特定的IPC地址 +#ifdef _WIN32 +#define REP_IPC_ADDRESS "tcp://127.0.0.1" +#else +#define REP_IPC_ADDRESS "ipc:///tmp/gateway_rep.ipc" +#endif + +class GatewayServerREPImpl : public TpGatewayServerREP +{ + int32_t repSockets_; + std::atomic running_{false}; + std::atomic messageCount_{0}; + std::atomic requestCount_{0}; + + std::thread workerThread_; + // std::vector workerThreads_; + + // 请求处理回调函数类型 + using RequestHandler = std::function; + std::unordered_map requestHandlers_; + std::mutex handlerMutex_; + + void workerThread() + { + while (running_) + { + char *msg = nullptr; + int32_t bytes = nn_recv(repSockets_, &msg, NN_MSG, 0); + + if (bytes > 0) + { + requestCount_++; + std::string requestData(msg, bytes); + // std::string clientId = generateClientId(threadId); + std::cout << " 收到请求!!!!" << std::endl; + std::string responseData = processRequest(requestData, ""); + + // 在同一线程中发送响应 + int32_t sendBytes = nn_send(repSockets_, responseData.c_str(), responseData.size(), 0); + + if (sendBytes < 0) + { + std::cout << " 响应发送失败: " << nn_strerror(nn_errno()) << std::endl; + } + else + { + std::cout << " 响应发送失败: " << nn_strerror(nn_errno()) << std::endl; + + } + + nn_freemsg(msg); + messageCount_++; + } + else if (bytes < 0 && nn_errno() != EAGAIN && running_) + { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + } + } + + std::string generateClientId(int workerId) + { + static std::atomic counter{0}; + return "worker_" + std::to_string(workerId) + "_client_" + + std::to_string(++counter); + } + + std::string processRequest(const std::string &requestData, const std::string &clientId) + { + std::cout << "处理请求来自 " << "ECHO: " + requestData + << ", 数据大小: " << requestData.size() + << " 字节" << std::endl; + + return "ECHO: " + requestData; + } + +public: + GatewayServerREPImpl() = default; + + ~GatewayServerREPImpl() override + { + stop(); + } + + bool start(uint16_t tcpPort) override + { + if (running_) + return true; + + int workerCount = 4; // 4个工作线程 + + // for (int i = 0; i < workerCount; ++i) + { + // 创建REP套接字 + repSockets_ = nn_socket(AF_SP_RAW, NN_REP); + if (repSockets_ < 0) + { + std::cout << "创建REP套接字失败: " << nn_strerror(nn_errno()) << std::endl; + return false; + } + + // 设置套接字选项 + int32_t recv_timeout = 1000; // 1秒接收超时 + int32_t send_timeout = 1000; // 1秒发送超时 + int32_t recv_buffer_size = 10 * 1024 * 1024; // 10MB + + nn_setsockopt(repSockets_, NN_SOL_SOCKET, NN_RCVTIMEO, + &recv_timeout, sizeof(recv_timeout)); + nn_setsockopt(repSockets_, NN_SOL_SOCKET, NN_SNDTIMEO, + &send_timeout, sizeof(send_timeout)); + nn_setsockopt(repSockets_, NN_SOL_SOCKET, NN_RCVBUF, + &recv_buffer_size, sizeof(recv_buffer_size)); + nn_setsockopt(repSockets_, NN_SOL_SOCKET, NN_SNDBUF, + &recv_buffer_size, sizeof(recv_buffer_size)); + + // 绑定地址 + std::string tcp_addr = "tcp://*:" + std::to_string(tcpPort); + std::string ipc_addr = REP_IPC_ADDRESS; + + // 优先尝试IPC绑定(更高效) + if (nn_bind(repSockets_, ipc_addr.c_str()) < 0) + { + std::cout << "IPC绑定失败,使用TCP: " << nn_strerror(nn_errno()) << std::endl; + // IPC失败时使用TCP + if (nn_bind(repSockets_, tcp_addr.c_str()) < 0) + { + std::cout << "TCP绑定失败: " << nn_strerror(nn_errno()) << std::endl; + stop(); + return false; + } + } + } + + running_ = true; + + // 启动请求处理线程 + workerThread_ = std::thread(&GatewayServerREPImpl::workerThread, this); + + // 启动工作线程 + // for (size_t i = 0; i < repSockets_.size(); ++i) + // { + // workerThreads_.emplace_back(&GatewayServerREPImpl::workerThread, this, i, repSockets_[i]); + // } + + std::cout << "启动REP工作线程" << std::endl; + return true; + } + + void stop() override + { + running_ = false; + + if (workerThread_.joinable()) + { + workerThread_.join(); + // } + // for (auto &thread : workerThreads_) + // { + // if (thread.joinable()) + // thread.join(); + // } + // workerThreads_.clear(); + + // for (auto socket : repSockets_) + // { + // nn_close(socket); + // } + // repSockets_.clear(); + } + nn_close(repSockets_); + } + + void registerRequestHandler(const std::string &command, RequestHandler handler) + { + std::lock_guard lock(handlerMutex_); + requestHandlers_[command] = handler; + } + + int32_t getRequestCount() const override + { + return static_cast(requestCount_.load()); + } +}; + +std::shared_ptr createGatewayREPServer() +{ + return std::make_shared(); +} \ No newline at end of file diff --git a/src/src/TpService/TpGatewayServerREP.h b/src/src/TpService/TpGatewayServerREP.h new file mode 100644 index 0000000000000000000000000000000000000000..4b6e273d76e94b0b9d658e3d74c962edeacd2f61 --- /dev/null +++ b/src/src/TpService/TpGatewayServerREP.h @@ -0,0 +1,20 @@ +#ifndef __GATEWAY_SERVER_REP_H +#define __GATEWAY_SERVER_REP_H + +#include +#include +#include + +class TpGatewayServerREP +{ +public: + virtual ~TpGatewayServerREP() = default; + + virtual bool start(uint16_t tcp_port = 6555) = 0; + virtual void stop() = 0; + + virtual int32_t getRequestCount() const = 0; +}; +std::shared_ptr createGatewayREPServer(); + +#endif // GATEWAY_SERVER_H \ No newline at end of file diff --git a/src/src/TpService/main.cpp b/src/src/TpService/main.cpp index 39ee3f85926367f888ac7a2f3b8272c5a89e8094..bfd68f88a70bf018f9fb735d8f762b2f60c5eb01 100644 --- a/src/src/TpService/main.cpp +++ b/src/src/TpService/main.cpp @@ -1,15 +1,52 @@ -#include "TpGatewayServer.h" #include #include #include #include #include +#include "TpGatewayServerPUBSUB.h" +#include "TpGatewayServerREP.h" -std::atomic g_running{true}; +std::atomic grunning{true}; void signalHandler(int signal) { - g_running = false; + grunning = false; +} + +// 请求问答服务端线程函数 +void dealFuncREP() +{ + auto repServer = createGatewayREPServer(); + if (!repServer->start()) + { + std::cerr << "请求问答网关服务创建失败!" << std::endl; + return; + } + std::cout << "请求问答网关服务启动成功!" << std::endl; + + // 主循环 + while (grunning) + { + // 每秒打印一次状态 + static auto last_time = std::chrono::steady_clock::now(); + auto now = std::chrono::steady_clock::now(); + auto elapsed = std::chrono::duration_cast(now - last_time).count(); + + if (elapsed >= 1) + { + int32_t reqCount = repServer->getRequestCount(); // 每秒消息数 + + std::cout << "请求应答消息数: " << reqCount + << " msgs/s" << std::endl; + + last_time = now; + } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + // 停止服务器 + repServer->stop(); } int main() @@ -25,21 +62,17 @@ int main() const uint16_t port = 5555; if (!server->start(port)) { - std::cerr << "网关服务创建失败!" << std::endl; + std::cerr << "发布订阅网关服务创建失败!" << std::endl; return 1; } - std::cout << "网关服务启动成功!" << std::endl; - std::cout << "监听 TCP 端口:订阅端口: " << port << " and 发布端口" << (port + 1) << std::endl; + std::cout << "发布订阅网关服务启动成功!" << std::endl; + std::cout << "发布订阅监听 端口:订阅端口: " << port << " and 发布端口" << (port + 1) << std::endl; - // #ifndef _WIN32 - // std::cout << "Also listening on IPC: " << 0000 << std::endl; - // #else - // std::cout << "Using TCP for local communicat0ion" << std::endl; - // #endif + // std::thread REPWorker(&dealFuncREP); // 主循环 - while (g_running) + while (grunning) { // 每秒打印一次状态 static auto last_time = std::chrono::steady_clock::now(); diff --git a/src/src/TpUtils/Service/TpSystemApi.cpp b/src/src/TpUtils/Service/TpSystemApi.cpp index 8d26d0c975a3ead8654329ceba10251b9d9b0b9f..61abf36f8e3b75d5e72b781b612c201824d82648 100644 --- a/src/src/TpUtils/Service/TpSystemApi.cpp +++ b/src/src/TpUtils/Service/TpSystemApi.cpp @@ -13,6 +13,8 @@ #include "TpSurface.h" #include "tinyPiXUtils.h" #include "tinyPiXSys.h" +#include "TpApp.h" +#include "TpApp_p.h" #include const TpString globalAppFilePathStr = "/System/app/"; @@ -21,6 +23,7 @@ struct TpSystemApiData { IPiSysApiAgent *globalAgent = tinyPiX_sys_create(); + // TODO 将缓存数据放入Service中,远程IPC调用 std::mutex readAppMutex; // 已启动应用的UUID和pid映射表 TpHash appUuidPidMap = TpHash(); @@ -121,8 +124,6 @@ void TpSystemApi::notifyWidgetsPaint(const TpString &widgetUuid) TpImage TpSystemApi::appImage(const TpString &uuid) { - // return TpImage(); - TpSystemApiData *apiData = static_cast(data_); if (!apiData) return TpImage(); @@ -131,18 +132,56 @@ TpImage TpSystemApi::appImage(const TpString &uuid) return TpImage(); int32_t appPid = apiData->appUuidPidMap.value(uuid); - - // 获取winID - int appId = tinyPiX_sys_find_win_main_id_bypid(apiData->globalAgent, appPid); - - IPiWFSurface *surfacePtr = tinyPiX_sys_get_obj_surface(apiData->globalAgent, appId, appPid); + IPiWFSurface *surfacePtr = tinyPiX_sys_get_process_surface(apiData->globalAgent, appPid); + // std::cout << "appPid " << appPid << " , " << surfacePtr << std::endl; if (!surfacePtr) return TpImage(); tpShared appDisplayImage = tpMakeShared(surfacePtr); + // 如果有工具栏,需要裁剪掉工具栏位置 + TpRect imageRect; + TpAppData *appData = (TpAppData *)TpApp::Inst()->appObjectSet(); + if (appData->deskStatusBarInfo_.statusBarVislble) + { + if (appData->deskStatusBarInfo_.statusBarLocation == 0) + { + imageRect.setX(0); + imageRect.setY(appData->deskStatusBarInfo_.statusBarHeight); + imageRect.setWidth(appDisplayImage->width()); + imageRect.setHeight(appDisplayImage->height() - appData->deskStatusBarInfo_.statusBarHeight); + } + else if (appData->deskStatusBarInfo_.statusBarLocation == 1) + { + imageRect.setX(0); + imageRect.setY(0); + imageRect.setWidth(appDisplayImage->width() - appData->deskStatusBarInfo_.statusBarWidth); + imageRect.setHeight(appDisplayImage->height()); + } + else if (appData->deskStatusBarInfo_.statusBarLocation == 2) + { + imageRect.setX(0); + imageRect.setY(0); + imageRect.setWidth(appDisplayImage->width()); + imageRect.setHeight(appDisplayImage->height() - appData->deskStatusBarInfo_.statusBarHeight); + } + else if (appData->deskStatusBarInfo_.statusBarLocation == 3) + { + imageRect.setX(appData->deskStatusBarInfo_.statusBarWidth); + imageRect.setY(0); + imageRect.setWidth(appDisplayImage->width() - appData->deskStatusBarInfo_.statusBarWidth); + imageRect.setHeight(appDisplayImage->height()); + } + else + { + imageRect.setX(0); + imageRect.setY(appData->deskStatusBarInfo_.statusBarHeight); + imageRect.setWidth(appDisplayImage->width()); + imageRect.setHeight(appDisplayImage->height() - appData->deskStatusBarInfo_.statusBarHeight); + } + } TpImage resImage; - resImage.load(appDisplayImage->matrix(), TpRect(0, 0, appDisplayImage->width(), appDisplayImage->height())); + resImage.load(appDisplayImage->matrix(), TpSize(appDisplayImage->width(), appDisplayImage->height()), imageRect); tinyPiX_surface_free(surfacePtr); @@ -303,8 +342,6 @@ TpVector TpSystemApi::runAppList() { PiShmBytes appIdInfo = appIdList[i]; - std::cout << "App Index " << i << std::endl; - std::cout << "App Id " << appIdInfo.s_id << " Pid " << appIdInfo.p_id << std::endl; if (runAppPidList.contains(appIdInfo.p_id)) { TpString curAppUuid = apiData->appUuidPidMap.key(appIdInfo.p_id); diff --git a/src/src/TpUtils/TpBrush.cpp b/src/src/TpUtils/TpBrush.cpp index 4449054a85b68c8b9bae0cd0be0526c2ceb7dd43..c21a7717c6f63f5b74c7532ad551d6de01c1c0fa 100644 --- a/src/src/TpUtils/TpBrush.cpp +++ b/src/src/TpUtils/TpBrush.cpp @@ -1,11 +1,13 @@ #include "TpBrush.h" +#include "TpLinearGradient.h" +#include "TpRadialGradient.h" // 画刷数据实现结构体 struct TpBrushData { - Tp::BrushStyle style; // 画刷样式 - TpColors color; // 画刷颜色 - TpGradient *gradient; // 渐变对象指针(如果是渐变画刷) + Tp::BrushStyle style; // 画刷样式 + TpColors color; // 画刷颜色 + TpGradient *gradient = nullptr; // 渐变对象指针(如果是渐变画刷) /// @brief 默认构造函数 TpBrushData() @@ -26,18 +28,18 @@ struct TpBrushData /// @brief 渐变画刷构造函数 /// @param g 渐变对象 TpBrushData(TpGradient *g) - : style(Tp::LinearGradientPattern), - gradient(g) + : style(Tp::LinearGradientPattern) { + copyGradient(g); } /// @brief 复制构造函数 /// @param other 要复制的数据对象 TpBrushData(const TpBrushData &other) : style(other.style), - color(other.color), - gradient(other.gradient) + color(other.color) { + copyGradient(other.gradient); } /// @brief 赋值运算符重载 @@ -49,10 +51,50 @@ struct TpBrushData { style = other.style; color = other.color; - gradient = other.gradient; + copyGradient(other.gradient); } return *this; } + + ~TpBrushData() + { + if (gradient) + { + delete gradient; + gradient = nullptr; + } + } + +private: + void copyGradient(TpGradient *others) + { + if (!others) + return; + + if (others->gradientType() == TpGradient::LinearGradient) + { + TpLinearGradient *inputGradient = dynamic_cast(others); + if (!inputGradient) + return; + + TpLinearGradient *lineGradient = new TpLinearGradient(); + *lineGradient = *inputGradient; + gradient = lineGradient; + } + else if (others->gradientType() == TpGradient::RadialGradient) + { + TpRadialGradient *inputGradient = dynamic_cast(others); + if (!inputGradient) + return; + + TpRadialGradient *radialGradient = new TpRadialGradient(); + *radialGradient = *inputGradient; + gradient = radialGradient; + } + else + { + } + } }; // 默认构造函数 diff --git a/src/src/TpUtils/TpColors.cpp b/src/src/TpUtils/TpColors.cpp index 00c754d2e0c0094423e2f76cf4bf4e009b694377..68e928c0cde461b936ed859eb2819212e63b58ac 100644 --- a/src/src/TpUtils/TpColors.cpp +++ b/src/src/TpUtils/TpColors.cpp @@ -1,19 +1,53 @@ -/*** - * @Author: hywang - * @Date: 2024-08-16 16:17:28 - * @LastEditors: hywang - * @LastEditTime: 2024-08-16 16:19:28 - * @FilePath: /pix-singlegui/PixSingleGUI/include/Utils/TpColors.cpp - * @Description: - * @ - * @PiXOS - */ #include "TpColors.h" +TpColors::TpColors() : isNull_(true) +{ + data_ = _RGBA(0, 0, 0, 255); +} + +TpColors::TpColors(int32_t colorSet) : isNull_(false) +{ + data_ = colorSet; +} + +TpColors::TpColors(const TpColors &color) : isNull_(false) +{ + data_ = color.rgba(); +} + +TpColors::TpColors(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : isNull_(false) +{ + data_ = _RGBA(r, g, b, a); +} + +TpColors::~TpColors() +{ +} + +void TpColors::setRed(uint8_t r) +{ + data_ = _RGBA(r, green(), blue(), alpha()); +} + +void TpColors::setGreen(uint8_t g) +{ + data_ = _RGBA(red(), g, blue(), alpha()); +} + +void TpColors::setBlue(uint8_t b) +{ + data_ = _RGBA(red(), green(), b, alpha()); +} + +void TpColors::setAlpha(uint8_t a) +{ + data_ = _RGBA(red(), green(), blue(), a); +} + inline void TpColors::setNull() { isNull_ = true; - this->colorSet_ = _RGBA(0, 0, 0, 255); + data_ = _RGBA(0, 0, 0, 255); } inline bool TpColors::isNull() @@ -24,5 +58,19 @@ inline bool TpColors::isNull() void TpColors::setRgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { isNull_ = false; - this->colorSet_ = _RGBA(r, g, b, a); -} \ No newline at end of file + data_ = _RGBA(r, g, b, a); +} + +TpColors TpColors::operator=(int32_t color) +{ + isNull_ = false; + data_ = color; + return *this; +} + +TpColors TpColors::operator=(const TpColors &others) +{ + isNull_ = others.isNull_; + data_ = others.data_; + return *this; +} diff --git a/src/src/TpUtils/TpCssData.cpp b/src/src/TpUtils/TpCssData.cpp index 4d528c04a1e95de9cc989a7c3db98fe5dcdc279c..7fabfd5d2c778f5d04bf7d698f3d7ecb4de0213a 100644 --- a/src/src/TpUtils/TpCssData.cpp +++ b/src/src/TpUtils/TpCssData.cpp @@ -176,7 +176,7 @@ int32_t TpCssData::width() TpCssDataData *cssData = static_cast(data_); if (cssData->cssDataMap.contains("width")) return cssData->cssDataMap.value("width").toInt(); - return 10; + return 1; } int32_t TpCssData::minimumWidth() @@ -200,7 +200,7 @@ int32_t TpCssData::height() TpCssDataData *cssData = static_cast(data_); if (cssData->cssDataMap.contains("height")) return cssData->cssDataMap.value("height").toInt(); - return 10; + return 1; } int32_t TpCssData::minimumHeight() @@ -295,7 +295,7 @@ void TpCssData::setBorderColor(const int32_t &color) { TpCssDataData *cssData = static_cast(data_); cssData->cssDataMap["border-color"] = TpString::number(color); - cssData->borderColor_.parse(cssData->cssDataMap["border-color"]); + cssData->borderColor_.parse(TpString::number(color)); } bool TpCssData::borderColorIsGradient() @@ -329,7 +329,7 @@ int32_t TpCssData::fontSize() TpCssDataData *cssData = static_cast(data_); if (cssData->cssDataMap.contains("font-size")) return cssData->cssDataMap.value("font-size").toInt(); - return 10; + return 1; } int32_t TpCssData::gap() @@ -411,7 +411,7 @@ int32_t TpCssData::iconSize() TpCssDataData *cssData = static_cast(data_); if (cssData->cssDataMap.contains("icon-size")) return cssData->cssDataMap.value("icon-size").toInt(); - return 10; + return 1; } int32_t TpCssData::iconBackground() diff --git a/src/src/TpUtils/TpGateway.cpp b/src/src/TpUtils/TpGateway.cpp index 8d4e3b9b548fe6f51c7865dff22a73319ce6d6bb..4eb4881fbda6e4b11c5daae2c0c12ded50091586 100644 --- a/src/src/TpUtils/TpGateway.cpp +++ b/src/src/TpUtils/TpGateway.cpp @@ -8,6 +8,7 @@ #include "nanomsg/pubsub.h" #include "nanomsg/pipeline.h" #include "nanomsg/pair.h" +#include "nanomsg/reqrep.h" #include "TpVector.h" #include "TpHash.h" @@ -45,44 +46,46 @@ public: disconnect(); } - bool connect(const TpString &server_address = "", uint16_t port = DEFAULT_PORT) + bool connect(const TpString &serverAddress = "", uint16_t port = DEFAULT_PORT) { if (connected) return true; // 设置服务器地址 - if (server_address.empty()) + if (serverAddress.empty()) { this->serverAddress = DEFAULT_SERVER; } else { - this->serverAddress = server_address; + this->serverAddress = serverAddress; } this->port = port; // 构建连接地址 - TpString pub_addr = this->serverAddress + ":" + std::to_string(port); - TpString sub_addr = this->serverAddress + ":" + std::to_string(port + 1); + TpString pubAddr = this->serverAddress + ":" + std::to_string(port); + TpString subAddr = this->serverAddress + ":" + std::to_string(port + 1); // 连接到服务器 - if (nn_connect(pubSocket, pub_addr.c_str()) < 0) + if (nn_connect(pubSocket, pubAddr.c_str()) < 0) { return false; } - if (nn_connect(subSocket, sub_addr.c_str()) < 0) + if (nn_connect(subSocket, subAddr.c_str()) < 0) { return false; } // 设置接收缓冲区大小 - int recv_size = 10 * 1024 * 1024; // 10MB - nn_setsockopt(subSocket, NN_SOL_SOCKET, NN_RCVBUF, &recv_size, sizeof(recv_size)); + int recvSize = 10 * 1024 * 1024; // 10MB + nn_setsockopt(subSocket, NN_SOL_SOCKET, NN_RCVBUF, &recvSize, sizeof(recvSize)); // 订阅所有主题 if (nn_setsockopt(subSocket, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) < 0) { + nn_close(pubSocket); + nn_close(subSocket); return false; } @@ -132,23 +135,24 @@ public: if (size == 0) return false; - // 消息格式: [主题长度(4字节)][主题][数据] - uint32_t topic_len = static_cast(strlen(topic)); - uint32_t total_size = sizeof(uint32_t) + topic_len + size; + // 消息格式: [主题长度(4字节)][主题][数据];主题长度+1,预留\0 + uint32_t topicLen = static_cast(strlen(topic) + 1); + uint32_t totalSize = sizeof(uint32_t) + topicLen + size; - if (total_size > MAX_MSG_SIZE) - { + if (totalSize > MAX_MSG_SIZE) return false; - } - void *msg = nn_allocmsg(total_size, 0); + void *msg = nn_allocmsg(totalSize, 0); if (!msg) return false; char *ptr = static_cast(msg); - *reinterpret_cast(ptr) = topic_len; - memcpy(ptr + sizeof(uint32_t), topic, topic_len); - memcpy(ptr + sizeof(uint32_t) + topic_len, data, size); + *reinterpret_cast(ptr) = topicLen; + memcpy(ptr + sizeof(uint32_t), topic, topicLen); + memcpy(ptr + sizeof(uint32_t) + topicLen, data, size); + + char *topicEnd = ptr + sizeof(uint32_t) + topicLen - 1; + *topicEnd = '\0'; int rc = nn_send(pubSocket, &msg, NN_MSG, NN_DONTWAIT); if (rc < 0) @@ -160,7 +164,7 @@ public: return true; } - bool subscribe(const char *topic, TpGateway *receiver) + bool subscribe(const char *topic, ITpGatewayHander *receiver) { std::lock_guard lock(subMutex); subscriptions[topic].emplace_back(Subscription(receiver, nullptr)); @@ -174,7 +178,7 @@ public: return true; } - bool unsubscribe(const char *topic, TpGateway *receiver) + bool unsubscribe(const char *topic, ITpGatewayHander *receiver) { std::lock_guard lock(subMutex); auto it = subscriptions.find(topic); @@ -222,13 +226,13 @@ public: private: struct Subscription { - TpGateway *receiver = nullptr; + ITpGatewayHander *receiver = nullptr; RecvDataFunc callback; Subscription() { } - Subscription(TpGateway *recv, RecvDataFunc callback) + Subscription(ITpGatewayHander *recv, RecvDataFunc callback) : receiver(recv), callback(callback) { } @@ -254,15 +258,13 @@ private: { char *msg = nullptr; int bytes = nn_recv(subSocket, &msg, NN_MSG, 0); - if (bytes > 0) { // 将消息处理任务提交给线程池 threadPool.enqueue([this, msg, bytes] - { + { processMessage(msg, bytes); - nn_freemsg(msg); - }); + nn_freemsg(msg); }); } } } @@ -272,15 +274,15 @@ private: // 消息格式: [主题长度(4字节)][主题][数据] if (bytes > 4) { - uint32_t topic_len = *reinterpret_cast(msg); - if (topic_len > 0 && static_cast(bytes) > sizeof(uint32_t) + topic_len) + uint32_t topicLen = *reinterpret_cast(msg); + if (topicLen > 0 && static_cast(bytes) > sizeof(uint32_t) + topicLen) { const char *topic = msg + sizeof(uint32_t); - const void *data = topic + topic_len; - uint32_t data_size = bytes - sizeof(uint32_t) - topic_len; + const void *data = msg + sizeof(uint32_t) + topicLen; + uint32_t dataSize = bytes - sizeof(uint32_t) - topicLen; // 通知订阅者 - notifySubscribers(topic, data, data_size); + notifySubscribers(topic, data, dataSize); } } } @@ -317,6 +319,9 @@ private: { sub.callback(recvTopic.c_str(), data, size); } + else + { + } } } }; @@ -339,9 +344,9 @@ bool initializeGateway(const char *serverAddress) std::lock_guard lock(gClientMutex); bool connectRes = false; - // if (server_address) + // if (serverAddress) // { - // connectRes = g_client.connect(server_address); + // connectRes = g_client.connect(serverAddress); // } // else // { @@ -365,7 +370,7 @@ bool publishGatewayData(const char *topic, const void *data, const uint32_t &siz return gClient.publish(topic, data, size); } -bool subscribeGatewayData(const char *topic, TpGateway *obj) +bool subscribeGatewayData(const char *topic, ITpGatewayHander *obj) { std::lock_guard lock(gClientMutex); return gClient.subscribe(topic, obj); @@ -377,7 +382,7 @@ bool subscribeGatewayData(const char *topic, RecvDataFunc func) return gClient.subscribe(topic, func); } -bool unsubscribeGatewayData(const char *topic, TpGateway *obj) +bool unsubscribeGatewayData(const char *topic, ITpGatewayHander *obj) { std::lock_guard lock(gClientMutex); return gClient.unsubscribe(topic, obj); @@ -394,4 +399,4 @@ void shutdownGateway() std::lock_guard lock(gClientMutex); gClient.disconnect(); gInitialized = false; // 重置初始化状态 -} \ No newline at end of file +} diff --git a/src/src/TpUtils/TpImage.cpp b/src/src/TpUtils/TpImage.cpp index 9063dd6d5e77389375247c226bfde532c8a3ce41..309cfa47a417f42059d679e608dc18b48a428560 100644 --- a/src/src/TpUtils/TpImage.cpp +++ b/src/src/TpUtils/TpImage.cpp @@ -29,7 +29,7 @@ TpImage::TpImage(const TpImage &other) : data_(nullptr) tvg::Initializer::init(cores / 2); TpImageData *imageData = new TpImageData(); - imageData->tvgPicture = tvg::Picture::gen(); + // imageData->tvgPicture = tvg::Picture::gen(); data_ = imageData; @@ -84,12 +84,6 @@ bool TpImage::load(const TpString &filename) if (!imageData) return false; - // if (imageData->loadBuffer) - // { - // delete[] imageData->loadBuffer; - // imageData->loadBuffer = nullptr; - // } - imageData->fileName = filename; imageData->tvgPicture->load(filename.c_str()); @@ -103,12 +97,12 @@ bool TpImage::load(const TpString &filename) return true; } -bool TpImage::load(void *martix, const TpRect &rect) +bool TpImage::load(void *martix, const TpSize &size, const TpRect &clipRect) { if (!martix) return false; - if (rect.width() == 0 || rect.height() == 0) + if (size.width() == 0 || size.height() == 0) return false; TpImageData *imageData = static_cast(data_); @@ -117,22 +111,49 @@ bool TpImage::load(void *martix, const TpRect &rect) imageData->fileName = ""; - // if (imageData->loadBuffer) - // { - // delete[] imageData->loadBuffer; - // imageData->loadBuffer = nullptr; - // } - - // imageData->loadBuffer = new uint32_t[rect.width() * rect.height()]; - // memcpy(imageData->loadBuffer, martix, sizeof(uint32_t) * rect.width() * rect.height()); - - imageData->tvgPicture->load((uint32_t*)martix, rect.width(), rect.height(), tvg::ColorSpace::ARGB8888, true); - // imageData->tvgPicture->load(imageData->loadBuffer, rect.width(), rect.height(), tvg::ColorSpace::ARGB8888); - - imageData->actualWidth = rect.width(); - imageData->actualHeight = rect.height(); - - // imageData->tvgPicture->size(&imageData->actualWidth, &imageData->actualHeight); + // 裁剪图片 + if (clipRect.width() != 0 && clipRect.height() != 0) + { + // 只加载裁剪数据 + // 分配新的 buffer,只包含裁剪区域 + uint32_t *croppedBuffer = new uint32_t[clipRect.width() * clipRect.height()]; + + // 从原始 buffer 复制裁剪区域的像素 + uint32_t *srcBuffer = (uint32_t *)martix; + for (int y = 0; y < clipRect.height(); y++) + { + int srcY = clipRect.y() + y; + if (srcY >= 0 && srcY < size.height()) + { + for (int x = 0; x < clipRect.width(); x++) + { + int srcX = clipRect.x() + x; + if (srcX >= 0 && srcX < size.width()) + { + croppedBuffer[y * clipRect.width() + x] = + srcBuffer[srcY * size.width() + srcX]; + } + } + } + } + + // 加载裁剪后的 buffer + imageData->tvgPicture->load(croppedBuffer, + clipRect.width(), + clipRect.height(), + tvg::ColorSpace::ARGB8888, + true); + + // 释放临时 buffer + delete[] croppedBuffer; + } + else + { + // 加载全量数据 + imageData->tvgPicture->load((uint32_t *)martix, size.width(), size.height(), tvg::ColorSpace::ARGB8888, true); + imageData->actualWidth = size.width(); + imageData->actualHeight = size.height(); + } return true; } @@ -401,7 +422,7 @@ TpImage &TpImage::operator=(const TpImage &others) if (imageData->tvgPicture) { delete imageData->tvgPicture; - imageData->tvgPicture = tvg::Picture::gen(); + // imageData->tvgPicture = tvg::Picture::gen(); } // if (imageData->loadBuffer) diff --git a/src/src/TpUtils/TpPainter.cpp b/src/src/TpUtils/TpPainter.cpp index 416f5b41394de973e38351363a79a3c9f753b895..0cdbb93fa669575ae2d0e6976715a3081300c44f 100644 --- a/src/src/TpUtils/TpPainter.cpp +++ b/src/src/TpUtils/TpPainter.cpp @@ -10,7 +10,7 @@ #include #include -TpPainter::TpPainter(tpShared surface, int32_t offsetX, int32_t offsetY, int32_t width, int32_t height) +TpPainter::TpPainter(tpShared surface, int32_t offsetX, int32_t offsetY, TpWidget* object) { // 根据CPU核心数;分配绘图引擎线程数 uint32_t cores = std::thread::hardware_concurrency(); @@ -27,18 +27,13 @@ TpPainter::TpPainter(tpShared surface, int32_t offsetX, int32_t offse painterData->offsetX = offsetX; painterData->offsetY = offsetY; - painterData->width = width; - painterData->height = height; - - // painterData->offsetX = 0; - // painterData->offsetY = 0; + painterData->paintWidget = object; painterData->TpSurfacePtr = surface; painterData->beUsed = (surface != nullptr); // TODO判断是GPU环境还是CPU环境 // painterData->swCanvas = tvg::SwCanvas::gen(); - // refreshCanvasTarget(painterData); this->data_ = painterData; @@ -58,9 +53,6 @@ TpPainter::~TpPainter() painterData->TpSurfacePtr = nullptr; painterData->beUsed = false; - // delete painterData->swCanvas; - // delete painterData->glCanvas; - delete painterData; painterData = nullptr; data_ = nullptr; @@ -76,28 +68,168 @@ void TpPainter::paintTest() return; refreshCanvasTarget(painterData); +#if 1 + auto fontScene = tvg::Scene::gen(); // 加载字体文件 // tvg::Text::load("/home/hawk/Public/TinyPiXOS/src/data/fonts/SourceHanSansCN/SourceHanSansCN-Normal.otf"); - tvg::Text::load("/home/hawk/Public/TinyPiXOS/src/data/fonts/Taipei Sans TC Beta.ttf"); - - // 创建文本对象 - auto text = tvg::Text::gen(); - - // text->font("Source Han Sans CN", 32); // 设置字体名称和大小 - text->font("Taipei Sans TC Beta"); // 设置字体名称和大小 - text->size(32); - text->text("Hello ThorVG 哈哈哈!"); // 设置文本内容 - text->fill(255, 0, 0); // 设置文本颜色 (红色) - text->translate(painterData->offsetX, painterData->offsetY); - - float textX, textY, textWidth, textHeight; - text->bounds(&textX, &textY, &textWidth, &textHeight); - - std::cout << "文本坐标信息: " << textX << " " << textY << " " << textWidth << " " << textHeight << std::endl; + tvg::Text::load("/root/examplesApp/data/SourceHanSerifCN-Regular.ttf"); + tvg::Text::load("/root/examplesApp/data/SourceHanSerifCN-Bold.ttf"); + + // ===== 普通文本 ===== + auto normalText = tvg::Text::gen(); + normalText->font("SourceHanSerifCN-Bold"); + normalText->size(12); + normalText->text("普通文本"); + normalText->fill(255, 200, 0); + normalText->translate(0, 0); + fontScene->push(normalText); + + // ===== 斜体文本 ===== + auto italicText = tvg::Text::gen(); + italicText->font("SourceHanSerifCN-Regular"); + italicText->size(12); + italicText->text("斜体文本"); + italicText->fill(255, 200, 0); + italicText->italic(0.18f); // 应用斜体效果 + italicText->translate(0, 30); + fontScene->push(italicText); + + // ===== 带轮廓的文本 ===== + auto outlineText = tvg::Text::gen(); + outlineText->font("SourceHanSerifCN-Regular"); + outlineText->size(18); + outlineText->text("轮廓文本"); + outlineText->fill(255, 255, 0); // 黄色填充 + outlineText->outline(2, 255, 100, 0); // 蓝色轮廓,宽度1 + outlineText->translate(0, 60); + fontScene->push(outlineText); + + // ===== 斜体 + 轮廓组合 ===== + auto combinedText = tvg::Text::gen(); + combinedText->font("SourceHanSerifCN-Regular"); + combinedText->size(12); + combinedText->text("斜体+轮廓"); + combinedText->fill(255, 100, 100); + combinedText->italic(0.2f); // 斜体 + combinedText->outline(2, 255, 255, 255); // 白色轮廓 + combinedText->translate(0, 90); + fontScene->push(combinedText); // 添加到 Canvas 并绘制 - painterData->tvgScene->push(std::move(text)); + // painterData->tvgScene->push(std::move(text)); + + // ===== 横向布局示例 ===== + auto horizontalText = tvg::Text::gen(); + horizontalText->font("SourceHanSerifCN-Regular"); + horizontalText->size(12); + horizontalText->text("这是一段横向排列的中文文本示例"); + horizontalText->fill(255, 255, 255); // 白色文字 + + // 设置横向布局约束和对齐方式 + horizontalText->layout(400, 0); // 宽度限制为400,高度不限制 + horizontalText->align(0.0f, 0.0f); // 左对齐,顶部对齐 + horizontalText->translate(0, 120); // 位置 + + fontScene->push(horizontalText); + + // ===== 横向居中布局示例 ===== + auto horizontalCenterText = tvg::Text::gen(); + horizontalCenterText->font("SourceHanSerifCN-Regular"); + horizontalCenterText->size(12); + horizontalCenterText->text("这是居中对齐的横向文本"); + horizontalCenterText->fill(255, 200, 0); // 橙色文字 + + horizontalCenterText->layout(400, 0); + horizontalCenterText->align(0.5f, 0.0f); // 水平居中,顶部对齐 + horizontalCenterText->translate(0, 150); + + fontScene->push(horizontalCenterText); + + // ===== 横向右对齐布局示例 ===== + auto horizontalRightText = tvg::Text::gen(); + horizontalRightText->font("SourceHanSerifCN-Regular"); + horizontalRightText->size(12); + horizontalRightText->text("这是右对齐的横向文本"); + horizontalRightText->fill(0, 255, 255); // 青色文字 + + horizontalRightText->layout(400, 0); + horizontalRightText->align(1.0f, 0.0f); // 右对齐,顶部对齐 + horizontalRightText->translate(0, 180); + + fontScene->push(horizontalRightText); + + // ===== 竖向布局示例(通过旋转实现) ===== + auto verticalText = tvg::Text::gen(); + verticalText->font("SourceHanSerifCN-Regular"); + verticalText->size(12); + verticalText->text("竖向文本"); + verticalText->fill(255, 100, 0); // 红色文字 + + // 竖向布局:先设置横向布局,然后旋转90度 + verticalText->layout(100, 0); // 高度限制为200 + verticalText->align(0.0f, 0.0f); + + verticalText->translate(20, 210); + // 旋转90度 (π/2 弧度) + + verticalText->rotate(90.0f); + + fontScene->push(verticalText); + + // ===== 带换行的横向布局示例 ===== + auto wrappedText = tvg::Text::gen(); + wrappedText->font("SourceHanSerifCN-Regular"); + wrappedText->size(12); + wrappedText->text("这是一段很长的文本,需要自动换行显示。ThorVG支持多种换行模式,包括字符换行和单词换行。"); + wrappedText->fill(150, 255, 150); // 绿色文字 + + wrappedText->layout(100, 0); // 宽度限制为100 + wrappedText->align(0.0f, 0.0f); + wrappedText->wrap(tvg::TextWrap::Smart); // 按单词换行 + wrappedText->translate(0, 300); + + fontScene->push(wrappedText); + + // 8. 获取文本边界框信息 + float x, y, w, h; + if (verticalText->bounds(&x, &y, &w, &h) == tvg::Result::Success) { + std::cout << "verticalText Text bounds:" << std::endl; + std::cout << " Position: (" << x << ", " << y << ")" << std::endl; + std::cout << " Size: " << w << " x " << h << std::endl; + } + + // painterData->tvgScene->push(fontScene); + +#endif + + // auto tmpScene = tvg::Scene::gen(); + + auto tmpScene = static_cast(fontScene->duplicate()); + + auto clipShape = tvg::Shape::gen(); + clipShape->appendRect(0, 300, 300, 300); // 玻璃面板位置 + clipShape->fill(255, 255, 255, 128); // 填充透明色 + fontScene->clip(clipShape); + // fontScene->push(tvg::SceneEffect::GaussianBlur, 30.0, 0, 0, 80); + + auto scene = tvg::Scene::gen(); + + // 创建背景矩形 + auto background = tvg::Shape::gen(); + background->appendRect(0, 300, 300, 300); + background->fill(255, 0, 0, 200); // 红色,半透明 (alpha=128) + + // 先添加背景,再添加其他内容 + scene->push(background); + scene->push(fontScene); + scene->push(tvg::SceneEffect::GaussianBlur, 30.0, 0, 0, 80); + + painterData->tvgScene->push(tmpScene); + + painterData->tvgScene->push(scene); + + // painterData->swCanvas->draw(); // painterData->swCanvas->sync(); } @@ -323,10 +455,6 @@ void TpPainter::drawImage(const TpPoint &point, const TpImage &image, int32_t ro float drawX = -(rotatedCenterX - originalCenterX); float drawY = -(rotatedCenterY - originalCenterY); - // std::cout << "原始中心点坐标: " << originalCenterX << " , " << originalCenterY << std::endl; - // std::cout << "旋转后中心点坐标: " << rotatedCenterX << " , " << rotatedCenterY << std::endl; - // std::cout << "新的绘制顶点坐标 " << drawX << " , " << drawY << std::endl; - // 调整绘制位置:减去偏移量,使中心点回到原位 pictureCopy->translate( painterData->offsetX + point.x() + drawX, @@ -598,7 +726,7 @@ void TpPainter::sync(void *object) TpWidget *paintWidget = static_cast(object); TpObjectData *paintWidgetData = static_cast(paintWidget->objectSets()); - paintWidgetData->grapImage.load(painterData->TpSurfacePtr->matrix(), TpRect(painterData->clipRect.x(), painterData->clipRect.y(), painterData->clipRect.width(), painterData->clipRect.height())); + paintWidgetData->grapImage.load(painterData->TpSurfacePtr->matrix(), TpSize(painterData->clipRect.width(), painterData->clipRect.height())); // static int32_t saveIndexS = 0; // TpString savePngPath = "/home/hawk/Public/TinyPiXOS/examples/TpGUI/test/grapWindow_" + std::to_string(saveIndexS++) + ".png"; diff --git a/src/src_p/TpGUI/Screen/TpFixScreen.cpp b/src/src_p/TpGUI/Screen/TpFixScreen.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ac5c25d3d477ef6c9725a35e1bec3970078a3757 --- /dev/null +++ b/src/src_p/TpGUI/Screen/TpFixScreen.cpp @@ -0,0 +1,121 @@ +#include "TpFixScreen.h" +#include "TpApp.h" +#include "TpDef.h" +#include "TpColors.h" +#include +#include +#include "TpCssParser.h" +#include "TpDefaultCss.h" +#include "TpString.h" +#include "TpVariant.h" +#include "TpDefaultCss.h" +#include "TpApp_p.h" +#include "TpApp.h" + +struct TpFixScreenData +{ + uint8_t alpha; + uint32_t color; + int32_t attr; + + TpFixScreenData() + : alpha(0), color(0), attr(0) + { + } +}; + +TpFixScreen::TpFixScreen(const char *type) + : TpScreen(type) +{ + TpFixScreenData *screenData = new TpFixScreenData(); + data_ = screenData; + + if (this->objectType() != Tp::TP_FIXSCREEN_OBJECT) + { + TpApp::Inst()->sendDelete(this); + } + + TpObjectData *set = static_cast(this->objectSets()); + if (!set) + return; + + setVisible(true); + + uint32_t rW = 0, rH = 0; + tinyPiX_wf_get_display_size(set->agent, &rW, &rH); + + set->absoluteRect.setRect(0, 0, rW, rH); + set->logicalRect.setRect(0, 0, rW, rH); + + screenData->alpha = 0xff; + screenData->color = TpColors::Black; + screenData->attr = TpFixScreen::ITP_POP_STYLE; + + this->setVScreenAttribute(screenData->alpha, screenData->color, screenData->attr); + + set->top = this->topObject(); +} + +TpFixScreen::~TpFixScreen() +{ + TpFixScreenData *screenData = static_cast(data_); + if (screenData) + { + delete screenData; + screenData = nullptr; + data_ = nullptr; + } +} + +Tp::TpObjectType TpFixScreen::objectType() +{ + return Tp::TP_FIXSCREEN_OBJECT; +} + +int32_t TpFixScreen::setVScreenAttribute(uint8_t alpha, uint32_t color, int32_t screenAttr) +{ + TpFixScreenData *screenData = static_cast(data_); + if (!screenData) + return false; + + switch (screenAttr) + { + case TpFixScreen::ITP_FULL_STYLE: + case TpFixScreen::ITP_POP_STYLE: + { + } + break; + default: + return false; + } + + TpObjectData *set = (TpObjectData *)this->objectSets(); + + if (set) + { + screenData->alpha = alpha; + screenData->color = color; + screenData->attr = screenAttr; + + return tinyPiX_wf_send_app_state(set->agent, TP_INVALIDATE_VALUE, this->visible(), this->objectActive(), color, alpha, screenAttr); + } + + return false; +} + +bool TpFixScreen::onActiveEvent(TpActiveEvent *event) +{ + TpFixScreenData *screenData = static_cast(data_); + if (!screenData) + return false; + + TpAppData *appData = (TpAppData *)TpApp::Inst()->appObjectSet(); + if (appData->mainWindow) + { + TpObjectData *mainWindowObjData = (TpObjectData *)appData->mainWindow->objectSets(); + tinyPiX_wf_set_visible(mainWindowObjData->agent, visible()); + mainWindowObjData->visible = visible(); + } + + return this->setVScreenAttribute(screenData->alpha, screenData->color, screenData->attr); +}