if(Container *cont = dynamic_cast<Container *>(wdg))
{
const Geometry &cgeom = wdg->get_geometry();
- Widget *wdg2 = cont->find_descendant_at(x-cgeom.x, y-cgeom.y);
- if(wdg2)
+ if(Widget *wdg2 = cont->find_descendant_at(x-cgeom.x, y-cgeom.y))
return wdg2;
}
return wdg;
void Image::update_icon()
{
- if(style)
- {
- Root *root = find_ancestor<Root>();
- if(root)
- {
- if(icon_name.empty())
- image = nullptr;
- else
- image = &root->get_resources().get<GL::Texture2D>(icon_name);
- signal_autosize_changed.emit();
- mark_rebuild();
- return;
- }
- }
-
image = nullptr;
+ if(!style)
+ return;
+
+ Root *root = find_ancestor<Root>();
+ if(!root)
+ return;
+
+ if(!icon_name.empty())
+ image = &root->get_resources().get<GL::Texture2D>(icon_name);
+ signal_autosize_changed.emit();
+ mark_rebuild();
}
void Image::rebuild_special(const Part &part)
#ifndef MSP_GLTK_LAYOUT_H_
#define MSP_GLTK_LAYOUT_H_
-#include <set>
#include <vector>
#include <sigc++/trackable.h>
#include <msp/strings/lexicalcast.h>
static TypeRegistry<Loader::AddChildType, Loader &> widget_registry;
static bool widget_registry_init_done;
- Panel(const Panel &);
- Panel &operator=(const Panel &);
public:
Panel();
virtual ~Panel();
add("size", &Loader::size);
}
-Part::Loader::~Loader()
+void Part::Loader::finish()
{
for(unsigned i=0; i<N_STATES_; ++i)
if(obj.graphic[i])
{
public:
Loader(Part &, Resources &);
- ~Loader();
private:
+ void finish() override;
+
void graphic_normal(const std::string &);
void graphic(State, const std::string &);
void align(float, float);
if(!rebuilding)
throw logic_error("!rebuilding");
- for(current=next; current!=parts.end(); ++current)
- if(current->part==&part)
- {
- parts.erase(next, current);
- break;
- }
+ current = find_if(next, parts.end(), [&part](const CachedPart &p){ return p.part==∂ });
+ if(current!=parts.end())
+ parts.erase(next, current);
if(current==parts.end())
current = parts.insert(next, CachedPart());
#include <msp/gl/matrix.h>
#include <msp/strings/format.h>
+#include <msp/strings/utils.h>
#include "container.h"
#include "resources.h"
#include "root.h"
else
{
string sname = get_class();
- if(!style_name.empty())
- {
- sname += '-';
- sname += style_name;
- }
+ append(sname, "-", style_name);
style = &root->get_resources().get<Style>(sname);
}