Skip to content

Commit

Permalink
alpha region in python gumps
Browse files Browse the repository at this point in the history
  • Loading branch information
spin committed Oct 16, 2012
1 parent 8031d18 commit da74fd6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/fluorescence/ui/python/modules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ BOOST_PYTHON_MODULE(gumps) {
.def("addImage", &PyGumpComponentContainer::addImage, bpy::return_value_policy<bpy::reference_existing_object>())
.def("addBackground", &PyGumpComponentContainer::addBackground, bpy::return_value_policy<bpy::reference_existing_object>())
.def("addAlphaRegion", &PyGumpComponentContainer::addAlphaRegion, bpy::return_value_policy<bpy::reference_existing_object>())
.def("addLabel", &PyGumpComponentContainer::addLabel, bpy::return_value_policy<bpy::reference_existing_object>())
;

// non-instanciable wrapper class for gump menus
Expand Down Expand Up @@ -118,6 +119,10 @@ BOOST_PYTHON_MODULE(gumps) {
// alpha region component
bpy::class_<components::AlphaRegion, bpy::bases<GumpComponent>, boost::noncopyable>("AlphaRegionWrapper", bpy::no_init)
;

// label component
bpy::class_<components::Label, bpy::bases<GumpComponent>, boost::noncopyable>("LabelWrapper", bpy::no_init)
;
}

}
Expand Down
12 changes: 11 additions & 1 deletion src/fluorescence/ui/python/pygumpcomponentcontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "pygumpcomponent.hpp"

#include <misc/log.hpp>
#include <ui/gumpmenu.hpp>

#include <ui/gumpmenu.hpp>
#include <ui/componentlist.hpp>

namespace fluo {
Expand Down Expand Up @@ -61,6 +61,16 @@ components::AlphaRegion* PyGumpComponentContainer::addAlphaRegion(CL_GUIComponen
return region;
}

components::Label* PyGumpComponentContainer::addLabel(CL_GUIComponent* self, boost::python::tuple& geom, const UnicodeString& text) {
components::Label* label = new components::Label(self);
PyGumpComponent::setGeometry(label, geom);
label->setText(text);

static_cast<GumpMenu*>(self->get_top_level_component())->addToCurrentPage(label);

return label;
}

}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/fluorescence/ui/python/pygumpcomponentcontainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#define FLUO_UI_PYTHON_PYGUMPCOMPONENTCONTAINER_HPP

#include <boost/shared_ptr.hpp>

#include <boost/python.hpp>

#include <misc/string.hpp>

class CL_GUIComponent;

namespace fluo {
Expand All @@ -35,6 +36,7 @@ namespace components {
class Image;
class Background;
class AlphaRegion;
class Label;
}

namespace python {
Expand All @@ -44,6 +46,7 @@ class PyGumpComponentContainer {
static components::AlphaRegion* addAlphaRegion(CL_GUIComponent* self, boost::python::tuple& geom, float alpha);
static components::Background* addBackground(CL_GUIComponent* self, boost::python::tuple& geom, unsigned int baseId);
static components::Image* addImage(CL_GUIComponent* self, boost::python::tuple& geom, boost::shared_ptr<ui::Texture> tex);
static components::Label* addLabel(CL_GUIComponent* self, boost::python::tuple& geom, const UnicodeString& text);
};

}
Expand Down

0 comments on commit da74fd6

Please sign in to comment.