UI: Region polling support #105088
|
@ -165,8 +165,8 @@ typedef struct ARegionType {
|
|||
/* exit is called when the region is hidden or removed */
|
||||
void (*exit)(struct wmWindowManager *wm, struct ARegion *region);
|
||||
/** Optional callback to decide whether the region should be treated as existing given the
|
||||
JulianEisel marked this conversation as resolved
Outdated
Hans Goudey
commented
Outdated
Review
```
/**
* Optional callback to decide whether the region should be treated as existing given the
* current context. When returning false, the region will be kept in storage, but is not
* available to the user in any way. Callbacks can assume that context has the owning area and
* space-data set.
*/
|
||||
current context. When returning false, the region will be kept in storage, but is not available
|
||||
to the user in any way. */
|
||||
* current context. When returning false, the region will be kept in storage, but is not
|
||||
* available to the user in any way. */
|
||||
bool (*poll)(const struct bContext *C);
|
||||
/* draw entirely, view changes should be handled here */
|
||||
void (*draw)(const struct bContext *C, struct ARegion *region);
|
||||
|
|
|
@ -728,7 +728,7 @@ static void screen_regions_poll(bContext *C, const wmWindow *win, bScreen *scree
|
|||
ScrArea *previous_area = CTX_wm_area(C);
|
||||
ARegion *previous_region = CTX_wm_region(C);
|
||||
|
||||
bool changed = false;
|
||||
bool any_changed = false;
|
||||
ED_screen_areas_iter (win, screen, area) {
|
||||
CTX_wm_area_set(C, area);
|
||||
|
||||
|
@ -743,17 +743,17 @@ static void screen_regions_poll(bContext *C, const wmWindow *win, bScreen *scree
|
|||
}
|
||||
|
||||
if (old_region_flag != region->flag) {
|
||||
any_changed = true;
|
||||
|
||||
/* Enforce complete re-init. */
|
||||
region->v2d.flag &= ~V2D_IS_INIT;
|
||||
changed = true;
|
||||
ED_region_visibility_change_update(C, area, region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
if (any_changed) {
|
||||
screen->do_refresh = true;
|
||||
// ED_area_tag_redraw();
|
||||
}
|
||||
|
||||
CTX_wm_area_set(C, previous_area);
|
||||
|
|
|
@ -145,17 +145,6 @@ static void file_init(wmWindowManager *UNUSED(wm), ScrArea *area)
|
|||
}
|
||||
/* Validate the params right after file read. */
|
||||
fileselect_refresh_params(sfile);
|
||||
|
||||
ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS);
|
||||
FileSelectParams *params = ED_fileselect_get_active_params(sfile);
|
||||
if (params && !(region_props->v2d.flag & V2D_IS_INIT)) {
|
||||
if (params->flag & FILE_HIDE_TOOL_PROPS) {
|
||||
region_props->flag |= RGN_FLAG_HIDDEN;
|
||||
}
|
||||
else {
|
||||
region_props->flag &= ~RGN_FLAG_HIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void file_exit(wmWindowManager *wm, ScrArea *area)
|
||||
|
@ -298,6 +287,28 @@ static void file_refresh(const bContext *C, ScrArea *area)
|
|||
sfile->layout->dirty = true;
|
||||
}
|
||||
|
||||
if (area) {
|
||||
ARegion *region_props = BKE_area_find_region_type(area, RGN_TYPE_TOOL_PROPS);
|
||||
const bool region_flag_old = region_props->flag;
|
||||
if (!(region_props->v2d.flag & V2D_IS_INIT)) {
|
||||
if (ED_fileselect_is_asset_browser(sfile)) {
|
||||
/* Hide by default in asset browser. */
|
||||
region_props->flag |= RGN_FLAG_HIDDEN;
|
||||
}
|
||||
else {
|
||||
if (params->flag & FILE_HIDE_TOOL_PROPS) {
|
||||
region_props->flag |= RGN_FLAG_HIDDEN;
|
||||
}
|
||||
else {
|
||||
region_props->flag &= ~RGN_FLAG_HIDDEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (region_flag_old != region_props->flag) {
|
||||
ED_region_visibility_change_update((bContext *)C, area, region_props);
|
||||
}
|
||||
}
|
||||
|
||||
ED_area_tag_redraw(area);
|
||||
}
|
||||
|
||||
|
@ -792,6 +803,10 @@ static int file_space_subtype_get(ScrArea *area)
|
|||
static void file_space_subtype_set(ScrArea *area, int value)
|
||||
{
|
||||
SpaceFile *sfile = area->spacedata.first;
|
||||
/* Force re-init. */
|
||||
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
||||
region->v2d.flag &= ~V2D_IS_INIT;
|
||||
}
|
||||
sfile->browse_mode = value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue