1
1

Compare commits

...

356 Commits

Author SHA1 Message Date
Severin
5a17c9bcbc Merge branch 'blender2.8' into temp-tab_drag_drop 2018-07-02 14:50:45 +02:00
Severin
9887b38692 Cleanup: Refactor button-group code
* Split generic button-group code from specific application
* Move button-group API to interface.c.
* Avoid struct abuse by using wrapper structs
* Naming, comments, etc.
2018-07-02 14:19:49 +02:00
Severin
9b2a4c6765 Fix error in reordering after new items were added. 2018-07-02 02:09:32 +02:00
Severin
edca1e3dbf Fix error in last merge
Was freeing memory too early, it will be correctly freed a few lines later.
2018-07-02 01:51:58 +02:00
Severin
e5f49598b0 Merge branch 'blender2.8' into temp-tab_drag_drop 2018-06-30 21:12:19 +02:00
Julian Eisel
b088a38791 Merge branch 'topbar' into temp-tab_drag_drop 2018-05-13 14:57:06 +02:00
Julian Eisel
3d376dfd52 Merge branch 'blender2.8' into topbar 2018-05-13 14:56:46 +02:00
Julian Eisel
0bbc97b63a Merge branch 'topbar' into temp-tab_drag_drop 2018-05-12 15:36:59 +02:00
Julian Eisel
ca4964a37a Merge branch 'blender2.8' into topbar
Keeping the branch for now, I might delete it soon though.
2018-05-12 15:30:35 +02:00
Julian Eisel
54d99ef2c3 Fix unintentional changes from merge conflicts 2018-04-20 17:09:52 +02:00
Julian Eisel
7ac193cd7a Merge branch 'blender2.8' into topbar 2018-04-20 16:05:07 +02:00
Julian Eisel
8ff385dd49 Move data of global areas into a separate struct
Made the struct accessible via a pointer in the ScrArea so that we can
use a simple NULL-check for this pointer to see if the area is global.

The struct is not written to files, meaning we have the freedom to do
changes to it without having to worry about compatibility.
2018-04-20 15:59:31 +02:00
Julian Eisel
17da4eadba Fix hint for makesdna to not write top-bar struct commented out
Just did this for testing, but should not have ended up in the commit.
2018-04-20 14:43:54 +02:00
Julian Eisel
032d268313 Support hiding the lower sub-bar by dragging the area edge up 2018-04-20 14:43:54 +02:00
Julian Eisel
93271e5857 Bring back unintentionally removed error print 2018-04-20 14:43:54 +02:00
ab10cb5ca8 Topbar: disable redo properties in topbar entirely for now, behind #ifdef.
This is going to be different with the tool / command separation plans, so
let's not confuse users for now.
2018-04-20 14:33:48 +02:00
f8872e8576 Fix error from one of the merges, this line should have been removed. 2018-04-20 14:33:37 +02:00
52883dd4ed Tweaks to topbar versioning code
* Don't write global area pointers at all, leaves .blends a little
  cleaner without broken pointers.
* Don't call editors functions from blenloader.
* Fix black topbar when loading some existing 2.8 saved .blends.
2018-04-19 19:39:21 +02:00
3f977d18f0 Merge branch 'blender2.8' into topbar 2018-04-19 19:39:19 +02:00
Julian Eisel
90c1426870 Fix typo in #define 2018-04-19 15:25:16 +02:00
Julian Eisel
f44680b360 Make global areas use properly managed screen-verts and screen-edges
* Added functions for ScrAreaMap to avoid code duplication
* Fixed loading files without top-bar not adding top-bar at all
2018-04-19 15:22:58 +02:00
Julian Eisel
9571a2b27f Add ScrAreaMap struct wrapping screen-areas, -edges and -vertices
Global areas will need to use the edge and vertex lists in future too.
Once the topbar branch is merged, we can also change bScreen to use this
struct, avoiding code duplication.
2018-04-19 12:42:58 +02:00
Julian Eisel
ff377b9c16 Don't allow changing area into topbar editor, hide its menu item
We probably want to allow Python scripts to check if an area is the
topbar or later the status bar. Not sure if that'll work right now, I
can't test since global areas are not iterable through BPY at all.
Maybe that's fine too ;)
2018-04-19 11:52:27 +02:00
Julian Eisel
72ca39f2a8 Disable toolshelf redo regions for now
Inteded to do that in rB223f4fa583cb386 already, but forgot to comment
out again after testing...
2018-04-19 11:03:04 +02:00
Julian Eisel
739d3bc534 Don't write topbar data into files (yet)
We decided to do this so we don't have to care much about compatibility. The
code for writing is just #ifdef'ed out so it can easily be brought back.
2018-04-19 11:02:39 +02:00
Julian Eisel
223f4fa583 Bring back toolshelf redo region, ifdef'ed out though
Just for until the design is better defined. Also moved SpaceTopBar
struct to a better place in its DNA file.
2018-04-18 23:40:35 +02:00
Julian Eisel
2fb94f457e Only remove info editors on top of the window using the full width
Removing all info editors could cause issues. Wanted to get proper
layout resolving to work, but wasted more than an entire day on that.
Still planning to look into that again though.
2018-04-18 22:35:31 +02:00
Julian Eisel
6979de0c17 Fixup for last merge 2018-04-18 22:32:57 +02:00
Julian Eisel
d7a063f166 Merge branch 'blender2.8' into topbar 2018-04-18 18:31:29 +02:00
Julian Eisel
39784b70e2 Merge branch 'blender2.8' into topbar 2018-04-17 10:36:45 +02:00
Julian Eisel
e519bfea37 Initial working drag & drop for workspace tabs
Had to do quite some changes to get this to work, mainly because we'd
want to have the customized order written to files. Also wanted to use
existing wmDrag and wmDropBox code but modify it for our needs.
And of course, this should not just work for a single case, code should
be applicable to other areas as well.

Note that file read/write is not working (yet), neither is versioning, region
copying and deleting workspaces working.
Code is also very WIP, much of it is placed in temporary places and
such.

Once the basics are done, we can add nicer feeback during drag & drop.
2018-04-16 19:09:14 +02:00
78fdd1a6f0 Merge branch 'blender2.8' into topbar 2018-04-16 15:26:37 +02:00
Julian Eisel
d03634b7d9 Merge branch 'blender2.8' into topbar 2018-04-13 11:09:25 +02:00
Julian Eisel
3df270b1cf Merge branch 'blender2.8' into topbar 2018-04-12 14:42:55 +02:00
Julian Eisel
4d250c4469 Merge branch 'blender2.8' into topbar 2018-04-08 15:01:51 +02:00
Julian Eisel
3a2d7ef541 Merge branch 'blender2.8' into topbar 2018-04-08 12:51:13 +02:00
Julian Eisel
aee5a80a83 Merge branch 'blender2.8' into topbar 2018-03-19 21:53:48 +01:00
Julian Eisel
ec6545efad Merge branch 'blender2.8' into topbar 2018-02-21 18:22:25 +01:00
Julian Eisel
3f0871dfcf Merge branch 'blender2.8' into topbar 2018-01-29 23:24:11 +01:00
Julian Eisel
53d94dafc4 Fix issues in .py after last merge 2017-12-07 18:02:12 +01:00
Julian Eisel
9d956c65a6 Merge branch 'blender2.8' into topbar 2017-12-06 17:42:39 +01:00
Julian Eisel
8f46733e77 Merge branch 'blender2.8' into topbar 2017-11-27 16:25:53 +01:00
Julian Eisel
e1f7ea1f0f Get rid of left over from redo panel in clip editor 2017-11-23 20:50:12 +01:00
Julian Eisel
3ba7204927 Fix context issues when using operator repeat from top-bar
Use same fix for it as rB815eebbe17ab632.
2017-11-23 19:53:22 +01:00
Julian Eisel
dbbbc1649b Fix glitches when using repeat button in top-bar
Repeat button is the one with the operator name in it.
In some cases it wouldn't work at all, e.g. Edit Mode toggle operator.
2017-11-23 19:00:51 +01:00
Julian Eisel
1b400c1364 Only add "More..." button when there are advanced operator properties 2017-11-23 18:26:50 +01:00
Julian Eisel
b8c2a79b87 Don't draw advanced operator properties in top-bar 2017-11-23 17:29:00 +01:00
Julian Eisel
400b610b7e Merge branch 'blender2.8' into topbar 2017-11-23 17:15:12 +01:00
Julian Eisel
8f753ca09f Merge branch 'blender2.8' into topbar 2017-11-18 05:01:49 +01:00
Julian Eisel
fbfe7cc50a Cleanup: Use enum instead of char codes, naming 2017-11-18 04:54:52 +01:00
Julian Eisel
d824d1026f Fix buttons for string properties not drawn nicely in top-bar 2017-11-18 04:12:49 +01:00
Julian Eisel
f25f7fd9f1 Merge branch 'blender2.8' into topbar 2017-11-15 23:52:16 +01:00
Julian Eisel
145077bea7 Fix top-bar showing "Redo Unsupported" in operator settings again
Own mistake in rBd6ca724a0e57791d96.
2017-10-28 01:06:07 +02:00
Julian Eisel
d6ca724a0e Refactor operator settings drawing to support operator-macros
Settings of operator-macros wouldn't be shown in the top-bar.
2017-10-27 17:13:53 +02:00
Julian Eisel
08258f92e4 Workaround for 1 px button alignment issue
Needed to offset layout by one pixel to the right and top. Spent hours
debugging what causes this, without luck. For now a stupid workaround
should do it.
2017-10-27 15:41:33 +02:00
Julian Eisel
98e72c2860 Corrections to screen-vertex placement 2017-10-27 15:30:02 +02:00
Julian Eisel
72ef82ea56 Fix crash when trying to maximize area while hovering separator 2017-10-26 23:33:16 +02:00
Julian Eisel
27fac6b417 Forbid flipping regions in top-bar 2017-10-26 23:30:02 +02:00
Julian Eisel
4400973ae4 Merge branch 'blender2.8' into topbar 2017-10-26 23:16:33 +02:00
Julian Eisel
e1557b0d7a Fix crash when trying to make top-bar area full-screen
Top-bar should never be full-screen, so disable operator.
2017-10-26 19:48:48 +02:00
Julian Eisel
5a5cdabb25 Merge branch 'blender2.8' into topbar 2017-10-25 22:04:27 +02:00
Julian Eisel
e3f8d16f4b Merge branch 'blender2.8' into topbar 2017-10-25 17:34:55 +02:00
Julian Eisel
8b5bc54dd6 Merge branch 'blender2.8' into topbar 2017-10-24 22:43:30 +02:00
Julian Eisel
815eebbe17 Solve context issues when tweaking operator settings from top-bar
E.g. editing settings after transforming in 3D View would print
warnings, or in Movie Clip Editor wouldn't work at all.

We now store the area & region an operator was executed in and restore
it temporarily when redoing.
Ideally operators wouldn't depend on screen context for event-less
execution (exec callback), but we're far from that.
2017-10-24 17:53:32 +02:00
Julian Eisel
85f7ed1aa8 Remove operator redo panel from clip editor 2017-10-24 17:53:32 +02:00
Dalai Felinto
093de3e97b Merge remote-tracking branch 'origin/blender2.8' into topbar 2017-10-23 18:49:56 -02:00
Julian Eisel
c0bc3c2e14 Move info editor removal versioning code to pre-lib-linking stage 2017-10-23 03:36:09 +02:00
Julian Eisel
1c9c25e5ae Cleanup: Avoid duplicated topbar creation code in versioning code 2017-10-23 03:04:24 +02:00
Julian Eisel
3ddc222c28 Merge branch 'blender2.8' into topbar 2017-10-23 02:18:32 +02:00
Julian Eisel
006efb5fbc Cleanup: Remove leftovers from when branch was based on workspace branch 2017-10-23 02:10:02 +02:00
Julian Eisel
d369421a1f Fixes for last merge 2017-10-23 01:09:52 +02:00
Julian Eisel
94fd6df9fa Merge branch 'blender2.8' into topbar 2017-10-23 00:23:10 +02:00
Julian Eisel
c9e67c49bb Merge branch 'blender2.8' into topbar 2017-10-22 15:02:20 +02:00
Julian Eisel
01880202d8 Cleanup: Change flag name, add comment 2017-10-21 16:17:10 +02:00
Julian Eisel
689b52bf6a Clarify region size refreshing code in ED_screen_ensure_updated 2017-10-21 16:05:02 +02:00
Julian Eisel
82b667bb00 Fix headers not using correct background color 2017-10-21 15:51:06 +02:00
Julian Eisel
3ebfd533ca Top-bar operator settings: Add simple "More..." button to show all settings
Doesn't make much sense yet, but it will once operator settings are
split into basic and advanced ones (see D2883).
2017-10-21 15:36:03 +02:00
Julian Eisel
f2b31b510a Fix errors in UI scripts after last merge
Patch by @sergey, with minor fixes.
2017-10-19 19:37:29 +02:00
Julian Eisel
69b4c9f6e5 Merge branch 'blender2.8' into topbar 2017-10-18 19:31:00 +02:00
Julian Eisel
c470620c16 Rework tab data storing to fix glitches & get rid of hacks
Fixes glitch where hovering an active tab would make the tab appear like
a hovered non-active one.

Still not the most beautiful solution, but it's as good as it can get
with our current UI code I'm afraid.
2017-10-15 15:06:13 +02:00
Julian Eisel
01cfcfaed6 Don't show redo buttons in top-bar if redo is not supported 2017-10-14 00:17:22 +02:00
Julian Eisel
6213b91952 Merge branch 'blender2.8' into topbar 2017-10-13 21:51:09 +02:00
Julian Eisel
7d97751b0c Merge branch 'blender2.8' into topbar 2017-10-10 17:31:51 +02:00
Julian Eisel
0aaffc4f03 Remove ED_area_global_initialize
Should be fine if global areas call ED_area_initialize now.
2017-10-07 16:42:06 +02:00
Julian Eisel
f05bad92bf Fix small jumps of area rectangles and contents
Should also fix some glitches/jumping on HiDPI screens.

Most of this is related cleanup, actual fix is rather small (check
changes in screen_vertices_scale and WM_window_screen_pixels_y)
2017-10-07 16:35:07 +02:00
Julian Eisel
a11ecbd8ef Merge branch 'blender2.8' into topbar 2017-10-06 23:28:06 +02:00
Julian Eisel
33bed11248 Add 'x' icon to active workspace tab to delete workspace
Icon could be a bit nicer, but is consistent with other places in the
UI. Code is also a bit hacky, as usual in interface handling...
2017-10-06 17:02:22 +02:00
Julian Eisel
b11679cbf6 Merge branch 'blender2.8' into topbar 2017-10-05 21:20:45 +02:00
Julian Eisel
abb8265368 Merge branch 'blender2.8' into topbar 2017-10-04 19:10:12 +02:00
Julian Eisel
ce8b061216 Splash: Increase contrast of build info text
Now uses "Text Selected" theme color of "Menu Back" widget colors. Also
repositioned text slightly to have same margin on top and right (measured
by eye ;) ).
Tested with all bundled themes (contrib and no-contrib) and worked fine.

Considering that different splashes may need different colors for
overlaid text, using theme color may not be the best solution. I would
like to try how this works before adding an ugly way to force a certain
text color though.
Also tried different approaches, but this one I find the least ugly :S

As far as longer term plans go, we wanted to get a redesigned multi-page
splash screen anyway. At this point we can rethink how splash colors work
in general (i.e. auto-contrast, own splash theme colors, etc).
2017-09-23 15:57:11 +02:00
Julian Eisel
357fd70acf Merge branch 'blender2.8' into topbar 2017-09-23 04:16:36 +02:00
Julian Eisel
6889c5d106 Merge branch 'blender2.8' into topbar 2017-09-20 21:46:32 +02:00
Julian Eisel
59f39055a8 Merge branch 'blender2.8' into topbar 2017-09-16 09:19:07 +02:00
Julian Eisel
e890a3f7cb Merge branch 'blender2.8' into topbar 2017-09-06 00:18:39 +02:00
Julian Eisel
671a0dd85f Merge branch 'blender2.8' into topbar
Conflicts:
    source/blender/windowmanager/intern/wm_event_system.c
2017-08-28 02:11:19 +02:00
Julian Eisel
6d65c2cff6 Merge branch 'blender2.8' into topbar
Conflicts:
	source/blender/editors/interface/resources.c
2017-08-18 21:00:39 +02:00
Julian Eisel
985c0cd39f Fix touchpad scrolling not working in topbar 2017-08-12 18:14:22 +02:00
Julian Eisel
9f9866b617 Remove redundant setting of area size; Add comments 2017-08-02 03:24:46 +02:00
Julian Eisel
7ee8c576b3 Merge branch 'blender2.8' into topbar 2017-08-01 14:05:49 +02:00
Julian Eisel
cc3ae5415a Show theme options for tags in UserPrefs
Also fix buffer out-of-range access and default color of tab outline.
2017-08-01 14:04:39 +02:00
Julian Eisel
f447c49772 Show 'Redo Last' button in the topbar, in front of redo settings 2017-07-29 20:47:44 +02:00
Julian Eisel
7ccf0c694f Don't open old info editor topbar when going fullscreen 2017-07-29 19:45:44 +02:00
Julian Eisel
38ccbac482 Fixes for topbar layout updating 2017-07-29 18:54:32 +02:00
Julian Eisel
4ad68e00a9 Get file read/write and undo/redo to work 2017-07-28 19:14:32 +02:00
Julian Eisel
8489bdccce Merge branch 'blender2.8' into topbar 2017-07-28 14:29:34 +02:00
Julian Eisel
c9a4f25594 Merge branch 'blender2.8' into topbar 2017-07-27 13:17:54 +02:00
Julian Eisel
0fe04593a8 Merge branch 'blender2.8' into topbar
Conflicts:
	source/blender/windowmanager/intern/wm_event_system.c
2017-07-27 13:16:55 +02:00
Julian Eisel
63f54f6d8d Fix scale glitches on startup & DPI change 2017-07-18 20:49:14 +02:00
Julian Eisel
be7bec33f6 Support renaming workspaces through tabs
Rename workspaces by double or ctrl clicking their tab.
2017-07-18 01:43:47 +02:00
Julian Eisel
f8cf3afb22 Minor corrections to tab drawing 2017-07-17 17:56:26 +02:00
e7d5cc8111 Merge branch 'blender2.8' into topbar 2017-07-17 16:05:58 +02:00
Julian Eisel
36806f935f Make topbar scale correctly with DPI 2017-07-11 21:03:16 +02:00
Julian Eisel
9525a41c32 Split topbar into multiple aligned & independently scrollable sections
Done by adding multiple window/header region types.
2017-07-11 05:57:37 +02:00
Julian Eisel
dd1509de43 Merge branch 'blender2.8' into topbar
Conflicts:
	source/blenderplayer/bad_level_call_stubs/stubs.c
2017-07-09 21:52:32 +02:00
Julian Eisel
26251c2673 Fix 'New Window' operator not creating topbar 2017-07-09 21:13:38 +02:00
Julian Eisel
84c2f941f5 Fix multiple tooltips appearing in topbar
Could happen on quick mouse moves throughout topbar regions.
2017-07-09 21:06:14 +02:00
Julian Eisel
bcb8bfdf60 Fix redraw glitches with popups overlapping topbar 2017-07-08 20:36:31 +02:00
Julian Eisel
bc1f409d1e Use tabs to list workspaces in topbar
Did some additional changes to make tabs align properly and look good.
2017-07-08 19:08:43 +02:00
Julian Eisel
e463dc8dac Merge branch 'blender2.8' into topbar
Conflicts:
	source/blender/blenloader/intern/versioning_280.c
	source/blenderplayer/bad_level_call_stubs/stubs.c
2017-07-08 16:09:25 +02:00
Julian Eisel
1675f7664d Quick fix for huge preview button in topbar 2017-06-28 14:05:34 +02:00
Julian Eisel
50b2122c70 Fix error in versioning code after latest merge 2017-06-12 03:32:36 +02:00
Julian Eisel
a0cc71ce7a Merge branch 'blender2.8' into topbar
Conflicts:
	release/scripts/startup/bl_ui/space_info.py
	source/blender/CMakeLists.txt
	source/blender/blenkernel/BKE_library.h
	source/blender/blenkernel/BKE_screen.h
	source/blender/blenkernel/BKE_workspace.h
	source/blender/blenkernel/intern/blendfile.c
	source/blender/blenkernel/intern/idcode.c
	source/blender/blenkernel/intern/library.c
	source/blender/blenkernel/intern/library_query.c
	source/blender/blenkernel/intern/screen.c
	source/blender/blenkernel/intern/workspace.c
	source/blender/blenloader/BLO_readfile.h
	source/blender/blenloader/intern/readfile.c
	source/blender/blenloader/intern/versioning_280.c
	source/blender/blenloader/intern/versioning_defaults.c
	source/blender/blenloader/intern/writefile.c
	source/blender/editors/include/ED_scene.h
	source/blender/editors/include/ED_screen.h
	source/blender/editors/interface/interface_intern.h
	source/blender/editors/interface/interface_layout.c
	source/blender/editors/interface/interface_templates.c
	source/blender/editors/interface/interface_utils.c
	source/blender/editors/object/object_edit.c
	source/blender/editors/scene/CMakeLists.txt
	source/blender/editors/scene/scene_edit.c
	source/blender/editors/screen/area.c
	source/blender/editors/screen/screen_edit.c
	source/blender/editors/screen/screen_intern.h
	source/blender/editors/screen/screen_ops.c
	source/blender/editors/screen/workspace_edit.c
	source/blender/editors/screen/workspace_layout_edit.c
	source/blender/editors/space_file/filesel.c
	source/blender/editors/space_outliner/outliner_intern.h
	source/blender/editors/space_view3d/view3d_header.c
	source/blender/editors/transform/transform_manipulator.c
	source/blender/editors/transform/transform_ops.c
	source/blender/editors/transform/transform_orientations.c
	source/blender/imbuf/intern/thumbs_blend.c
	source/blender/makesdna/DNA_ID.h
	source/blender/makesdna/intern/makesdna.c
	source/blender/makesrna/intern/rna_internal.h
	source/blender/makesrna/intern/rna_main.c
	source/blender/makesrna/intern/rna_main_api.c
	source/blender/makesrna/intern/rna_scene.c
	source/blender/makesrna/intern/rna_screen.c
	source/blender/makesrna/intern/rna_space.c
	source/blender/makesrna/intern/rna_space_api.c
	source/blender/makesrna/intern/rna_wm.c
	source/blender/makesrna/intern/rna_workspace.c
	source/blender/python/intern/bpy_library_load.c
	source/blender/windowmanager/intern/wm_draw.c
	source/blender/windowmanager/intern/wm_event_system.c
	source/blender/windowmanager/intern/wm_files_link.c
	source/blender/windowmanager/intern/wm_window.c
	source/blenderplayer/bad_level_call_stubs/stubs.c
2017-06-12 03:16:07 +02:00
Julian Eisel
f920910ca4 Update topbar theme colors 2017-05-11 21:16:57 +02:00
Julian Eisel
99e16eb2f6 Remove 3D View redo region/panel 2017-05-11 03:59:04 +02:00
Julian Eisel
5546dae589 Move around buttons in topbar 2017-05-11 03:42:48 +02:00
Julian Eisel
25556e9eaa Show operator redo buttons in topbar
Just an initial implementation, could use some more work/polish.
2017-05-11 03:29:46 +02:00
Julian Eisel
bbbeae4531 Draw lower bar of top-bar using header drawing & definition code 2017-05-11 00:07:02 +02:00
Julian Eisel
bd0e396557 Fix compile error, cleanup 2017-05-10 23:21:50 +02:00
Julian Eisel
58c6d5c1c1 Merge branch 'workspaces' into topbar 2017-05-10 20:26:31 +02:00
Julian Eisel
3f5ddbf724 Merge branch 'blender2.8' into workspaces 2017-05-08 00:19:46 +02:00
Julian Eisel
b7c756985a Revert redundant workaround for buffer overflow
This reverts commit 9ddb857c7a.
Should be redundant after rB839bf119c1a774b475.
2017-05-07 23:57:08 +02:00
Julian Eisel
9b1a5b942c Better fix for reading fullscreens from old files
Old fix was rBe38481e53b84db. We now solve this in a nicer way by doing
all workspace versioning after lib-linking.
2017-05-07 23:26:42 +02:00
Julian Eisel
99184b77f9 Fix empty default workspace configuration
The default workspace configuration bundled with Blender was supposed to
contain the pre-2.8 default screen-layouts converted to workspaces ("3D
View Full", "Animation", "Compositing", ...). Apparently I committed the
configuration with only one workspace though ("General"), so correcting
now.
2017-05-07 20:58:10 +02:00
Julian Eisel
d0f4a4fc67 Fix crash opening startup.blend as regular .blend (again)
Earlier fix could cause issues and was reverted in rBfc601d8eaa79a7.
Fixed now by avoiding CTX_ call when context hasn't been setup
completely yet.
I think it's fine to assume G.main equals CTX_data_main call at this point.
2017-05-07 02:00:21 +02:00
Julian Eisel
84f9c8e618 Fix (harmless) error print with multiple workspaces
Fixes issue reported in https://developer.blender.org/D2451#62155.
Caused by rB8c250c9b73797520.
2017-05-07 01:44:03 +02:00
Julian Eisel
b10943568b Fix failing assert on undo
Caused by rB9fa84d640f151 which set the deprecated pointer for forward
compatibility, leading to failling assertion of this pointer being NULL.
We now NULL the pointer again after writing to file.
2017-05-07 01:03:53 +02:00
Julian Eisel
31f9627d95 Merge branch 'blender2.8' into workspaces 2017-05-07 00:38:29 +02:00
Julian Eisel
b4ff8e9947 Fix crash when loading .blend with multiple scenes 2017-05-06 01:50:22 +02:00
Julian Eisel
9e9ebf6210 Fix crash loading pre-2.80 .blends
Caused by rBe0f4fbd45ad6e57b.
2017-05-05 21:46:35 +02:00
Julian Eisel
52c46ceede Fix unfreed IDProperties, caused by branch merges 2017-05-05 21:42:22 +02:00
Julian Eisel
638a0410d1 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/blenloader/intern/versioning_280.c
2017-05-05 21:40:36 +02:00
Julian Eisel
33ab40504d Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/readfile.c
2017-05-05 13:20:41 +02:00
Julian Eisel
e0f4fbd45a Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenkernel/intern/scene.c
	source/blender/blenloader/intern/readfile.c
	source/blender/blenloader/intern/versioning_280.c
2017-05-03 23:49:53 +02:00
d0937aa54b Merge branch '28' into workspaces 2017-05-02 10:06:02 +10:00
b7607949f7 Use iterator for for do_version_workspaces_after_lib_link 2017-05-02 09:16:50 +10:00
f7e57c4474 Disabling USE_WORKSPACE_MODE works again 2017-05-02 09:03:54 +10:00
d9d769732d Use uppercase for macros 2017-05-02 09:00:58 +10:00
08d36367ed Use DNA as a prefix, for workspace define too 2017-05-02 08:35:11 +10:00
e2b73c5bfd Use DNA as a prefix 2017-05-02 08:33:23 +10:00
fca4be1c82 Cleanup: formatting 2017-05-02 08:32:06 +10:00
7502b07806 Clear win->screen pointer
Caused assert when loading
2017-05-02 07:22:05 +10:00
4d7d7f6e57 Merge branch '28' into workspaces 2017-05-02 07:03:53 +10:00
fc601d8eaa Revert minor order change - wm_file_read_post
This function is meant to be last and I couldn't redo any bugs after
re-ordering.
2017-05-02 06:57:18 +10:00
4963a41382 Use Main as the first argument 2017-05-02 06:54:27 +10:00
e38481e53b Fix for crash loading a file containing a temp (maximized) screen.
Not pretty, we need to remove temp workspaces after creating them
because of order-of-initialization logic here, see: D2451#62433
2017-05-02 06:46:20 +10:00
6f54ce516d Re-order for versioning 2017-05-02 02:06:54 +10:00
1d12ab0281 Use printf instead of assert
I can only assume BLI_assert wasn't configured to call real asserts,
is seems this is more of a warning.
2017-05-02 01:54:14 +10:00
9ddb857c7a Fix buffer overrun when setting the name
Would happen on default startup file. Strings allocations were set to
`but->hardmax + 1`, not `items->maxstrlen`
2017-05-02 01:18:44 +10:00
a2c8c32f01 Odd use of BLI_strncpy (just use strcpy) 2017-05-02 00:13:05 +10:00
41541b33f8 Merge branch '28' into workspaces 2017-05-01 23:51:09 +10:00
Julian Eisel
cdf7722bee Merge branch 'workspaces' into topbar
Conflicts:
	source/blender/blenloader/intern/versioning_280.c
	source/blender/editors/screen/workspace_edit.c
2017-04-27 01:27:06 +02:00
Julian Eisel
7cb2f43b07 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenkernel/BKE_layer.h
	source/blender/blenkernel/intern/layer.c
	source/blender/blenkernel/intern/library_query.c
	source/blender/editors/interface/interface_eyedropper.c
	source/blender/editors/space_image/space_image.c
2017-04-26 21:54:28 +02:00
07f76baa86 App Templates: optionally use app-template path for workspaces
Also make WM_OT_save_workspace_file follow WM_OT_save_userpref logic
more closely.
2017-04-25 16:54:09 +10:00
a09609f21e Minor changes only, use BKE prefix and remove nested header 2017-04-25 16:24:26 +10:00
63822449f9 Merge branch '28' into workspaces 2017-04-14 18:32:43 +10:00
1614853d6d Merge branch 'blender2.8' into workspaces 2017-04-12 21:08:26 +10:00
Julian Eisel
0d122bb7b4 Merge branch 'blender2.8' into workspaces 2017-04-09 22:52:56 +02:00
Julian Eisel
9936f702ba Fix missing workspace render-layer update when changing scene 2017-04-09 14:41:39 +02:00
Julian Eisel
3e77baafa7 Minor fix for notifiers & cleanup 2017-04-09 14:30:26 +02:00
Julian Eisel
4af46de05b Merge branch 'blender2.8' into workspaces 2017-04-09 13:55:33 +02:00
6e12bd6cf2 Merge branch 'blender2.8' into workspaces 2017-04-09 16:12:07 +10:00
6525396057 Cleanup: use calloc for DNA data
ensures pad-members are set, avoids junk data in the file & quiets
memory checking tools.
2017-04-09 15:03:36 +10:00
7ab89c260e Cleanup: use BLI_find util functions 2017-04-09 15:02:29 +10:00
Julian Eisel
4e7a99047f Add/use utility macros for getters/setters in BKE_workspace.h 2017-04-08 17:42:29 +02:00
Julian Eisel
8c250c9b73 General cleanup of workspace files (naming, function ordering, etc) 2017-04-08 17:23:48 +02:00
fca0b1a790 Merge branch 'blender2.8' into workspaces 2017-04-08 14:22:24 +10:00
Julian Eisel
86d6ee427c Sync with blender2.8, cleanup, remove unintentionally committed files 2017-04-07 17:54:08 +02:00
Julian Eisel
1042a22cbb OpenGL: Get rid of PRIM_QUADS usage in manipulators code 2017-04-07 17:04:14 +02:00
Julian Eisel
5ec9754286 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/depsgraph/intern/depsgraph_tag.cc
	source/blender/editors/screen/screen_edit.c
2017-04-07 16:30:18 +02:00
6a287b2551 Remove DNA_workspace_types
Accidentally committed after choosing not to rename
2017-04-07 10:06:24 +10:00
Julian Eisel
c749bfef52 Fix search menu using wrong search list in full window draw mode
Turns out we can't use static struct data here, so just adding logic for
freeing custom search data when needed.
2017-04-07 01:09:15 +02:00
Julian Eisel
b3e69525a4 Remove redundant TODO mark
workspaces.blend file contain nothing but workspaces (mostly), so there's
nothing to skip when reading.
2017-04-07 00:03:42 +02:00
Julian Eisel
8edb116a81 Don't append temporary screen-layouts with workspaces 2017-04-06 23:46:58 +02:00
Julian Eisel
1ad7359efd Bundle default workspace user configuration file with Blender
This contains nothing but the old screen-layouts converted into
workspaces (and "Default" layout/workspace is now called "General").

Note that this adds the workspaces.blend directly, no datatoc conversion
is used like for default startup.blend. Mainly for these two reasons:
* Appending only supports regular .blend files
* Regular .blend is much smaller than datatoc one (181kB vs. 1.4MB)
2017-04-06 23:32:45 +02:00
Julian Eisel
711a2f59da Rename workflow.blend -> workspaces.blend
Idea was that workflow.blend could be used for non-workspace data later,
but it's not worth the confusion it may cause.
2017-04-06 16:29:12 +02:00
Julian Eisel
6bf8907863 Fix crash opening startup.blend as regular .blend
Also fixed incorrect context change.
2017-04-06 15:32:14 +02:00
Julian Eisel
2825498518 Allow storing workspaces as part of user config (UI preliminary)
Adds a button in the User Preference Interface tab to save all
workspaces of the current file into [user config
path]/config/worflow.blend.
When clicking the button to add a new workspace, the menu will list
these then (and of course the option to duplicate current workspace).

Note that the operator currently overrides all workspaces in the config
file. There should be ways to add and remove workspaces from it instead,
but we need to figure out a good UI design for how to do that still.
2017-04-06 12:19:23 +02:00
9586e36fdc Fix workspace mode syncing
Toggling off a mode didn't correctly update the workspace.
2017-04-05 16:39:01 +10:00
6fa06bdb79 Minor changes
- Remove utildefines from BKE_workspace header
- doxy example are typically for code examples, just use heading
- wrap args, avoid right shift
2017-04-04 23:49:21 +10:00
9fa84d640f Fix files loading with wrong screen in 2.7x 2017-04-04 23:09:37 +10:00
cf47de1201 Place holder icon
Superficial but looks buggy having no icon
2017-04-04 23:09:37 +10:00
Julian Eisel
fd79a1139c Rename WorkSpaceDataAssignment -> WorkSpaceDataRelation 2017-04-04 14:14:01 +02:00
Julian Eisel
d9b9f53090 Comments: Try to describe WorkSpaceDataAssignment struct better 2017-04-04 13:51:32 +02:00
Julian Eisel
6b29ce360b Merge branch 'blender2.8' into workspaces 2017-04-04 13:05:02 +02:00
1a46fad5f8 Merge branch 'blender2.8' into workspaces 2017-04-04 17:52:50 +10:00
e7d47c2821 Indent to avoid conflicts
without this many lines differ from 2.8x
2017-04-04 17:37:20 +10:00
f737f04457 Merge branch 'blender2.8' into workspaces 2017-04-04 16:29:52 +10:00
924444a640 Error in last commit 2017-04-04 14:12:42 +10:00
125e74d02e Alternate workaround for accessing window at startup 2017-04-04 14:09:48 +10:00
5089fdec18 Merge branch 'blender2.8' into workspaces 2017-04-04 13:58:19 +10:00
a1e997e0be Merge branch 'blender2.8' into workspaces 2017-04-04 13:53:37 +10:00
76cbb49001 Merge branch 'blender2.8' into workspaces 2017-04-04 13:51:49 +10:00
3ba200ccfe Merge branch 'blender2.8' into workspaces 2017-04-04 13:43:13 +10:00
d43aee8320 Merge branch 'blender2.8' into workspaces 2017-04-04 13:35:07 +10:00
7f842e5910 Merge branch 'blender2.8' into workspaces 2017-04-04 13:24:35 +10:00
a881f1da88 Workaround for crash using CTX_data_scene_layer 2017-04-04 13:23:11 +10:00
6b55cd9e08 Merge branch 'blender2.8' into workspaces 2017-04-04 11:54:48 +10:00
5c3641bee4 Merge branch 'blender2.8' into workspaces 2017-04-04 11:25:50 +10:00
fccfc3d76b Merge branch 'blender2.8' into workspaces 2017-04-04 10:51:18 +10:00
Julian Eisel
bde3cda710 Rename editors/workspace back to editors/screen
We'll keep the name 'screen' to describe everything visible within the
window, including the global bars (top bar, status bar) which are not
part of bScreen struct (which describes the customizable screen-layout).
It's quite confusing to have the term 'screen' used for bScreen
operations too, but plan is to get rid of bScreen and move its data to
WorkSpace and WorkSpaceLayout (could be called ScreenLayout then).
2017-03-30 01:30:50 +02:00
Julian Eisel
5896e8ea4e Fix incorrect operator name 2017-03-30 00:48:56 +02:00
Julian Eisel
2803e9ef67 Make branch work with recent changes from master/workspaces 2017-03-30 00:35:27 +02:00
Julian Eisel
0934578f8c Merge branch 'workspaces' into topbar
Conflicts:
	source/blender/blenloader/intern/versioning_280.c
2017-03-30 00:20:01 +02:00
Julian Eisel
ee1177c896 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/versioning_280.c
2017-03-30 00:08:55 +02:00
Julian Eisel
8255daa459 Make reading without UI work again (and undo)
We now try to read the workspace render-layer from the opened file and
activate it in all workspaces.
The workspace of the first stored window is used hereby, just like we use
the scene from the first window too.
2017-03-29 21:33:18 +02:00
Julian Eisel
d045feca5b Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/makesrna/intern/rna_userdef.c
	source/blender/windowmanager/intern/wm_window.c
2017-03-28 23:33:13 +02:00
Julian Eisel
848df59773 Allow choosing workspace from user config when adding workspace
When clicking the '+' icon to add a new workspace, a menu is spawned
now, showing the option 'Duplicate Current', but also a list of all
workspaces stored in a 'workflow.blend' as part of the user
configuration (next to startup.blend and userpref.blend)
Note that this workflow.blend has to be stored manually into the user
config folder right now. Of course it's not supposed to stay like this,
it should all be handled through simple operators for adding and removing
workspaces from the user configuration. We need to find out how that
would work UI wise though (tm).

When choosing a workspace from the menu, Blender does nothing but
appending the workspace from the workflow.blend file.

This design allows having a custom workspace setup stored as part of
the user configuration, it's however still possible to append workspaces
from regular .blend files.
This is useful e.g. if users want to open their workspaces without
overriding the workflow.blend when using the machine of someone else.
2017-03-28 22:52:02 +02:00
Julian Eisel
c0638a4afa Fix crashes when appending workspaces
Also removed FileData access in after-lib-link versioning code, which
can't be used reliably.
2017-03-28 21:20:44 +02:00
Julian Eisel
37c7cfd2c6 Merge branch 'blender2.8' into workspaces 2017-03-25 18:11:33 +01:00
Julian Eisel
dd3707a83d Add missing file 2017-03-17 17:18:24 +01:00
Julian Eisel
b8de04423c Merge branch 'blender2.8' into topbar
Conflicts:
	source/blender/editors/interface/resources.c
2017-03-17 17:17:25 +01:00
Julian Eisel
6a42a17d18 Merge branch 'workspaces' into topbar
Conflicts:
	source/blender/blenloader/intern/writefile.c
2017-03-17 16:19:13 +01:00
Julian Eisel
ae188045fc Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/writefile.c

Adapted branch to changes in blender2.8
2017-03-17 16:09:26 +01:00
Julian Eisel
ff67b9010c Fix wrong render layer used for multi-window setups 2017-03-17 14:59:38 +01:00
Julian Eisel
88eafe078a Fix crash when displaying tooltip of 'New Window' operator 2017-03-17 14:19:19 +01:00
Julian Eisel
6287d254b4 Avoid duplicating layout when activating workspace with used layout
We now fall-back to the first un-used layout we can find, we only create
a new one if none can be found.
2017-03-17 12:39:43 +01:00
Julian Eisel
5f8a1a40b7 Fix new window always duplicating active window instead of selected one
Also removed wrong assert.
2017-03-17 12:01:56 +01:00
Julian Eisel
49f001cd3a Fix 'New Window' operator using name from screen, not layout 2017-03-17 11:41:06 +01:00
Julian Eisel
c7ee2d0e7c Fix crash creating new window with existing layout 2017-03-16 22:58:52 +01:00
Julian Eisel
cf5238aab6 Uber-picky: Remove single pixel offset on topbar 2017-03-16 21:50:16 +01:00
Julian Eisel
bc4590cfe1 Remove all Info Editors when loading old files
Had to move some functions from ED to BKE to avoid having to duplicate
it all.
Works surprisingly well, didn't expect it to be that easy :)
2017-03-16 21:39:01 +01:00
Julian Eisel
dfb442bf4a Merge branch 'workspaces' into topbar
Conflicts:
	source/blender/blenloader/intern/versioning_280.c
	source/blender/editors/workspace/screen_ops.c
	source/blender/editors/workspace/workspace_layout_edit.c
	source/blender/gpu/intern/gpu_framebuffer.c
	source/blender/windowmanager/intern/wm.c
2017-03-16 20:14:13 +01:00
Julian Eisel
e5f3acb123 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/versioning_280.c
	source/blenderplayer/bad_level_call_stubs/stubs.c

Also had to do some more changes in versioning_280.c to prevent startup
crash.
2017-03-16 19:54:35 +01:00
Julian Eisel
3c1b955b4d Store active layout of each workspace per window
Allows users having a different active window stored even in inactive
workspaces per window. So that when activating a workspace the layout
is activated that was active the last time the workspace was active in
this window.
This is basically a per window, per workspace storage, but it's probably
how users would expect things to work.

Also, getting file read/write to work correctly was a challenge once
again, had to use global oldnew-map for pointer lookup on file read.

And another 'also': had to change order in which IDs are freed, so that
workspaces are freed after window-manager. Needed so that we can free
assignments/relations correctly when closing windows.
2017-03-16 18:50:53 +01:00
Julian Eisel
398c6541d0 Fix layout duplicating when changing/adding workspaces
Also fixes glitch with name clash handling when duplicating layout.
2017-03-15 15:17:57 +01:00
Julian Eisel
a283a7f29b Merge branch 'blender2.8' into workspaces 2017-03-15 12:51:51 +01:00
Julian Eisel
a65880dc69 Fix layout being duplicated when activating already active workspace 2017-03-15 12:07:38 +01:00
Julian Eisel
c8f9be2930 Fix crashes when reading files saved with workspace branch
Wasn't easy to solve this and would prefer a more elegant solution,
commented in code what the issues are.
2017-03-15 12:01:34 +01:00
Julian Eisel
4a66507972 Only ensure unique layout name within workspace
For users it doesn't make sense to have screen-layout names unique in
the entire .blend, since they are just a sub-set of workspaces for them.

Uses RNA_def_struct_name_property to override the RNA name of bScreen
and makes sure template_ID gets the name from RNA, not from ID directly.
2017-03-14 16:50:10 +01:00
Julian Eisel
f97fc5f7d7 Support multi-window setups nicely
Opening new windows now never duplicates the workspace, you can now
show the same workspace in multiple windows. The layout is per window
though, so you can have the same workspace active in multiple windows,
but use a different active layout.

Opening windows behaves as follows now:
* Adapt behavior of rB7bc76f8a3c1416b
* Duplicating an area into a new window creates a new screen-layout, we agreed this is probably what users would want.
* Creating a new temporary window (e.g. UserPrefs) adds a new hidden screen-layout
* Enabling multi-view time-sequential creates a new window but doesn't duplicate screen-layout anymore
2017-03-14 12:59:59 +01:00
Julian Eisel
f01ec6e27e Allow changing to workspace that's open in another window
This needs more work still.
2017-03-14 11:42:37 +01:00
Julian Eisel
6e0e156c83 Store active screen-layout per window 2017-03-13 23:21:52 +01:00
Julian Eisel
b8a36f1b07 Fix crashes on file read 2017-03-13 22:34:14 +01:00
Julian Eisel
333719193a Move window level workspace data into struct managed by workspace code 2017-03-13 22:12:33 +01:00
Julian Eisel
8e529690cf Merge branch 'blender2.8' into workspaces 2017-03-13 16:20:50 +01:00
Julian Eisel
40fea5ac9d Get basic button handling in top bar to work 2017-03-13 16:14:03 +01:00
Julian Eisel
5c6eca9467 Support topbar drawing for all draw methods 2017-03-13 15:58:51 +01:00
Julian Eisel
982cd7ef5e Add/use iterator for all areas in screen (not just screen-layout) 2017-03-13 15:28:40 +01:00
Julian Eisel
d7535d4374 Draw info editor buttons in topbar
Basically copies most of the UI definitions from info editor to top bar.
2017-03-13 14:58:18 +01:00
Julian Eisel
c642c2420b Create global areas for all non-temp windows 2017-03-13 11:22:26 +01:00
Julian Eisel
0320b667ab Get rid of hardcoded screen-size calculation
Screen size is the rectangle that can be used by screen layouts, so it
excludes global areas.
2017-03-13 11:04:00 +01:00
Julian Eisel
3ccc83f7bf Merge branch 'workspaces' into topbar
Conflicts:
	source/blender/blenloader/intern/readfile.h
	source/blender/blenloader/intern/versioning_280.c
2017-03-13 10:53:02 +01:00
Julian Eisel
a0b275e8a4 Merge branch 'blender2.8' into workspaces 2017-03-13 10:05:18 +01:00
Julian Eisel
1a64b03963 Merge branch 'blender2.8' into workspaces 2017-03-11 17:46:10 +01:00
Julian Eisel
d88e033f30 Merge branch 'blender2.8' into workspaces 2017-03-09 12:13:33 +01:00
Julian Eisel
e081df9597 Merge branch 'blender2.8' into workspaces 2017-03-06 13:01:43 +01:00
Julian Eisel
d642b25440 Merge branch 'blender2.8' into workspaces 2017-03-03 13:02:32 +01:00
Julian Eisel
d8fe5e0ea1 Support render layer per workspace
We decided to keep workspace and scene render layer separate for now,
but in future they'll probably be either unified or there are going to
be ways to sync them.
2017-03-03 12:35:56 +01:00
Julian Eisel
5941d4e33b Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/makesrna/intern/rna_space.c
2017-03-02 19:26:29 +01:00
Dalai Felinto
c1f0139899 Merge remote-tracking branch 'origin/blender2.8' into workspaces 2017-02-28 14:25:14 +01:00
Julian Eisel
771610bbaf Merge branch 'workspaces' into topbar 2017-02-28 01:30:56 +01:00
Julian Eisel
8e724b6043 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/editors/workspace/glutil.c
	source/blender/gpu/intern/gpu_framebuffer.c
2017-02-28 01:29:53 +01:00
06c51dfa94 OpenGL: wm_gesture uses new imm mode
D2376 by @ianwill, part of T49043
review by @merwin

Box select, circle select, etc. Introducing the dashed-line shader! See D2376 for more info.
2017-02-28 01:21:33 +01:00
dabeaf806c OpenColorIO: Update glsl implementation to be ready for ogl 3.3 core 2017-02-28 01:21:33 +01:00
4cc07f819b Opengl glaDrawPixels removal: More descriptive setup. 2017-02-28 01:21:33 +01:00
Dalai Felinto
3414b883f6 Fix break in drawscredge_area_draw when in fullscreen 2017-02-28 01:21:32 +01:00
Dalai Felinto
a8ad736682 Fix T50714: Collections: Adding object to scene without an existing collection
This was causing blender to segfault.

We now add create a new collection and link to the layer before adding
the new object

(also included unittests, and requires updated lib/tests)
2017-02-28 01:21:31 +01:00
Dalai Felinto
a097123701 Unittest: split object_add in individual test files
(and small cleanup in unittest)

This is required to the upcoming unittest + bugfix
2017-02-28 01:21:31 +01:00
Dalai Felinto
aab365df37 Silence warnings in draw_armature.c
Also add note about incomplete functions there
2017-02-28 01:21:31 +01:00
9a2745b95a OpenGl immediate mode: drawnode.c
Part of T49043
2017-02-28 01:21:31 +01:00
897bd04465 Add immDrawBorderCorners function
This replaces `glaDrawBorderCorners`.
2017-02-28 01:21:31 +01:00
863cc2ebec Opengl glaDrawPixels removal: #if 0 glDrawPixels... 2017-02-28 01:21:30 +01:00
61a7ddb2b2 Opengl glaDrawPixels removal: mask_draw.c 2017-02-28 01:21:30 +01:00
31c4fef9c8 Opengl glaDrawPixels removal: image_draw.c
Using float buffer is still laggy because of the data volume we have to transfer to the GC.
2017-02-28 01:21:30 +01:00
acca78d651 Opengl glaDrawPixels removal: interface 2017-02-28 01:21:30 +01:00
15367dce76 Opengl glaDrawPixels removal: editors/spaces 2017-02-28 01:21:29 +01:00
e428dcaf0d Opengl glaDrawPixels removal: windowmanager 2017-02-28 01:21:29 +01:00
bf9666ae5f Opengl glaDrawPixels removal: editors/render 2017-02-28 01:21:29 +01:00
cd487d654d OpenGL: Make glaDrawImBuf_glsl functions compatible with new immDrawPixels
And change relevant function calls.
2017-02-28 01:21:29 +01:00
61aa808a54 OpenGL immediate mode: new shader image shuffle color
new shader to draw an image with one isolated channel
2017-02-28 01:21:29 +01:00
8a1d44cbd2 OpenGL immediate mode: fix asserts in clip dopesheet 2017-02-28 01:21:29 +01:00
c228848ee5 OpenGL immediate mode: modifying immDrawPixelsTex
This way OCIO can be used with it.
2017-02-28 01:21:28 +01:00
70ceb16552 Clay Engine: fix format (3D instead of 2D) 2017-02-28 01:21:27 +01:00
28ccb92f2a OpenGL immediate mode: gpu_framebuffer.c
I had to make some changes to the sep_gaussian_blur shader to be compliant for gl 3.3 leap
2017-02-28 01:21:27 +01:00
Julian Eisel
f1cedca822 Make global areas draw-able 2017-02-26 15:49:58 +01:00
Julian Eisel
79de361970 Add Top Bar space-type 2017-02-25 22:48:36 +01:00
Julian Eisel
2aa7e32bbd Merge branch 'workspaces' into topbar 2017-02-25 22:12:45 +01:00
Julian Eisel
d0bfb9d1c6 Merge branch 'blender2.8' into workspaces 2017-02-25 22:12:25 +01:00
Julian Eisel
07a1c20398 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenloader/intern/readfile.c
	source/blender/editors/workspace/screen_draw.c
2017-02-24 00:57:17 +01:00
Julian Eisel
95644ec046 Merge branch 'blender2.8' into workspaces 2017-02-12 21:57:10 +01:00
Julian Eisel
af0f9835f8 Merge branch 'blender2.8' into workspaces 2017-02-10 22:48:25 +01:00
Julian Eisel
6a73beed32 Force some free space in window for global topbar 2017-02-10 05:21:47 +01:00
Julian Eisel
92e4f85686 Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/blenkernel/intern/context.c
	source/blender/blenkernel/intern/depsgraph.c
	source/blender/blenkernel/intern/library_query.c
	source/blender/blenloader/intern/readfile.c
	source/blender/blenloader/intern/readfile.h
	source/blender/blenloader/intern/versioning_270.c
	source/blender/editors/workspace/screen_context.c
	source/blender/makesdna/intern/makesdna.c
	source/blenderplayer/bad_level_call_stubs/stubs.c
2017-02-10 03:51:18 +01:00
Julian Eisel
2c400527c5 Change workspace allocation string
Makes it easier to grep.
2017-01-23 17:20:23 +01:00
Julian Eisel
b2c610c92e Fix error on some compiler configurations
Sergey was having compile errors here, I couldn't recreate them though. It actually seems weird that we have to include BLI_utildefines.h before BLI_listbase.h, since the latter one already includes the former. Don't want to bother much with such minor issues though, so let's just make all compilers happy ;)

Patch is by @sergey himself.
2017-01-23 17:18:58 +01:00
Julian Eisel
63d69cf157 Merge branch 'blender2.8' into workspaces 2017-01-22 23:26:44 +01:00
Julian Eisel
9031d5cc8f Fix and compile time option for workspace object-mode
Now we also sync the workspace object-mode when selecting a different object. It's still quite easy to get the mode of the active object and the one stored in the workspace out of sync, but fixing this would require a bunch of changes that would only be temporary anyway. Remember, plan is to make object-mode a purely workspace level option, not storing it within the object anymore.
The current object-mode syncing isn't supposed to stay there for long, I added a #define USE_WORKSPACE_MODE so we can disable it easily (DNA still stores it in files though).
2017-01-22 20:56:18 +01:00
Julian Eisel
f6ceeea4f7 Fix compile error and warning in release builds 2017-01-06 01:18:34 +01:00
Julian Eisel
f05b6afec5 More cleanup (renaming, comments, etc), added asserts 2017-01-05 23:34:50 +01:00
Julian Eisel
7c4a6963e2 Fix foreach_ID_link iterator, undo version bump, cleanup 2017-01-05 22:24:17 +01:00
Julian Eisel
ab46e5402a Improve button placement in Info Editor
* Moved object mode menu in front of scene selection buttons.
* Added separators.
* Show scene selection buttons in editor full-screen

Of course this will all change again once the actual new top-bar is there.
2017-01-05 20:49:52 +01:00
Julian Eisel
2ae0736591 Remove accidentally committed files 2017-01-05 20:33:03 +01:00
Julian Eisel
7aa53f4520 Rename directory editors/screen/ to editors/workspace/
Screen is now considered lower level as workspaces, so screen files should rather be in a folder called 'workspace' instead of having workspace files in a 'screen' directory.
Also corrected doxygen info for editors/scene/.
2017-01-05 20:23:58 +01:00
Julian Eisel
66776bd2f7 Cleanup: Screen/workspace change functions, comments, naming, etc 2017-01-05 19:35:47 +01:00
Julian Eisel
e3c12bb139 Fix glitch when removing custom transform orientations
Scenes aren't stored within screens anymore, meaning we can't associate a 3D View in an inactive workspace/screen with a scene. This again means we can't identify the active transform orientation of a 3D View by its index (it might belong to a different scene) to unset it correctly  when removing it. We now additionally store a pointer in the 3D View to the active custom orientation data to identify it.
2017-01-05 16:43:05 +01:00
Julian Eisel
7f173aea9f Remove "Use Global Scene" option
This option isn't really needed now that scenes are only on window level.
2017-01-05 01:15:42 +01:00
Julian Eisel
dc76cd65cc Remove redundant Depsgraph update call
Scene can't be changed by changing a screen or workspace anymore.
2017-01-05 01:00:06 +01:00
Julian Eisel
b809b02ea5 Merge branch 'blender2.8' into workspaces 2017-01-05 00:36:31 +01:00
Julian Eisel
ff829a365f Fix minor mistake in python UI code 2017-01-05 00:17:51 +01:00
Julian Eisel
73eb89c643 Make object mode part of the workspace
Each workspace now stores the last set object mode type, activating a workspace also activates this mode. This commit also removes the object mode menu from the 3D view header, it's displayed in the info editor header now (and later will be in the top-bar).

We have one issue with Grease Pencil here though: The active grease pencil data-block depends on the active editor, and an editor can only enter GPencil edit mode if it has an active GPencil data-block. The new object mode menu is independent of 3D Views (or any other editor supporting GPencil) though. For now the menu simply won't show the GPencil edit mode item, it will be back once GPencil gets its own object type (as planned). GPencil still provides other ways to enter this mode.
2017-01-04 23:35:24 +01:00
Julian Eisel
9206c3d40a Move workspace DNA back into DNA module
Added some special include guards to protect from access from outside of BKE_workspace and makesdna.
2017-01-04 02:21:43 +01:00
Julian Eisel
2ff803992c Properly append screens with workspaces
Meaning screen data is now fully editable when appending a screen(-layout) indirectly by appending a workspace. Screens aren't visible while browsing inside .blend files, don't think we need/want that.
2017-01-04 01:12:23 +01:00
Julian Eisel
44088be22d Merge branch 'blender2.8' into workspaces 2017-01-04 00:55:26 +01:00
Julian Eisel
18ae49948f Make workspaces appendable, but non-linkable
This basically adds support for data-blocks that are either linkable, appendable or both and uses it for making workspaces appendable only. Note that non-appendable but linkable data-blocks aren't used currently and poorly tested, added note about this in code.
2017-01-04 00:47:28 +01:00
Julian Eisel
7cda7bd22e Make workspaces append-/linkable
TODO:
* Make indirectly linked screens local.
* Make workspaces only appendable, it doesn't make sense to link them.
2017-01-02 02:50:11 +01:00
Julian Eisel
6e1db12a12 Rename "Default" workspace to "General"
Default screen-layout is still called "Default", not sure if we should change that. Ideally the layouts shouldn't be identified by names anyway.
2016-12-31 17:59:20 +01:00
Julian Eisel
fca739e731 Remove workspaces/screen-layouts from default startup.blend except of "Default" one
This means in the default startup.blend, there's only going to be one workspace and one screen-layout, both called "Default" (will be renamed to "General" though). Idea is that users will have the option add a pre-configured workspace from a menu. This avoids cluttering screen space with workspaces the user won't use even.

For compatibility, screen-layouts from old files are still converted to workspaces, this only affects the default startup.blend.
2016-12-31 17:54:23 +01:00
Julian Eisel
d19ebcbe07 Use new after lib-linking versioning 2016-12-31 15:42:42 +01:00
Julian Eisel
f6a43e07ab Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/editors/space_outliner/outliner_intern.h
2016-12-31 02:11:48 +01:00
Julian Eisel
cbaaeb8d9b Deprecate Screen.scene completely
Removing a custom transform orientation is a bit broken right now because we don't know which scene is visible in hidden 3D Views. Think I know how to fix this, but want to go on with other stuff first.
2016-12-31 01:45:59 +01:00
Julian Eisel
0bd8b8fc71 Add/use function to get/set window workspace 2016-12-24 01:31:32 +01:00
Julian Eisel
f98cab1c4b Remove temp workspace when closing temp window (e.g. UserPrefs)
The active screen of the workspace was freed which caused use-after-free in some corner-cases. Now workspace, workspace layout and the screen are deleted correctly.
2016-12-23 20:39:14 +01:00
Julian Eisel
4597b93b52 Make undo and file loading without UI work
Phew, that wasn't easy... lots of digging through history to understand why code is like it is... Also, the window manager relinking in blo_lib_link_screen_restore was never executed (I think) because WM is recreated during file read and was NULL at this point. Now we need to run it, so we simply pass old WM. Things are working quite stable now.
2016-12-23 20:29:21 +01:00
Julian Eisel
e9ba64cb9d Fix incorrect RNA function parameter flags 2016-12-22 14:04:58 +01:00
Julian Eisel
52a80cfc6b Merge branch 'blender2.8' into workspaces
Conflicts:
	source/blender/editors/screen/screen_draw.c
	source/blender/editors/screen/screen_edit.c
	source/blender/editors/screen/screen_intern.h
2016-12-22 02:27:02 +01:00
Julian Eisel
b7e9161833 Make 3D View scene data syncing work with window level scenes.
We previously updated all screens - visible or not - when changing scene layers or scene camera. Now we only update visible ones and ensure a screen is updated when activating it. This simplifies things a bit and makes it possible to update 3D Views directly through notifiers.
2016-12-22 01:50:20 +01:00
Julian Eisel
40272b43c0 Fix crashes when opening new windows 2016-12-21 03:52:44 +01:00
Julian Eisel
61ac773ac1 Find correct scene from screen in RNA callbacks 2016-12-21 03:26:20 +01:00
Julian Eisel
3788eeaad8 Add missing CMakeLists file 2016-12-09 14:01:35 +01:00
Julian Eisel
bdc209faa9 Make WorkSpace and WorkSpaceLayout local DNA structs
Wanted to try this to avoid having (almost) global scope of DNA structs, instead, everything should be handled through BKE_workspace API.
2016-12-09 14:00:05 +01:00
Julian Eisel
f99252693b File read/write support 2016-12-09 02:42:04 +01:00
Julian Eisel
f633873784 Move screen drawing functions into new screen_draw.c 2016-12-08 23:02:29 +01:00
Julian Eisel
944b920a5f Move scene utils into own file (and improve API)
Previously they were kinda mixed with screen utils.
2016-12-08 22:44:34 +01:00
Julian Eisel
adfc9b8550 Make window-level scene switching work 2016-12-08 20:24:29 +01:00
Julian Eisel
56fa168eeb Update RNA and UI scripts to use scene from window 2016-12-08 18:36:59 +01:00
Julian Eisel
c435be7f90 Main work to move active scene into window
Added scene as argument to area/region listeners. It's only used in a really few cases though, I might instead do a lookup.
2016-12-08 00:17:34 +01:00
Julian Eisel
6c64d85eb4 Rename notifier category: NC_SCREEN -> NC_WORKSPACE 2016-12-06 23:52:52 +01:00
Julian Eisel
bdaf74c05e Fix crash when duplicating window 2016-12-06 23:43:40 +01:00
Julian Eisel
476aeb68f6 Manage screen creation within workspace-layout editor API 2016-12-06 23:14:50 +01:00
Julian Eisel
788319b13d Move ED_workspace_layout API into own file 2016-12-06 17:43:30 +01:00
Julian Eisel
e56bfc27bd Fix crash when deleting layouts
Behavior change: The layout we switch to when deleting another one now has to meet similar requirements as the one we choose for cycling layouts (Ctrl+Arrow left/right). E.g. no hidden screen will be activated.
2016-12-06 15:36:40 +01:00
Julian Eisel
db07bce54f Fix crash when toggling area fullscreen 2016-12-06 02:42:05 +01:00
Julian Eisel
20809ec279 Make layout cycling work (Ctrl+Arrow Left/Right) 2016-12-06 01:58:22 +01:00
Julian Eisel
cd20acc529 Make changing layout within workspace work 2016-12-06 00:36:09 +01:00
Julian Eisel
fceaa8f959 Fix mistake in last (non-merge) commit 2016-12-05 18:26:23 +01:00
Julian Eisel
1d04d5f221 Merge branch 'blender2.8' into workspaces 2016-12-05 18:22:03 +01:00
Julian Eisel
387bc547cb Make layout template only show layouts of current workspace
Mainly had to do some changes to template_ID to make this work. It now supports setting a custom RNA collection to search the ID's in.
2016-12-05 18:14:38 +01:00
Julian Eisel
436c1e0221 Make duplicating workspaces work 2016-12-04 23:08:41 +01:00
Julian Eisel
4552b8e1b5 Fixes for changing layout with workspace
Changing workspace should now change to the active layout of the workspace just fine.
Screen/workspace changing is still a bit hacky since we can't do it during normal handlers. Not sure how we could do it instead, for now I'm just copying hacks from screen changing.
2016-12-04 21:47:26 +01:00
Julian Eisel
5c0c1ef8fa Fix layout changing when changing workspace 2016-12-04 00:51:21 +01:00
Julian Eisel
6b47c1d90b Move active screen layout into the active workspace
Changing the workspace now also changes the layout. Note that there is a drawing issue here so you'll have to move the window to see the change. There is also a crash when closing Blender, need to investigate some more.
This commit also cares for compatibility, we simply create a new workspace for each screen layout of the old file.

I want to avoid any low-level access of workspace related data, instead everything should go through an API. Thus I also added some API functions for workspaces.
To store bScreens (aka layout) using a ListBase in a workspace, I had to add a bScreen wrapper, called WorkSpaceLayout.
2016-12-03 14:43:45 +01:00
Julian Eisel
b9d1d90b90 Add/use worksace API functions for adding/changing/deleting
Also removed anything that influences workspace user count, from now on it's simply *always* 1.
2016-12-02 17:40:31 +01:00
Julian Eisel
974c0d3828 Add workspace to bContext 2016-12-02 11:58:36 +01:00
Julian Eisel
8174f8fcbe Add a workspace browsing button to Info Editor header
And actually make it work.
2016-12-02 11:33:58 +01:00
Julian Eisel
177b53fe86 Store a workspace in each window
Some details need to be figured out still (Windows should probably be able to share an active workspace).
2016-12-01 23:59:57 +01:00
Julian Eisel
7a20bbd30e Initially add WorkSpace ID type 2016-12-01 22:54:25 +01:00
20 changed files with 672 additions and 65 deletions

View File

@@ -59,6 +59,9 @@ struct WorkSpace;
struct GPUFXSettings;
struct wmMsgBus;
struct ScrAreaMap;
struct uiBlock;
struct uiButtonGroup;
struct uiButtonGroupItemInfo;
#include "BLI_compiler_attrs.h"
@@ -255,6 +258,18 @@ typedef struct uiListType {
ExtensionRNA ext;
} uiListType;
typedef bool (*uiButtonGroupIdentifyFunc)(struct uiButtonGroup *, void *);
typedef void (*uiButtonGroupItemsFunc)(void *, ListBase *);
typedef void (*uiButtonGroupItemDrawFunc)(struct uiBlock *, void *, struct uiButtonGroupItemInfo *);
typedef struct uiButtonGroupType {
const char *idname;
uiButtonGroupIdentifyFunc identify;
uiButtonGroupItemsFunc items;
uiButtonGroupItemDrawFunc item_draw;
} uiButtonGroupType;
/* header types */
typedef struct HeaderType {

View File

@@ -414,10 +414,16 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar)
}
}
for (uiButtonGroup *group = ar->button_groups.first; group; group = group->next) {
BLI_freelistN(&group->items);
MEM_SAFE_FREE(group->reordered_indices);
}
if (ar->manipulator_map != NULL) {
region_free_manipulatormap_callback(ar->manipulator_map);
}
BLI_freelistN(&ar->button_groups);
BLI_freelistN(&ar->ui_lists);
BLI_freelistN(&ar->ui_previews);
BLI_freelistN(&ar->panels_category);

View File

@@ -75,6 +75,7 @@ struct wmDrag;
struct wmEvent;
struct wmManipulator;
struct wmMsgBus;
struct uiButtonGroup;
struct wmKeyMap;
typedef struct uiBut uiBut;
@@ -551,6 +552,7 @@ void UI_but_drag_set_rna(uiBut *but, struct PointerRNA *ptr);
void UI_but_drag_set_path(uiBut *but, const char *path, const bool use_free);
void UI_but_drag_set_name(uiBut *but, const char *name);
void UI_but_drag_set_value(uiBut *but);
void UI_but_drag_set_reorder(uiBut *but);
void UI_but_drag_set_image(
uiBut *but, const char *path, int icon, struct ImBuf *ima, float scale, const bool use_free);
@@ -664,6 +666,7 @@ enum {
BUT_GET_RNA_LABEL,
BUT_GET_RNAENUM_LABEL,
BUT_GET_RNA_LABEL_CONTEXT, /* Context specified in CTX_XXX_ macros are just unreachable! */
BUT_GET_VALUE,
BUT_GET_TIP,
BUT_GET_RNA_TIP,
BUT_GET_RNAENUM_TIP,
@@ -807,6 +810,12 @@ void UI_but_focus_on_enter_event(struct wmWindow *win, uiBut *but);
void UI_but_func_hold_set(uiBut *but, uiButHandleHoldFunc func, void *argN);
struct uiButtonGroup *UI_button_group_ensure(struct ARegion *region, const char *name, void *custom_data);
void UI_button_group_add_sorted_items(struct uiButtonGroup *group, uiBlock *block, void *custom_data);
void UI_button_group_item_add(void *data, ListBase *items);
void UI_block_button_group_begin(uiBlock *block, struct uiButtonGroup *group);
void UI_block_button_group_end(uiBlock *block);
/* Autocomplete
*
* Tab complete helper functions, for use in uiButCompleteFunc callbacks.

View File

@@ -54,6 +54,7 @@ set(SRC
interface_eyedropper_driver.c
interface_handlers.c
interface_icons.c
interface_init_exit.c
interface_layout.c
interface_ops.c
interface_panel.c

View File

@@ -3296,8 +3296,12 @@ static uiBut *ui_def_but(
BLI_addtail(&block->buttons, but);
if (block->curlayout)
if (block->curlayout) {
ui_layout_add_but(block->curlayout, but);
}
if (block->current_group) {
but->group = block->current_group;
}
#ifdef WITH_PYTHON
/* if the 'UI_OT_editsource' is running, extract the source info from the button */
@@ -4155,6 +4159,12 @@ void UI_but_drag_set_value(uiBut *but)
but->dragtype = WM_DRAG_VALUE;
}
void UI_but_drag_set_reorder(uiBut *but)
{
but->dragtype = WM_DRAG_BUT_REORDER;
but->dragpoin = but; /* Assign the button itself, later wmDrag can access it then. */
}
void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale, const bool use_free)
{
but->dragtype = WM_DRAG_PATH;
@@ -4574,21 +4584,23 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
int type = si->type;
char *tmp = NULL;
if (type == BUT_GET_LABEL) {
if (but->str) {
if (ELEM(type, BUT_GET_LABEL, BUT_GET_VALUE)) {
char *but_str = (type == BUT_GET_LABEL) ? but->str : but->drawstr;
if (but_str && but_str[0]) {
const char *str_sep;
size_t str_len;
if ((but->flag & UI_BUT_HAS_SEP_CHAR) &&
(str_sep = strrchr(but->str, UI_SEP_CHAR)))
(str_sep = strrchr(but_str, UI_SEP_CHAR)))
{
str_len = (str_sep - but->str);
str_len = (str_sep - but_str);
}
else {
str_len = strlen(but->str);
str_len = strlen(but_str);
}
tmp = BLI_strdupn(but->str, str_len);
tmp = BLI_strdupn(but_str, str_len);
}
else {
type = BUT_GET_RNA_LABEL; /* Fail-safe solution... */
@@ -4749,11 +4761,173 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
}
}
/* -------------------------------------------------------------------- */
/**
* \name Button Group
* \brief Generate buttons with custom, storable order.
*
* Button groups have the following key characteristics:
* * Sortable: Contained buttons can be sorted.
* * Generates: They in fact do not contain buttons, but manage info on how to
* create and sort buttons on runtime.
* * Storable: The mapping for custom sorting is written into files, alongside
* an identifier for this specific group. That way the group can be
* identified and the custom sorting re-applied after reading files.
*
* Maybe button group is a bit of a misleading term, since it doesn't actually
* store the buttons itself.
* Via a callback a button-group gathers information from which another
* callback can create the buttons then. In-between those two callbacks the
* items are sorted in a customizable way.
*
* \{ */
uiButtonGroup *UI_button_group_ensure(ARegion *region, const char *name, void *custom_data)
{
uiButtonGroup *group;
for (group = region->button_groups.first; group; group = group->next) {
if (STREQ(group->type->idname, name) && group->type->identify(group, custom_data)) {
return group;
}
}
group = MEM_callocN(sizeof(*group), __func__);
group->type = WM_uibuttongrouptype_find(name, false);
BLI_addtail(&region->button_groups, group);
return group;
}
typedef struct SortedButtonGroupItemInfo {
struct SortedButtonGroupItemInfo *next, *prev;
uiButtonGroupItemInfo *item;
int new_position_index;
} SortedButtonGroupItemInfo;
static int ui_button_group_items_cmp(const void *a, const void *b)
{
const SortedButtonGroupItemInfo *item_a = a, *item_b = b;
return item_a->new_position_index > item_b->new_position_index ? 1 : 0;
}
static void ui_button_group_sort(
const uiButtonGroup *group, const ListBase *items,
ListBase *r_sorted_items)
{
int i = 0;
for (uiButtonGroupItemInfo *item = items->first; item; item = item->next, i++) {
SortedButtonGroupItemInfo *sort_item = MEM_callocN(sizeof(*sort_item), __func__);
sort_item->item = item;
sort_item->new_position_index = group->reordered_indices[i];
BLI_addtail(r_sorted_items, sort_item);
}
BLI_listbase_sort(r_sorted_items, ui_button_group_items_cmp);
}
static void ui_button_group_find_added_items(
const uiButtonGroup *group, const ListBase *items,
const int prev_tot_items,
ListBase *r_added_items)
{
const int difference = group->tot_items - prev_tot_items;
if (difference == 0) {
return;
}
if (difference > 0) {
for (uiButtonGroupItemInfo *item = items->first; item; item = item->next) {
const bool has_item = BLI_findptr(&group->items, item->data,
offsetof(uiButtonGroupItemInfo, data)) != NULL;
if (!has_item) {
uiButtonGroupItemInfo *item_new = MEM_dupallocN(item);
BLI_addtail(r_added_items, item_new);
}
}
}
}
static void ui_button_group_handle_added_or_removed_items(
uiButtonGroup *group, const ListBase *new_items,
int old_tot_items)
{
ListBase added_items = {NULL, NULL};
group->reordered_indices = MEM_recallocN(
group->reordered_indices, sizeof(*group->reordered_indices) * group->tot_items);
ui_button_group_find_added_items(group, new_items, old_tot_items, &added_items);
/* Add new items at the end of the list. */
const int tot_new_items = group->tot_items - old_tot_items;
BLI_assert(BLI_listbase_count(&added_items) == tot_new_items);
int i = 0;
for (uiButtonGroupItemInfo *new_item = added_items.first; new_item; new_item = new_item->next, i++) {
for (int j = group->tot_items - tot_new_items + i; j > new_item->position_index; j--) {
group->reordered_indices[j] = group->reordered_indices[j - 1];
}
group->reordered_indices[new_item->position_index] = group->tot_items - tot_new_items + i;
}
BLI_freelistN(&added_items);
/* TODO support removing items */
}
void UI_button_group_add_sorted_items(uiButtonGroup *group, uiBlock *block, void *custom_data)
{
const int old_tot_items = group->tot_items;
ListBase new_items = {NULL, NULL};
ListBase sorted_items = {NULL, NULL};
group->type->items(custom_data, &new_items);
group->tot_items = BLI_listbase_count(&new_items);
if (!group->reordered_indices || (group->tot_items != old_tot_items)) {
ui_button_group_handle_added_or_removed_items(group, &new_items, old_tot_items);
}
ui_button_group_sort(group, &new_items, &sorted_items);
UI_block_button_group_begin(block, group);
for (SortedButtonGroupItemInfo *sorted_item = sorted_items.first; sorted_item; sorted_item = sorted_item->next) {
group->type->item_draw(block, custom_data, sorted_item->item);
}
UI_block_button_group_end(block);
BLI_freelistN(&sorted_items);
BLI_freelistN(&group->items);
group->items = new_items;
}
void UI_button_group_item_add(void *data, ListBase *items)
{
uiButtonGroupItemInfo *item = MEM_callocN(sizeof(*item), __func__);
BLI_addtail(items, item);
item->data = data;
item->position_index = item->prev ? ((uiButtonGroupItemInfo *)item->prev)->position_index + 1 : 0;
}
void UI_block_button_group_begin(uiBlock *block, uiButtonGroup *group)
{
BLI_assert(block->current_group == NULL);
block->current_group = group;
}
void UI_block_button_group_end(uiBlock *block)
{
block->current_group = NULL;
}
/* Program Init/Exit */
void UI_init(void)
{
ui_resources_init();
ui_init_button_group_types();
}
/* after reading userdef file */
@@ -4773,4 +4947,5 @@ void UI_exit(void)
{
ui_resources_free();
ui_but_clipboard_free();
ui_exit_button_group_types();
}

View File

@@ -1713,6 +1713,12 @@ static bool ui_but_contains_point_px_icon(uiBut *but, ARegion *ar, const wmEvent
return BLI_rcti_isect_pt(&rect, x, y);
}
static void ui_but_drop_handler(wmDrag *drag, const wmEvent *event);
struct uiButDrag {
uiBut *dragged_but;
uiButStore *but_store;
int drag_start_xy[2];
};
static bool ui_but_drag_init(
bContext *C, uiBut *but,
uiHandleButtonData *data, const wmEvent *event)
@@ -1782,6 +1788,22 @@ static bool ui_but_drag_init(
return false;
}
}
/* Allow reordering buttons via drag & drop */
else if (but->group) {
ListBase *dropbox_list = WM_dropboxmap_find("User Interface", 0, 0);
struct uiButDrag *but_drag = MEM_mallocN(sizeof(*but_drag), "uiButDrag");
but_drag->dragged_but = but;
but_drag->but_store = UI_butstore_create(but->block);
copy_v2_v2_int(but_drag->drag_start_xy, &event->x);
UI_butstore_register(but_drag->but_store, &but_drag->dragged_but);
WM_event_start_drag(C, but->icon, but->dragtype, but_drag, ui_but_value_get(but),
WM_DRAG_FREE_DATA | WM_DRAG_NOP);
WM_dropbox_add_custom_drop_handler(dropbox_list, ui_but_drop_handler);
return true;
}
else {
wmDrag *drag = WM_event_start_drag(
C, but->icon, but->dragtype, but->dragpoin,
@@ -2007,6 +2029,98 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
/* ******************* drop event ******************** */
enum ReinsertPosition {
BUT_REINSERT_BEFORE,
BUT_REINSERT_AFTER,
};
static void ui_but_find_to_reinsert_next_to(
const wmEvent *event, const uiBut *dragged_but, const int drag_start_xy[2],
uiBut **r_but, enum ReinsertPosition *r_reinsert_position)
{
uiBut *but_candidate = NULL;
if (event->x < drag_start_xy[0]) {
for (uiBut *but_iter = dragged_but->prev; but_iter; but_iter = but_iter->prev) {
if ((but_iter->group == dragged_but->group) && (event->x < BLI_rctf_cent_x(&but_iter->rect))) {
but_candidate = but_iter;
}
}
*r_reinsert_position = BUT_REINSERT_BEFORE;
}
else {
for (uiBut *but_iter = dragged_but->next; but_iter; but_iter = but_iter->next) {
if ((but_iter->group == dragged_but->group) && (event->x > BLI_rctf_cent_x(&but_iter->rect))) {
but_candidate = but_iter;
}
}
*r_reinsert_position = BUT_REINSERT_AFTER;
}
*r_but = but_candidate;
}
static uiButtonGroupItemInfo *ui_block_button_group_find_item_from_data(
const uiButtonGroup *group,
const void *data)
{
return BLI_findptr(&group->items, data, offsetof(uiButtonGroupItemInfo, data));
}
static void ui_but_drop_handler(wmDrag *drag, const wmEvent *event)
{
if (drag->type == WM_DRAG_BUT_REORDER) {
struct uiButDrag *but_drag = drag->poin;
uiBut *dragged_but = but_drag->dragged_but;
uiBut *drop_neighbor;
enum ReinsertPosition reinsert_pos;
ui_but_find_to_reinsert_next_to(event, dragged_but, but_drag->drag_start_xy,
&drop_neighbor, &reinsert_pos);
if (drop_neighbor) {
uiButtonGroup *group = dragged_but->group;
uiButtonGroupItemInfo *dragged_item = ui_block_button_group_find_item_from_data(
group, dragged_but->custom_data);
uiButtonGroupItemInfo *drop_neighbor_item = ui_block_button_group_find_item_from_data(
group, drop_neighbor->custom_data);
/* New index of the dragged item is the old reorder index of the neighbor */
const int item_new_index = group->reordered_indices[drop_neighbor_item->position_index];
BLI_assert(!ELEM(NULL, dragged_item, drop_neighbor_item));
if (reinsert_pos == BUT_REINSERT_AFTER) {
/* modify the reorder index of all items in a certain range */
const int min = group->reordered_indices[dragged_item->position_index] + 1;
const int max = group->reordered_indices[drop_neighbor_item->position_index];
for (int i = 0; i < group->tot_items; i++) {
if (IN_RANGE_INCL(group->reordered_indices[i], min, max)) {
group->reordered_indices[i]--;
}
}
}
else if (reinsert_pos == BUT_REINSERT_BEFORE) {
const int min = group->reordered_indices[drop_neighbor_item->position_index];
const int max = group->reordered_indices[dragged_item->position_index] - 1;
for (int i = 0; i < group->tot_items; i++) {
if (IN_RANGE_INCL(group->reordered_indices[i], min, max)) {
group->reordered_indices[i]++;
}
}
}
else {
BLI_assert(0);
}
group->reordered_indices[dragged_item->position_index] = item_new_index;
}
UI_butstore_free(but_drag->dragged_but->block, but_drag->but_store);
ED_region_tag_redraw(drag->init_region);
}
}
/* only call if event type is EVT_DROP */
static void ui_but_drop(bContext *C, const wmEvent *event, uiBut *but, uiHandleButtonData *data)
{
@@ -3756,8 +3870,14 @@ static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, c
static int ui_do_but_TAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
if ((event->type == LEFTMOUSE) &&
((event->val == KM_DBL_CLICK) || event->ctrl))
if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
data->dragstartx = event->x;
data->dragstarty = event->y;
return WM_UI_HANDLER_BREAK;
}
else if ((event->type == LEFTMOUSE) &&
((event->val == KM_DBL_CLICK) || event->ctrl))
{
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
return WM_UI_HANDLER_BREAK;
@@ -3778,6 +3898,9 @@ static int ui_do_but_TAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
return WM_UI_HANDLER_BREAK;
}
}
else if (data->state == BUTTON_STATE_WAIT_DRAG) {
return ui_do_but_EXIT(C, but, data, event);
}
else if (data->state == BUTTON_STATE_TEXT_EDITING) {
ui_do_but_textedit(C, block, but, data, event);
return WM_UI_HANDLER_BREAK;

View File

@@ -0,0 +1,57 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2018 Blender Foundation.
* All rights reserved.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/interface/interface_init_exit.h
* \ingroup edinterface
*/
#include "BLI_rect.h"
#include "DNA_screen_types.h"
#include "DNA_userdef_types.h"
#include "BKE_screen.h"
#include "MEM_guardedalloc.h"
#include "RNA_access.h"
#include "UI_interface.h"
#include "WM_api.h"
#include "WM_types.h"
#include "interface_intern.h"
void ui_init_button_group_types(void)
{
WM_uibuttongrouptype_init();
WM_uibuttongrouptype_add(UI_BGT_sortable_id_tabs());
}
void ui_exit_button_group_types(void)
{
WM_uibuttongrouptype_free();
}

View File

@@ -317,6 +317,7 @@ struct uiBut {
/* pointer back */
uiBlock *block;
uiButtonGroup *group;
};
typedef struct uiButTab {
@@ -355,6 +356,7 @@ struct uiBlock {
ListBase buttons;
Panel *panel;
uiBlock *oldblock;
uiButtonGroup *current_group;
ListBase butstore; /* UI_butstore_* runtime function */
@@ -792,6 +794,13 @@ void ui_layout_list_set_labels_active(uiLayout *layout);
/* menu callback */
void ui_item_paneltype_func(struct bContext *C, struct uiLayout *layout, void *arg_pt);
/* interface_templates.c */
struct uiButtonGroupType *UI_BGT_sortable_id_tabs(void);
/* interface_init_exit.c */
void ui_init_button_group_types(void);
void ui_exit_button_group_types(void);
/* interface_align.c */
bool ui_but_can_align(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
void ui_block_align_calc(uiBlock *block, const ARegion *region);

View File

@@ -1399,4 +1399,6 @@ void ED_keymap_ui(wmKeyConfig *keyconf)
eyedropper_modal_keymap(keyconf);
eyedropper_colorband_modal_keymap(keyconf);
WM_dropboxmap_find("User Interface", 0, 0);
}

View File

@@ -103,6 +103,100 @@ void UI_template_fix_linking(void)
{
}
typedef struct TemplateID {
PointerRNA ptr;
PropertyRNA *prop;
ListBase *idlb;
short idcode;
short filter;
int prv_rows, prv_cols;
bool preview;
} TemplateID;
typedef struct SortableIDTabsData {
TemplateID *template_id;
wmOperatorType *unlink_ot;
PointerRNA active_ptr;
} SortableIDTabsData;
/* TODO After file read, we need to be able to identify button groups. That's what should later happen here. */
static bool ui_sortable_id_tabs_button_group_identify(uiButtonGroup *group, void *UNUSED(custom_data))
{
if (STREQ(group->type->idname, "UI_BGT_sortable_id_tabs")) {
// XXX
return true;
}
return false;
}
static void ui_sortable_id_tabs_items(void *custom_data, ListBase *r_items)
{
SortableIDTabsData *data = custom_data;
for (ID *id = data->template_id->idlb->first; id; id = id->next) {
UI_button_group_item_add(id, r_items);
}
}
static void template_ID_set_property_cb(bContext *C, void *arg_template, void *item);
static void ui_sortable_id_tab_item_draw(
uiBlock *block, void *custom_data, uiButtonGroupItemInfo *item)
{
SortableIDTabsData *data = custom_data;
ID *id = item->data;
uiStyle *style = UI_style_get_dpi();
const bool is_active = data->active_ptr.data == id;
const unsigned int but_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X +
(is_active ? ICON_DEFAULT_WIDTH_SCALE : 0);
// const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;
uiButTab *tab = (uiButTab *)uiDefButR_prop(
block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y,
&data->template_id->ptr, data->template_id->prop, 0, 0.0f,
sizeof(id->name) - 2, 0.0f, 0.0f, "");
UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(data->template_id), id);
UI_but_drawflag_enable(&tab->but, UI_BUT_ALIGN_DOWN); /* TODO fixed alignment - should be based on region alignment */
UI_but_drag_set_reorder(&tab->but);
tab->but.custom_data = (void *)id;
tab->unlink_ot = data->unlink_ot;
if (is_active) {
UI_but_flag_enable(&tab->but, UI_BUT_VALUE_CLEAR);
}
}
uiButtonGroupType *UI_BGT_sortable_id_tabs(void)
{
uiButtonGroupType *group_type = MEM_callocN(sizeof(uiButtonGroupType), __func__);
group_type->idname = "UI_BGT_sortable_id_tabs"; // TODO not needed?
group_type->identify = ui_sortable_id_tabs_button_group_identify;
group_type->items = ui_sortable_id_tabs_items;
group_type->item_draw = ui_sortable_id_tab_item_draw;
return group_type;
}
static void ui_template_sortable_id_tabs(
ARegion *region, uiBlock *block, TemplateID *template_ui, wmOperatorType *unlink_ot)
{
uiButtonGroup *group = UI_button_group_ensure(region, "UI_BGT_sortable_id_tabs", template_ui);
SortableIDTabsData data;
data.template_id = template_ui;
data.unlink_ot = unlink_ot;
data.active_ptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop);
UI_button_group_add_sorted_items(group, block, &data);
}
/**
* Add a block button for the search menu for templateID and templateSearch.
*/
@@ -228,17 +322,6 @@ void uiTemplateHeader(uiLayout *layout, bContext *C)
/********************** Search Callbacks *************************/
typedef struct TemplateID {
PointerRNA ptr;
PropertyRNA *prop;
ListBase *idlb;
short idcode;
short filter;
int prv_rows, prv_cols;
bool preview;
} TemplateID;
/* Search browse menu, assign */
static void template_ID_set_property_cb(bContext *C, void *arg_template, void *item)
{
@@ -826,36 +909,15 @@ static void template_ID_tabs(
bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag,
const char *newop, const char *UNUSED(openop), const char *unlinkop)
{
const ARegion *region = CTX_wm_region(C);
ARegion *region = CTX_wm_region(C);
const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop);
const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;
wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false);
const int but_height = UI_UNIT_Y * 1.1;
uiBlock *block = uiLayoutGetBlock(layout);
uiStyle *style = UI_style_get_dpi();
for (ID *id = template->idlb->first; id; id = id->next) {
wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false);
const bool is_active = active_ptr.data == id;
const unsigned int but_width = (
UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X +
(is_active ? ICON_DEFAULT_WIDTH_SCALE : 0));
uiButTab *tab;
tab = (uiButTab *)uiDefButR_prop(
block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y * 1.1,
&template->ptr, template->prop, 0, 0.0f,
sizeof(id->name) - 2, 0.0f, 0.0f, "");
UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(template), id);
tab->but.custom_data = (void *)id;
tab->unlink_ot = unlink_ot;
if (is_active) {
UI_but_flag_enable(&tab->but, UI_BUT_VALUE_CLEAR);
}
UI_but_drawflag_enable(&tab->but, but_align);
}
ui_template_sortable_id_tabs(region, block, template, unlink_ot);
if (flag & UI_ID_ADD_NEW) {
const bool editable = RNA_property_editable(&template->ptr, template->prop);

View File

@@ -1135,6 +1135,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
layout_new = ED_workspace_layout_add(bmain, workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, workspace, layout_new);
ED_screen_global_areas_create(newwin);
/* copy area to new screen */
ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);

View File

@@ -370,6 +370,7 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "directory", directory);
if (workspace_append(C, directory, idname) != OPERATOR_CANCELLED) {
/* XXX broken, name may have been changed */
WorkSpace *appended_workspace = BLI_findstring(&bmain->workspaces, idname, offsetof(ID, name) + 2);
BLI_assert(appended_workspace != NULL);

View File

@@ -214,6 +214,34 @@ typedef struct uiList { /* some list UI data need to be saved in file
uiListDyn *dyn_data;
} uiList;
/* These two Lines with # tell makesdna this struct can be excluded. */
#
#
typedef struct uiButtonGroupItemInfo {
struct uiButtonGroupItemInfo *next, *prev;
int position_index;
int pad;
void *data;
} uiButtonGroupItemInfo;
/* TODO Better name for this? Alternatives:
* * uiSortedButtonGenerator
* * uiButtonGroupGenerator
* * uiStorableItems
*/
typedef struct uiButtonGroup {
struct uiButtonGroup *next, *prev;
struct uiButtonGroupType *type;
ListBase items; /* uiButtonGroupItemInfo */
// uiButtonGroupItemInfo *items;
int tot_items;
int pad;
int *reordered_indices;
} uiButtonGroup;
typedef struct TransformOrientation {
struct TransformOrientation *next, *prev;
char name[64]; /* MAX_NAME */
@@ -346,6 +374,7 @@ typedef struct ARegion {
ListBase ui_previews; /* uiPreview */
ListBase handlers; /* wmEventHandler */
ListBase panels_category; /* Panel categories runtime */
ListBase button_groups; /* uiButtonGroup */
struct wmManipulatorMap *manipulator_map; /* manipulator-map of this region */
struct wmTimer *regiontimer; /* blend in/out */

View File

@@ -836,6 +836,12 @@ void RNA_api_ui_layout(StructRNA *srna)
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
RNA_def_function_return(func, parm);
#ifdef WITH_REDO_REGION_REMOVAL
func = RNA_def_function(srna, "template_operator_redo_props", "uiTemplateOperatorRedoProperties");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Adds properties of the last executed operator using redo");
#endif
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");

View File

@@ -71,6 +71,7 @@ struct ScrArea;
struct Main;
struct ViewLayer;
struct GPUViewport;
struct uiButtonGroupType;
#ifdef WITH_INPUT_NDOF
struct wmNDOFMotionData;
@@ -432,6 +433,12 @@ bool WM_uilisttype_add(struct uiListType *ult);
void WM_uilisttype_freelink(struct uiListType *ult);
void WM_uilisttype_free(void);
/* *************** button group types ******************** */
void WM_uibuttongrouptype_init(void);
void WM_uibuttongrouptype_add(struct uiButtonGroupType *group_type);
struct uiButtonGroupType *WM_uibuttongrouptype_find(const char *idname, bool quiet);
void WM_uibuttongrouptype_free(void);
/* *************** menu types ******************** */
void WM_menutype_init(void);
struct MenuType *WM_menutype_find(const char *idname, bool quiet);
@@ -479,6 +486,8 @@ void WM_drag_free_list(struct ListBase *lb);
struct wmDropBox *WM_dropbox_add(
ListBase *lb, const char *idname, bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event),
void (*copy)(struct wmDrag *, struct wmDropBox *));
struct wmDropBox *WM_dropbox_add_custom_drop_handler(
ListBase *dropbox_list, void (*drop_handler)(struct wmDrag *, const struct wmEvent *));
ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
/* Set OpenGL viewport and scissor */

View File

@@ -638,12 +638,16 @@ typedef void (*wmPaintCursorDraw)(struct bContext *C, int, int, void *customdata
/* *************** Drag and drop *************** */
#define WM_DRAG_ID 0
#define WM_DRAG_RNA 1
#define WM_DRAG_PATH 2
#define WM_DRAG_NAME 3
#define WM_DRAG_VALUE 4
#define WM_DRAG_COLOR 5
enum wmDragType {
WM_DRAG_ID,
WM_DRAG_RNA,
WM_DRAG_PATH,
WM_DRAG_NAME,
WM_DRAG_VALUE,
WM_DRAG_COLOR,
/* Drag the entire button for button drag & drop reordering */
WM_DRAG_BUT_REORDER,
};
typedef enum wmDragFlags {
WM_DRAG_NOP = 0,
@@ -655,7 +659,9 @@ typedef enum wmDragFlags {
typedef struct wmDrag {
struct wmDrag *next, *prev;
int icon, type; /* type, see WM_DRAG defines above */
struct ARegion *init_region; /* Region in which we started dragging */
int icon, type; /* type, see wmDragType defines above */
void *poin;
char path[1024]; /* FILE_MAX */
double value;
@@ -679,6 +685,9 @@ typedef struct wmDropBox {
/* before exec, this copies drag info to wmDrop properties */
void (*copy)(struct wmDrag *, struct wmDropBox *);
/* XXX */
void (*drop_handler)(struct wmDrag *, const wmEvent *);
/* if poll survives, operator is called */
wmOperatorType *ot; /* not saved in file, so can be pointer */

View File

@@ -282,6 +282,44 @@ void WM_uilisttype_free(void)
uilisttypes_hash = NULL;
}
/* ************ uiButtonGroupType handling ************** */
static GHash *uibuttongrouptypes_hash = NULL;
void WM_uibuttongrouptype_init(void)
{
uibuttongrouptypes_hash = BLI_ghash_str_new("uibuttongrouptypes_hash");
}
void WM_uibuttongrouptype_add(uiButtonGroupType *group_type)
{
BLI_ghash_insert(uibuttongrouptypes_hash, (void *)group_type->idname, group_type);
}
uiButtonGroupType *WM_uibuttongrouptype_find(const char *idname, bool quiet)
{
uiButtonGroupType *group_type;
if (idname[0]) {
group_type = BLI_ghash_lookup(uibuttongrouptypes_hash, idname);
if (group_type) {
return group_type;
}
}
if (!quiet) {
printf("search for unknown uibuttongrouptype%s\n", idname);
}
return NULL;
}
void WM_uibuttongrouptype_free(void)
{
BLI_ghash_free(uibuttongrouptypes_hash, NULL, MEM_freeN);
uibuttongrouptypes_hash = NULL;
}
/* ************ MenuType handling ************** */
static GHash *menutypes_hash = NULL;

View File

@@ -120,6 +120,17 @@ wmDropBox *WM_dropbox_add(
return drop;
}
wmDropBox *WM_dropbox_add_custom_drop_handler(
ListBase *dropbox_list, void (*drop_handler)(wmDrag *, const wmEvent *))
{
wmDropBox *drop = MEM_callocN(sizeof(wmDropBox), "wmDropBox");
drop->drop_handler = drop_handler;
BLI_addtail(dropbox_list, drop);
return drop;
}
void wm_dropbox_free(void)
{
wmDropBoxMap *dm;
@@ -151,6 +162,7 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin,
/* if multiple drags are added, they're drawn as list */
BLI_addtail(&wm->drags, drag);
drag->init_region = CTX_wm_region(C);
drag->flags = flags;
drag->icon = icon;
drag->type = type;
@@ -195,7 +207,7 @@ static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag,
if (handler->dropboxes) {
wmDropBox *drop = handler->dropboxes->first;
for (; drop; drop = drop->next) {
if (drop->poll(C, drag, event))
if (drop->poll && drop->poll(C, drag, event))
/* XXX Doing translation here might not be ideal, but later we have no more
* access to ot (and hence op context)... */
return RNA_struct_ui_name(drop->ot->srna);
@@ -277,19 +289,44 @@ static void wm_drop_operator_draw(const char *name, int x, int y)
UI_fontstyle_draw_simple_backdrop(fstyle, x, y, name, col_fg, col_bg);
}
static const char *wm_drag_name(wmDrag *drag)
/* XXX copied from interface_handlers.c */
struct uiButDrag {
uiBut *dragged_but;
uiButStore *but_store;
int drag_start_xy[2];
};
static void wm_drag_name(bContext *C, wmDrag *drag, char (*r_name)[UI_MAX_NAME_STR])
{
char *name;
bool free_name = false;
switch (drag->type) {
case WM_DRAG_ID:
{
ID *id = drag->poin;
return id->name + 2;
name = id->name + 2;
break;
}
case WM_DRAG_PATH:
case WM_DRAG_NAME:
return drag->path;
name = drag->path;
break;
case WM_DRAG_BUT_REORDER:
{
struct uiButDrag *but_drag = drag->poin;
uiStringInfo but_label = {BUT_GET_VALUE, NULL};
UI_but_string_info_get(C, but_drag->dragged_but, &but_label, NULL);
name = but_label.strinfo;
free_name = true;
break;
}
}
BLI_strncpy(*r_name, name, sizeof(*r_name));
if (free_name) {
MEM_freeN(name);
}
return "";
}
static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2)
@@ -313,6 +350,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
wmDrag *drag;
const int winsize_y = WM_window_pixels_y(win);
int cursorx, cursory, x, y;
char drag_name[UI_MAX_NAME_STR];
cursorx = win->eventstate->x;
cursory = win->eventstate->y;
@@ -327,6 +365,8 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
int iconsize = UI_DPI_ICON_SIZE;
int padding = 4 * UI_DPI_FAC;
wm_drag_name(C, drag, &drag_name);
/* image or icon */
if (drag->imb) {
x = cursorx - drag->sx / 2;
@@ -362,12 +402,12 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
}
if (rect) {
int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag));
int w = UI_fontstyle_string_width(fstyle, drag_name);
drag_rect_minmax(rect, x, y, x + w, y + iconsize);
}
else {
const unsigned char col[] = {255, 255, 255, 255};
UI_fontstyle_draw_simple(fstyle, x, y, wm_drag_name(drag), col);
UI_fontstyle_draw_simple(fstyle, x, y, drag_name, col);
}
/* operator name with roundbox */
@@ -392,7 +432,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
}
if (rect) {
int w = UI_fontstyle_string_width(fstyle, wm_drag_name(drag));
int w = UI_fontstyle_string_width(fstyle, drag_name);
drag_rect_minmax(rect, x, y, x + w, y + iconsize);
}
else

View File

@@ -2346,16 +2346,27 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
wmDrag *drag;
for (drag = lb->first; drag; drag = drag->next) {
if (drop->poll(C, drag, event)) {
drop->copy(drag, drop);
/* free the drags before calling operator */
WM_drag_free_list(lb);
if (!drop->poll || drop->poll(C, drag, event)) {
if (drop->copy) {
drop->copy(drag, drop);
}
event->customdata = NULL;
event->custom = 0;
WM_operator_name_call_ptr(C, drop->ot, drop->opcontext, drop->ptr);
if (drop->ot) {
/* free the drags before calling operator */
WM_drag_free_list(lb);
WM_operator_name_call_ptr(C, drop->ot, drop->opcontext, drop->ptr);
}
else if (drop->drop_handler) {
drop->drop_handler(drag, event);
WM_drag_free_list(lb);
}
else {
BLI_assert(0);
}
action |= WM_HANDLER_BREAK;
/* XXX fileread case */

View File

@@ -290,6 +290,7 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src, const bool duplicate_la
WM_window_set_active_workspace(win_dst, workspace);
layout_new = duplicate_layout ? ED_workspace_layout_duplicate(bmain, workspace, layout_old, win_dst) : layout_old;
WM_window_set_active_layout(win_dst, workspace, layout_new);
ED_screen_global_areas_create(win_dst);
*win_dst->stereo3d_format = *win_src->stereo3d_format;
@@ -772,6 +773,9 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
{
ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
WM_event_add_dropbox_handler(&win->handlers, lb);
lb = WM_dropboxmap_find("User Interface", 0, 0);
WM_event_add_dropbox_handler(&win->handlers, lb);
}
wm_window_title(wm, win);