Fix missing redraw of asset shelves on tool changes

Context sensitivity for asset shelves is important, for example it may react to
mode or tool changes.

Initially reviewed in:
https://projects.blender.org/blender/blender/pulls/121671

Part of the brush assets project, see:
- https://projects.blender.org/blender/blender/issues/116337
- https://projects.blender.org/blender/blender/pulls/106303
This commit is contained in:
Brecht Van Lommel
2024-07-07 18:47:33 +02:00
committed by Julian Eisel
parent 1ae0bc8e9e
commit 9ba74d7429
4 changed files with 20 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ struct Main;
struct SpaceType;
struct uiBlock;
struct RegionPollParams;
struct wmRegionMessageSubscribeParams;
struct wmWindowManager;
namespace blender {
@@ -52,6 +53,7 @@ void region_init(wmWindowManager *wm, ARegion *region);
int region_snap(const ARegion *region, int size, int axis);
void region_on_user_resize(const ARegion *region);
void region_listen(const wmRegionListenerParams *params);
void region_message_subscribe(const wmRegionMessageSubscribeParams *params);
void region_layout(const bContext *C, ARegion *region);
void region_draw(const bContext *C, ARegion *region);
void region_on_poll_success(const bContext *C, ARegion *region);

View File

@@ -26,6 +26,7 @@
#include "ED_asset_list.hh"
#include "ED_screen.hh"
#include "RNA_access.hh"
#include "RNA_prototypes.h"
#include "UI_interface.hh"
@@ -34,6 +35,7 @@
#include "UI_view2d.hh"
#include "WM_api.hh"
#include "WM_message.hh"
#include "ED_asset_shelf.hh"
#include "asset_shelf.hh"
@@ -329,6 +331,20 @@ void region_listen(const wmRegionListenerParams *params)
}
}
void region_message_subscribe(const wmRegionMessageSubscribeParams *params)
{
wmMsgBus *mbus = params->message_bus;
WorkSpace *workspace = params->workspace;
ARegion *region = params->region;
wmMsgSubscribeValue msg_sub_value_region_tag_redraw{};
msg_sub_value_region_tag_redraw.owner = region;
msg_sub_value_region_tag_redraw.user_data = region;
msg_sub_value_region_tag_redraw.notify = ED_region_do_msg_notify_tag_redraw;
WM_msg_subscribe_rna_prop(
mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
}
void region_init(wmWindowManager *wm, ARegion *region)
{
/* Region-data should've been created by a previously called #region_on_poll_success(). */

View File

@@ -1204,6 +1204,7 @@ void ED_spacetype_image()
art->free = asset::shelf::region_free;
art->on_poll_success = asset::shelf::region_on_poll_success;
art->listener = asset::shelf::region_listen;
art->message_subscribe = asset::shelf::region_message_subscribe;
art->poll = asset::shelf::regions_poll;
art->snap_size = asset::shelf::region_snap;
art->on_user_resize = asset::shelf::region_on_user_resize;

View File

@@ -2179,6 +2179,7 @@ void ED_spacetype_view3d()
art->free = asset::shelf::region_free;
art->on_poll_success = asset::shelf::region_on_poll_success;
art->listener = asset::shelf::region_listen;
art->message_subscribe = asset::shelf::region_message_subscribe;
art->poll = asset::shelf::regions_poll;
art->snap_size = asset::shelf::region_snap;
art->on_user_resize = asset::shelf::region_on_user_resize;