About Store Forum Documentation Contact



Post Reply 
Gui library
Author Message
rndbit Offline
Member

Post: #31
RE: Gui library
i paint on image buffer too, works like charm. could you post me values of wid, hig, top, left, dx and dy whenever top or left is negative? maybe i could brainstorm something out of this
05-30-2011 07:11 PM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #32
RE: Gui library
First: /facepalm

How stupid, I was using image pitch instead of width lol

Your code works fine now, except that I get the odd -dx/-dy that is way too big, like -683, and I get an access violation. It happens in windowed mode when I click outside the window and back in while scrolling. So I've added a few size checks, and it's more robust.

Here's my (your) new code for image painting... Thanks again

PHP Code:
if (!image.is()) return;

    
image.lock();

    
unsigned chartexd image.data();
    
UInt tw image.x();
    
UInt th image.y();
    
UInt sz tw*th*4;
    
    
// scrolling
    
{
        
Int wid scrollRect.width();
        
Int hig scrollRect.height();
        
Int top scrollRect.top();
        
Int left scrollRect.left();


        if(
dy 0)    // scroll down
        
{
            for (
int y = -dyhigy++)
            {
                
UInt tb = ((top y) * tw left) * 4;
                
UInt tb2 tb dy tw 4;
                if (
tb >= && tb sz && tb2 >= && tb2 szmemcpy(&texd[tb2], &texd[tb], wid 4);
            }
        }
        else if(
dy 0)    // scroll up
        
{
            for (
int y hig dy> -1y--)
            {
                
UInt tb = ((top y) * tw left) * 4;
                
UInt tb2 tb dy tw 4;
                if (
tb >= && tb sz && tb2 >= && tb2 szmemcpy(&texd[tb2], &texd[tb], wid 4);
            }
        }

        if(
dx != 0)    // scroll
        
{
            
int subx dx : -dx;
            for (
int y 0higy++)
            {
                
UInt tb = ((top y) * tw left) * 4;
                
UInt tb2 tb dx 4;
                if (
tb >= && tb sz && tb2 >= && tb2 szmemcpy(&texd[tb], &texd[tb2], wid subx);

            }
        }
    }

    
// copy new rects
    
for(UInt i 0numCopyRectsi++)
    {
        
Berkelium::Rect cr copyRects[i];
        
Int wid cr.width();
        
Int hig cr.height();
        
Int top cr.top() - sourceBufferRect.top();
        
Int left cr.left() - sourceBufferRect.left();

        for(
int y 0higy++)
        {
            
UInt tb = ((cr.top() + y) * tw cr.left()) * 4;
            
UInt tb2 = (left + (top) * sourceBufferRect.width()) * 4;
            if (
tb >= && tb sz && tb2 >= && tb2 szmemcpy(&texd[tb], &sourceBuffer[tb2], wid 4);
        }
    }

    
image.unlock(); 
(This post was last modified: 05-31-2011 01:41 AM by andargor.)
05-31-2011 01:39 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #33
RE: Gui library
Oh, and how the heck do you enable Flash? I get a "The Flash plug-in is out of date" message when I go to Youtube.

EDIT: nm, found it. Install Chrome on some other machine and get the gcswf32.dll file from the Document and Settings\<user>\Local Settings\Application Data\Google\Chrome\Application\<version> directory and put it in the same directory as berkelium.exe

BTW, I'm on a boat grin


Attached File(s) Image(s)
   
(This post was last modified: 05-31-2011 04:47 AM by andargor.)
05-31-2011 04:08 AM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #34
RE: Gui library
that looks great smile
05-31-2011 08:00 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #35
RE: Gui library
Your keyboard code works. I started on my own, and quickly aborted. My mod keys aren't working but it's not a big deal for now.

EDIT: Which embedded web server do you use?
EDIT2: Went with Mongoose, crazy easy to implement o.0
(This post was last modified: 06-01-2011 03:39 AM by andargor.)
06-01-2011 02:46 AM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #36
RE: Gui library
embedded web server? why would i need one? browser accesses stuff from disk just fine for the gui ;] And implementing this would let you access files even from pak :] http://code.google.com/p/berkelium-sharp...mpl.cpp#91
(This post was last modified: 06-01-2011 07:55 AM by rndbit.)
06-01-2011 07:54 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #37
RE: Gui library
I want an embedded web browser because some browser security features interfere with javascript/jquery when dealing with local files, and I like to design web stuff using tools like firebug, which I can now do live outside the application while it's running (and see the immediate result). I will see if I can control the application that way (which would be nice with a dual screen environment).

In any case it was ridiculously easy to implement (4-5 lines of code, literally) and it's 40KB... So now I have it.

Thanks for the link, I knew custom protocols could be implemented, but examples are always good.
(This post was last modified: 06-01-2011 04:29 PM by andargor.)
06-01-2011 04:27 PM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #38
RE: Gui library
glad you did it smile im not sure what interference you have in mind tho. so far i had no browser interference with my work on local files.
06-02-2011 05:52 AM
Find all posts by this user Quote this message in a reply
andargor Offline
Member

Post: #39
RE: Gui library
(06-02-2011 05:52 AM)rndbit Wrote:  glad you did it smile im not sure what interference you have in mind tho. so far i had no browser interference with my work on local files.

You might not have any need for it, but for example cross-domain scripting is normally blocked for local files (URI file:///). So if you were to fetch a block of html with javascript from some other site, it won't work from static local files. Well, unless you disable the security features of the browser and I'm not sure how Berkelium handles that. In any case, the normal way is to use a local web server.

An example of fetching external content is "content syndication", where you would get a news feed from somewhere, and show it in game. Or a player list for multi-player, leader boards, e-store content, whatever, from an external website.
(This post was last modified: 06-02-2011 03:54 PM by andargor.)
06-02-2011 03:52 PM
Find all posts by this user Quote this message in a reply
rndbit Offline
Member

Post: #40
RE: Gui library
few hours after asking my last question i faced exactly that. i personally needed local file to load another local file via ajax. well im not comfortable with running webserver via GUI. yesterday i recompiled chromium with some of security checks disabled to allow loading local files via ajax. will see how that works today
06-03-2011 07:49 AM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Member

Post: #41
RE: Gui library
fyi, I worked a bit more on the code mentioned here and made an extended gui element from it. It's posted in the code snippets topic, which seemed a better place for this.
09-14-2011 01:17 PM
Find all posts by this user Quote this message in a reply
Post Reply