View Poll Results: What do you think about my GUI's first demo?

Voters
7. You may not vote on this poll
  • It's great!

    1 14.29%
  • It's a good start.

    4 57.14%
  • It's ok...

    0 0%
  • It needs improvement inorder to be a good start...

    0 0%
  • Ditch it! Bad start...

    2 28.57%
Results 1 to 21 of 21

Thread: My GUI... check, optimization, hints...

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    My GUI... check, optimization, hints...

    Greetings fellow programmers... On Wed, Oct 2nd I started coding my GUI for my operating system. I did this every school day since then in my spare time in Period 3 of 4 (In my peer-tutoring class - I help Grade 10's program in Turing). Because I have to help people, I get about 30 mins a day...

    Stats about the GUI:
    - Compiled with the PowerC Compiler (email me for it)
    - Can handle a current MAX of 64 windows. (can be
    changed to whatever with 1 line)
    - Enables the user to move, select, deselect
    windows to make them active or what not.
    - 500 lines of C Code...
    - 2D engine allows clipped rectangles and pixels
    EVENTUALLY I WILL ADD A DOUBLE BUFFER TO REMOVE FLICKERING

    Controls(will change to mouse soon): Arrow keys to move the cursor (a pixel) and space bar to select windows for making active, once more to select to move, and once more to deselct. Currently I have tons of other squares and such drawn... the GUI itself is the group of 3 windows. Here is a search loop:

    Code:
    unsigned char inwhatwin(int x, int y)
    {
        unsigned int tz;
        unsigned char i;
    
        for (tz = 0; tz < MAXWINDOWS; tz++)
        {
            for (i = 0; i < MAXWINDOWS; i++)
            {
                if (wm_elements[i].zorder == tz)
                {
                    if (wm_elements[i].flags & WMFLAGS_ACTIVE)
                    {        
                        if ((x >= wm_elements[i].x) && (x < (wm_elements[i].x + wm_elements[i].width)))
                            if ((y >= wm_elements[i].y) && (y < (wm_elements[i].y + wm_elements[i].height)))
                                return i;
                    }
                }
            }
        }
    
        return 255;
    }
    That will start at the top(most visible) active window and search if (x,y) is in it. If not, it'll check the next top most, next top most, etc... wm_elements are the windows. MAXWINDOWS is 64. Returns the handle of the window that the (x,y) point is in of 255 if in none... All of my search and redraw loops look pretty much the same as that. I don't want to give out my actual source file...

    I am wondering if ANY one could optimize this loop to make it run faster.
    Attached Files Attached Files
    Designer/Programmer of the Comtech Operating System(CTOS)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width