PiRSquared17 / gccv2

Automatically exported from code.google.com/p/gccv2
0 stars 0 forks source link

Flicker effect of Menu (solved by me) #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hello sorry for my english but i'm italian. I solved a bug related to the 
annoying flicker effect of the menu when scrolling. To solve the problem must 
override in the MenuPage.cs this method

protected override void OnPaintBackground(PaintEventArgs e)
        {

        }

and change OnPaint method in this way (first draw all components in a bitmap 
image and only last draw into e.Graphics ;) )

  protected override void OnPaint(PaintEventArgs e)
        {
            bWidth = this.Width / 3;
            bHeigh = bWidth / 2;
            GridHeigh = bHeigh * 3 / 2;

            if (Form1.gps.OpenedOrSuspended)
                mBAr[(int)BFkt.gps_toggle] = mBGpsOn;
            else
                mBAr[(int)BFkt.gps_toggle] = mBGpsOff;
            SolidBrush br = new SolidBrush(this.ForeColor);

            Bitmap temp = new Bitmap(this.Width, this.Height);
            Graphics graphics = Graphics.FromImage(temp);
            graphics.Clear(this.BackColor);

            for (int i = so; i <= (int)BFkt.endOfMenuPage; i++)
            {
                int ix = (i - so) % 3; int iy = (i - so) / 3;
                if ((2 * iy + 1) * GridHeigh > 2 * Size.Height)            //show minimum half
                    break;                              // not enough room for a complete button
                Rectangle dest_rect = new Rectangle(bWidth * ix, GridHeigh * iy + mouseDrag, bWidth, bHeigh);
                Bitmap bm = (i == i_p) ? mBAr[i].icon_p : mBAr[i].icon;
                graphics.DrawImage(bm, dest_rect, new Rectangle(0, 0, mBAr[i].icon.Width, mBAr[i].icon.Height), GraphicsUnit.Pixel);
                SizeF Tsize = e.Graphics.MeasureString(mBAr[i].text, this.Font);
                graphics.DrawString(mBAr[i].text, this.Font, br, bWidth * ix + (bWidth - Tsize.Width) / 2, GridHeigh * iy + bHeigh + mouseDrag);
                lastDisplayed = i;
            }

            e.Graphics.Clear(this.BackColor);

            if (!Form1.isLandscape)
            {
                Rectangle cliprec = e.ClipRectangle;
                cliprec.Height = cliprec.Height * 31 / 32;      //create a black separator between mPage buttons and standard buttons on bottom
                e.Graphics.Clip = new System.Drawing.Region(cliprec);
            }

            e.Graphics.DrawImage(temp,0,0);
            temp.Dispose();

            base.OnPaint(e);
        }

And i advice to use

        public bool DownPossible
        {
            get { return so <= (int)BFkt.endOfMenuPage - 15; }
        }

to don't scroll menu over the necessary (all tested on my Htc Touch HD, WM6.5)

I hope you change this code in next version of this fantastic program =) if you 
want a nickname to thanks in the changelog version to the person that solved 
bug my nickname is 'dokkis', if you don't mention my nickname isn't a problem!
when i've a bit of time i try to solve the other flicker problem =)

goodbye to all =)

Original issue reported on code.google.com by dokkis1...@gmail.com on 3 Sep 2011 at 7:25

GoogleCodeExporter commented 9 years ago
in the same way i've modify picturebutton and pictureselectionbutton and the 
flicker effect seems doesn't appear never.
Therefore i wanted the map redrawing when moving (the redraw happens only when 
i release the finger) then i've modify the form1 removing MouseMoving variable 
and all related references and the map now refresh when moving =)
and i've inverted button on and off of gps in main view because (imho) when gps 
is off the button should be appear on to indicate that if i pressed the button 
i turn gps on ^^

Original comment by dokkis1...@gmail.com on 4 Sep 2011 at 10:03

GoogleCodeExporter commented 9 years ago
to try the difference i attach the cab of modified gcc (see the difference in 
scrolling menu and map, and i've inverted button on\off of gps in first view)

Original comment by dokkis1...@gmail.com on 4 Sep 2011 at 10:52

Attachments:

GoogleCodeExporter commented 9 years ago
Hi dokkis,
I have introduced your improvements regarding flicker (thank you) and some 
further small improvements. Also I payed attention that it works on other 
screens (your change -15 instead of -9).
For map redraw while moving: I think I make an option or I leave it. On my 
device,  which is not so powerful, it is a bit awful.
Regarding GPS of or on, I thought about thoroughly when designing it. And I 
decided to look at it as a current status indicator rather than what the button 
will do if pressed. Thousands of users are using it that way and I can not 
change it and I don't want to. If you like it the other way, you can change the 
button images without modifying the code (and loosing it on update). See 
readme.htm chapter 12. Custom button skins.
Klaus

Original comment by kmb...@gmx.de on 4 Sep 2011 at 6:59

GoogleCodeExporter commented 9 years ago
hi! i'm happy that this program is actually in developed mode and i'm happy 
that i help to little improve it =) In my screen -15 works but i don't know if 
there is a difference with other screen! For map redraw i thinked that in less 
powered phone it slow the map scrolling (then is good implement option for this 
feature, disabled for default). For the GPS on\off i will change the name of 
files, this isn't a problem :D
in the next release (that will be released in date?) all of this bug fix and 
feature will be in?
thanks for the attention =)
bye

Original comment by dokkis1...@gmail.com on 5 Sep 2011 at 8:40

GoogleCodeExporter commented 9 years ago
Hi dokkis,
a new beta release is available with reduced flicker:
http://forum.xda-developers.com/showpost.php?p=17415507&postcount=1560
Klaus

Original comment by kmb...@gmx.de on 11 Sep 2011 at 8:59