Fred or Freak: Smooth IDE resize
Fred or Freak: Smooth IDE resize
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.
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.
Re: Fred or Freak: Smooth IDE resize
The IDE does not use a SplitterGadget on the main window on Windows. It uses the mouse messages directly to implement the draging.
quidquid Latine dictum sit altum videtur
Re: Fred or Freak: Smooth IDE resize
Ok, thanks. Is it written in PB?
Does that mean you have many CompilerIfs (or IfDef's) for the OS?
Does that mean you have many CompilerIfs (or IfDef's) for the OS?
-
- Addict
- Posts: 1675
- Joined: Sun Dec 12, 2010 12:36 am
- Location: Somewhere in the midwest
- Contact:
Re: Fred or Freak: Smooth IDE resize
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
(but not saying it doesn't)
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

Re: Fred or Freak: Smooth IDE resize
SmartWindowRefresh(0,1)
poor English...
PureBasic & Delphi & VBA
PureBasic & Delphi & VBA
Re: Fred or Freak: Smooth IDE resize
There is one old trick to avoid flickering of scintilla control (ScintillaGadget).
Just add to main window flag #WS_CLIPCHILDREN like this:
And work fine without flickering 
Just add to main window flag #WS_CLIPCHILDREN like this:
Code: Select all
;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

Re: Fred or Freak: Smooth IDE resize
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: Select all
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
Re: Fred or Freak: Smooth IDE resize
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!
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!
-
- Addict
- Posts: 1518
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: Fred or Freak: Smooth IDE resize
The editor, without flicker.
http://www.mediafire.com/?jdt7pr5ptd18g3q
http://www.mediafire.com/?jdt7pr5ptd18g3q
Re: Fred or Freak: Smooth IDE resize
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!
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!
Re: Fred or Freak: Smooth IDE resize
Foz,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)
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: Select all
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
Re: Fred or Freak: Smooth IDE resize
Be careful, a friend told me that User_Russian's pbTorrent could possibly contain a Trojan. It loads another .EXE by HTTP GET.Tenaja wrote:I just ran your exe (have not yet installed the xp library), [...]
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.
Re: Fred or Freak: Smooth IDE resize
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: Select all
Macro RedrawWindow()
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
RedrawWindow_(WindowID(#WIN1), 0, 0, #RDW_UPDATENOW)
CompilerEndIf
EndMacro
-
- Addict
- Posts: 1518
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Re: Fred or Freak: Smooth IDE resize
In the torrent client is not malware, which cause harm to your computer or download other Trojan programs on the computer.Danilo wrote:Be careful, a friend told me that User_Russian's pbTorrent could possibly contain a Trojan. It loads another .EXE by HTTP GET.Tenaja wrote:I just ran your exe (have not yet installed the xp library), [...]
I've never created a virus and is not going to do it.
You can check pbTorrent, on the site. www.virustotal.com
Re: Fred or Freak: Smooth IDE resize
The panel gadget flickers alot, so if you use that for the tabs you will get flicker.