Images on top of each other...

I frequently use layers to overlay one image on top of another. Is there a way I can do that using some sort of z layer setting with a canvas (or window) or something?

I’m also trying to layer text on top of an image, can set the background of a label I believe, but need this label to then be on top of another image…

Hello jrmayhew,
Yes, SmartClient provides a number of methods to manage the Z-Order of components - see the zIndex documentation for the most common methods.

For the simple case of positioning text over an image, you can specify the backgroundImage for some Canvas (or subclass of Canvas, such as a Label), and also specify its contents (text to be written over the image)

Hope this helps
Thanks
Isomorphic Software

Must be missing something…

I have created a header example in which I attempting to get the label in front of the images. However I cannot use the bringToFront call on it (says no object) I then created a raw canvas which I can call bring to front on however is remains aligned within the horizontal layout. Should I not be using a hlayout?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<SCRIPT>var isomorphicDir="../isomorphic/";</SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Core.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Containers.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Grids.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_Forms.js></SCRIPT>
    <SCRIPT SRC=../isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
	<SCRIPT SRC=../isomorphic/skins/SmartClient/load_skin.js></SCRIPT>
	<link href="renweb.css" rel="stylesheet" type="text/css" />
</head>

<body>
<SCRIPT>
isc.Img.create({
    imageType:"tile",
    src:"[SKIN]grid.gif",
    title:"Img3",
    height:70,
    ID:"Img3",
    width:150,
    layoutAlign:"center",
    autoDraw:false
})



isc.VLayout.create({
    members:[
        Img3
    ],
    backgroundColor:"#FFFFFF",
    height:70,
    ID:"VLayout4",
    width:"25%",
    autoDraw:false
})



isc.Label.create({
    contents:"Name <br> Mascott",
    height:20,
    ID:"Label0",
    styleName:"headertext",
	layoutAlign:"center",
    autoDraw:false
})



isc.Img.create({
    imageType:"tile",
    src:"[SKIN]grid.gif",
    title:"Img1",
    height:70,
    ID:"Img1",
    width:70,
    autoDraw:false
})



isc.LayoutSpacer.create({ID:"LayoutSpacer0", autoDraw:false})



isc.Img.create({
    imageType:"tile",
    src:"[SKIN]grid.gif",
    title:"Img2",
    height:70,
    ID:"Img2",
    width:400,
    autoDraw:false
})

isc.Canvas.create({
	height:70,
	title:"C1",
    ID:"C1",
    width:80,
	backgroundColor: "#CCCCCC",
	layoutAlign:"center",
	autoDraw:false
})

isc.HLayout.create({
    members:[
		Label0,
		C1,
        Img1,
        LayoutSpacer0,
        Img2
    ],
    backgroundColor:"#800000",
    height:70,
    ID:"HLayout0",
    width:"*",
    autoDraw:false
})



Label0.setContents("hello")
C1.bringToFront()



isc.HLayout.create({
    members:[
        VLayout4,
        HLayout0
    ],
    ID:"HLayout2",
    autoDraw:false
})



isc.VLayout.create({
    members:[
        HLayout2
    ],
    height:"100%",
    width:"100%",
    autoDraw:true
})
</SCRIPT>



</body>
</html>

Here is what I am building…

http://backstage.cyfunmedia.com/clients/renweb/parentsweb/test.jpg

as you can see I cut the front corner of the image so the banner will scale correctly, now need to get the label on top of the image, thought the image might help.

Looking to have the light image with the text sit on top of the back image (as they will be different color combinations)

Hi Jrmayhew,

The right solution depends on exactly what you’re trying to achieve.
If you simply want text floating over a single image, you can use the backgroundImage property of a Canvas like this

[script]

isc.Canvas.create({
backgroundImage:“[SKIN]grid.gif”,
backgroundRepeat:isc.Canvas.REPEAT,
contents:“Some text to appear over the image”,
height:70,
width:150
})

[/script]

If you need the Label type behavior of centering the text vertically and horizontally, you can use the backgroundImage property of a label, like this:

[script]

isc.Label.create({
backgroundImage:“[SKIN]grid.gif”,
backgroundRepeat:isc.Canvas.REPEAT,
contents:“Some text to appear over the image”,
height:70,
width:150
})

[/script]

From the link you provided and your description, it sounds like you’re trying to achieve something slightly more complex, such as a banner running across the top of a page, consisting of a scaleable image in the center and a fixed size image at one end, with text floating above it.
I don’t want to get into trying to build this exact case for you, but fundamentally, your approach of creating an HLayout containing a number of Img components (some scaleable and some of fixed size) should work fine. Another approach you might want to take a look at is using the StretchImg class, which allows you to create scalable images consisting of both scaleable and fixed-size media.

To address the specific issues that seem to be blocking you:

  • The ‘bringToFront()’ method is supported on any SmartClient widget, so should definitely not be giving you an error when called on a Label as opposed to a Canvas. If you’re consistently reproducing this problem, and you’ve double checked your code to make sure you’re calling the method on the correct object, we’d love to get to the bottom of this to make sure it’s not a bug in the SmartClient system. If you can put together a reproducible case for us and paste the code into this thread, we’d be happy to take a look.

  • All members in a VLayout / HLayout take up space. In other words, if you have a VLayout with a members array consisting of an Img, a label, and another Img, the label will appear in between the 2 images (vertically).
    If you want to have 2 images in a layout and layer another widget on top of them, it should not be included in the Layout, but instead be a child of the same parent as the Layout.
    For example:

isc.Canvas.create({
    ID:"headerBar",
    width:"100%",
    children:[
        isc.HLayout.create({
             ID:"mediaLayout",
              ... include some images as members that will appear
                  next to each other
        }),
        isc.Label.create({
            ID:"headerBarTitle",
            ... various properties for the label
                including left/top position to position it over
                the 'mediaLayout'
        })
    ]  
})

// Ensure the label shows up above the HLayout
headerBarTitle.moveAbove(mediaLayout);

I hope this is enough to get you going
Let us know if you run into problems

Thanks
Isomorphic Software

Thanks will try that out

Yes definately trying to build the more complex layout.

I think the key point you made is to not include it in the layout but as a child.

Will give it a try. THANKS :slight_smile: