add GuiLite demo
This commit is contained in:
15
components/gui/GuiLite/UIcode/CMakeLists.txt
Normal file
15
components/gui/GuiLite/UIcode/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
PROJECT(UIcode)
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
|
||||
|
||||
FILE(GLOB SOURCE *.cpp)
|
||||
FILE(GLOB RESOURCE resource/*.cpp)
|
||||
|
||||
ADD_LIBRARY(UIcode ${SOURCE}
|
||||
${RESOURCE})
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/.sync_build.sh HelloStar
|
||||
)
|
4798
components/gui/GuiLite/UIcode/GuiLite.h
Normal file
4798
components/gui/GuiLite/UIcode/GuiLite.h
Normal file
File diff suppressed because it is too large
Load Diff
97
components/gui/GuiLite/UIcode/UIcode.cpp
Normal file
97
components/gui/GuiLite/UIcode/UIcode.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#define GUILITE_ON //Do not define this macro once more!!!
|
||||
#include "GuiLite.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define UI_WIDTH 240
|
||||
#define UI_HEIGHT 240
|
||||
|
||||
static c_surface* s_surface;
|
||||
static c_display* s_display;
|
||||
|
||||
class c_star {
|
||||
public:
|
||||
c_star(){
|
||||
initialize();
|
||||
}
|
||||
void initialize() {
|
||||
m_x = m_start_x = rand() % UI_WIDTH;
|
||||
m_y = m_start_y = rand() % UI_HEIGHT;
|
||||
m_size = 1;
|
||||
m_x_factor = UI_WIDTH;
|
||||
m_y_factor = UI_HEIGHT;
|
||||
m_size_factor = 1;
|
||||
}
|
||||
void move() {
|
||||
s_surface->fill_rect(m_x, m_y, m_x + m_size - 1, m_y + m_size - 1, 0, Z_ORDER_LEVEL_0);//clear star footprint
|
||||
|
||||
m_x_factor -= 6;
|
||||
m_y_factor -= 6;
|
||||
m_size += m_size / 20;
|
||||
if (m_x_factor < 1 || m_y_factor < 1)
|
||||
{
|
||||
return initialize();
|
||||
}
|
||||
if (m_start_x > (UI_WIDTH / 2) && m_start_y > (UI_HEIGHT / 2))
|
||||
{
|
||||
m_x = (UI_WIDTH / 2) + (UI_WIDTH * (m_start_x - (UI_WIDTH / 2)) / m_x_factor);
|
||||
m_y = (UI_HEIGHT / 2) + (UI_HEIGHT * (m_start_y - (UI_HEIGHT / 2)) / m_y_factor);
|
||||
}
|
||||
else if (m_start_x <= (UI_WIDTH / 2) && m_start_y > (UI_HEIGHT / 2))
|
||||
{
|
||||
m_x = (UI_WIDTH / 2) - (UI_WIDTH * ((UI_WIDTH / 2) - m_start_x) / m_x_factor);
|
||||
m_y = (UI_HEIGHT / 2) + (UI_HEIGHT * (m_start_y - (UI_HEIGHT / 2)) / m_y_factor);
|
||||
}
|
||||
else if (m_start_x > (UI_WIDTH / 2) && m_start_y <= (UI_HEIGHT / 2))
|
||||
{
|
||||
m_x = (UI_WIDTH / 2) + (UI_WIDTH * (m_start_x - (UI_WIDTH / 2)) / m_x_factor);
|
||||
m_y = (UI_HEIGHT / 2) - (UI_HEIGHT * ((UI_HEIGHT / 2) - m_start_y) / m_y_factor);
|
||||
}
|
||||
else if (m_start_x <= (UI_WIDTH / 2) && m_start_y <= (UI_HEIGHT / 2))
|
||||
{
|
||||
m_x = (UI_WIDTH / 2) - (UI_WIDTH * ((UI_WIDTH / 2) - m_start_x) / m_x_factor);
|
||||
m_y = (UI_HEIGHT / 2) - (UI_HEIGHT * ((UI_HEIGHT / 2) - m_start_y) / m_y_factor);
|
||||
}
|
||||
|
||||
if (m_x < 0 || (m_x + m_size - 1) >= UI_WIDTH ||
|
||||
m_y < 0 || (m_y + m_size - 1) >= UI_HEIGHT)
|
||||
{
|
||||
return initialize();
|
||||
}
|
||||
s_surface->fill_rect(m_x, m_y, m_x + m_size - 1, m_y + m_size - 1, GL_RGB(255, 255, 255), Z_ORDER_LEVEL_0);//draw star
|
||||
}
|
||||
int m_start_x, m_start_y;
|
||||
float m_x, m_y, m_x_factor, m_y_factor, m_size_factor, m_size;
|
||||
};
|
||||
|
||||
//////////////////////// start UI ////////////////////////
|
||||
|
||||
c_star stars[100];
|
||||
void create_ui(void* phy_fb, int screen_width, int screen_height, int color_bytes, struct EXTERNAL_GFX_OP* gfx_op) {
|
||||
c_display display = c_display(phy_fb, screen_width, screen_height, UI_WIDTH, UI_HEIGHT, color_bytes, 1, gfx_op);
|
||||
s_display = &display;
|
||||
s_surface = display.alloc_surface(Z_ORDER_LEVEL_0);
|
||||
s_surface->set_active(true);
|
||||
|
||||
s_surface->fill_rect(0, 0, UI_WIDTH - 1, UI_HEIGHT - 1, 0, Z_ORDER_LEVEL_0);
|
||||
|
||||
while(1) {
|
||||
for (int i = 0; i < sizeof(stars)/sizeof(c_star); i++) {
|
||||
stars[i].move();
|
||||
}
|
||||
thread_sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////// interface for all platform ////////////////////////
|
||||
extern "C" void startHelloStar(void* phy_fb, int width, int height, int color_bytes, struct EXTERNAL_GFX_OP* gfx_op) {
|
||||
create_ui(phy_fb, width, height, color_bytes, gfx_op);
|
||||
}
|
||||
|
||||
void* getUiOfHelloStar(int* width, int* height, bool force_update)
|
||||
{
|
||||
if (s_display)
|
||||
{
|
||||
return s_display->get_updated_fb(width, height, force_update);
|
||||
}
|
||||
return NULL;
|
||||
}
|
22
components/gui/GuiLite/UIcode/UIcode.sln
Normal file
22
components/gui/GuiLite/UIcode/UIcode.sln
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28010.2050
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UIcode", "UIcode.vcxproj", "{8BE32B2A-F5E4-49E7-A2C9-0FAEA62B7FED}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8BE32B2A-F5E4-49E7-A2C9-0FAEA62B7FED}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{8BE32B2A-F5E4-49E7-A2C9-0FAEA62B7FED}.Debug|x86.Build.0 = Debug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {30A9AE4B-6122-4B94-AF72-DAB8B75463BF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
158
components/gui/GuiLite/UIcode/UIcode.vcxproj
Normal file
158
components/gui/GuiLite/UIcode/UIcode.vcxproj
Normal file
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="UIcode.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{8BE32B2A-F5E4-49E7-A2C9-0FAEA62B7FED}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>UIcode</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>call "$(MSBuildProjectDirectory)\sync_build.bat" "HelloStar"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
6
components/gui/GuiLite/UIcode/UIcode.vcxproj.filters
Normal file
6
components/gui/GuiLite/UIcode/UIcode.vcxproj.filters
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="UIcode.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
BIN
components/gui/GuiLite/UIcode/curl.exe
Normal file
BIN
components/gui/GuiLite/UIcode/curl.exe
Normal file
Binary file not shown.
28
components/gui/GuiLite/UIcode/sync_build.bat
Normal file
28
components/gui/GuiLite/UIcode/sync_build.bat
Normal file
@@ -0,0 +1,28 @@
|
||||
echo off
|
||||
set argC=0
|
||||
for %%x in (%*) do Set /A argC+=1
|
||||
if NOT "1" == "%argC%" (
|
||||
echo "Invalidate arguments"
|
||||
goto :eof
|
||||
)
|
||||
|
||||
set url="https://api.powerbi.com/beta/72f988bf-86f1-41af-91ab-2d7cd011db47/datasets/2ff1e8a8-2f6f-4d73-a75d-86829e3f4574/rows?key=8f5xLp1gP8%%2FzSee4vCUBcyjR65I9zZ6nb%%2B%%2F7bbzex%%2FSctLX3ntIlAR0sxWpDdguuYyDtLdHK%%2Fxbxj%%2FrSBkX7eQ%%3D%%3D"
|
||||
|
||||
for /f "tokens=2-4 delims=/ " %%a in ("%date%") do (set MM=%%a& set DD=%%b& set YYYY=%%c)
|
||||
set YY=%YYYY:~0,2%
|
||||
if not "%YY%" == "20" (rem For Chinese date format
|
||||
for /f "tokens=1-3 delims=/ " %%a in ("%date%") do (set YYYY=%%a& set MM=%%b& set DD=%%c))
|
||||
|
||||
set datetime=%YYYY%-%MM%-%DD%T%time: =0%0+0800
|
||||
set devie_info=Win-%USERNAME%
|
||||
set raw_data=[{^
|
||||
\"device_info\" :\"%devie_info%\",^
|
||||
\"project_info\" :\"%1\",^
|
||||
\"time\" :\"%datetime%\",^
|
||||
\"weight\" : 1^
|
||||
}]
|
||||
|
||||
curl.exe --include --request POST --header "Content-Type: application/json" --data-binary^
|
||||
"%raw_data%" "%url%"
|
||||
|
||||
exit /B 0
|
Reference in New Issue
Block a user