mirror of
https://gitee.com/idea4good/GuiLite.git
synced 2025-01-15 17:02:52 +08:00
fix conflict
This commit is contained in:
commit
1e208399f3
@ -11,7 +11,7 @@ read -p "Please input:[1-3]:" input
|
|||||||
|
|
||||||
# build GuiLite.h
|
# build GuiLite.h
|
||||||
cd core_include
|
cd core_include
|
||||||
cat api.h cmd_target.h rect.h msg.h resource.h theme.h surface.h display.h word.h bitmap.h wnd.h audio.h > core.h
|
cat api.h cmd_target.h rect.h resource.h theme.h surface.h display.h word.h bitmap.h wnd.h audio.h > core.h
|
||||||
mv core.h ../
|
mv core.h ../
|
||||||
|
|
||||||
cd ../widgets_include
|
cd ../widgets_include
|
||||||
|
@ -9,8 +9,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
|||||||
# core
|
# core
|
||||||
FILE(GLOB CORE_SRC core/*.cpp)
|
FILE(GLOB CORE_SRC core/*.cpp)
|
||||||
FILE(GLOB CORE_ADAPTER core/adapter/api_linux.cpp
|
FILE(GLOB CORE_ADAPTER core/adapter/api_linux.cpp
|
||||||
core/adapter/audio_linux.cpp
|
core/adapter/audio_linux.cpp)
|
||||||
core/adapter/msg_linux.cpp)
|
|
||||||
# gui
|
# gui
|
||||||
FILE(GLOB WIDGETS_SRC widgets/*.cpp)
|
FILE(GLOB WIDGETS_SRC widgets/*.cpp)
|
||||||
|
|
||||||
|
@ -427,11 +427,6 @@
|
|||||||
<FileType>8</FileType>
|
<FileType>8</FileType>
|
||||||
<FilePath>.\core\adapter\api_unknow.cpp</FilePath>
|
<FilePath>.\core\adapter\api_unknow.cpp</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
|
||||||
<FileName>msg_unknow.cpp</FileName>
|
|
||||||
<FileType>8</FileType>
|
|
||||||
<FilePath>.\core\adapter\msg_unknow.cpp</FilePath>
|
|
||||||
</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{DF7A4FAD-A68D-3E43-9C4B-7DE4EE77F732}</ProjectGuid>
|
<ProjectGuid>{DF7A4FAD-A68D-3E43-9C4B-7DE4EE77F732}</ProjectGuid>
|
||||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
<ProjectName>GuiLite</ProjectName>
|
<ProjectName>GuiLite</ProjectName>
|
||||||
@ -46,12 +46,12 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
@ -390,7 +390,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="core\adapter\api_win.cpp" />
|
<ClCompile Include="core\adapter\api_win.cpp" />
|
||||||
<ClCompile Include="core\adapter\audio_win.cpp" />
|
<ClCompile Include="core\adapter\audio_win.cpp" />
|
||||||
<ClCompile Include="core\adapter\msg_win.cpp" />
|
|
||||||
<ClCompile Include="core\bitmap.cpp" />
|
<ClCompile Include="core\bitmap.cpp" />
|
||||||
<ClCompile Include="core\cmd_target.cpp" />
|
<ClCompile Include="core\cmd_target.cpp" />
|
||||||
<ClCompile Include="core\display.cpp" />
|
<ClCompile Include="core\display.cpp" />
|
||||||
|
@ -67,9 +67,6 @@
|
|||||||
<ClCompile Include="core\adapter\audio_win.cpp">
|
<ClCompile Include="core\adapter\audio_win.cpp">
|
||||||
<Filter>core\adapter</Filter>
|
<Filter>core\adapter</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="core\adapter\msg_win.cpp">
|
|
||||||
<Filter>core\adapter</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="core">
|
<Filter Include="core">
|
||||||
|
@ -57,6 +57,7 @@ GuiLite is the smallest GUI library with 5000 lines of code, could run on **all
|
|||||||
### IoT Solution & Code Telemetry
|
### IoT Solution & Code Telemetry
|
||||||
- Report build activities to cloud:<br>![BuildInfo](doc/BuildInfo.png)
|
- Report build activities to cloud:<br>![BuildInfo](doc/BuildInfo.png)
|
||||||
- Sync running data to cloud:<br>![DataOnCloud](doc/data_on_cloud.png)
|
- Sync running data to cloud:<br>![DataOnCloud](doc/data_on_cloud.png)
|
||||||
|
- ⚠️To stop telemetry, remove script files(e,g: sync_build.bat .sync.sh .sync_build.sh)
|
||||||
***
|
***
|
||||||
### Support Docker
|
### Support Docker
|
||||||
We build GuiLite demo as docker image, you can update/deploy/run the latest GuiLite demo on your device with single command below:
|
We build GuiLite demo as docker image, you can update/deploy/run the latest GuiLite demo on your device with single command below:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "../../core_include/api.h"
|
#include "../../core_include/api.h"
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -14,6 +13,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define MAX_TIMER_CNT 10
|
#define MAX_TIMER_CNT 10
|
||||||
#define TIMER_UNIT 50//ms
|
#define TIMER_UNIT 50//ms
|
||||||
@ -318,3 +318,68 @@ int build_bmp(const char *filename, unsigned int width, unsigned int height, uns
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c_fifo::c_fifo()
|
||||||
|
{
|
||||||
|
m_head = m_tail = 0;
|
||||||
|
m_read_sem = malloc(sizeof(sem_t));
|
||||||
|
m_write_mutex = malloc(sizeof(pthread_mutex_t));
|
||||||
|
|
||||||
|
sem_init((sem_t*)m_read_sem, 0, 0);
|
||||||
|
pthread_mutex_init((pthread_mutex_t*)m_write_mutex, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int c_fifo::read(void* buf, int len)
|
||||||
|
{
|
||||||
|
unsigned char* pbuf = (unsigned char*)buf;
|
||||||
|
int i = 0;
|
||||||
|
while(i < len)
|
||||||
|
{
|
||||||
|
if (m_tail == m_head)
|
||||||
|
{//empty
|
||||||
|
sem_wait((sem_t*)m_read_sem);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*pbuf++ = m_buf[m_head];
|
||||||
|
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if(i != len)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c_fifo::write(void* buf, int len)
|
||||||
|
{
|
||||||
|
unsigned char* pbuf = (unsigned char*)buf;
|
||||||
|
int i = 0;
|
||||||
|
int tail = m_tail;
|
||||||
|
|
||||||
|
pthread_mutex_lock((pthread_mutex_t*)m_write_mutex);
|
||||||
|
while(i < len)
|
||||||
|
{
|
||||||
|
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
||||||
|
{//full, clear data has been written;
|
||||||
|
m_tail = tail;
|
||||||
|
log_out("Warning: fifo full\n");
|
||||||
|
pthread_mutex_unlock((pthread_mutex_t*)m_write_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
m_buf[m_tail] = *pbuf++;
|
||||||
|
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock((pthread_mutex_t*)m_write_mutex);
|
||||||
|
|
||||||
|
if(i != len)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sem_post((sem_t*)m_read_sem);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
@ -75,3 +75,56 @@ int build_bmp(const char *filename, unsigned int width, unsigned int height, uns
|
|||||||
log_out("Not support now");
|
log_out("Not support now");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c_fifo::c_fifo()
|
||||||
|
{
|
||||||
|
m_head = m_tail = 0;
|
||||||
|
m_read_sem = m_write_mutex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c_fifo::read(void* buf, int len)
|
||||||
|
{
|
||||||
|
unsigned char* pbuf = (unsigned char*)buf;
|
||||||
|
int i = 0;
|
||||||
|
while(i < len)
|
||||||
|
{
|
||||||
|
if (m_tail == m_head)
|
||||||
|
{//empty
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*pbuf++ = m_buf[m_head];
|
||||||
|
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if(i != len)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c_fifo::write(void* buf, int len)
|
||||||
|
{
|
||||||
|
unsigned char* pbuf = (unsigned char*)buf;
|
||||||
|
int i = 0;
|
||||||
|
int tail = m_tail;
|
||||||
|
|
||||||
|
while(i < len)
|
||||||
|
{
|
||||||
|
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
||||||
|
{//full, clear data has been written;
|
||||||
|
m_tail = tail;
|
||||||
|
log_out("Warning: fifo full\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
m_buf[m_tail] = *pbuf++;
|
||||||
|
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i != len)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "../../core_include/api.h"
|
#include "../../core_include/api.h"
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -325,3 +324,68 @@ int build_bmp(const char *filename, unsigned int width, unsigned int height, uns
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c_fifo::c_fifo()
|
||||||
|
{
|
||||||
|
m_head = m_tail = 0;
|
||||||
|
m_read_sem = CreateSemaphore(0, // default security attributes
|
||||||
|
0, // initial count
|
||||||
|
1, // maximum count
|
||||||
|
0); // unnamed semaphore
|
||||||
|
m_write_mutex = CreateMutex(0, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int c_fifo::read(void* buf, int len)
|
||||||
|
{
|
||||||
|
unsigned char* pbuf = (unsigned char*)buf;
|
||||||
|
int i = 0;
|
||||||
|
while (i < len)
|
||||||
|
{
|
||||||
|
if (m_tail == m_head)
|
||||||
|
{//empty
|
||||||
|
WaitForSingleObject(m_read_sem, INFINITE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*pbuf++ = m_buf[m_head];
|
||||||
|
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (i != len)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int c_fifo::write(void* buf, int len)
|
||||||
|
{
|
||||||
|
unsigned char* pbuf = (unsigned char*)buf;
|
||||||
|
int i = 0;
|
||||||
|
int tail = m_tail;
|
||||||
|
|
||||||
|
WaitForSingleObject(m_write_mutex, INFINITE);
|
||||||
|
while (i < len)
|
||||||
|
{
|
||||||
|
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
||||||
|
{//full, clear data has been written;
|
||||||
|
m_tail = tail;
|
||||||
|
log_out("Warning: fifo full\n");
|
||||||
|
ReleaseMutex(m_write_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
m_buf[m_tail] = *pbuf++;
|
||||||
|
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ReleaseMutex(m_write_mutex);
|
||||||
|
|
||||||
|
if (i != len)
|
||||||
|
{
|
||||||
|
ASSERT(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReleaseSemaphore(m_read_sem, 1, 0);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "../../core_include/api.h"
|
#include "../../core_include/api.h"
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
#include "../../core_include/audio.h"
|
#include "../../core_include/audio.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <mmdeviceapi.h>
|
#include <mmdeviceapi.h>
|
||||||
|
|
||||||
#include "../../core_include/api.h"
|
#include "../../core_include/api.h"
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
#include "../../core_include/audio.h"
|
#include "../../core_include/audio.h"
|
||||||
|
|
||||||
#ifndef AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM
|
#ifndef AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
#include "../../core_include/api.h"
|
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
c_fifo::c_fifo()
|
|
||||||
{
|
|
||||||
m_head = m_tail = 0;
|
|
||||||
m_read_sem = malloc(sizeof(sem_t));
|
|
||||||
m_write_mutex = malloc(sizeof(pthread_mutex_t));
|
|
||||||
|
|
||||||
sem_init((sem_t*)m_read_sem, 0, 0);
|
|
||||||
pthread_mutex_init((pthread_mutex_t*)m_write_mutex, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int c_fifo::read(void* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned char* pbuf = (unsigned char*)buf;
|
|
||||||
int i = 0;
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
if (m_tail == m_head)
|
|
||||||
{//empty
|
|
||||||
sem_wait((sem_t*)m_read_sem);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*pbuf++ = m_buf[m_head];
|
|
||||||
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if(i != len)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int c_fifo::write(void* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned char* pbuf = (unsigned char*)buf;
|
|
||||||
int i = 0;
|
|
||||||
int tail = m_tail;
|
|
||||||
|
|
||||||
pthread_mutex_lock((pthread_mutex_t*)m_write_mutex);
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
|
||||||
{//full, clear data has been written;
|
|
||||||
m_tail = tail;
|
|
||||||
log_out("Warning: fifo full\n");
|
|
||||||
pthread_mutex_unlock((pthread_mutex_t*)m_write_mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
m_buf[m_tail] = *pbuf++;
|
|
||||||
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock((pthread_mutex_t*)m_write_mutex);
|
|
||||||
|
|
||||||
if(i != len)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sem_post((sem_t*)m_read_sem);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
#include "../../core_include/api.h"
|
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
|
|
||||||
c_fifo::c_fifo()
|
|
||||||
{
|
|
||||||
m_head = m_tail = 0;
|
|
||||||
m_read_sem = m_write_mutex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int c_fifo::read(void* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned char* pbuf = (unsigned char*)buf;
|
|
||||||
int i = 0;
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
if (m_tail == m_head)
|
|
||||||
{//empty
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*pbuf++ = m_buf[m_head];
|
|
||||||
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if(i != len)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int c_fifo::write(void* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned char* pbuf = (unsigned char*)buf;
|
|
||||||
int i = 0;
|
|
||||||
int tail = m_tail;
|
|
||||||
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
|
||||||
{//full, clear data has been written;
|
|
||||||
m_tail = tail;
|
|
||||||
log_out("Warning: fifo full\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
m_buf[m_tail] = *pbuf++;
|
|
||||||
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i != len)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
#include "../../core_include/api.h"
|
|
||||||
#include "../../core_include/msg.h"
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
c_fifo::c_fifo()
|
|
||||||
{
|
|
||||||
m_head = m_tail = 0;
|
|
||||||
m_read_sem = CreateSemaphore(0, // default security attributes
|
|
||||||
0, // initial count
|
|
||||||
1, // maximum count
|
|
||||||
0); // unnamed semaphore
|
|
||||||
m_write_mutex = CreateMutex(0, false, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int c_fifo::read(void* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned char* pbuf = (unsigned char*)buf;
|
|
||||||
int i = 0;
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
if (m_tail == m_head)
|
|
||||||
{//empty
|
|
||||||
WaitForSingleObject(m_read_sem, INFINITE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*pbuf++ = m_buf[m_head];
|
|
||||||
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if(i != len)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int c_fifo::write(void* buf, int len)
|
|
||||||
{
|
|
||||||
unsigned char* pbuf = (unsigned char*)buf;
|
|
||||||
int i = 0;
|
|
||||||
int tail = m_tail;
|
|
||||||
|
|
||||||
WaitForSingleObject(m_write_mutex, INFINITE);
|
|
||||||
while(i < len)
|
|
||||||
{
|
|
||||||
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
|
|
||||||
{//full, clear data has been written;
|
|
||||||
m_tail = tail;
|
|
||||||
log_out("Warning: fifo full\n");
|
|
||||||
ReleaseMutex(m_write_mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
m_buf[m_tail] = *pbuf++;
|
|
||||||
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ReleaseMutex(m_write_mutex);
|
|
||||||
|
|
||||||
if(i != len)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReleaseSemaphore(m_read_sem, 1, 0);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
#include "../core_include/api.h"
|
#include "../core_include/api.h"
|
||||||
#include "../core_include/rect.h"
|
#include "../core_include/rect.h"
|
||||||
#include "../core_include/cmd_target.h"
|
#include "../core_include/cmd_target.h"
|
||||||
#include "../core_include/msg.h"
|
|
||||||
#include "../core_include/surface.h"
|
#include "../core_include/surface.h"
|
||||||
#include "../core_include/display.h"
|
#include "../core_include/display.h"
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ c_surface* c_display::alloc_surface(Z_ORDER_LEVEL max_zorder)
|
|||||||
return m_surface_group[i];
|
return m_surface_group[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int c_display::merge_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
|
int c_display::swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y1, int offset)
|
||||||
{
|
{
|
||||||
int surface_width = s0->get_width();
|
int surface_width = s0->get_width();
|
||||||
int surface_height = s0->get_height();
|
int surface_height = s0->get_height();
|
||||||
|
@ -53,4 +53,19 @@ unsigned int get_cur_thread_id();
|
|||||||
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg);
|
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg);
|
||||||
void thread_sleep(unsigned int milli_seconds);
|
void thread_sleep(unsigned int milli_seconds);
|
||||||
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data);
|
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data);
|
||||||
|
|
||||||
|
#define FIFO_BUFFER_LEN 1024
|
||||||
|
class c_fifo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
c_fifo();
|
||||||
|
int read(void* buf, int len);
|
||||||
|
int write(void* buf, int len);
|
||||||
|
private:
|
||||||
|
unsigned char m_buf[FIFO_BUFFER_LEN];
|
||||||
|
int m_head;
|
||||||
|
int m_tail;
|
||||||
|
void* m_read_sem;
|
||||||
|
void* m_write_mutex;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
unsigned int surface_width, unsigned int surface_height,
|
unsigned int surface_width, unsigned int surface_height,
|
||||||
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
|
unsigned int color_bytes, unsigned int surface_cnt, EXTERNAL_GFX_OP* gfx_op = 0);
|
||||||
c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder);
|
c_surface* alloc_surface(Z_ORDER_LEVEL max_zorder);
|
||||||
int merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y2, int offset);
|
int swipe_surface(c_surface* s0, c_surface* s1, int x0, int x1, int y0, int y2, int offset);
|
||||||
unsigned int get_width() { return m_width; }
|
unsigned int get_width() { return m_width; }
|
||||||
unsigned int get_height() { return m_height; }
|
unsigned int get_height() { return m_height; }
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
#ifndef GUILITE_CORE_INCLUDE_MSG_H
|
|
||||||
#define GUILITE_CORE_INCLUDE_MSG_H
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned int dwMsgId;
|
|
||||||
unsigned int dwParam1;
|
|
||||||
unsigned int dwParam2;
|
|
||||||
}MSG_INFO;
|
|
||||||
|
|
||||||
#define FIFO_BUFFER_LEN 1024
|
|
||||||
class c_fifo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
c_fifo();
|
|
||||||
int read(void* buf, int len);
|
|
||||||
int write(void* buf, int len);
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned char m_buf[FIFO_BUFFER_LEN];
|
|
||||||
int m_head;
|
|
||||||
int m_tail;
|
|
||||||
void* m_read_sem;
|
|
||||||
void* m_write_mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,5 +1,4 @@
|
|||||||
#include "../core_include/api.h"
|
#include "../core_include/api.h"
|
||||||
#include "../core_include/msg.h"
|
|
||||||
#include "../core_include/rect.h"
|
#include "../core_include/rect.h"
|
||||||
#include "../core_include/surface.h"
|
#include "../core_include/surface.h"
|
||||||
#include "../core_include/display.h"
|
#include "../core_include/display.h"
|
||||||
@ -9,46 +8,24 @@
|
|||||||
#include "../widgets_include/slide_group.h"
|
#include "../widgets_include/slide_group.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
//#define FLIP_STEP 300//for arm
|
//#define SWIPE_STEP 300//for arm
|
||||||
#define FLIP_STEP 10//for PC & ANDROID
|
#define SWIPE_STEP 10//for PC & ANDROID
|
||||||
#define MOVE_THRESHOLD 10
|
#define MOVE_THRESHOLD 10
|
||||||
|
|
||||||
void* c_gesture::task_handle_msg(void* param)
|
c_gesture::c_gesture(c_slide_group* group)
|
||||||
{
|
{
|
||||||
c_gesture* This = (c_gesture*)param;
|
|
||||||
MSG_INFO msg;
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
This->m_hid_fifo->read(&msg, sizeof(msg));
|
|
||||||
if(This->handle_flip(msg))
|
|
||||||
{
|
|
||||||
This->handle_hid_msg(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
c_gesture::c_gesture(c_wnd* root, c_slide_group* group, c_fifo* hid_fifo)
|
|
||||||
{
|
|
||||||
m_root = root;
|
|
||||||
m_slide_group = group;
|
m_slide_group = group;
|
||||||
m_hid_fifo = hid_fifo;
|
m_state = TOUCH_IDLE;
|
||||||
m_action = TOUCH_IDLE;
|
|
||||||
m_down_x = m_down_y = m_move_x = m_move_y = 0;
|
m_down_x = m_down_y = m_move_x = m_move_y = 0;
|
||||||
|
|
||||||
unsigned long pid;
|
|
||||||
create_thread(&pid, 0, task_handle_msg, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool c_gesture::handle_flip(MSG_INFO &msg)
|
bool c_gesture::handle_swipe(int x, int y, TOUCH_ACTION action)
|
||||||
{
|
{
|
||||||
int x = msg.dwParam1;
|
if(action == TOUCH_DOWN)//MOUSE_LBUTTONDOWN
|
||||||
|
|
||||||
if(msg.dwMsgId == 0x4700)//MOUSE_LBUTTONDOWN
|
|
||||||
{
|
{
|
||||||
if(m_action == TOUCH_IDLE)
|
if(m_state == TOUCH_IDLE)
|
||||||
{
|
{
|
||||||
m_action = TOUCH_MOVE;
|
m_state = TOUCH_MOVE;
|
||||||
m_move_x = m_down_x = x;
|
m_move_x = m_down_x = x;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -57,12 +34,12 @@ bool c_gesture::handle_flip(MSG_INFO &msg)
|
|||||||
return on_move(x);
|
return on_move(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(msg.dwMsgId == 0x4600)//MOUSE_LBUTTONUP
|
else if(action == TOUCH_UP)//MOUSE_LBUTTONUP
|
||||||
{
|
{
|
||||||
if(m_action == TOUCH_MOVE)
|
if(m_state == TOUCH_MOVE)
|
||||||
{
|
{
|
||||||
m_action = TOUCH_IDLE;
|
m_state = TOUCH_IDLE;
|
||||||
return on_flip(x);
|
return on_swipe(x);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -97,7 +74,7 @@ bool c_gesture::on_move(int x)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool c_gesture::on_flip(int x)
|
bool c_gesture::on_swipe(int x)
|
||||||
{
|
{
|
||||||
if (m_slide_group == 0)
|
if (m_slide_group == 0)
|
||||||
{
|
{
|
||||||
@ -113,11 +90,11 @@ bool c_gesture::on_flip(int x)
|
|||||||
m_move_x = x;
|
m_move_x = x;
|
||||||
if ((m_move_x - m_down_x) > 0)
|
if ((m_move_x - m_down_x) > 0)
|
||||||
{
|
{
|
||||||
page = flip_right();
|
page = swipe_right();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
page = flip_left();
|
page = swipe_left();
|
||||||
}
|
}
|
||||||
if (page >= 0)
|
if (page >= 0)
|
||||||
{
|
{
|
||||||
@ -130,7 +107,7 @@ bool c_gesture::on_flip(int x)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int c_gesture::flip_left()
|
int c_gesture::swipe_left()
|
||||||
{
|
{
|
||||||
if (m_slide_group == 0)
|
if (m_slide_group == 0)
|
||||||
{
|
{
|
||||||
@ -155,17 +132,17 @@ int c_gesture::flip_left()
|
|||||||
m_slide_group->get_screen_rect(rc);
|
m_slide_group->get_screen_rect(rc);
|
||||||
while(step < rc.Width())
|
while(step < rc.Width())
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
s1->get_display()->swipe_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
||||||
step += FLIP_STEP;
|
step += SWIPE_STEP;
|
||||||
}
|
}
|
||||||
if (step != rc.Width())
|
if (step != rc.Width())
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, rc.Width());
|
s1->get_display()->swipe_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, rc.Width());
|
||||||
}
|
}
|
||||||
return (index + 1);
|
return (index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int c_gesture::flip_right()
|
int c_gesture::swipe_right()
|
||||||
{
|
{
|
||||||
if (m_slide_group == 0)
|
if (m_slide_group == 0)
|
||||||
{
|
{
|
||||||
@ -190,12 +167,12 @@ int c_gesture::flip_right()
|
|||||||
int step = rc.Width() - (m_move_x - m_down_x);
|
int step = rc.Width() - (m_move_x - m_down_x);
|
||||||
while(step > 0)
|
while(step > 0)
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
s1->get_display()->swipe_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, step);
|
||||||
step -= FLIP_STEP;
|
step -= SWIPE_STEP;
|
||||||
}
|
}
|
||||||
if (step != 0)
|
if (step != 0)
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, 0);
|
s1->get_display()->swipe_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, 0);
|
||||||
}
|
}
|
||||||
return (index - 1);
|
return (index - 1);
|
||||||
}
|
}
|
||||||
@ -215,7 +192,7 @@ void c_gesture::move_left()
|
|||||||
m_slide_group->get_screen_rect(rc);
|
m_slide_group->get_screen_rect(rc);
|
||||||
if(s1->get_display() == s2->get_display())
|
if(s1->get_display() == s2->get_display())
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, (m_down_x - m_move_x));
|
s1->get_display()->swipe_surface(s2, s1, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, (m_down_x - m_move_x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,19 +211,6 @@ void c_gesture::move_right()
|
|||||||
m_slide_group->get_screen_rect(rc);
|
m_slide_group->get_screen_rect(rc);
|
||||||
if(s1->get_display() == s2->get_display())
|
if(s1->get_display() == s2->get_display())
|
||||||
{
|
{
|
||||||
s1->get_display()->merge_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, (rc.Width() - (m_move_x - m_down_x)));
|
s1->get_display()->swipe_surface(s1, s2, rc.m_left, rc.m_right, rc.m_top, rc.m_bottom, (rc.Width() - (m_move_x - m_down_x)));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void c_gesture::handle_hid_msg(MSG_INFO &msg)
|
|
||||||
{
|
|
||||||
switch(msg.dwMsgId)
|
|
||||||
{
|
|
||||||
case 0x4700://MOUSE_LBUTTONDOWN
|
|
||||||
m_root->on_touch(msg.dwParam1, msg.dwParam2, TOUCH_DOWN);
|
|
||||||
break;
|
|
||||||
case 0x4600://MOUSE_LBUTTONUP
|
|
||||||
m_root->on_touch(msg.dwParam1, msg.dwParam2, TOUCH_UP);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
#include "../core_include/wnd.h"
|
#include "../core_include/wnd.h"
|
||||||
#include "../core_include/surface.h"
|
#include "../core_include/surface.h"
|
||||||
#include "../widgets_include/dialog.h"
|
#include "../widgets_include/dialog.h"
|
||||||
|
#include "../widgets_include/gesture.h"
|
||||||
#include "../widgets_include/slide_group.h"
|
#include "../widgets_include/slide_group.h"
|
||||||
|
|
||||||
c_slide_group::c_slide_group()
|
c_slide_group::c_slide_group()
|
||||||
{
|
{
|
||||||
|
m_gesture = new c_gesture(this);
|
||||||
for(int i = 0; i < MAX_PAGES; i++)
|
for(int i = 0; i < MAX_PAGES; i++)
|
||||||
{
|
{
|
||||||
m_slides[i] = 0;
|
m_slides[i] = 0;
|
||||||
@ -157,9 +159,13 @@ bool c_slide_group::on_touch(int x, int y, TOUCH_ACTION action)
|
|||||||
{
|
{
|
||||||
x -= m_wnd_rect.m_left;
|
x -= m_wnd_rect.m_left;
|
||||||
y -= m_wnd_rect.m_top;
|
y -= m_wnd_rect.m_top;
|
||||||
if (m_slides[m_active_slide_index])
|
|
||||||
|
if (m_gesture->handle_swipe(x, y, action))
|
||||||
{
|
{
|
||||||
m_slides[m_active_slide_index]->on_touch(x, y, action);
|
if (m_slides[m_active_slide_index])
|
||||||
|
{
|
||||||
|
m_slides[m_active_slide_index]->on_touch(x, y, action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4,35 +4,27 @@
|
|||||||
typedef enum{
|
typedef enum{
|
||||||
TOUCH_MOVE,
|
TOUCH_MOVE,
|
||||||
TOUCH_IDLE
|
TOUCH_IDLE
|
||||||
}ACTION;
|
}TOUCH_STATE;
|
||||||
|
|
||||||
class c_slide_group;
|
class c_slide_group;
|
||||||
class c_gesture{
|
class c_gesture{
|
||||||
public:
|
public:
|
||||||
c_gesture(c_wnd* root, c_slide_group* group, c_fifo* hid_fifo);
|
c_gesture(c_slide_group* group);
|
||||||
void set_page_group(c_slide_group* group){m_slide_group = group;}
|
bool handle_swipe(int x, int y, TOUCH_ACTION action);
|
||||||
protected:
|
|
||||||
bool handle_flip(MSG_INFO &msg);
|
|
||||||
bool on_move(int x);
|
|
||||||
bool on_flip(int x);
|
|
||||||
private:
|
private:
|
||||||
int flip_left();
|
bool on_move(int x);
|
||||||
int flip_right();
|
bool on_swipe(int x);
|
||||||
|
int swipe_left();
|
||||||
|
int swipe_right();
|
||||||
void move_left();
|
void move_left();
|
||||||
void move_right();
|
void move_right();
|
||||||
void handle_hid_msg(MSG_INFO &msg);
|
|
||||||
|
|
||||||
int m_down_x;
|
int m_down_x;
|
||||||
int m_down_y;
|
int m_down_y;
|
||||||
int m_move_x;
|
int m_move_x;
|
||||||
int m_move_y;
|
int m_move_y;
|
||||||
ACTION m_action;
|
TOUCH_STATE m_state;
|
||||||
|
|
||||||
c_slide_group* m_slide_group;
|
c_slide_group* m_slide_group;
|
||||||
c_wnd* m_root;
|
|
||||||
c_fifo* m_hid_fifo;
|
|
||||||
|
|
||||||
static void* task_handle_msg(void* param);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define GUILITE_WIDGETS_INCLUDE_SLIDE_GROUP_H
|
#define GUILITE_WIDGETS_INCLUDE_SLIDE_GROUP_H
|
||||||
|
|
||||||
#define MAX_PAGES 5
|
#define MAX_PAGES 5
|
||||||
|
class c_gesture;
|
||||||
class c_slide_group : public c_wnd {
|
class c_slide_group : public c_wnd {
|
||||||
public:
|
public:
|
||||||
c_slide_group();
|
c_slide_group();
|
||||||
@ -23,6 +23,7 @@ protected:
|
|||||||
virtual c_wnd* clone(){return new c_slide_group();}
|
virtual c_wnd* clone(){return new c_slide_group();}
|
||||||
c_wnd* m_slides[MAX_PAGES];
|
c_wnd* m_slides[MAX_PAGES];
|
||||||
int m_active_slide_index;
|
int m_active_slide_index;
|
||||||
|
c_gesture* m_gesture;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
unsigned int get_col_num(){ return m_col_num;}
|
unsigned int get_col_num(){ return m_col_num;}
|
||||||
c_rect get_item_rect(int row, int col);
|
c_rect get_item_rect(int row, int col);
|
||||||
protected:
|
protected:
|
||||||
void draw_item(int col, int row, const char* str, unsigned int color);
|
void draw_item(int row, int col, const char* str, unsigned int color);
|
||||||
|
|
||||||
unsigned int m_align_type;
|
unsigned int m_align_type;
|
||||||
unsigned int m_row_num;
|
unsigned int m_row_num;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user