diff options
author | Hans Goudey <h.goudey@me.com> | 2021-11-20 01:36:11 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-11-20 01:36:11 +0300 |
commit | 01df48a983944ab3f8a6f3be926f825ac83bbc14 (patch) | |
tree | 8fab42eb2a468786351e274027faa4538ecc631a /source/blender/editors/space_spreadsheet/space_spreadsheet.cc | |
parent | a0780ad6253fcb9768dd3184351998effef6d178 (diff) |
Refactor: Port spreadsheet data set to UI tree view
This patch removes a bunch of specific code for drawing the spreadsheet
data set region, which was an overly specific solution for a generic UI.
Nowadays, the UI tree view API used for asset browser catalogs is a much
better way to implement this behavior.
To make this possible, the tree view API is extended in a few ways.
Collapsibility can now be turned off, and whether an item should
be active is moved to a separate virtual function.
The only visual change is that the items are now drawn in a box,
just like the asset catalog.
Differential Revision: https://developer.blender.org/D13198
Diffstat (limited to 'source/blender/editors/space_spreadsheet/space_spreadsheet.cc')
-rw-r--r-- | source/blender/editors/space_spreadsheet/space_spreadsheet.cc | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index 50b67c55bd6..b37706e02e8 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -41,6 +41,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "BLT_translation.h" + #include "BLF_api.h" #include "spreadsheet_intern.hh" @@ -591,35 +593,10 @@ static void spreadsheet_dataset_region_listener(const wmRegionListenerParams *pa spreadsheet_header_region_listener(params); } -static void spreadsheet_dataset_region_init(wmWindowManager *wm, ARegion *region) -{ - region->v2d.scroll |= V2D_SCROLL_RIGHT; - region->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP | V2D_SCROLL_BOTTOM); - region->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; - region->v2d.scroll |= V2D_SCROLL_VERTICAL_HIDE; - - UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy); - - wmKeyMap *keymap = WM_keymap_ensure( - wm->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, 0); - WM_event_add_keymap_handler(®ion->handlers, keymap); -} - static void spreadsheet_dataset_region_draw(const bContext *C, ARegion *region) { spreadsheet_update_context_path(C); - - View2D *v2d = ®ion->v2d; - UI_view2d_view_ortho(v2d); - UI_ThemeClearColor(TH_BACK); - - draw_dataset_in_region(C, region); - - /* reset view matrix */ - UI_view2d_view_restore(C); - - /* scrollers */ - UI_view2d_scrollers_draw(v2d, nullptr); + ED_region_panels(C, region); } static void spreadsheet_sidebar_init(wmWindowManager *wm, ARegion *region) @@ -710,11 +687,12 @@ void ED_spacetype_spreadsheet(void) /* regions: channels */ art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spreadsheet dataset region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex = 200 + V2D_SCROLL_WIDTH; + art->prefsizex = 150 + V2D_SCROLL_WIDTH; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init = spreadsheet_dataset_region_init; + art->init = ED_region_panels_init; art->draw = spreadsheet_dataset_region_draw; art->listener = spreadsheet_dataset_region_listener; + blender::ed::spreadsheet::spreadsheet_data_set_region_panels_register(*art); BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); |