• Welcome to TodayPlus Boards v2.
 

Update region problem

Started by alpax, November 11, 2003, 04:29:39 PM

Previous topic - Next topic

alpax

I'm trying to create my first simple skin, and need some help about the regions update.
The idea is to have a clock and resource meters and of course have them updated each several seconds.
The problem is that those gadgets are located inside another region with almost static data (date and calendar). So, I have one big region, which doesn't need to be updated periodically, and a couple of internal ones, with update time about 5 seconds:

...
region,1,0,-1
defregion,1,0,0,240,60,1
...
////Show digital clock (update every 5 seconds)
region,11,0,5
changefont,tahoma,16,b
time,130,17,-1,5,rs,,"HH:mm"
endregion,11,0
...
////Resource meters
region,13,0,5
//defregion,13,0,32,150,27,1
changefont,tahoma,11,

////Memory details
draw,roundrect,2,32,60,11,-1_6_-1,h
memory,barused,3,33,58,9,gradient_green-red gradient.png
...
endregion,13,0

offsetadd,0,60
endregion,1,0

If I have the "defregion,13,0,..." line commented out, the internal regions 11&13 do not get updated periodically. If I'm enabling that "defregion", my region #13 just disappears in 5 seconds and never comes back (maybe I have to use another ID instead of the darned 13? :))

I've found that adding an update interval to the whole region #1 (region,1,0,5) solves the problem with region #13, but another static internal region #12 (region,12,0,-1) starts desappearing, so I have to set an update interval for it too. I don't like this because the extra updates for a static info just eat resources without any real job.

So, can someone clarify please, how to define "automatically updatable" nested regions correctly?

alpax

Any thought guys?
I don't believe nobody except me has faced this!

srs

sorry, didn't notice this before

the way things work now (I want to rewrite this code to make thinks more flexable) is that the defregions contorl which areas of the screen are cleared  during updates.

so region 13 has a defregion with associated coordinates and an update interval of 5.  what happes is that every 5 seconds the region defined by the defregion is cleared (because region 13 needs to be updated), and then the skin is parsed.  The important thing here is that the region is cleared before the skin is parsed.  At the time I wrote this part of the code, it seemed to make sense but as more features got added, this way of handling updates turns out to be a bad idea.  Ideally the region should be cleared when the region is encountered in the skin, but this will require some relatively major code changes.

anyways, everything is fine so far, we've cleared the area associated with region 13, and region 13 is marked for updating.  This is where the problem occurs.  The skin file is parsed, but since region 1 is not marked for update, that whole region is skipped (with region 13 being inside it).  The end result is that the area belonging to region 13 is cleared, but region 13 is not actually redrawn.

thats the (lengthy) explanation of whats going on, and here is a workaround:

define region 13 outside of region 1.  use an updateregions,13 command inside region 1 to make sure that region 13 gets updated whenever 1 is updated (make sure that region 13 is below region 1 in the skin file, since the skin is processed top -> bottom).  This method would leave no easy to switch "off" region 13 and region 1 together though, other than manually adding another button that also switches "off" region 13 whenever region 1 is switched "off".

another solution would be to not have one big defregion for region 1 but smaller ones for each internal region, and have an update interval for region 1 and for region 13.

let me know if anything didn't make sense as I typed this all out rather hastily, and if you need anything else explained.

alpax

Thank you for the explanation srs.
Now it's clear, I supposed something like this. Probably I'll just make them as separate regions.
The only question: why do I need to use updateregions,N even if the region N will have its own update interval?

BTW, I agree that a region should be better cleared right before its update. This looks more logical. Even if the region might be not get updated because the external region doesn't have an update interval, at least it won't disappear, and that's understandable.

arbitrajeu

Quote from: alpaxThe only question: why do I need to use updateregions,N even if the region N will have its own update interval?
This is because updates may not be in sync.  So, if you don't have updateregions,13 in your region 1, you would lose the region 13 whevener region 1 refreshes, as it clears the whole area (presuming you keep region 13 in the same place on the screen when you separate the code).  Region 13 would probably come back again when it's refresh interval triggers, I guess.

srs - thanks for explaining so many concepts in one reply.  I feel a Tips & Tricks or FAQ post coming on...
[size=14]arbitrajeu[/size]
[size=12]todayplus moderator[/size]
[size=10]
iPAQ 3970, Windows Mobile 2003, 256MB SD, AgendaFusion 5[/size]

alpax

Quote from: arbitrajeuThis is because updates may not be in sync.  So, if you don't have updateregions,13 in your region 1, you would lose the region 13 whevener region 1 refreshes, as it clears the whole area (presuming you keep region 13 in the same place on the screen when you separate the code).
I see, but I supposed if I'll make the regions separate, I have to place them so they do not intersect. Do you mean even separate (not nested) regions can be located at one place? Hmm, I have to try that...
Thanks for the reply!

alpax

I've just checked - didn't modify the region definitions a lot - just moved the internal ones (11,12,13) out of the region 1 in the skin file. Even though the independent regions are overlapped they are updated correctly.
Thank you guys!