From: <sv...@ww...> - 2007-06-16 15:58:35
|
Author: nsmoooose Date: 2007-06-16 08:58:06 -0700 (Sat, 16 Jun 2007) New Revision: 2128 Added: trunk/csp/cspsim/wf/Image.cpp trunk/csp/cspsim/wf/Image.h Modified: trunk/csp/csplib/ trunk/csp/cspsim/ trunk/csp/cspsim/SConscript trunk/csp/cspsim/wf/ControlGeometryBuilder.cpp trunk/csp/cspsim/wf/ControlGeometryBuilder.h trunk/csp/cspsim/wf/Serialization.cpp trunk/csp/data/ui/scripts/windows/ trunk/csp/data/ui/themes/default/desktop.xml trunk/csp/data/ui/themes/default/styles.xml trunk/csp/data/ui/window_document.xsd Log: Added image widget to the window framework. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2128 Property changes on: trunk/csp/csplib ___________________________________________________________________ Name: svn:ignore - .bin *.pyc + .bin *.pyc .dox Property changes on: trunk/csp/cspsim ___________________________________________________________________ Name: svn:ignore - .bin *.pyc *.sconsign + .bin *.pyc *.sconsign .dox Modified: trunk/csp/cspsim/SConscript =================================================================== --- trunk/csp/cspsim/SConscript 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/cspsim/SConscript 2007-06-16 15:58:06 UTC (rev 2128) @@ -392,6 +392,8 @@ 'wf/ControlCallback.h', 'wf/ControlGeometryBuilder.cpp', 'wf/ControlGeometryBuilder.h', + 'wf/Image.cpp', + 'wf/Image.h', 'wf/InputInterfaceManager.cpp', 'wf/InputInterfaceManager.h', 'wf/Label.cpp', Modified: trunk/csp/cspsim/wf/ControlGeometryBuilder.cpp =================================================================== --- trunk/csp/cspsim/wf/ControlGeometryBuilder.cpp 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/cspsim/wf/ControlGeometryBuilder.cpp 2007-06-16 15:58:06 UTC (rev 2128) @@ -28,6 +28,7 @@ #include <csp/cspsim/wf/Button.h> #include <csp/cspsim/wf/CheckBox.h> #include <csp/cspsim/wf/ControlGeometryBuilder.h> +#include <csp/cspsim/wf/Image.h> #include <csp/cspsim/wf/Label.h> #include <csp/cspsim/wf/ListBox.h> #include <csp/cspsim/wf/ListBoxItem.h> @@ -669,6 +670,33 @@ return group.release(); } +osg::Group* ControlGeometryBuilder::buildImage(const Image* image) const { + Style style = StyleBuilder::buildStyle(image); + + // Test if the control is visible or not. + if (style.visible && *style.visible == false) { + return NULL; + } + + osg::ref_ptr<osg::Geode> geode = new osg::Geode; + float z = 0; + + buildControl(geode.get(), z, style, image); + + osg::ref_ptr<osg::Group> group = new osg::Group; + group->addChild(geode.get()); + + osg::StateSet *stateSet = group->getOrCreateStateSet(); + stateSet->setRenderBinDetails(100, "RenderBin"); + stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); + + osg::ref_ptr<osg::BlendFunc> blendFunction = new osg::BlendFunc; + stateSet->setAttributeAndModes(blendFunction.get()); + + return group.release(); +} + osg::Group* ControlGeometryBuilder::buildListBox(const ListBox* listBox) const { Style style = StyleBuilder::buildStyle(listBox); Modified: trunk/csp/cspsim/wf/ControlGeometryBuilder.h =================================================================== --- trunk/csp/cspsim/wf/ControlGeometryBuilder.h 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/cspsim/wf/ControlGeometryBuilder.h 2007-06-16 15:58:06 UTC (rev 2128) @@ -51,6 +51,7 @@ class Button; class CheckBox; class Control; +class Image; class Label; class ListBox; class ListBoxItem; @@ -67,6 +68,7 @@ virtual void buildControl(osg::Geode* geode, float& z, const Style& style, const Control* control) const; virtual osg::Group* buildCheckBox(const CheckBox* checkBox) const; virtual osg::Group* buildLabel(const Label* label) const; + virtual osg::Group* buildImage(const Image* image) const; virtual osg::Group* buildListBox(const ListBox* listBox) const; virtual osg::Group* buildListBoxItem(const ListBox* listBox, const ListBoxItem* listBoxItem) const; virtual osg::Group* buildButton(const Button* button) const; Added: trunk/csp/cspsim/wf/Image.cpp =================================================================== --- trunk/csp/cspsim/wf/Image.cpp (rev 0) +++ trunk/csp/cspsim/wf/Image.cpp 2007-06-16 15:58:06 UTC (rev 2128) @@ -0,0 +1,54 @@ +// Combat Simulator Project +// Copyright (C) 2002 The Combat Simulator Project +// http://csp.sourceforge.net +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * @file Image.cpp + * + **/ + +#include <csp/cspsim/wf/ControlGeometryBuilder.h> +#include <csp/cspsim/wf/Image.h> +#include <osg/Group> + +CSP_NAMESPACE + +namespace wf { + +Image::Image() { +} + +Image::~Image() { +} + +std::string Image::getName() const { + return "Image"; +} + +void Image::buildGeometry() { + // Make sure that all our child controls onInit() is called. + Control::buildGeometry(); + + ControlGeometryBuilder geometryBuilder; + osg::ref_ptr<osg::Group> image = geometryBuilder.buildImage(this); + getNode()->addChild(image.get()); +} + +} // namespace wf + +CSP_NAMESPACE_END Added: trunk/csp/cspsim/wf/Image.h =================================================================== --- trunk/csp/cspsim/wf/Image.h (rev 0) +++ trunk/csp/cspsim/wf/Image.h 2007-06-16 15:58:06 UTC (rev 2128) @@ -0,0 +1,49 @@ +// Combat Simulator Project +// Copyright (C) 2002 The Combat Simulator Project +// http://csp.sourceforge.net +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +/** + * @file Image.h + * + **/ + +#ifndef __CSPSIM_WF_IMAGE_H__ +#define __CSPSIM_WF_IMAGE_H__ + +#include <csp/cspsim/wf/Control.h> + +CSP_NAMESPACE + +namespace wf { + +class CSPSIM_EXPORT Image : public Control { +public: + Image(); + virtual ~Image(); + + virtual std::string getName() const; + + virtual void buildGeometry(); +}; + +} // namespace wf + +CSP_NAMESPACE_END + +#endif // __CSPSIM_WF_IMAGE_H__ + Modified: trunk/csp/cspsim/wf/Serialization.cpp =================================================================== --- trunk/csp/cspsim/wf/Serialization.cpp 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/cspsim/wf/Serialization.cpp 2007-06-16 15:58:06 UTC (rev 2128) @@ -31,6 +31,7 @@ #include <csp/cspsim/Config.h> #include <csp/cspsim/wf/Button.h> #include <csp/cspsim/wf/CheckBox.h> +#include <csp/cspsim/wf/Image.h> #include <csp/cspsim/wf/Label.h> #include <csp/cspsim/wf/ListBox.h> #include <csp/cspsim/wf/Model.h> @@ -274,6 +275,11 @@ archive.loadControl(control.get(), node); return control; } + else if(name == "Image") { + Ref<Image> control = new Image(); + archive.loadControl(control.get(), node); + return control; + } else if(name == "Label") { Ref<Label> control = new Label(); archive.loadControl(control.get(), node); Property changes on: trunk/csp/data/ui/scripts/windows ___________________________________________________________________ Name: svn:ignore + *.pyc Modified: trunk/csp/data/ui/themes/default/desktop.xml =================================================================== --- trunk/csp/data/ui/themes/default/desktop.xml 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/data/ui/themes/default/desktop.xml 2007-06-16 15:58:06 UTC (rev 2128) @@ -8,14 +8,14 @@ <Control> <MultiControlContainer> <Controls> - <Label SizeWidth="550" SizeHeight="550"> + <Image SizeWidth="550" SizeHeight="550"> <Style> <BackgroundColor>ffffffff</BackgroundColor> <BackgroundImage>images/csplogo_large.png</BackgroundImage> <VerticalAlign>middle</VerticalAlign> <HorizontalAlign>center</HorizontalAlign> </Style> - </Label> + </Image> </Controls> </MultiControlContainer> </Control> Modified: trunk/csp/data/ui/themes/default/styles.xml =================================================================== --- trunk/csp/data/ui/themes/default/styles.xml 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/data/ui/themes/default/styles.xml 2007-06-16 15:58:06 UTC (rev 2128) @@ -54,6 +54,11 @@ <BorderWidth>0</BorderWidth> <BorderColor>000000ff</BorderColor> </Style> + + <Style Name="Image"> + <Color>000000ff</Color> + <BackgroundColor>00000000</BackgroundColor> + </Style> <Style Name="Label"> <FontFamily>prima_sans_bt.ttf</FontFamily> Modified: trunk/csp/data/ui/window_document.xsd =================================================================== --- trunk/csp/data/ui/window_document.xsd 2007-06-16 15:16:41 UTC (rev 2127) +++ trunk/csp/data/ui/window_document.xsd 2007-06-16 15:58:06 UTC (rev 2128) @@ -167,6 +167,14 @@ </xsd:complexContent> </xsd:complexType> + <xsd:complexType name="Image_t"> + <xsd:complexContent> + <xsd:extension base="Control_t"> + <xsd:attribute name="Text" type="xsd:string" /> + </xsd:extension> + </xsd:complexContent> + </xsd:complexType> + <xsd:complexType name="ListBox_t"> <xsd:complexContent> <xsd:extension base="Container_t"> @@ -208,6 +216,7 @@ <xsd:element name="Button" type="Button_t" /> <xsd:element name="CheckBox" type="CheckBox_t" /> <xsd:element name="Label" type="Label_t" /> + <xsd:element name="Image" type="Image_t" /> <xsd:element name="ListBox" type="ListBox_t" /> <xsd:element name="Model" type="Model_t" /> <xsd:element name="MultiControlContainer" type="MultiControlContainer_t" /> |