sync with github bd3351e572
As always, full log is in GitHub. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2234 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
f7fbd6bc6d
commit
08e05eb3b4
@ -1,4 +1,4 @@
|
|||||||
Import('RTT_ROOT')
|
import os
|
||||||
from building import *
|
from building import *
|
||||||
|
|
||||||
common_src = Split("""
|
common_src = Split("""
|
||||||
@ -72,10 +72,10 @@ widgets/panel.c
|
|||||||
# The set of source files associated with this SConscript file.
|
# The set of source files associated with this SConscript file.
|
||||||
src = common_src + server_src + widgets_src
|
src = common_src + server_src + widgets_src
|
||||||
|
|
||||||
path = [RTT_ROOT + '/components/rtgui/include',
|
cwd = GetCurrentDir()
|
||||||
RTT_ROOT + '/components/rtgui/common',
|
dirs = ['include', 'common', 'server', 'widgets']
|
||||||
RTT_ROOT + '/components/rtgui/server',
|
path = [os.path.join(cwd, i) for i in dirs]
|
||||||
RTT_ROOT + '/components/rtgui/widgets']
|
|
||||||
group = DefineGroup('RTGUI', src, depend = ['RT_USING_RTGUI'], CPPPATH = path)
|
group = DefineGroup('RTGUI', src, depend = ['RT_USING_RTGUI'], CPPPATH = path)
|
||||||
|
|
||||||
Return('group')
|
Return('group')
|
||||||
|
@ -251,21 +251,7 @@ static int mem_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_
|
|||||||
|
|
||||||
static int mem_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num)
|
static int mem_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
struct rtgui_filerw_mem* mem = (struct rtgui_filerw_mem*)context;
|
|
||||||
|
|
||||||
if ((mem->mem_position + (num * size)) > mem->mem_end)
|
|
||||||
{
|
|
||||||
num = (mem->mem_end - mem->mem_position)/size;
|
|
||||||
}
|
|
||||||
|
|
||||||
rt_memcpy(mem->mem_position, ptr, num*size);
|
|
||||||
mem->mem_position += num*size;
|
|
||||||
|
|
||||||
return num;
|
|
||||||
#else
|
|
||||||
return 0; /* not support memory write */
|
return 0; /* not support memory write */
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mem_tell(struct rtgui_filerw* context)
|
static int mem_tell(struct rtgui_filerw* context)
|
||||||
|
@ -82,7 +82,7 @@ static struct rtgui_image_engine* rtgui_image_get_engine(const char* type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
||||||
static struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn)
|
struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn)
|
||||||
{
|
{
|
||||||
struct rtgui_list_node *node;
|
struct rtgui_list_node *node;
|
||||||
struct rtgui_image_engine *engine;
|
struct rtgui_image_engine *engine;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2012-01-24 onelife Reimplement to improve efficiency and add
|
* 2012-01-24 onelife Reimplement to improve efficiency and add
|
||||||
* features. The new decoder uses configurable fixed size working buffer and
|
* features. The new decoder uses configurable fixed size working buffer and
|
||||||
* provides scaledown function.
|
* provides scaledown function.
|
||||||
*/
|
*/
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
@ -19,58 +19,53 @@
|
|||||||
#ifdef RTGUI_IMAGE_BMP
|
#ifdef RTGUI_IMAGE_BMP
|
||||||
/* Compression encodings for BMP files */
|
/* Compression encodings for BMP files */
|
||||||
#ifndef BI_RGB
|
#ifndef BI_RGB
|
||||||
#define BI_RGB 0
|
#define BI_RGB 0
|
||||||
#define BI_RLE8 1
|
#define BI_RLE8 1
|
||||||
#define BI_RLE4 2
|
#define BI_RLE4 2
|
||||||
#define BI_BITFIELDS 3
|
#define BI_BITFIELDS 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BMP_WORKING_BUFFER_SIZE (384) /* In multiple of 12 and bigger than 48 */
|
#define BMP_WORKING_BUFFER_SIZE (384) /* In multiple of 12 and bigger than 48 */
|
||||||
#define BMP_MAX_SCALING_FACTOR (10) // TODO: find the max value!
|
#define BMP_MAX_SCALING_FACTOR (10) // TODO: find the max value!
|
||||||
#define hw_driver (rtgui_graphic_driver_get_default())
|
#define hw_driver (rtgui_graphic_driver_get_default())
|
||||||
|
|
||||||
struct rtgui_image_bmp
|
struct rtgui_image_bmp
|
||||||
{
|
{
|
||||||
rt_bool_t is_loaded;
|
rt_bool_t is_loaded;
|
||||||
rt_uint8_t *pixels;
|
rt_uint8_t *pixels;
|
||||||
struct rtgui_filerw* filerw;
|
struct rtgui_filerw *filerw;
|
||||||
rt_uint32_t w, h;
|
rt_uint32_t w, h;
|
||||||
rt_uint32_t pixel_offset;
|
rt_uint32_t pixel_offset;
|
||||||
rt_uint32_t pitch; rt_uint8_t scale;
|
rt_uint32_t pitch;
|
||||||
rt_uint8_t bit_per_pixel;
|
rt_uint8_t scale;
|
||||||
rt_uint8_t pad;
|
rt_uint8_t bit_per_pixel;
|
||||||
|
rt_uint8_t pad;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw* file,
|
static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw *file);
|
||||||
rt_uint32_t *width, rt_uint32_t *height);
|
static rt_bool_t rtgui_image_bmp_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
|
||||||
static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image,
|
static void rtgui_image_bmp_unload(struct rtgui_image *image);
|
||||||
struct rtgui_filerw* file, rt_uint8_t scale, rt_bool_t load); */
|
static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *rect);
|
||||||
static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw* file);
|
|
||||||
static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load);
|
|
||||||
static void rtgui_image_bmp_unload(struct rtgui_image* image);
|
|
||||||
static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect);
|
|
||||||
|
|
||||||
|
|
||||||
struct rtgui_image_engine rtgui_image_bmp_engine =
|
struct rtgui_image_engine rtgui_image_bmp_engine =
|
||||||
{
|
{
|
||||||
"bmp",
|
"bmp",
|
||||||
{ RT_NULL },
|
{ RT_NULL },
|
||||||
rtgui_image_bmp_check,
|
rtgui_image_bmp_check,
|
||||||
rtgui_image_bmp_load,
|
rtgui_image_bmp_load,
|
||||||
rtgui_image_bmp_unload,
|
rtgui_image_bmp_unload,
|
||||||
rtgui_image_bmp_blit
|
rtgui_image_bmp_blit
|
||||||
};
|
};
|
||||||
|
|
||||||
static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw* file)
|
static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw *file)
|
||||||
//static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw* file,
|
|
||||||
// rt_uint32_t *width, rt_uint32_t *height)
|
|
||||||
{
|
{
|
||||||
rt_uint8_t buffer[18];
|
rt_uint8_t buffer[18];
|
||||||
rt_bool_t is_bmp = RT_FALSE;
|
rt_bool_t is_bmp = RT_FALSE;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!file )
|
if (!file)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -85,47 +80,46 @@ static rt_bool_t rtgui_image_bmp_check(struct rtgui_filerw* file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Read file type */
|
/* Read file type */
|
||||||
if (buffer[0] != 'B' || buffer[1] != 'M')
|
if (buffer[0] != 'B' || buffer[1] != 'M')
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read BMP header size */
|
/* Read BMP header size */
|
||||||
if (*(rt_uint32_t *)&buffer[14] == 12)
|
if (*(rt_uint32_t *)&buffer[14] == 12)
|
||||||
{ /* Bitmap Header Version 2.x */
|
{
|
||||||
|
/* Bitmap Header Version 2.x */
|
||||||
if (rtgui_filerw_read(file, (void *)buffer, 8, 1) != 8)
|
if (rtgui_filerw_read(file, (void *)buffer, 8, 1) != 8)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Read image size */
|
/* Read image size */
|
||||||
// *width = (rt_uint32_t)*(rt_uint16_t *)&buffer[0];
|
|
||||||
// *height = (rt_uint32_t)*(rt_uint16_t *)&buffer[2];
|
|
||||||
is_bmp = RT_TRUE;
|
is_bmp = RT_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* Bitmap Header Version bigger than 2.x */
|
{
|
||||||
|
/* Bitmap Header Version bigger than 2.x */
|
||||||
if (rtgui_filerw_read(file, (void *)buffer, 8, 1) != 8)
|
if (rtgui_filerw_read(file, (void *)buffer, 8, 1) != 8)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Read image size */
|
/* Read image size */
|
||||||
// *width = *(rt_uint32_t *)&buffer[0];
|
|
||||||
// *height = *(rt_uint32_t *)&buffer[4];
|
|
||||||
is_bmp = RT_TRUE;
|
is_bmp = RT_TRUE;
|
||||||
}
|
}
|
||||||
} while(0);
|
}
|
||||||
|
while (0);
|
||||||
|
|
||||||
return is_bmp;
|
return is_bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rtgui_image_palette* rtgui_image_bmp_load_palette(
|
static struct rtgui_image_palette *rtgui_image_bmp_load_palette(
|
||||||
struct rtgui_filerw* file,
|
struct rtgui_filerw *file,
|
||||||
rt_uint32_t colorsUsed,
|
rt_uint32_t colorsUsed,
|
||||||
rt_bool_t alpha)
|
rt_bool_t alpha)
|
||||||
{
|
{
|
||||||
/* Load the palette, if any */
|
/* Load the palette, if any */
|
||||||
rt_uint32_t i;
|
rt_uint32_t i;
|
||||||
struct rtgui_image_palette *palette;
|
struct rtgui_image_palette *palette;
|
||||||
|
|
||||||
palette = rtgui_image_palette_create(colorsUsed);
|
palette = rtgui_image_palette_create(colorsUsed);
|
||||||
if (palette == RT_NULL)
|
if (palette == RT_NULL)
|
||||||
@ -135,41 +129,39 @@ static struct rtgui_image_palette* rtgui_image_bmp_load_palette(
|
|||||||
|
|
||||||
if (alpha)
|
if (alpha)
|
||||||
{
|
{
|
||||||
rt_uint8_t temp[4];
|
rt_uint8_t temp[4];
|
||||||
for (i = 0; i < colorsUsed; i++)
|
for (i = 0; i < colorsUsed; i++)
|
||||||
{
|
{
|
||||||
if (rtgui_filerw_read(file, (void *)&temp, 1, 4) != 4)
|
if (rtgui_filerw_read(file, (void *)&temp, 1, 4) != 4)
|
||||||
{
|
{
|
||||||
rtgui_free(palette);
|
rtgui_free(palette);
|
||||||
return RT_NULL;
|
return RT_NULL;
|
||||||
}
|
}
|
||||||
palette->colors[i] = RTGUI_ARGB(temp[3], temp[2], temp[1], temp[0]);
|
palette->colors[i] = RTGUI_ARGB(temp[3], temp[2], temp[1], temp[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rt_uint8_t temp[3];
|
rt_uint8_t temp[3];
|
||||||
for (i = 0; i < colorsUsed; i++)
|
for (i = 0; i < colorsUsed; i++)
|
||||||
{
|
{
|
||||||
if (rtgui_filerw_read(file, (void *)&temp, 1, 3) != 3)
|
if (rtgui_filerw_read(file, (void *)&temp, 1, 3) != 3)
|
||||||
{
|
{
|
||||||
rtgui_free(palette);
|
rtgui_free(palette);
|
||||||
return RT_NULL;
|
return RT_NULL;
|
||||||
}
|
}
|
||||||
palette->colors[i] = RTGUI_RGB(temp[2], temp[1], temp[0]);
|
palette->colors[i] = RTGUI_RGB(temp[2], temp[1], temp[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_filerw* file, rt_bool_t load)
|
static rt_bool_t rtgui_image_bmp_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load)
|
||||||
//static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image,
|
|
||||||
// struct rtgui_filerw* file, rt_uint8_t scale, rt_bool_t load)
|
|
||||||
{
|
{
|
||||||
rt_uint8_t scale = 2;
|
rt_uint8_t scale = 0;
|
||||||
rt_uint8_t *wrkBuffer;
|
rt_uint8_t *wrkBuffer;
|
||||||
struct rtgui_image_bmp* bmp;
|
struct rtgui_image_bmp *bmp;
|
||||||
rt_uint32_t bmpHeaderSize;
|
rt_uint32_t bmpHeaderSize;
|
||||||
rt_uint32_t colorsUsed;
|
rt_uint32_t colorsUsed;
|
||||||
|
|
||||||
@ -187,7 +179,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bmp = (struct rtgui_image_bmp*)rtgui_malloc(sizeof(struct rtgui_image_bmp));
|
bmp = (struct rtgui_image_bmp *)rtgui_malloc(sizeof(struct rtgui_image_bmp));
|
||||||
if (bmp == RT_NULL)
|
if (bmp == RT_NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -203,10 +195,10 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Read file type */
|
/* Read file type */
|
||||||
if (wrkBuffer[0] != 'B' || wrkBuffer[1] != 'M')
|
if (wrkBuffer[0] != 'B' || wrkBuffer[1] != 'M')
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// rt_kprintf("BMP: format ok\n");
|
// rt_kprintf("BMP: format ok\n");
|
||||||
/* Read pixel array offset */
|
/* Read pixel array offset */
|
||||||
bmp->pixel_offset = *(rt_uint32_t *)&wrkBuffer[10];
|
bmp->pixel_offset = *(rt_uint32_t *)&wrkBuffer[10];
|
||||||
@ -216,19 +208,21 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
// rt_kprintf("BMP: bmpHeaderSize %d\n", bmpHeaderSize);
|
// rt_kprintf("BMP: bmpHeaderSize %d\n", bmpHeaderSize);
|
||||||
colorsUsed = 0;
|
colorsUsed = 0;
|
||||||
if (bmpHeaderSize == 12)
|
if (bmpHeaderSize == 12)
|
||||||
{ /* Bitmap Header Version 2.x */
|
{
|
||||||
|
/* Bitmap Header Version 2.x */
|
||||||
if (rtgui_filerw_read(file, (void *)wrkBuffer, 8, 1) != 8)
|
if (rtgui_filerw_read(file, (void *)wrkBuffer, 8, 1) != 8)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Read image size */
|
/* Read image size */
|
||||||
bmp->w = (rt_uint32_t)*(rt_uint16_t *)&wrkBuffer[0];
|
bmp->w = (rt_uint32_t) * (rt_uint16_t *)&wrkBuffer[0];
|
||||||
bmp->h = (rt_uint32_t)*(rt_uint16_t *)&wrkBuffer[2];
|
bmp->h = (rt_uint32_t) * (rt_uint16_t *)&wrkBuffer[2];
|
||||||
/* Read bits per pixel */
|
/* Read bits per pixel */
|
||||||
bmp->bit_per_pixel = (rt_uint8_t)*(rt_uint16_t *)&wrkBuffer[6];
|
bmp->bit_per_pixel = (rt_uint8_t) * (rt_uint16_t *)&wrkBuffer[6];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* Bitmap Header Version bigger than 2.x */
|
{
|
||||||
|
/* Bitmap Header Version bigger than 2.x */
|
||||||
rt_uint32_t compression;
|
rt_uint32_t compression;
|
||||||
|
|
||||||
if (rtgui_filerw_read(file, (void *)wrkBuffer, 36, 1) != 36)
|
if (rtgui_filerw_read(file, (void *)wrkBuffer, 36, 1) != 36)
|
||||||
@ -239,7 +233,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
bmp->w = *(rt_uint32_t *)&wrkBuffer[0];
|
bmp->w = *(rt_uint32_t *)&wrkBuffer[0];
|
||||||
bmp->h = *(rt_uint32_t *)&wrkBuffer[4];
|
bmp->h = *(rt_uint32_t *)&wrkBuffer[4];
|
||||||
/* Read bits per pixel */
|
/* Read bits per pixel */
|
||||||
bmp->bit_per_pixel = (rt_uint8_t)*(rt_uint16_t *)&wrkBuffer[10];
|
bmp->bit_per_pixel = (rt_uint8_t) * (rt_uint16_t *)&wrkBuffer[10];
|
||||||
if (bmp->bit_per_pixel > 32)
|
if (bmp->bit_per_pixel > 32)
|
||||||
{
|
{
|
||||||
rt_kprintf("BMP err: unsupported format\n");
|
rt_kprintf("BMP err: unsupported format\n");
|
||||||
@ -269,7 +263,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
image->palette = rtgui_image_bmp_load_palette(file, colorsUsed,
|
image->palette = rtgui_image_bmp_load_palette(file, colorsUsed,
|
||||||
bmpHeaderSize > 12 ? RT_TRUE : RT_FALSE);
|
bmpHeaderSize > 12 ? RT_TRUE : RT_FALSE);
|
||||||
if (image->palette == RT_NULL)
|
if (image->palette == RT_NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -281,11 +275,11 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
bmp->scale = scale;
|
bmp->scale = scale;
|
||||||
if (bmp->bit_per_pixel == 1)
|
if (bmp->bit_per_pixel == 1)
|
||||||
{
|
{
|
||||||
bmp->pitch = (bmp->w + 7) >> 3;
|
bmp->pitch = (bmp->w + 7) >> 3;
|
||||||
}
|
}
|
||||||
else if (bmp->bit_per_pixel == 4)
|
else if (bmp->bit_per_pixel == 4)
|
||||||
{
|
{
|
||||||
bmp->pitch = (bmp->w + 1) >> 1;
|
bmp->pitch = (bmp->w + 1) >> 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -364,7 +358,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
{
|
{
|
||||||
dst = bmp->pixels + (image->h - y - 1) * imageWidth;
|
dst = bmp->pixels + (image->h - y - 1) * imageWidth;
|
||||||
readIndex = 0;
|
readIndex = 0;
|
||||||
skipLength= 0;
|
skipLength = 0;
|
||||||
|
|
||||||
/* Process a line */
|
/* Process a line */
|
||||||
while (readIndex < bmp->pitch)
|
while (readIndex < bmp->pitch)
|
||||||
@ -374,7 +368,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
|
|
||||||
/* Read data to buffer */
|
/* Read data to buffer */
|
||||||
readLength = (BMP_WORKING_BUFFER_SIZE > (bmp->pitch - readIndex)) ? \
|
readLength = (BMP_WORKING_BUFFER_SIZE > (bmp->pitch - readIndex)) ? \
|
||||||
(bmp->pitch - readIndex) : BMP_WORKING_BUFFER_SIZE;
|
(bmp->pitch - readIndex) : BMP_WORKING_BUFFER_SIZE;
|
||||||
if (rtgui_filerw_read(file, (void *)wrkBuffer, 1, readLength) != readLength)
|
if (rtgui_filerw_read(file, (void *)wrkBuffer, 1, readLength) != readLength)
|
||||||
{
|
{
|
||||||
rt_kprintf("BMP err: read failed\n");
|
rt_kprintf("BMP err: read failed\n");
|
||||||
@ -446,7 +440,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
/* Skip padding bytes */
|
/* Skip padding bytes */
|
||||||
if (bmp->pad)
|
if (bmp->pad)
|
||||||
{
|
{
|
||||||
if ( rtgui_filerw_seek(file, bmp->pad, RTGUI_FILE_SEEK_CUR) < 0)
|
if (rtgui_filerw_seek(file, bmp->pad, RTGUI_FILE_SEEK_CUR) < 0)
|
||||||
{
|
{
|
||||||
error = RT_TRUE;
|
error = RT_TRUE;
|
||||||
break;
|
break;
|
||||||
@ -457,7 +451,7 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
if (bmp->scale)
|
if (bmp->scale)
|
||||||
{
|
{
|
||||||
if (rtgui_filerw_seek(file, (bmp->pitch + bmp->pad) * ((1 << bmp->scale) - 1),
|
if (rtgui_filerw_seek(file, (bmp->pitch + bmp->pad) * ((1 << bmp->scale) - 1),
|
||||||
RTGUI_FILE_SEEK_CUR) < 0)
|
RTGUI_FILE_SEEK_CUR) < 0)
|
||||||
{
|
{
|
||||||
error = RT_TRUE;
|
error = RT_TRUE;
|
||||||
break;
|
break;
|
||||||
@ -475,48 +469,49 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image* image, struct rtgui_fi
|
|||||||
// rt_kprintf("BMP: load to RAM\n");
|
// rt_kprintf("BMP: load to RAM\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release memory */
|
/* Release memory */
|
||||||
rt_free(wrkBuffer);
|
rt_free(wrkBuffer);
|
||||||
return RT_TRUE;
|
return RT_TRUE;
|
||||||
} while(0);
|
}
|
||||||
|
while (0);
|
||||||
|
|
||||||
/* Release memory */
|
/* Release memory */
|
||||||
rt_free(wrkBuffer);
|
rt_free(wrkBuffer);
|
||||||
rtgui_free(image->palette);
|
rtgui_free(image->palette);
|
||||||
rtgui_free(bmp->pixels);
|
rtgui_free(bmp->pixels);
|
||||||
rtgui_free(bmp);
|
rtgui_free(bmp);
|
||||||
return RT_FALSE;
|
return RT_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtgui_image_bmp_unload(struct rtgui_image* image)
|
static void rtgui_image_bmp_unload(struct rtgui_image *image)
|
||||||
{
|
{
|
||||||
struct rtgui_image_bmp* bmp;
|
struct rtgui_image_bmp *bmp;
|
||||||
|
|
||||||
if (image != RT_NULL)
|
if (image != RT_NULL)
|
||||||
{
|
{
|
||||||
bmp = (struct rtgui_image_bmp*)image->data;
|
bmp = (struct rtgui_image_bmp *)image->data;
|
||||||
|
|
||||||
/* Release memory */
|
/* Release memory */
|
||||||
rtgui_free(bmp->pixels);
|
rtgui_free(bmp->pixels);
|
||||||
if (bmp->filerw != RT_NULL)
|
if (bmp->filerw != RT_NULL)
|
||||||
{
|
{
|
||||||
/* Close file */
|
/* Close file */
|
||||||
rtgui_filerw_close(bmp->filerw);
|
rtgui_filerw_close(bmp->filerw);
|
||||||
bmp->filerw = RT_NULL;
|
bmp->filerw = RT_NULL;
|
||||||
}
|
}
|
||||||
rtgui_free(bmp);
|
rtgui_free(bmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* dst_rect)
|
static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc, struct rtgui_rect *dst_rect)
|
||||||
{
|
{
|
||||||
rt_uint16_t w, h;
|
rt_uint16_t w, h;
|
||||||
struct rtgui_image_bmp* bmp;
|
struct rtgui_image_bmp *bmp;
|
||||||
rt_uint8_t bytePerPixel;
|
rt_uint8_t bytePerPixel;
|
||||||
rt_uint32_t imageWidth;
|
rt_uint32_t imageWidth;
|
||||||
rt_bool_t error;
|
rt_bool_t error;
|
||||||
|
|
||||||
bmp = (struct rtgui_image_bmp*)image->data;
|
bmp = (struct rtgui_image_bmp *)image->data;
|
||||||
RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL || bmp != RT_NULL);
|
RT_ASSERT(image != RT_NULL || dc != RT_NULL || dst_rect != RT_NULL || bmp != RT_NULL);
|
||||||
|
|
||||||
bytePerPixel = bmp->bit_per_pixel / 8;
|
bytePerPixel = bmp->bit_per_pixel / 8;
|
||||||
@ -560,19 +555,25 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
rt_uint8_t skipLength;
|
rt_uint8_t skipLength;
|
||||||
rt_uint16_t x, y;
|
rt_uint16_t x, y;
|
||||||
rt_int8_t scale1, scale2;
|
rt_int8_t scale1, scale2;
|
||||||
|
rt_uint16_t y_start = dst_rect->y1 + h - 1;
|
||||||
wrkBuffer = (rt_uint8_t *)rt_malloc(BMP_WORKING_BUFFER_SIZE);
|
|
||||||
if (wrkBuffer == RT_NULL)
|
|
||||||
{
|
|
||||||
rt_kprintf("BMP err: no mem (%d)\n", BMP_WORKING_BUFFER_SIZE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read the pixels. Note that the bmp image is upside down */
|
/* Read the pixels. Note that the bmp image is upside down */
|
||||||
if (rtgui_filerw_seek(bmp->filerw, bmp->pixel_offset, RTGUI_FILE_SEEK_SET) < 0)
|
if (rtgui_filerw_seek(bmp->filerw, bmp->pixel_offset, RTGUI_FILE_SEEK_SET) < 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* the image is upside down. So we need to start from middle if the
|
||||||
|
* image is higher than the dst_rect. */
|
||||||
|
if (image->h > rtgui_rect_height(*dst_rect))
|
||||||
|
{
|
||||||
|
int hdelta = image->h - rtgui_rect_height(*dst_rect);
|
||||||
|
if (rtgui_filerw_seek(bmp->filerw, hdelta * (bmp->pitch + bmp->pad) * (1 << bmp->scale),
|
||||||
|
RTGUI_FILE_SEEK_CUR) < 0)
|
||||||
|
{
|
||||||
|
error = RT_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bmp->bit_per_pixel == 1)
|
if (bmp->bit_per_pixel == 1)
|
||||||
{
|
{
|
||||||
@ -601,23 +602,32 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wrkBuffer = (rt_uint8_t *)rt_malloc(
|
||||||
|
(BMP_WORKING_BUFFER_SIZE > bmp->pitch) ? \
|
||||||
|
bmp->pitch : BMP_WORKING_BUFFER_SIZE);
|
||||||
|
if (wrkBuffer == RT_NULL)
|
||||||
|
{
|
||||||
|
rt_kprintf("BMP err: no mem (%d)\n", BMP_WORKING_BUFFER_SIZE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Process whole image */
|
/* Process whole image */
|
||||||
y = 0;
|
y = 0;
|
||||||
while (y < image->h)
|
while (y < h)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
readIndex = 0;
|
readIndex = 0;
|
||||||
skipLength= 0;
|
skipLength = 0;
|
||||||
|
|
||||||
/* Process a line */
|
/* Process a line */
|
||||||
while (readIndex < bmp->pitch)
|
while (readIndex < bmp->pitch)
|
||||||
{
|
{
|
||||||
/* Put progress indicator */
|
/* Put progress indicator */
|
||||||
rt_kprintf("\r%lu%%", y * 100UL / image->h);
|
rt_kprintf("\r%lu%%", y * 100UL / h);
|
||||||
|
|
||||||
/* Read data to buffer */
|
/* Read data to buffer */
|
||||||
readLength = (BMP_WORKING_BUFFER_SIZE > (bmp->pitch - readIndex)) ? \
|
readLength = (BMP_WORKING_BUFFER_SIZE > (bmp->pitch - readIndex)) ? \
|
||||||
(bmp->pitch - readIndex) : BMP_WORKING_BUFFER_SIZE;
|
(bmp->pitch - readIndex) : BMP_WORKING_BUFFER_SIZE;
|
||||||
if (rtgui_filerw_read(bmp->filerw, (void *)wrkBuffer, 1, readLength) != readLength)
|
if (rtgui_filerw_read(bmp->filerw, (void *)wrkBuffer, 1, readLength) != readLength)
|
||||||
{
|
{
|
||||||
rt_kprintf("BMP err: read failed\n");
|
rt_kprintf("BMP err: read failed\n");
|
||||||
@ -629,18 +639,19 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
/* Process read buffer */
|
/* Process read buffer */
|
||||||
if (bmp->bit_per_pixel == 1)
|
if (bmp->bit_per_pixel == 1)
|
||||||
{
|
{
|
||||||
rt_uint8_t j;
|
|
||||||
rtgui_color_t color;
|
|
||||||
|
|
||||||
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += 1 << scale1)
|
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += 1 << scale1)
|
||||||
{
|
{
|
||||||
|
rt_uint8_t j;
|
||||||
for (j = 0; j < 8; j += 1 << scale2)
|
for (j = 0; j < 8; j += 1 << scale2)
|
||||||
{
|
{
|
||||||
|
rtgui_color_t color;
|
||||||
color = image->palette->colors[(wrkBuffer[loadIndex] & (1 << (7 - j))) >> (7 - j)];
|
color = image->palette->colors[(wrkBuffer[loadIndex] & (1 << (7 - j))) >> (7 - j)];
|
||||||
rtgui_dc_draw_color_point(dc,
|
rtgui_dc_draw_color_point(dc,
|
||||||
dst_rect->x1 + x++,
|
dst_rect->x1 + x++,
|
||||||
dst_rect->y1 + image->h - y,
|
y_start - y,
|
||||||
color);
|
color);
|
||||||
|
if (x >= w)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (scale1 && (readLength % (1 << scale1)))
|
if (scale1 && (readLength % (1 << scale1)))
|
||||||
{
|
{
|
||||||
@ -650,18 +661,19 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
}
|
}
|
||||||
else if (bmp->bit_per_pixel == 4)
|
else if (bmp->bit_per_pixel == 4)
|
||||||
{
|
{
|
||||||
rt_uint8_t j;
|
|
||||||
rtgui_color_t color;
|
|
||||||
|
|
||||||
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += 1 << scale1)
|
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += 1 << scale1)
|
||||||
{
|
{
|
||||||
|
rt_uint8_t j;
|
||||||
for (j = 0; j < 8; j += 1 << (2 + scale2))
|
for (j = 0; j < 8; j += 1 << (2 + scale2))
|
||||||
{
|
{
|
||||||
|
rtgui_color_t color;
|
||||||
color = image->palette->colors[(wrkBuffer[loadIndex] & (0x0F << (4 - j))) >> (4 - j)];
|
color = image->palette->colors[(wrkBuffer[loadIndex] & (0x0F << (4 - j))) >> (4 - j)];
|
||||||
rtgui_dc_draw_color_point(dc,
|
rtgui_dc_draw_color_point(dc,
|
||||||
dst_rect->x1 + x++,
|
dst_rect->x1 + x++,
|
||||||
dst_rect->y1 + image->h - y,
|
y_start - y,
|
||||||
color);
|
color);
|
||||||
|
if (x >= w)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scale1 && (readLength % (1 << scale1)))
|
if (scale1 && (readLength % (1 << scale1)))
|
||||||
@ -671,15 +683,16 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
}
|
}
|
||||||
else if (bmp->bit_per_pixel == 8)
|
else if (bmp->bit_per_pixel == 8)
|
||||||
{
|
{
|
||||||
rtgui_color_t color;
|
|
||||||
|
|
||||||
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += 1 << bmp->scale)
|
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += 1 << bmp->scale)
|
||||||
{
|
{
|
||||||
|
rtgui_color_t color;
|
||||||
color = image->palette->colors[wrkBuffer[loadIndex]];
|
color = image->palette->colors[wrkBuffer[loadIndex]];
|
||||||
rtgui_dc_draw_color_point(dc,
|
rtgui_dc_draw_color_point(dc,
|
||||||
dst_rect->x1 + x++,
|
dst_rect->x1 + x++,
|
||||||
dst_rect->y1 + image->h - y,
|
y_start - y,
|
||||||
color);
|
color);
|
||||||
|
if (x >= w)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (readLength % (1 << bmp->scale))
|
if (readLength % (1 << bmp->scale))
|
||||||
{
|
{
|
||||||
@ -707,15 +720,17 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (loadIndex = skipLength;
|
for (loadIndex = skipLength;
|
||||||
loadIndex < readLength;
|
loadIndex < readLength;
|
||||||
loadIndex += bytePerPixel << bmp->scale)
|
loadIndex += bytePerPixel << bmp->scale)
|
||||||
{
|
{
|
||||||
blit_line(temp, &wrkBuffer[loadIndex], bytePerPixel);
|
blit_line(temp, &wrkBuffer[loadIndex], bytePerPixel);
|
||||||
dc->engine->blit_line(dc,
|
dc->engine->blit_line(dc,
|
||||||
dst_rect->x1 + x, dst_rect->x1 + x + 1,
|
dst_rect->x1 + x, dst_rect->x1 + x + 1,
|
||||||
dst_rect->y1 + image->h - y,
|
y_start - y,
|
||||||
temp);
|
temp);
|
||||||
x++;
|
x++;
|
||||||
|
if (x >= w)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (readLength % (1 << bmp->scale))
|
if (readLength % (1 << bmp->scale))
|
||||||
{
|
{
|
||||||
@ -732,7 +747,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
/* Skip padding bytes */
|
/* Skip padding bytes */
|
||||||
if (bmp->pad)
|
if (bmp->pad)
|
||||||
{
|
{
|
||||||
if ( rtgui_filerw_seek(bmp->filerw, bmp->pad, RTGUI_FILE_SEEK_CUR) < 0)
|
if (rtgui_filerw_seek(bmp->filerw, bmp->pad, RTGUI_FILE_SEEK_CUR) < 0)
|
||||||
{
|
{
|
||||||
error = RT_TRUE;
|
error = RT_TRUE;
|
||||||
break;
|
break;
|
||||||
@ -743,7 +758,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
if (bmp->scale)
|
if (bmp->scale)
|
||||||
{
|
{
|
||||||
if (rtgui_filerw_seek(bmp->filerw, (bmp->pitch + bmp->pad) * ((1 << bmp->scale) - 1),
|
if (rtgui_filerw_seek(bmp->filerw, (bmp->pitch + bmp->pad) * ((1 << bmp->scale) - 1),
|
||||||
RTGUI_FILE_SEEK_CUR) < 0)
|
RTGUI_FILE_SEEK_CUR) < 0)
|
||||||
{
|
{
|
||||||
error = RT_TRUE;
|
error = RT_TRUE;
|
||||||
break;
|
break;
|
||||||
@ -761,7 +776,7 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
rt_uint16_t x, y;
|
rt_uint16_t x, y;
|
||||||
rt_uint8_t* ptr;
|
rt_uint8_t *ptr;
|
||||||
|
|
||||||
for (y = 0; y < h; y ++)
|
for (y = 0; y < h; y ++)
|
||||||
{
|
{
|
||||||
@ -775,9 +790,9 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
{
|
{
|
||||||
color = image->palette->colors[*(ptr++)];
|
color = image->palette->colors[*(ptr++)];
|
||||||
rtgui_dc_draw_color_point(dc,
|
rtgui_dc_draw_color_point(dc,
|
||||||
dst_rect->x1 + x,
|
dst_rect->x1 + x,
|
||||||
dst_rect->y1 + y,
|
dst_rect->y1 + y,
|
||||||
color);
|
color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -805,20 +820,21 @@ static void rtgui_image_bmp_blit(struct rtgui_image* image, struct rtgui_dc* dc,
|
|||||||
blit_line(temp, ptr, bytePerPixel);
|
blit_line(temp, ptr, bytePerPixel);
|
||||||
ptr += bytePerPixel;
|
ptr += bytePerPixel;
|
||||||
dc->engine->blit_line(dc,
|
dc->engine->blit_line(dc,
|
||||||
dst_rect->x1 + x, dst_rect->x1 + x + 1,
|
dst_rect->x1 + x, dst_rect->x1 + x + 1,
|
||||||
dst_rect->y1 + y,
|
dst_rect->y1 + y,
|
||||||
temp);
|
temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// rt_kprintf("BMP: blit ok\n");
|
// rt_kprintf("BMP: blit ok\n");
|
||||||
} while(0);
|
}
|
||||||
|
while (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtgui_image_bmp_init()
|
void rtgui_image_bmp_init()
|
||||||
{
|
{
|
||||||
/* register bmp on image system */
|
/* register bmp on image system */
|
||||||
rtgui_image_register_engine(&rtgui_image_bmp_engine);
|
rtgui_image_register_engine(&rtgui_image_bmp_engine);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -60,6 +60,7 @@ typedef struct rtgui_image rtgui_image_t;
|
|||||||
void rtgui_system_image_init(void);
|
void rtgui_system_image_init(void);
|
||||||
|
|
||||||
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
|
||||||
|
struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn);
|
||||||
struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
|
struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load);
|
||||||
struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load);
|
struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load);
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,6 +34,7 @@ struct rtgui_notebook* rtgui_notebook_create(const rtgui_rect_t* rect, rt_uint8_
|
|||||||
void rtgui_notebook_destroy(struct rtgui_notebook* notebook);
|
void rtgui_notebook_destroy(struct rtgui_notebook* notebook);
|
||||||
|
|
||||||
void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child);
|
void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, struct rtgui_widget* child);
|
||||||
|
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index);
|
||||||
struct rtgui_widget* rtgui_notebook_get_current(struct rtgui_notebook* notebook);
|
struct rtgui_widget* rtgui_notebook_get_current(struct rtgui_notebook* notebook);
|
||||||
rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook* notebook);
|
rt_int16_t rtgui_notebook_get_current_index(struct rtgui_notebook* notebook);
|
||||||
|
|
||||||
|
@ -133,10 +133,6 @@ void rtgui_win_move(struct rtgui_win* win, int x, int y);
|
|||||||
/* reset extent of window */
|
/* reset extent of window */
|
||||||
void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect);
|
void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect);
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
|
||||||
void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
|
void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
|
||||||
void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
|
void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler);
|
||||||
void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler);
|
void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler);
|
||||||
|
@ -231,6 +231,8 @@ void rtgui_notebook_add(struct rtgui_notebook* notebook, const char* label, stru
|
|||||||
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index)
|
void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index)
|
||||||
{
|
{
|
||||||
struct rtgui_notebook_tab tab;
|
struct rtgui_notebook_tab tab;
|
||||||
|
rt_bool_t need_update = RT_FALSE;
|
||||||
|
|
||||||
RT_ASSERT(notebook != RT_NULL);
|
RT_ASSERT(notebook != RT_NULL);
|
||||||
|
|
||||||
if (index < notebook->count)
|
if (index < notebook->count)
|
||||||
@ -244,8 +246,11 @@ void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (notebook->current == index)
|
||||||
|
need_update = RT_TRUE;
|
||||||
|
|
||||||
tab = notebook->childs[index];
|
tab = notebook->childs[index];
|
||||||
for (;index < notebook->count - 1; index ++)
|
for (;index < notebook->count - 1; index++)
|
||||||
{
|
{
|
||||||
notebook->childs[index] = notebook->childs[index + 1];
|
notebook->childs[index] = notebook->childs[index + 1];
|
||||||
}
|
}
|
||||||
@ -255,16 +260,17 @@ void rtgui_notebook_remove(struct rtgui_notebook* notebook, rt_uint16_t index)
|
|||||||
sizeof(struct rtgui_notebook_tab) * notebook->count);
|
sizeof(struct rtgui_notebook_tab) * notebook->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: do we really want to destroy it?
|
|
||||||
rtgui_widget_destroy(tab.widget);
|
|
||||||
rtgui_free(tab.title);
|
rtgui_free(tab.title);
|
||||||
|
|
||||||
if (notebook->current == index)
|
if (need_update)
|
||||||
{
|
{
|
||||||
/* update tab */
|
|
||||||
if (notebook->current > notebook->count - 1)
|
if (notebook->current > notebook->count - 1)
|
||||||
notebook->current = notebook->count - 1;
|
notebook->current = notebook->count - 1;
|
||||||
|
|
||||||
|
rtgui_widget_hide(tab.widget);
|
||||||
|
rtgui_widget_show(notebook->childs[notebook->current].widget);
|
||||||
rtgui_widget_update(RTGUI_WIDGET(notebook));
|
rtgui_widget_update(RTGUI_WIDGET(notebook));
|
||||||
|
rtgui_widget_set_parent(tab.widget, RT_NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ static void _rtgui_widget_destructor(rtgui_widget_t *widget)
|
|||||||
{
|
{
|
||||||
if (widget == RT_NULL) return;
|
if (widget == RT_NULL) return;
|
||||||
|
|
||||||
if (widget->parent != RT_NULL)
|
if (widget->parent != RT_NULL && RTGUI_IS_CONTAINER(widget->parent))
|
||||||
{
|
{
|
||||||
/* remove widget from parent's children list */
|
/* remove widget from parent's children list */
|
||||||
rtgui_list_remove(&(RTGUI_CONTAINER(widget->parent)->children), &(widget->sibling));
|
rtgui_list_remove(&(RTGUI_CONTAINER(widget->parent)->children), &(widget->sibling));
|
||||||
@ -413,8 +413,7 @@ rt_bool_t rtgui_widget_onupdate_toplvl(struct rtgui_object *object, struct rtgui
|
|||||||
|
|
||||||
rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* event)
|
rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* event)
|
||||||
{
|
{
|
||||||
RT_ASSERT(object != RT_NULL);
|
RTGUI_WIDGET_EVENT_HANDLER_PREPARE;
|
||||||
RT_ASSERT(event != RT_NULL);
|
|
||||||
|
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
@ -538,9 +537,10 @@ rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *e
|
|||||||
{
|
{
|
||||||
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
||||||
|
|
||||||
/* update the clip info of widget */
|
if (!RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(object)))
|
||||||
|
return RT_FALSE;
|
||||||
|
|
||||||
RTGUI_WIDGET_UNHIDE(widget);
|
RTGUI_WIDGET_UNHIDE(widget);
|
||||||
rtgui_widget_update_clip(widget);
|
|
||||||
|
|
||||||
if (widget->on_show != RT_NULL)
|
if (widget->on_show != RT_NULL)
|
||||||
widget->on_show(RTGUI_OBJECT(widget), RT_NULL);
|
widget->on_show(RTGUI_OBJECT(widget), RT_NULL);
|
||||||
@ -552,6 +552,9 @@ rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *e
|
|||||||
{
|
{
|
||||||
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
||||||
|
|
||||||
|
if (RTGUI_WIDGET_IS_HIDE(RTGUI_WIDGET(object)))
|
||||||
|
return RT_FALSE;
|
||||||
|
|
||||||
/* hide this widget */
|
/* hide this widget */
|
||||||
RTGUI_WIDGET_HIDE(widget);
|
RTGUI_WIDGET_HIDE(widget);
|
||||||
|
|
||||||
|
@ -594,16 +594,6 @@ void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef RTGUI_USING_SMALL_SIZE
|
|
||||||
void rtgui_win_set_box(rtgui_win_t* win, rtgui_box_t* box)
|
|
||||||
{
|
|
||||||
if (win == RT_NULL || box == RT_NULL) return;
|
|
||||||
|
|
||||||
rtgui_container_add_child(RTGUI_CONTAINER(win), RTGUI_WIDGET(box));
|
|
||||||
rtgui_widget_set_rect(RTGUI_WIDGET(box), &(RTGUI_WIDGET(win)->extent));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler)
|
void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler)
|
||||||
{
|
{
|
||||||
if (win != RT_NULL)
|
if (win != RT_NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user