0
votes

I have the following code snippet using cluttermm 1.24:

#include <cluttermm.h>

int main(int argc, char *argv[]){
    Clutter::init(argc, argv);

    auto stage = Clutter::Stage::create();
    stage->set_size(1280, 720);

    //create a parent actor
    auto parent = Clutter::Actor::create();
    parent->set_size(1240, 720);
    parent->set_margins(20, 20, 20, 20);

    //create children
    for(unsigned i=0; i<84; i++){
        auto child = Clutter::Actor::create();
        child->set_name(std::to_string(i).c_str());
        child->set_size(80, 80);
        child->set_background_color(Clutter::Color(80));
        child->set_reactive(true);
        child->signal_button_press_event().connect([child](Clutter::ButtonEvent* evt){
            g_print("Child: %s", child->get_name().c_str());
            return true;
        });

        parent->add_child(child);
    }

    auto layout = Clutter::FlowLayout::create(Clutter::FlowOrientation::FLOW_HORIZONTAL);
    layout->set_column_spacing(20);
    layout->set_row_spacing(20);
    parent->set_layout_manager(layout);
    stage->add_child(parent);

    stage->show();

    Clutter::main();
}

Child actors should print "Child:XX" when clicked on. But they do not react at all. When changing the parent type to the (deprecated) Clutter::Group then the click behaviour is as expected but the FlowLayout does not work anymore. What am I missing here? Do I need to enable something on the parent actor to enable container functionality?

EDIT: Replacing the parent actor with c code behaves as expected:

auto parent = clutter_actor_new ();
clutter_actor_set_layout_manager (parent, CLUTTER_LAYOUT_MANAGER(layout->gobj()));
clutter_actor_set_size (parent, 1240, 720);
clutter_actor_add_child (CLUTTER_ACTOR(stage->gobj()), parent);
...
clutter_actor_add_child (parent, child->gobj());
1

1 Answers

0
votes

I found the problem. Cluttermm wrapped the deprecated "pick" signal. Apparently this prevented the button press signal from propagating. So I've forked cluttermm and changed the bindings.

See this commit: https://github.com/underdoeg/cluttermm/commit/0e40c9c673c2415ab1b4eb90dd1ebcd95a515810