Page 1 of 1

Creating staticimage in Runtime

Posted: Tue Jul 01, 2008 18:59
by jaguillard
I'm making something like a mini-map, with dots representing objects in the world. I need to create StaticImage windows during runtime for each object in the scene. Now the WindowManager class can get me the window, but I can't figure out how to set the image into it. While the XML has the Image property, it isn't showing up in code.

Posted: Tue Jul 01, 2008 19:16
by CrazyEddie
Hi,

You might consider a creating custom widget instead - having lots of little static image windows sound expensive to me ;)

Anyway, to answer your question - you still use the property from code:

Code: Select all

myStaticImage->setProperty( "Image", "set:MiniMapObjects image:Whatever" );


HTH

CE.

Posted: Tue Jul 01, 2008 21:20
by jaguillard
So far I've yet to get the staticimage to appear. I've debugged through and the size and position are right, but the window won't appear. I must be missing a step in creating it at runtime.

Code: Select all

CEGUI::Window* contact = CEGUI::WindowManager::getSingleton().createWindow("WaveloreGUI/StaticImage", "GreenBlipIcon");
mGuiWindow->getChild("SceneMapImage")->addChildWindow(contact);
contact->setProperty("Image", "set:GreenBlipImage image:full_image");
contact->setVisible(true);
contact->setMaxSize(CEGUI::UVector2(CEGUI::UDim(1,0), CEGUI::UDim(1,0)));
contact->setWidth(CEGUI::UDim(0, 50));
contact->setHeight(CEGUI::UDim(0, 50));
contact->setPosition(position);
contact->moveToFront();


That's basically what I have for the window, but nothing will appear. Even tried adding a font and text.

Posted: Wed Jul 02, 2008 08:30
by CrazyEddie
Hi,

Are there any errors in the log file?

Failing that, can you post any relevant scheme entries and LookNFeel definitions used for the "WaveloreGUI/StaticImage" type?

CE.

Posted: Wed Jul 02, 2008 14:21
by jaguillard
No errors in the log.

Code: Select all

<FalagardMapping WindowType="WaveloreGUI/StaticImage" TargetType="DefaultWindow" Renderer="Falagard/StaticImage" LookNFeel="WaveloreGUI/StaticImage" />

Code: Select all

  <WidgetLook name="WaveloreGUI/StaticImage">
    <PropertyDefinition name="ImageColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
    <PropertyDefinition name="FrameColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
    <PropertyDefinition name="BackgroundColours" initialValue="tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF" redrawOnWrite="true" />
    <PropertyDefinition name="VertFormatting" initialValue="Stretched" redrawOnWrite="true" />
    <PropertyDefinition name="HorzFormatting" initialValue="Stretched" redrawOnWrite="true" />
    <Property name="BackgroundEnabled" value="False" />
    <Property name="FrameEnabled" value="False" />
    <ImagerySection name="image_withframe">
      <ImageryComponent>
        <Area>
          <Dim type="LeftEdge" >
            <ImageDim imageset="WaveloreGUI" image="Border_Left" dimension="Width" />
          </Dim>
          <Dim type="TopEdge" >
            <ImageDim imageset="WaveloreGUI" image="Border_Top" dimension="Height" />
          </Dim>
          <Dim type="RightEdge" >
            <UnifiedDim scale="1" type="RightEdge">
              <DimOperator op="Subtract">
                <ImageDim imageset="WaveloreGUI" image="Border_Right" dimension="Width" />
              </DimOperator>
            </UnifiedDim>
          </Dim>
          <Dim type="BottomEdge" >
            <UnifiedDim scale="1" type="BottomEdge">
              <DimOperator op="Subtract">
                <ImageDim imageset="WaveloreGUI" image="Border_Bottom" dimension="Height" />
              </DimOperator>
            </UnifiedDim>
          </Dim>
        </Area>
        <ImageProperty name="Image" />
        <ColourRectProperty name="ImageColours" />
        <VertFormatProperty name="VertFormatting" />
        <HorzFormatProperty name="HorzFormatting" />
      </ImageryComponent>
    </ImagerySection>
    <ImagerySection name="image_noframe">
      <ImageryComponent>
        <Area>
          <Dim type="LeftEdge" >
            <AbsoluteDim value="0" />
          </Dim>
          <Dim type="TopEdge" >
            <AbsoluteDim value="0" />
          </Dim>
          <Dim type="Width" >
            <UnifiedDim scale="1" type="Width" />
          </Dim>
          <Dim type="Height" >
            <UnifiedDim scale="1" type="Height" />
          </Dim>
        </Area>
        <ImageProperty name="Image" />
        <ColourRectProperty name="ImageColours" />
        <VertFormatProperty name="VertFormatting" />
        <HorzFormatProperty name="HorzFormatting" />
      </ImageryComponent>
    </ImagerySection>
    <StateImagery name="Enabled" />
    <StateImagery name="Disabled" />
    <StateImagery name="EnabledFrame">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="frame" />
      </Layer>
    </StateImagery>
    <StateImagery name="DisabledFrame">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="frame" />
      </Layer>
    </StateImagery>
    <StateImagery name="WithFrameEnabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background" />
      </Layer>
    </StateImagery>
    <StateImagery name="WithFrameDisabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background" />
      </Layer>
    </StateImagery>
    <StateImagery name="NoFrameEnabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background_noframe" />
      </Layer>
    </StateImagery>
    <StateImagery name="NoFrameDisabledBackground">
      <Layer>
        <Section look="WaveloreGUI/StaticShared" section="background_noframe" />
      </Layer>
    </StateImagery>
    <StateImagery name="WithFrameImage">
      <Layer>
        <Section section="image_withframe" />
      </Layer>
    </StateImagery>
    <StateImagery name="NoFrameImage">
      <Layer>
        <Section section="image_noframe" />
      </Layer>
    </StateImagery>
  </WidgetLook>


I haven't had any issues with StaticImage windows created through XML. This is the only situation. I've tested the imageset and image on other StaticImage windows and had no problems. Tried different sizes and positions. Tried making it a child of the root.


The only thing I can think is the createWindow function isn't working right. I checked the .cpp for the function and noticed that it should call the logger to write that a window was created. That message isn't in the log. I just had to assume that the "type" was a type define in the Scheme, as putting in just "Window" or "StaticImage" caused a crash.

Posted: Wed Jul 02, 2008 16:47
by jaguillard
Problem solved. The position variable being passed to the window's setPosition() was the problem. I set the offset, but didn't check that the scale wasn't initialized. Without setting it to zero, the value was chode and the position was completely borked.

Posted: Wed Jul 02, 2008 17:49
by CrazyEddie
ah! I'm glad you managed to solve it :) (It's always the simple thing you never think of!)

CE.