RE: Gui library
hmmm last time i checked awesomium it didnt have free option, or it was very well hidden. this type of licensing move i really like.
regarding website design - well judging from that is just plain wrong, but i admit, adding berkelium to esenthel took quite a bit of research, however i dont know if awesomium makes it easier. i suspect it draws to buffer and programmer has to render that buffer himself - thats what berkelium does. well berkelium has a native support for flash and javascript, since latest stable version uses chromium 8 engine. it may not look too appealing since you have to put chromium runtime to your game folder. good thing is that berkelium can be extended to handle custom uri, letting access of stuff directly from pak. also i had some glitches with input, but all that could be perfectly worked around.
so yeah, overall i agree that awesomium might be better, but for ones who like opensource and compiling their libs themselves - i guess there aint better alternative than berkelium.
@Driklyn:
code isnt of best quality and certainly not of plug&play type. main issues are drawing berkelium buffers on texture (Image) and keyboard input forwarding. Also i use customized berkelium version and code depends on customizations.
keyboard code:
Code:
u32 berkTxtBtns[][3] = {
{ KB_ENTER, 13, 0 },
{ KB_ESC, 27, 0 },
{ KB_DEL, 0x2E, 0 },
{ KB_NPENTER, 13, 0 },
{ KB_BACK, (u32)'\b', 0 }
};
u32 berkSpecBtns[][3] = {
{ KB_TAB, (u32)'\t', 0 }
};
int mods = Wugi::GetBerkeliuMods();
static u32 kbRepeatTimeout = 300;
while(const c8 c = Kb.c())
{
kbRepeatTimeout = 300;
if (c == ' ' || c == 127 || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
recv->keyEvent(true, mods, c, 0);
c16 outchars[2] = { c, 0 };
recv->textEvent(outchars, 1);
Kb.nextBufferedChar();
}
for (u32 i = 0; i < SIZEOF_ARRAY(berkTxtBtns); i++)
{
bool bp = Kb.bp((KB_BUTTON)berkTxtBtns[i][0]);
u32 timeDiff = GetTickCount() - berkTxtBtns[i][2];
if(bp || (Kb.b((KB_BUTTON)berkTxtBtns[i][0]) && timeDiff > kbRepeatTimeout))
{
if(!bp || timeDiff < 100)
kbRepeatTimeout = 30;
else
kbRepeatTimeout = 300;
recv->keyEvent(true, mods, berkTxtBtns[i][1], 0);
c16 outchars[2] = { berkTxtBtns[i][1], 0 };
recv->textEvent(outchars, 1);
berkTxtBtns[i][2] = GetTickCount();
}
}
for (u32 i = 0; i < SIZEOF_ARRAY(berkSpecBtns); i++)
{
bool bp = Kb.bp((KB_BUTTON)berkSpecBtns[i][0]);
u32 timeDiff = GetTickCount() - berkSpecBtns[i][2];
if(bp || (Kb.b((KB_BUTTON)berkSpecBtns[i][0]) && timeDiff > kbRepeatTimeout))
{
if(!bp || timeDiff < 100)
kbRepeatTimeout = 30;
else
kbRepeatTimeout = 300;
recv->keyEvent(true, mods, berkSpecBtns[i][1], 0);
}
}
Kb.eat();
texture painting code:
Code:
void HTMLRenderer::onWidgetPaint( Berkelium::Window *wnd, Berkelium::Widget *wgt, const u8* src, const Berkelium::Rect &srcRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect )
{
WidgetRenderers::iterator i = _widgets.find(wgt);
if(i != _widgets.end())
{
paintOnTexture(((HTMLRenderer::WidgetRenderer*)i->second)->texture, src, srcRect, numCopyRects, copyRects, dx, dy, scrollRect);
}
}
void HTMLRenderer::onPaint( Berkelium::Window *win, const unsigned char *sourceBuffer, const Berkelium::Rect &sourceBufferRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect )
{
paintOnTexture(_texture, sourceBuffer, sourceBufferRect, numCopyRects, copyRects, dx, dy, scrollRect);
}
void HTMLRenderer::paintOnTexture( Texture* tex, const u8* src, const Berkelium::Rect &srcRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect )
{
u8* texd = tex->buffer;
u32 tw = tex->width;
// scrolling
{
s32 wid = scrollRect.width();
s32 hig = scrollRect.height();
s32 top = scrollRect.top();
s32 left = scrollRect.left();
if(dy < 0) // scroll down
{
for (int y = -dy; y < hig; y++)
{
u32 tb = ((top + y) * tw + left) * 4;
u32 tb2 = tb + dy * tw * 4;
memcpy(&texd[tb2], &texd[tb], wid * 4);
}
}
else if(dy > 0) // scroll up
{
for (int y = hig - dy; y > -1; y--)
{
u32 tb = ((top + y) * tw + left) * 4;
u32 tb2 = tb + dy * tw * 4;
memcpy(&texd[tb2], &texd[tb], wid * 4);
}
}
if(dx != 0) // scroll
{
int subx = dx > 0 ? 0 : -dx;
for (int y = 0; y < hig; y++)
{
u32 tb = ((top + y) * tw + left) * 4;
u32 tb2 = tb - dx * 4;
memcpy(&texd[tb], &texd[tb2], wid * 4 - subx);
}
}
}
// copy new rects
for(u32 i = 0; i < numCopyRects; i++)
{
Berkelium::Rect cr = copyRects[i];
s32 wid = cr.width();
s32 hig = cr.height();
s32 top = cr.top() - srcRect.top();
s32 left = cr.left() - srcRect.left();
for(int y = 0; y < hig; y++)
{
u32 tb = ((cr.top() + y) * tw + cr.left()) * 4;
memcpy(&texd[tb], &src[(left + (y + top) * srcRect.width()) * 4], wid * 4);
}
}
}
void HTMLRenderer::paintOnTexture(Texture* dest, Texture* src, Berkelium::Rect& srcRect)
{
for (u32 j = 0; j < srcRect.height() && dest->height > (srcRect.mTop + j); j++)
memcpy(&dest->buffer[(srcRect.mLeft + (srcRect.mTop + j) * dest->width) * 4], &src->buffer[j * srcRect.mWidth * 4], srcRect.mWidth * 4);
}
|