GPv3: send notifiers and undo push when changing the active layer #110378
|
@ -18,6 +18,8 @@
|
||||||
#include "RNA_access.h"
|
#include "RNA_access.h"
|
||||||
#include "RNA_prototypes.h"
|
#include "RNA_prototypes.h"
|
||||||
|
|
||||||
|
#include "ED_undo.h"
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace blender::ui::greasepencil {
|
namespace blender::ui::greasepencil {
|
||||||
|
@ -180,9 +182,18 @@ class LayerViewItem : public AbstractTreeViewItem {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_activate(bContext & /*C*/) override
|
void on_activate(bContext &C) override
|
||||||
{
|
{
|
||||||
this->grease_pencil_.set_active_layer(&layer_);
|
PointerRNA grease_pencil_ptr, value_ptr;
|
||||||
|
RNA_pointer_create(&grease_pencil_.id, &RNA_GreasePencilv3Layers, nullptr, &grease_pencil_ptr);
|
||||||
|
RNA_pointer_create(&grease_pencil_.id, &RNA_GreasePencilLayer, &layer_, &value_ptr);
|
||||||
|
|
||||||
|
|||||||
|
PropertyRNA *prop = RNA_struct_find_property(&grease_pencil_ptr, "active");
|
||||||
|
|
||||||
|
RNA_property_pointer_set(&grease_pencil_ptr, prop, value_ptr, nullptr);
|
||||||
|
RNA_property_update(&C, &grease_pencil_ptr, prop);
|
||||||
Julian Eisel
commented
View item buttons are not designed to control RNA properties. It just happens to work in this case because they reuse View item buttons are not designed to control RNA properties. It just happens to work in this case because they reuse `ui_apply_but_ROW()` (which applies the value of `but->hardmax` which you set to the layer index here). But this is not intentional design and can break easily.
|
|||||||
|
|
||||||
|
ED_undo_push(&C, "Active Grease Pencil Layer");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supports_renaming() const override
|
bool supports_renaming() const override
|
||||||
|
|
Loading…
Reference in New Issue
Passing a value to the
reference
parameter is usually only needed for specific cases, is there any reason your doing this? Otherwise I'd prefer keeping this null, so it's clear that it's not needed (making further refactors to remove the argument easier).Also, thinking about this, I think it's better to use RNA here, so that the message bus also gets notified about the change. Call
RNA_property_pointer_set()
andRNA_property_update()
for this.