Progress Bar vs. "lock screen"

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

PlaidFlannel
Posts: 38
Joined: Fri Aug 21, 2020 7:06 pm
Location: Denver, CO

Progress Bar vs. "lock screen"

Post by PlaidFlannel » Tue Feb 23, 2021 9:12 pm

My project has a long-running task (60-90 seconds typically) than uses scripted paint tools to create a large graphic. Those tools only work in an image graphic that is in the top visual layer, so there is considerable visual clutter on the screen while the painting happens. To clean up this mess, I wrapped that part of the script in a "lock screen/unlock screen" pair of statements.

To help the user, I would like to use a scrollbar as a progress bar during the painting. But I assume that the locked screen will prevent that from being successful. Can anyone confirm that?

Is there another way of accomplishing some kind of visual progress feedback with the screen locked? A numeric countdown in the message box, maybe?

One experiment I tried was to move the image graphic off-screen (unlocked) during the painting. I set the topLeft of the image to -2000, -2000, and then adjusted the painting code to use that point as the origin for its coordinate system. After painting, the contents of that image were copied to an on-screen image object. (That paint-and-copy technique works well when the image is on-screen.)

I could not get that to work, although the progress bar worked. But the experiment somehow damaged my stack and LiveCode, forcing me to reload LiveCode from my original MacOS .dmg file, and to reload my stack from my Time Machine backup. Is there something about painting at coordinates outside the bounds of my stack that might cause this kind of damage?

stam
Posts: 243
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Progress Bar vs. "lock screen"

Post by stam » Wed Feb 24, 2021 12:59 am

Not sure about your main question... but another approach may be to use a spinner widget this will (probably) work with lock screen, although you probably can't overlay your graphics with it...

raugert
Posts: 81
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Progress Bar vs. "lock screen"

Post by raugert » Wed Feb 24, 2021 4:40 am

I do something like this, but instead of using "LockScreen", I have the painted objects load with their visibility "Off". Once they are all loaded, I turn the visibility "On" for each object. This way I can show the progress bar while the objects are loading.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7405
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Progress Bar vs. "lock screen"

Post by dunbarx » Wed Feb 24, 2021 7:15 am

Raugert.

I like the way you chose to hide the painting process, to allow the progress bar to run "normally"

I use graphic objects a lot, and they have a property, the "points", that paint images do not. This gives them a "solidity" similar to, say, a field.

I never use paint tools, but I played around a bit with them after reading your post. I had thought it might be possible to paint on another card while the progress bar was running, then bring the image to the frontmost card, but It seems that one cannot paint anywhere at all except on the visible portion of the current visible card.

I am attaching a stack that shows this. On card 1, I paint two identical images with the same code, one of which is partly off screen. The off-screen portion is never drawn, something I did not know.

On card 2, I found something else I do not understand. I wrote a handler that may perhaps be similar to yours, hiding the painting process while a progress bar is running. But I get two entirely different results depending on whether the visible of the paint image is true or false. I have no idea why this is so.

Anyone know?
drawingMusingslivecode.zip
(194.64 KiB) Downloaded 10 times
Craig

raugert
Posts: 81
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Progress Bar vs. "lock screen"

Post by raugert » Wed Feb 24, 2021 6:21 pm

Hi Craig,

I should have been more clear about the way I was using "paint". I wasn't using paint "tools" as such, but rather the "Import Paint" command to import a series of image files. The issue of using "Lockscreen" was similar, in that I couldn't show the progress bar if the screen was locked. Hiding the images until they were all loaded instead of using "Lockscreen" was my solution.

I was mostly thinking the ops issue of not being able to show the progress bar while loading controls. Sorry to have confused the issue...

However, it's interesting what you've discovered. I haven't worked much with paint tools, but I can see where it may not paint if it's not within the Card's rect as in Card1. Although, I would have thought it should paint on Card2 even when it's not visible.


Richard

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8421
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Progress Bar vs. "lock screen"

Post by FourthWorld » Wed Feb 24, 2021 6:53 pm

PlaidFlannel wrote:
Tue Feb 23, 2021 9:12 pm
My project has a long-running task (60-90 seconds typically) than uses scripted paint tools to create a large graphic.
Can you post the code you use to paint the image? Or at least describe what the image is? There may be ways to optimize that, perhaps to the point that a progress bar isn't needed.
One experiment I tried was to move the image graphic off-screen (unlocked) during the painting. I set the topLeft of the image to -2000, -2000, and then adjusted the painting code to use that point as the origin for its coordinate system. After painting, the contents of that image were copied to an on-screen image object. (That paint-and-copy technique works well when the image is on-screen.)

I could not get that to work, although the progress bar worked. But the experiment somehow damaged my stack and LiveCode, forcing me to reload LiveCode from my original MacOS .dmg file, and to reload my stack from my Time Machine backup. Is there something about painting at coordinates outside the bounds of my stack that might cause this kind of damage?
Neither the stack file nor the IDE should be damaged from such an operation. If we can reproduce this we can submit a bug report to prevent this from happening in the future.
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7405
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Progress Bar vs. "lock screen"

Post by dunbarx » Wed Feb 24, 2021 9:10 pm

Richard (OP)

Well, why not just lock, import, update the progress bar, unlock, repeat:

Code: Select all

on mouseUp
   clearAllDrawings
   repeat with y = 1 to 100
      lock screen
      import paint from file  "yourPathNameHere"
      set the thumbPos of scrollbar 1 to y
      unlock screen
      wait 1
   end repeat
   
   choose browse tool
end mouseUp
You need to update the import step, of course.

Craig

raugert
Posts: 81
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Progress Bar vs. "lock screen"

Post by raugert » Wed Feb 24, 2021 10:15 pm

dunbarx wrote:
Wed Feb 24, 2021 9:10 pm
Well, why not just lock, import, update the progress bar, unlock, repeat:
I actually wanted the controls to appear all at once rather than one at a time. It's a cleaner look for the users. :)
I think your method would show each control as they are loading...

AxWald
Posts: 489
Joined: Thu Mar 06, 2014 2:57 pm

Re: Progress Bar vs. "lock screen"

Post by AxWald » Wed Feb 24, 2021 11:38 pm

Hi,
possibly stupid question: Can't you start with a dummy in a group (background, frame or such), make the group invisible, create grc in grp & draw until done, make visible again?

Have fun!
Livecode programming until the cat hits the fan ...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7405
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Progress Bar vs. "lock screen"

Post by dunbarx » Thu Feb 25, 2021 2:48 am

You do not have to show each image. Hide them as they appear. Keep the progress bar running. After the repeat loop ends, start another to show all, and then finally unlock the screen.

Craig

raugert
Posts: 81
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Progress Bar vs. "lock screen"

Post by raugert » Thu Feb 25, 2021 3:35 am

@Craig

That's essentially what I am doing, but I removed the "Lock/Unlock Screen" commands. I couldn't see the reason to "Lock screen" if the controls were not visible while loading. It seemed redundant. Unless I missed something . Would Lock/Unlock screen for each image improve performance ? :?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7405
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Progress Bar vs. "lock screen"

Post by dunbarx » Thu Feb 25, 2021 3:29 pm

Lots of ways to do things in LC. In my test stack for fooling around with this thread:

Code: Select all

on mouseUp
   clearAllDrawings --deletes any existing images
   
   repeat with y = 1 to 100
      lock screen
      if y mod 10 = 0 then --get ten images
         import paint from file  "yourFileHere"
         hide last img
      end if
      set the thumbPos of scrollbar 1 to y
      unlock screen
   end repeat
   
   repeat with y = 1 to the number of images
      show img y
   end repeat
   choose browse tool
end mouseUp
This took 12 ticks. How are you updating the progress bar without using lock/unlock?

Craig

raugert
Posts: 81
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Progress Bar vs. "lock screen"

Post by raugert » Fri Feb 26, 2021 7:12 pm

Hi Craig,

I feel dumb. :oops: I had another look at my program and realized that in fact when I "import" from a file, I do lock the screen !

I have another script in the program where I create buttons from a "Sample" Button, where the visibility property is "off" and then I customize them according to a CSV file and show them once they are all loaded. Because they are already hidden, I don't have to lock the screen.

Sorry my bad, I was confusing the 2 scripts.
Richard

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7405
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Progress Bar vs. "lock screen"

Post by dunbarx » Fri Feb 26, 2021 7:51 pm

I confuse everything in my life.

I would do everything I possibly could NOT to use CSV formatted data, or at least to reformat them wherever possible. There are a lot of threads about this.

Craig

AxWald
Posts: 489
Joined: Thu Mar 06, 2014 2:57 pm

Re: Progress Bar vs. "lock screen"

Post by AxWald » Sun Feb 28, 2021 1:39 pm

Hi,
dunbarx wrote:
Fri Feb 26, 2021 7:51 pm
I would do everything I possibly could NOT to use CSV formatted data, or at least to reformat them wherever possible. There are a lot of threads about this.
Yup. CSV MUST DIE! DIE!

Code: Select all

put the hilitedLines of fld "myFld"
--> "2,5,14,23,42"
Hmpf.

Code: Select all

put the textColor of fld "myFld"
--> "0,0,0"
Arghh!

Code: Select all

put the rect of fld "myFld"
--> "10,10,250,250"
NooooOOOOooooOOOOooo ...

Code: Select all

put the mouseLoc
--> "425,352"
"Bang!" - "Ouch!" - [silence].

Sorry, couldn't resist ;-))

Have fun!
Livecode programming until the cat hits the fan ...

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”