Page 1 of 1

[SOLVED]Progress bar help

Posted: Fri Jun 12, 2009 10:04
by maori
hi guys

i'am trying to get a prgress bar to go up and down when i use the throttle of a joystick

i,ve managed to get the throttle name to appear ok but cant seem to work out how to make the progress bar work

can someone see where i messed up please

xml layout

Code: Select all

<Window Type="skin/ProgressBar" Name="throttle" >
                    <Property Name="StepSize" Value="0.01" />
                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                    <Property Name="CurrentProgress" Value="0" />
                    <Property Name="UnifiedAreaRect" Value="{{0.357247,0},{0.191645,0},{0.607247,0},{0.274619,0}}" />
                </Window>


code

Code: Select all

float Throttle;
ProgressBar* line = static_cast<ProgressBar*>(winMgr.getWindow( "throttle"))->setProgress(Throttle);
         if(Throttle <= 1.0f)
   {
      line->setPosition(CEGUI::Point(0, 1 -Throttle));
   }
   else if(nuiThrottleScale > 1.0f)
   {
      line->setPosition(CEGUI::Point(0, 0));
   }
   else
   {
      line->setPosition(CEGUI::Point(0, 1));
   }


TIA

Re: Progress bar help

Posted: Sun Jun 14, 2009 10:07
by CrazyEddie
Hi,

Your code completely confuses me :)

In order to set the progress, you the the ProgressBar::setProgress function, though in your code you appear to be using 'setPosition' and passing a CEGUI::Point, which does not compile, right? The progress bar use is highly similar to the slider usage, in that you set a progress value of between 0.0 and 1.0 to represent the percentage of progress to show, the direction and behaviour of operation is controlled via the 'vertical' and/or 'reversed' option settings.

The main things you need to consider in doing this are the arrangement of the progress bar(s), and the format of the incoming data from the joystick. Meaning you have to consider how you translate that joystick data into relevant progress values for your progress bar(s) - if that data is already using the same scale, or something like -1.0 to +1.0, then you should be pretty much set - otherwise what you need to do, and how, will depend :)

CE.

Re: Progress bar help

Posted: Mon Jun 15, 2009 11:42
by maori
Thanks CE

i think i understand :oops: will let you now if i can solve it here if not i be back :P

Re: Progress bar help

Posted: Wed Jun 24, 2009 13:17
by maori
heya

ok some progress here :P
one prob is when i set

Code: Select all

ProgressBar *m_thottle = static_cast<ProgressBar*>(winMgr.getWindow( "mythrottle"));
    m_throttle->setProperty( "VerticalProgress", "True" );


the bar stays horizontal ??

Re: Progress bar help

Posted: Thu Jun 25, 2009 08:58
by CrazyEddie
This setting affects the internal workings of the progress bar rather than the visual appearance (obviously at some point the two are linked, but not in the way you want). What this means is that modifying the the setting will not change a progress bar designed to be horizontal into one that's vertical, or to put it another way, it's a setting intended to be used at the skin definition level rather than the application / layout level.

In order to get a vertical progress bar in a skin / theme that does not already have one, one would need to define a new WidgetLook in the skin, and an appropriate mapping in the scheme.

I think this is the right answer :)

CE.

Re: Progress bar help

Posted: Fri Jun 26, 2009 10:21
by maori
heya CE

Thanks for the answer sir thought it was me doing something silly again :P

Re: Progress bar help

Posted: Mon Jun 29, 2009 10:43
by maori
heya

okidoki getting close but image is off and could use some help with the look"n"feel :oops:
at present i have

Code: Select all

               <WidgetLook name="mySkin/VerticalProgressBar">
  <NamedArea name="ProgressArea">
    <Area>
      <Dim type="LeftEdge" >
        <ImageDim imageset="mySkin" image="VerticalProgressBarTop" dimension="Width" />
      </Dim>
      <Dim type="TopEdge" >
        <AbsoluteDim value="0" />
      </Dim>
      <Dim type="RightEdge" >
        <UnifiedDim scale="1" type="RightEdge">
          <DimOperator op="Subtract">
            <ImageDim imageset="mySkin" image="VerticalProgressBarBottom" dimension="Width" />
          </DimOperator>
        </UnifiedDim>
      </Dim>
      <Dim type="Height" >
        <UnifiedDim scale="1" type="Height" />
      </Dim>
    </Area>
  </NamedArea>
  <ImagerySection name="frame">
    <FrameComponent>
      <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>
      <Image type="LeftEdge" imageset="mySkin" image="VerticalProgressBarTop" />
      <Image type="RightEdge" imageset="mySkin" image="VerticalProgressBarBottom" />
      <Image type="Background" imageset="mySkin" image="VerticalProgressBarMiddle" />
    </FrameComponent>
  </ImagerySection>
  <ImagerySection name="progress_lights" >
    <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>
      <Image imageset="mySkin" image="VerticalProgressHighlight" />
      <VertFormat type="Stretched" />
      <HorzFormat type="Tiled" />
    </ImageryComponent>
  </ImagerySection>
  <StateImagery name="Enabled">
    <Layer>
      <Section section="frame" />
    </Layer>
  </StateImagery>
  <StateImagery name="Disabled">
    <Layer>
      <Section section="frame">
    <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
      </Section>
    </Layer>
  </StateImagery>
  <StateImagery name="EnabledProgress">
    <Layer>
      <Section section="progress_lights" />
    </Layer>
  </StateImagery>
  <StateImagery name="DisabledProgress">
    <Layer>
      <Section section="progress_lights">
        <Colours topLeft="FF7F7F7F" topRight="FF7F7F7F" bottomLeft="FF7F7F7F" bottomRight="FF7F7F7F" />
      </Section>
    </Layer>
  </StateImagery>
</WidgetLook>

and this gives me an image like so how can i disable the side parts ?Image all i really need is the parts with the 2 thin blue lines and the middle if that makes sense
Thanks

Re: Progress bar help

Posted: Tue Jun 30, 2009 09:03
by CrazyEddie
This issue is due to the images you are using in the FrameComponent part of the progress bar frame. See these images here:

Code: Select all

      <Image type="LeftEdge" imageset="mySkin" image="VerticalProgressBarTop" />
      <Image type="RightEdge" imageset="mySkin" image="VerticalProgressBarBottom" />

You're using 'top' and 'bottom' images for 'left' and 'right' respectively, presumably these top and botom images are wider than just the thin lines, which is why you're seeing what you are. What you need to do is replace the use of those particular images with some that are more appropriate.

HTH

CE.

Re: Progress bar help

Posted: Tue Jun 30, 2009 18:43
by maori
Thanks CE