It is currently Thu Jun 20, 2013 5:46 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Fred or Freak: Smooth IDE resize
PostPosted: Sat Feb 25, 2012 6:25 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
Ok, so what's the trick? The PB IDE resizes without flickering the main text window.

JaPBe flickers horribly when resizing. (Almost beyond flicker, to just blank off.)
EPB is even worse.

I wrote a simple IDE with tabs and 2 splitters formatted just like the PB IDE, and while not nearly as bad as JaPBe, the main text window still flickers. The flicker is gray, but the text disappears. I debugged all of the events going on, and I don't have any calls other than getting windowheight (etc) and resizing the gadgets.

Is it the Scintila restyle? Even that is called very infrequently compared to the window resize...but can it be temporarily disabled until the resize is finished?

...and while I am asking about this topic, is there a place to reference the values of all #SCI_ constants?

Thanks.


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Sat Feb 25, 2012 8:02 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5184
Location: Germany
The IDE does not use a SplitterGadget on the main window on Windows. It uses the mouse messages directly to implement the draging.

_________________
Perl – The only language that looks the same before and after RSA encryption.
-- Keith Bostic


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Sat Feb 25, 2012 8:51 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
Ok, thanks. Is it written in PB?

Does that mean you have many CompilerIfs (or IfDef's) for the OS?


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Sun Feb 26, 2012 9:47 pm 
Offline
Addict
Addict

Joined: Sun Dec 12, 2010 12:36 am
Posts: 1309
Location: Waterloo, WI - USA
I think the bigger tell here might also be the IDE uses a Scintilla text box as well.. Maybe it has its own routines to handle the redraw or something? Or maybe you're using that already...

Either way, I think the forums are littered with thread after thread about GUI/Window resizing, how to get it flicker free, and stuff like that.. I don't know if it has to be ownerdrawn but I think I've seen that term mentioned a lot.

Maybe a forum search will help you get more info.


All I know is, ProGUI is a lot better about that. I don't think I've ever seen it flicker :mrgreen: (but not saying it doesn't)

_________________
Image


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Mon Feb 27, 2012 2:29 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Dec 23, 2009 3:26 pm
Posts: 130
SmartWindowRefresh(0,1)

_________________
poor English...

PureBasic & Delphi & VBA


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Mon Feb 27, 2012 10:52 pm 
Offline
User
User
User avatar

Joined: Wed Nov 18, 2009 11:18 pm
Posts: 25
There is one old trick to avoid flickering of scintilla control (ScintillaGadget).
Just add to main window flag #WS_CLIPCHILDREN like this:
Code:
;scintilla control in editor app
#SCI_STYLESETFORE = 2051
#SCI_SETTEXT = 2181
Define win.i
win = 1
Define hsci.i
Define htext.s
htext = "This is a simple Scintilla with text..."
hsci=1
Define winstyle
winstyle = (#PB_Window_SystemMenu|#PB_Window_SizeGadget |#PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget|#WS_CLIPCHILDREN)

  OpenWindow(win,100, 100, 640, 480, "Scintilla Control",winstyle )
     If InitScintilla()
        hsci=ScintillaGadget(win, 10, 52, 600, 400, #Null )
       
        ; front set color
        SendMessage_(hsci, #SCI_STYLESETFORE, 0, RGB(0, 0, 0))
       
        SendMessage_(hsci,#SCI_STYLESETBACK,32,RGB(249,248,218))
       
        SendMessage_(hsci,#SCI_STYLECLEARALL, 0, 1)
       
        scifontsize.i = 9
         For i = 0 To 12
           SendMessage_(hsci,#SCI_STYLESETFONT, i, "Courier New")
         SendMessage_(hsci,#SCI_STYLESETSIZE, i, scifontsize)
         Next i
;set number margin (For numnbers)
SendMessage_(hsci, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
SendMessage_(hsci, #SCI_SETMARGINWIDTHN, 0, 46)
;set color of caret line
SendMessage_ (hsci,#SCI_SETCARETLINEBACK,RGB(225,225,245),0)
;Set caret line visible
SendMessage_ (hsci,#SCI_SETCARETLINEVISIBLE,1,0)
        ;test
        SendMessage_(hsci, #SCI_SETTEXT, 100, htext)
       
       
       
     EndIf
     
     Repeat
       wmsg=WaitWindowEvent()
       
       Select wmsg
           
        Case #WM_SIZE   
           winW = WindowWidth(win)
           winH = WindowHeight(win)
           ResizeGadget(1, 10, 52, (winW-20), (winH-64))
         
       EndSelect
       
       
     Until wmsg = #WM_CLOSE
 


And work fine without flickering :wink:


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Mon Feb 27, 2012 11:51 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 13, 2007 12:42 pm
Posts: 1307
Location: Manchester, UK
And another Windows only method that feels wrong when resizing, but definitely removes all flickering (by removing all the updates until the resize has finished):
Code:
Procedure ResizeGadgets()
  ResizeGadget(4, 0, 0, WindowWidth(0), WindowHeight(0))
EndProcedure


Procedure WndProc(hwnd, uMsg, wParam, lParam)
  Protected result = #PB_ProcessPureBasicEvents
 
  If uMsg = #WM_EXITSIZEMOVE
    ResizeGadgets()
  EndIf
 
  ProcedureReturn result
EndProcedure

ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
  ;
  ; The ProcedureDLL declaration is important for the callback to work correctly on MacOSX,
  ; on all other OS it has no effect.
  ;
EndProcedure

InitScintilla()


OpenWindow(0, 0, 0, 500, 500, "Resize Test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_WindowCentered)
ScintillaGadget(0, 0, 0, 0, 0, @ScintillaCallBack())
ScintillaGadget(1, 0, 0, 0, 0, @ScintillaCallBack())
SplitterGadget(2, 0, 0, 0, 0, 0, 1, #PB_Splitter_Separator | #PB_Splitter_Vertical    )
ScintillaGadget(3, 0, 0, 0, 0, @ScintillaCallBack())
SplitterGadget(4, 0, 0, 500, 500, 2, 3, #PB_Splitter_Separator )

SetWindowCallback(@WndProc(), 0)

Repeat
  Event  = WaitWindowEvent()
 
  Select Event
    Case #PB_Event_MaximizeWindow, #PB_Event_RestoreWindow
      ResizeGadgets()
     
    Case #PB_Event_CloseWindow
      Define Quit = 1
  EndSelect
 
Until Quit = 1


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Tue Feb 28, 2012 1:33 am 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
Foz--thanks for the sample; I've saved it for later reference, although it is not suitable for this app.

Aston--with your short sample, the flickering was not noticeable at all. Since mine has a couple splitters, though, it did make a difference--but not without its own artifacts, leaving a trail of scrollbars. With this trick, it appears there are slightly fewer artifacts (or they disappear sooner) in Scintilla gadget if it is positioned on the top/left, like the PB IDE has. I prefer the Proc and Var list on the left, though, because it allows for smaller mouse moves. I just might replace the splitter with direct manipulation, as Freak mentioned. (When I have time to kill.)

Thanks a lot!


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Thu Mar 01, 2012 11:08 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 239
Location: Russia
The editor, without flicker.
http://www.mediafire.com/?jdt7pr5ptd18g3q

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Thu Mar 01, 2012 7:48 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
I just ran your exe (have not yet installed the xp library), but it is way smoother than even the PB IDE. Very nice. I will have to dig into the code to see if your tricks are win-only...and make sure it is not because it is just very few features.

Unfortunately, the comments are kind of difficult to read. In PB's IDE, they are all vowels...
; Èäåíòèôèêàòîð ðåäàêòîðà ðåäàêòîðà

Anyway, I will figure it out. Thank you very much!


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Thu Mar 01, 2012 8:57 pm 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
Foz wrote:
And another Windows only method that feels wrong when resizing, but definitely removes all flickering (by removing all the updates until the resize has finished):... (CODE CUT)

Foz,
I just had an idea that expanded upon yours, and it works reasonably well. (I still haven't dissected the Russian code.) Instead of redrawing on every event (one extreme), or waiting for only a single redraw (the other extreme), it updates with a pre-set time delay. Instead of continual artifacts, you get stepped artifacts. Kind of a compromise that allows precise resizing yet reduces smearingartifacts. It does require a Case #WM_EXITSIZEMOVE, to accommodate for resizes between the time-outs.

With my 4-year old dual core laptop, with the delay at 100ms, I skip over 3-10 redraw calls, depending upon how fast I move the mouse and how large the window is on my 26" monitor.

If I can't get a good cross-platform solution from the Russian code, I will leave this in.

Code:
             Case #WM_EXITSIZEMOVE
                     maximized = 0
                     windowW = WindowWidth(#WIN1)
                     windowH = WindowHeight(#WIN1)         ;for saving in Prefs.
                     If GetWindowState(#WIN1) = #PB_Window_Maximize
                        maximized = 1
                     EndIf
                     ResizeGadget(#SPLITTER_Left,0,ToolBarHgt,windowW, windowH-ToolBarHgt-StatusBarHeight(#STAT1) - MenuHeight())
                     timeResizeLast = ElapsedMilliseconds()
                     Debug "ExitSizeMove " + Str(ResizeCounter)
                     ResizeCounter = 0
          
          
            Case #PB_Event_SizeWindow
                  timeResizeNow = ElapsedMilliseconds()
                  If timeResizeNow > timeResizeLast + #RESIZEDELAY      ; 100ms is a good delay
                     maximized = 0
                     windowW = WindowWidth(#WIN1)
                     windowH = WindowHeight(#WIN1)         ;for saving in Prefs.
                     If GetWindowState(#WIN1) = #PB_Window_Maximize
                        maximized = 1
                     EndIf
                     ResizeGadget(#SPLITTER_Left,0,ToolBarHgt,windowW, windowH-ToolBarHgt-StatusBarHeight(#STAT1) - MenuHeight())
                     timeResizeLast = ElapsedMilliseconds()
                     Debug ResizeCounter
                     ResizeCounter = 0
                  Else
                     ResizeCounter + 1
                  EndIf


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Thu Mar 01, 2012 9:09 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 1291
Tenaja wrote:
I just ran your exe (have not yet installed the xp library), [...]

Be careful, a friend told me that User_Russian's pbTorrent could possibly contain a Trojan. It loads another .EXE by HTTP GET.

Be smart and do not run any .EXE from User_Russian on your main desktop.
Just look at the source code and if you still want to test the executable, run it within a protected environment.

Just a warning, be careful.


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Fri Mar 02, 2012 3:20 am 
Offline
Addict
Addict

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 808
Turns out a call to this macro after every resize gets rid of the scroll-bar smearing artifacts--with it, the window even looks nicer than the PB IDE. (Too bad it is not cross-platform.)
Code:
Macro RedrawWindow()
   CompilerIf #PB_Compiler_OS = #PB_OS_Windows
      RedrawWindow_(WindowID(#WIN1), 0, 0, #RDW_UPDATENOW)
   CompilerEndIf
EndMacro


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Fri Mar 02, 2012 9:59 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 239
Location: Russia
Danilo wrote:
Tenaja wrote:
I just ran your exe (have not yet installed the xp library), [...]

Be careful, a friend told me that User_Russian's pbTorrent could possibly contain a Trojan. It loads another .EXE by HTTP GET.
In the torrent client is not malware, which cause harm to your computer or download other Trojan programs on the computer.
I've never created a virus and is not going to do it.

You can check pbTorrent, on the site. www.virustotal.com

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
 
 Post subject: Re: Fred or Freak: Smooth IDE resize
PostPosted: Fri Mar 02, 2012 3:00 pm 
Offline
Always Here
Always Here
User avatar

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7304
Location: Norway
The panel gadget flickers alot, so if you use that for the tabs you will get flicker.

_________________
Woa, I set up a web server.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: marroh and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye