stack semi-transparent over main stack? |SOLVED|

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

stack semi-transparent over main stack? |SOLVED|

Post by Johan_VH » Wed Jul 09, 2014 3:52 pm

Hi all,

I have a stack that holds all my popup boxes, and that is called succesfully when needed, but I have a problem with the background.

When the popup is visible, the popup itself should be on screen with a blend of 0 as normal, but behind the popup I have a black jpg that covers the entire screen and should be semi-transparent over the stack that called the popup. Like this, I can have my regular navigation buttons disabled and the focus is clearly on the popup message.

I set the blend of that jpg to 50, but it doesn't work. It only seems to work in the popup stack itself, when I place it on top of the popup graphic, I can see it is indeed semi-transparent. I can change the blend of the entire stack, but then the popup graphic is blended too of course...
I know I could set the mode of the stack to modal in order to prevent my buttons from working, but if I do that my xml socket that is running in the background won't receive anything anymore right? And I need that because in this particular instance, the popup asks to rescan the RFID-tag before commiting the user's registration-data to the server.

As usual, any help will be greatly appreciated!

Johan
Last edited by Johan_VH on Thu Jul 10, 2014 3:45 pm, edited 1 time in total.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stack semi-transparent over main stack?

Post by Klaus » Wed Jul 09, 2014 4:01 pm

Dag Johan,

not sure what you mean!?
Could you eventually post a screenshot of how it is now and a mockup how it should be?
I am more a "visual" guy.

In any way, I'm afraid you need to do this some other way :D


Best

Klaus

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stack semi-transparent over main stack?

Post by Johan_VH » Wed Jul 09, 2014 4:32 pm

Grüss dich Klaus,

the initial screen
http://imgur.com/hc9GfMJ

the screen with the popup
http://imgur.com/C2OMNFa

As you can see, the buttons and text are dimmed when the popup is active.

Thanks!

Johan

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stack semi-transparent over main stack?

Post by Klaus » Wed Jul 09, 2014 5:18 pm

Ah, I think I got it! :D

Lets name your mainstack stackA and your "popup" stackB!

1. You do not need a black JPEG image for this, a filled (opaque) rectangular graphic will also do :D

2. Put the graphic (or JPEG if you like) into stackA! Yes, stackA!
Set its blendlevel to whatever you like.

3. Then do this in the script that opens the "popup" stackB

Code: Select all

...
## Make sure it is on top of everything
set the layer of grc "the blended one" to top
show grc "the blended one"
go stack "stackB"
...
4. In the stack script of "stackB"

Code: Select all

on closestack
  hide grp "the blended one" of stack "stackA"
end closestack
5. To prevent StackB from disappearing when someone clicks thegraphis, I would add another script ot that garphic:

Code: Select all

on mouseup
  toplevel "stackB"
end mouseup
At least that would solve your problem as I understood it.
This is out of my head, so no guarantees whatsoever :D


Best

Klaus

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stack semi-transparent over main stack?

Post by Johan_VH » Thu Jul 10, 2014 9:21 am

Hi Klaus,

just to make sure: I have to put the black graphic layer in every card right? I can't just make a new card that contains just the graphic and have it visible on top of whatever other card of the stack I am using?

Johan

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stack semi-transparent over main stack?

Post by Klaus » Thu Jul 10, 2014 12:05 pm

Hi Johan,
Johan_VH wrote:I have to put the black graphic layer in every card right?
on every card where you need it!
In your case I would simply group the single graphic and place that group on every card where neccessary.
Johan_VH wrote:I can't just make a new card that contains just the graphic and have it visible on top of whatever other card of the stack I am using?
Counter question: Can you display TWO cards of the SAME stack at the SAME time? 8)
Or do you mean something different?

Some considerations:
If you plan to use your stack also on the mobile paltform, then you should not use a separate stack, but put everything into a group
and place this on every card where neccessary. Knowo what I mean?


Best

Klaus

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stack semi-transparent over main stack?

Post by Johan_VH » Thu Jul 10, 2014 1:46 pm

I tried it this morning with as I thought a graphic layer in each card, since yes, displaying 2 cards of the same stack at the same time is quite impossible.
Although I didn't group the graphic (I'm still using a jpg so I can easily change it if I ever need to have a different color overlay, with a watermarked logo, a gradient...) it doesn't work. When I close the popup stack I can see that the graphic is on top of everything else, blended as it should be, but my popup stack is opaque even though I unchecked that in the card properties.

This is what I do (yes, I know, I can use 'show' and 'hide', but I'm used to go boolean for things like this ;-)

Code: Select all

set the visible of  image "back.jpg" to true
 go  to card "scan" of stack "popup"
I'm now thinking of going the path of setting the shape of the popup layer to the size of the actual popup graphic, and I hope I can change this dynamically since not all popups will be the same size.

And one more thing that has been eating my time for the last 2 hours: on the last card of my 'registration' stack, the user has to select a button to indicate whether he or she is male or female. When I then click on the 'next' button, I have to click 2 times, because for some reason or other, the "owner of the target" is set as "registration", which is the name of my stack. After the second click it sees the "owner of the target" as the name of the group as it should and then executes my switch command. I tried some more going back and forth, and it happens regularly. Never on the buttons that are unique to the cards, but only on my navigation buttons that behave like a background... I've put that on the backburner for now, as I'm now working on my timeout-script, but this is something that I need to get sorted out...

thanks for any suggestions!

Johan

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: stack semi-transparent over main stack?

Post by magice » Thu Jul 10, 2014 2:01 pm

Here is a crazy idea. Take a screen shot of how you want it to look. Create a new card. Place that screen shot on the background of the new card. Add your active buttons. Now just go to that card instead of worrying about visibilities and transparencies.

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stack semi-transparent over main stack?

Post by Johan_VH » Thu Jul 10, 2014 2:04 pm

True, but that would take the fun out of coding wouldn't it... :-)

magice
Posts: 457
Joined: Wed Mar 18, 2009 12:57 am

Re: stack semi-transparent over main stack?

Post by magice » Thu Jul 10, 2014 2:10 pm

Johan_VH wrote:True, but that would take the fun out of coding wouldn't it... :-)
Not at all. If you want a challenge, create the new card, background and all dynamically when your new dialog is needed.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stack semi-transparent over main stack?

Post by Klaus » Thu Jul 10, 2014 2:25 pm

Johan_VH wrote:When I close the popup stack I can see that the graphic is on top of everything else, blended as it should be,...
Don't you read all the postings here?
I already gave an answer to this one, which is definitively OBVIOUS!

See Nr. 4 in one of my earlier postings...

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stack semi-transparent over main stack?

Post by Johan_VH » Thu Jul 10, 2014 3:21 pm

You mean:

Code: Select all

on closestack
  hide grp "the blended one" of stack "stackA"
end closestack
I do that, albeit in my main script which handles the entire navigation, but that is not the problem. The thing is that when the popup stack (stack B in your code) is displayed, it completely covers stack A.

Maybe I should note that stack B is the exact size of stack A, and I'm thinking that is the problem. Hence my plan to dynamically change the shape of stack B. I already found out that I can do this from the code with

Code: Select all

set the windowShape of stack to
, but that will be something for tomorrow!

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stack semi-transparent over main stack?

Post by Klaus » Thu Jul 10, 2014 3:35 pm

On your screenshots your "popup" stack look RECTANGULAR!?
If that is really the case, you don't need any "windowshape"!

Just set "the decorations" of that stack to none, adjust its size and open it at the loc of stack "stackA":
...
set the loc of stack "stackB" to the loc of stack "stackA"
go stack "stackB"
...

Johan_VH
Posts: 67
Joined: Fri Mar 28, 2014 2:46 pm

Re: stack semi-transparent over main stack?

Post by Johan_VH » Thu Jul 10, 2014 3:44 pm

Why postpone till tomorrow when you can do it today?
So I just tried it, and it works.

http://imgur.com/BSkx8ih

The mask is a png with alpha channel, the part that is to be shown is black. The entire png is the same size as the main stack.

The code used is the following:

Code: Select all

on preOpenCard
   set the windowShape of stack "popup" to 1015
end preOpenCard
You cannot use the name of the mask as reference, it has to be it's ID.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: stack semi-transparent over main stack? |SOLVED|

Post by Klaus » Thu Jul 10, 2014 3:56 pm

Dag Johan,

GREAT!
That "workaround" would have been my next proposal :D


Best & Groetjes

Klaus

Post Reply