[Solved] SplitterGadget redraw issue

Just starting out? Need help? Post your questions and find answers here.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

[Solved] SplitterGadget redraw issue

Post by Dude »

I've got a ListIconGadget (top) and EditorGadget (bottom) that are separated with a SplitterGadget in the middle. Whenever I drag the splitter up, I get a whole bunch of lines briefly shown, which shouldn't be there. They disappear after I release the mouse. See the below image to see what I mean. How can I stop these lines showing?

I tried SmartWindowRefresh() but it didn't help. I can't post the code, but I did try a standalone snippet to try to reproduce it, but I can't -- so it must be something in my event loop but I can't figure out what. So, has anyone experienced this before and if so, what did you discover was causing it? Thanks.

PS. Yes, I have the latest video drivers for my PC. ;)

Image

Here is the standalone snippet which does NOT show the lines, but it's pretty much the same as my problem code. That's why I can't work out why it's glitching with redraw lines. :(

Code: Select all

If OpenWindow(0, 0, 0, 700, 630, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  #Button1  = 0
  #Button2  = 1
  #Splitter = 2

  ListIconGadget(#Button1, 0, 0, 0, 0, "", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
  AddGadgetColumn(#Button1, 1, "", 550)
  For i=0 To 50
    AddGadgetItem(#Button1,-1,Str(i)+#LF$+Str(i))
  Next

  EditorGadget(#Button2, 0, 0, 0, 0, #PB_Editor_ReadOnly)
  SetGadgetAttribute(#Button2,#PB_Editor_WordWrap,1)
  a$=GetHomeDirectory()+" "
  For i=0 To 100
    t$+a$
  Next
  SetGadgetText(#Button2, t$)

  SplitterGadget(#Splitter, 5, 5, 680, 620, #Button1, #Button2, #PB_Splitter_Separator)

  StickyWindow(0, #True)

  Repeat
  Until WaitWindowEvent(1) = #PB_Event_CloseWindow

EndIf
Last edited by Dude on Sat Sep 02, 2017 8:36 am, edited 1 time in total.
infratec
Always Here
Always Here
Posts: 7589
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: SplitterGadget redraw issue

Post by infratec »

Hi,

works without problems:

PB 5.50 x86 on Win10 x64

Bernd
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: SplitterGadget redraw issue

Post by Dude »

Thanks, but you misread my post. The snippet above was just to show what I was doing. It was NOT showing the problem. But in my production app, which uses code just like the above, the problem DOES occur. So, it doesn't make sense and I was wondering if anyone had any clues as to why.

I even ripped out the actual event code from my production app and ran it as a standalone window, and the problem did NOT occur then, either. It's a mystery! :shock:
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: SplitterGadget redraw issue

Post by firace »

Does your production app use different fonts, or a more complex gadget layout perhaps?
If it's not confidential, can we see a screenshot?

Do you also get the issue with "modern XP theme support" disabled?
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: SplitterGadget redraw issue

Post by Dude »

Hi firace. Disabling "modern XP theme support" fixed the issue! But I can't do that. :(

The interface is just as in that little screenshot: a ListIconGadget, SplitterGadget, and EditorGadget. They have colored backgrounds and a custom font each, but removing those attributes didn't fix it. Only disabling modern XP theme fixed it.

But it's weird that when run as a standalone exe, the redraw is normal. Maybe something else running in the production app is slowing the events down (the app uses threads). I'll keep playing with it.
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: SplitterGadget redraw issue

Post by firace »

Do the ghost lines appear inside the editorgadget or listicongadget?
Also, do the listicon and editor gadgets in the production code hold much more data?
If you manage to reproduce the bug in your sample code I might be able to help further.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: SplitterGadget redraw issue

Post by Dude »

Now I have a similar problem again, but this time with PanelGadgets. :(

When I add a PanelGadget to my window, and resize the window vertically DOWN in any way, I get the resize glitch lines shown in the screenshot below. Dragging the window UP vertically doesn't show them. If I remove the PanelGadget, no lines appear when dragging down, so the PanelGadget is the only change to my code. Disabling modern XP theme doesn't help and the lines still appear; also in a final exe build when not run from the IDE.

I'm using SmartWindowRefresh() to reduce the problem, because without it, the entire PanelGadget DISAPPEARS from my window while dragging, instead of just showing the flickering lines. So I "prefer" the lines but would ideally like them gone, too.

Again, let me stress: the lines ONLY appear when the window has the PanelGadget added with the gadgets on it; without the PanelGadget and my gadgets on the window itself = no lines. Showing example code isn't going to help in any way, because the only code difference is putting PanelGadget() before the other gadgets, and CloseGadgetList() at the end of the other gadgets.

Using PureBasic 5.60 (x86) on Windows 7 (64-bit) with latest graphics drivers.

Image
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: SplitterGadget redraw issue

Post by PureLust »

Looks like a redrawing-Problem with overlapping Gadgets to me.

Do you have Gadgets overlapping other Gadgets?
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: SplitterGadget redraw issue

Post by Dude »

No, nothing is overlapped.

Here's some code ripped from my source (text edited for privacy):

Code: Select all

panel=PanelGadget(#panel,10,8,700,400)
AddGadgetItem(#panel,-1,"Stuff",Catch_Img_Stuff)
button=ButtonGadget(#button,9,8,25,25,"Button")
CloseGadgetList()
If I delete everything except the ButtonGadget() line (remove the PanelGadget completely), then there's no flickering anymore! That's literally the only difference in my code. I haven't changed anything else. It seems that just putting my gadgets on the panel is causing the flickering.

Side-note: The flickering also occurs on Win 10 in VirtualBox.
Last edited by Dude on Sat Sep 02, 2017 2:19 am, edited 1 time in total.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget redraw issue

Post by RASHAD »

This problem caused by the grid lines of the ListIcon
It had been discussed before
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: SplitterGadget redraw issue

Post by Dude »

RASHAD wrote:This problem caused by the grid lines of the ListIcon
But my ListIconGadget() doesn't have gridlines. The repeated lines (the flicker) is from the horizontal scrollbar of the ListIconGadget().

And why does putting the ListIconGadget() on a PanelGadget() create the problem?

[Edit] I just found out it's to do with the SplitterGadget() in my app, because if remove that, the flicker goes away. Hmm.
Last edited by Dude on Sat Sep 02, 2017 2:36 am, edited 1 time in total.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget redraw issue

Post by RASHAD »

You said it is OK when you disabled XP themes
Disable the theme for the gadgets one at a time to isolate the problem
Then we will see what we can do
BTW your example has listicon gridlines

Code: Select all

SetWindowTheme_(GadgetID(#Gadget), @null.w, @null.w)
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: SplitterGadget redraw issue

Post by Dude »

RASHAD wrote:You said it is OK when you disabled XP themes
...
BTW your example has listicon gridlines
Sorry Rashad, I'm talking about a new problem; not the code posted above with the gridlined listicon. I really should have started a new thread but since it was related, I didn't. That's why I said "Now I have a similar problem again, but this time with PanelGadgets."

I discovered it's to do with the SplitterGadget. I removed it, and the flickering goes away. When I put it back, the flickering occurs. But I sort-of solved it by using LockWindowUpdate_(#splitter) in my resize callback code, then setting that back to 0 after the resize is done. That removes the flickering but doesn't redraw the splitter and listicons for about 20 ms. It's a good-enough compromise for now, as my app isn't one that gets resized often. I just wanted it to look nice when the user did choose to resize it, without seeing repeated redraw lines.

Everything worked fine and redrew properly before I put everything on the new PanelGadget, though. :( Maybe panels and splitters don't work well together. I'll try to make some reproducible code to show it.
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: SplitterGadget redraw issue

Post by PureLust »

Hmmm ... strange. :?

Maybe my DeFlicker-Module can help.

It's not designed to fix this kind of redrawing-issues, but to test it, you only have to add two lines of code, so maybe it's worth a try.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget redraw issue

Post by RASHAD »

Hi Dude
Try

Code: Select all

Procedure splitterCB()
  InvalidateRect_(WindowID(#Window),0,1)
EndProcedure
.
.
.
BindGadgetEvent(2,@splitterCB())
Egypt my love
Post Reply