CHDK - virtual keyboard - testers needed! - page 14 - General Discussion and Assistance - CHDK Forum

CHDK - virtual keyboard - testers needed!

  • 150 Replies
  • 48226 Views
Re: CHDK - virtual keyboard - testers needed!
« Reply #130 on: 27 / January / 2012, 15:52:14 »
Advertisements
I've modified layout a little - groups are arranged to mimic position of the keyboard (the same thing that Tobi done before, but with new charmaps it's simpler).

To do so I moved variable 'w' to global static. It should be renamed to tbox_width or something like this, but I had no time to do so (searching for string 'w' in whole code is not user-friendly :D).

Most changes are here:

Code: (c) [Select]
else if ( Mode == 'K' )
        {
            // draw keyboard
            char ch;
            color cl;
            int offs;

            // clean previous symbols line

            int pline = (line == 0)?lines:line-1;
            offs=(camera_screen.width - w*FONT_WIDTH)>>1;
            draw_filled_rect(offs, tbox_buttons_y, offs+(w-1)*FONT_WIDTH, tbox_buttons_y+3*FONT_HEIGHT, cl_greygrey);

            // draw current symbols line
            int x, group;

            for (x = offs, group = 0; group < 4; group++)
            {
                char *tstr = map_chars(line,group);

                int y=tbox_buttons_y;

                switch (group) {
                    case 0:
                        x=offs+FONT_WIDTH;
                        y=tbox_buttons_y+FONT_HEIGHT;
                        break;
                    case 1:
                        x=offs+((w*FONT_WIDTH-strlen(map_chars(line,group))*FONT_WIDTH)>>1);
                        y=tbox_buttons_y;
                        break;
                    case 2:
                        x=offs+(w-strlen(map_chars(line,group))-1)*FONT_WIDTH;
                        y=tbox_buttons_y+FONT_HEIGHT;
                        break;
                    case 3:
                        x=offs+((w*FONT_WIDTH-strlen(map_chars(line,group))*FONT_WIDTH)>>1);
                        y=tbox_buttons_y+2*FONT_HEIGHT;
                        break;
                }

                for(i = 0; tstr[i] != '\0'; i++, x += FONT_WIDTH) {
                    ch = tstr[i];

                    if ( (i != curchar) || (group != curgroup) )
                        cl = MAKE_COLOR(COLOR_GREY, COLOR_WHITE);
                    else if ( ch != ' ' )
                        cl = MAKE_COLOR(COLOR_GREY, COLOR_RED);
                    else
                        cl = MAKE_COLOR(COLOR_RED,COLOR_GREY);    // "space" is special color case (inverted)

                    draw_char(x, y, ch, cl);
                }

            }
           
        }

Now I'll do some code cleanup.


EDIT:

Although map_line_len() is used many times it seems to be useless now and could be replaced with 'w' or maybe 'w-1'...
« Last Edit: 27 / January / 2012, 16:11:00 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK - virtual keyboard - testers needed!
« Reply #131 on: 27 / January / 2012, 16:39:11 »
I've modified layout a little - groups are arranged to mimic position of the keyboard (the same thing that Tobi done before, but with new charmaps it's simpler).

To do so I moved variable 'w' to global static. It should be renamed to tbox_width or something like this, but I had no time to do so (searching for string 'w' in whole code is not user-friendly :D).


Nice.

I've added this to the tbox_test branch, renamed the 'w' variable and adjusted the layout slightly (to bring the left and right string closer to the center).

If there are no problems I will move all the tbox_test changes to the main trunk.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: CHDK - virtual keyboard - testers needed!
« Reply #132 on: 27 / January / 2012, 16:51:04 »
If you could wait for a while I'll post a little bit cleaned code with less variables ;) Some of them are really useless if code is a little rearanged.
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - virtual keyboard - testers needed!
« Reply #133 on: 27 / January / 2012, 18:00:26 »
It was a longer while... I accidentally broke something and had to find the bug :D

Ok, I have new version. tbox_charmap_init() and map_line_len() are removed. All the things they used to do have been taken by others and it seems to be more natural to me.

Note line 142 and resulting useless 122. Is this ok? Or maybe lines counting can be done simpler way?

Althought I have tested this version very closely I'm not sure that nothing was broken...

PS. Forgive me that I didn't follow your changes, I had to fight with the layout and it was not easy to me:D I didn't want to have more mess ;)
« Last Edit: 27 / January / 2012, 18:11:35 by outslider »
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick


*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: CHDK - virtual keyboard - testers needed!
« Reply #134 on: 27 / January / 2012, 21:01:34 »
It was a longer while... I accidentally broke something and had to find the bug :D

Ok, I have new version. tbox_charmap_init() and map_line_len() are removed. All the things they used to do have been taken by others and it seems to be more natural to me.

Note line 142 and resulting useless 122. Is this ok? Or maybe lines counting can be done simpler way?

Althought I have tested this version very closely I'm not sure that nothing was broken...

PS. Forgive me that I didn't follow your changes, I had to fight with the layout and it was not easy to me:D I didn't want to have more mess ;)

Looks good, I'm going to merge this and the rest of the text box stuff from the tbox_test branch back to the main trunk.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: CHDK - virtual keyboard - testers needed!
« Reply #135 on: 31 / January / 2012, 06:23:49 »
I've seen your changes, it looks very good.
I think it should be merged into trunk.

Re: CHDK - virtual keyboard - testers needed!
« Reply #136 on: 31 / January / 2012, 06:35:54 »
It has already been merged :) Since #1616:

http://trac.assembla.com/chdk/changeset/1616

Of course only in unstable release, not 1.0.
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

Re: CHDK - virtual keyboard - testers needed!
« Reply #137 on: 31 / January / 2012, 06:50:42 »
Oh, I've only seen it in tbox_test branch :)
Thanks


Re: CHDK - virtual keyboard - testers needed!
« Reply #138 on: 28 / February / 2012, 12:20:24 »
Hi,
The last post is long ago but now i have new ideas.
I think we should implement a "flags" feature like the tbox button flags but for the input type.
So we could make flags for normal text (all buttons), numbers (only Numbers and dot) and filenames (only in filenames allowed chars)

Please reply if you think that that is really bad, otherwise I try to implement it.  :D

Re: CHDK - virtual keyboard - testers needed!
« Reply #139 on: 28 / February / 2012, 13:14:02 »
It was sugested somewhere before and I think it's good idea. This will avoid safe checks with each user entered text. But is it possible to do this not breaking compatibility with previous version?

If there's no such possibility I'm still for it, but the best would be to have back compatibility :)
if (2*b || !2*b) {
    cout<<question
}

Compile error: poor Yorick

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal