2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-01-07 18:03:41 +00:00
|
|
|
* 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
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-01-07 18:03:41 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-01-07 18:03:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edscr
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2013-12-04 11:54:56 +11:00
|
|
|
#include "BLI_linklist_stack.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-21 17:18:36 +00:00
|
|
|
#include "BKE_global.h"
|
2019-02-07 10:08:01 +01:00
|
|
|
#include "BKE_image.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BKE_screen.h"
|
2018-03-01 01:26:02 +11:00
|
|
|
#include "BKE_workspace.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2013-06-09 16:18:23 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
2017-11-13 19:43:34 +11:00
|
|
|
#include "WM_message.h"
|
2018-05-23 08:20:46 +02:00
|
|
|
#include "WM_toolsystem.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-19 12:48:30 +00:00
|
|
|
#include "ED_screen.h"
|
|
|
|
#include "ED_screen_types.h"
|
2010-08-06 18:11:49 +00:00
|
|
|
#include "ED_space_api.h"
|
2008-12-19 12:48:30 +00:00
|
|
|
|
2016-08-22 23:39:42 -04:00
|
|
|
#include "GPU_immediate.h"
|
2017-04-05 18:30:14 +10:00
|
|
|
#include "GPU_immediate_util.h"
|
2017-03-21 02:51:02 -04:00
|
|
|
#include "GPU_matrix.h"
|
2016-12-13 15:43:13 -05:00
|
|
|
#include "GPU_draw.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
|
|
|
#include "GPU_framebuffer.h"
|
2016-08-22 23:39:42 -04:00
|
|
|
|
2009-05-05 23:10:32 +00:00
|
|
|
#include "BLF_api.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2015-04-20 19:57:57 +02:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
2018-04-05 16:27:15 +02:00
|
|
|
#include "IMB_metadata.h"
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
#include "UI_interface.h"
|
2014-10-14 15:05:44 -03:00
|
|
|
#include "UI_interface_icons.h"
|
Port of part of the Interface code to 2.50.
This is based on the current trunk version, so these files should not need
merges. There's two things (clipboard and intptr_t) that are missing in 2.50
and commented out with XXX 2.48, these can be enabled again once trunk is
merged into this branch.
Further this is not all interface code, there are many parts commented out:
* interface.c: nearly all button types, missing: links, chartab, keyevent.
* interface_draw.c: almost all code, with some small exceptions.
* interface_ops.c: this replaces ui_do_but and uiDoBlocks with two operators,
making it non-blocking.
* interface_regions: this is a part of interface.c, split off, contains code to
create regions for tooltips, menus, pupmenu (that one is crashing currently),
color chooser, basically regions with buttons which is fairly independent of
core interface code.
* interface_panel.c and interface_icons.c: not ported over, so no panels and
icons yet. Panels should probably become (free floating) regions?
* text.c: (formerly language.c) for drawing text and translation. this works
but is using bad globals still and could be cleaned up.
Header Files:
* ED_datafiles.h now has declarations for datatoc_ files, so those extern
declarations can be #included instead of repeated.
* The user interface code is in UI_interface.h and other UI_* files.
Core:
* The API for creating blocks, buttons, etc is nearly the same still. Blocks
are now created per region instead of per area.
* The code was made non-blocking, which means that any changes and redraws
should be possible while editing a button. That means though that we need
some sort of persistence even though the blender model is to recreate buttons
for each redraw. So when a new block is created, some matching happens to
find out which buttons correspond to buttons in the previously created block,
and for activated buttons some data is then copied over to the new button.
* Added UI_init/UI_init_userdef/UI_exit functions that should initialize code
in this module, instead of multiple function calls in the windowmanager.
* Removed most static/globals from interface.c.
* Removed UIafterfunc_ I don't think it's needed anymore, and not sure how it
would integrate here?
* Currently only full window redraws are used, this should become per region
and maybe per button later.
Operators:
* Events are currently handled through two operators: button activate and menu
handle. Operators may not be the best way to implement this, since there are
currently some issues with events being missed, but they can become a special
handler type instead, this should not be a big change.
* The button activate operator runs as long as a button is active, and will
handle all interaction with that button until the button is not activated
anymore. This means clicking, text editing, number dragging, opening menu
blocks, etc.
* Since this operator has to be non-blocking, the ui_do_but code needed to made
non-blocking. That means variables that were previously on the stack, now
need to be stored away in a struct such that they can be accessed again when
the operator receives more events.
* Additionally the place in the ui_do_but code indicated the state, now that
needs to be set explicit in order to handle the right events in the right
state. So an activated button can be in one of these states: init, highlight,
wait_flash, wait_release, wait_key_event, num_editing, text_editing,
text_selecting, block_open, exit.
* For each button type an ui_apply_but_* function has also been separated out
from ui_do_but. This makes it possible to continuously apply the button as
text is being typed for example, and there is an option in the code to enable
this. Since the code non-blocking and can deal with the button being deleted
even, it should be safe to do this.
* When editing text, dragging numbers, etc, the actual data (but->poin) is not
being edited, since that would mean data is being edited without correct
updates happening, while some other part of blender may be accessing that
data in the meantime. So data values, strings, vectors are written to a
temporary location and only flush in the apply function.
Regions:
* Menus, color chooser, tooltips etc all create screen level regions. Such menu
blocks give a handle to the button that creates it, which will contain the
results of the menu block once a MESSAGE event is received from that menu
block.
* For this type of menu block the coordinates used to be in window space. They
are still created that way and ui_positionblock still works with window
coordinates, but after that the block and buttons are brought back to region
coordinates since these are now contained in a region.
* The flush/overdraw frontbuffer drawing code was removed, the windowmanager
should have enough information with these screen level regions to have full
control over what gets drawn when and to then do correct compositing.
Testing:
* The header in the time space currently has some buttons to test the UI code.
2008-11-11 18:31:32 +00:00
|
|
|
#include "UI_resources.h"
|
2008-12-10 13:56:54 +00:00
|
|
|
#include "UI_view2d.h"
|
Port of part of the Interface code to 2.50.
This is based on the current trunk version, so these files should not need
merges. There's two things (clipboard and intptr_t) that are missing in 2.50
and commented out with XXX 2.48, these can be enabled again once trunk is
merged into this branch.
Further this is not all interface code, there are many parts commented out:
* interface.c: nearly all button types, missing: links, chartab, keyevent.
* interface_draw.c: almost all code, with some small exceptions.
* interface_ops.c: this replaces ui_do_but and uiDoBlocks with two operators,
making it non-blocking.
* interface_regions: this is a part of interface.c, split off, contains code to
create regions for tooltips, menus, pupmenu (that one is crashing currently),
color chooser, basically regions with buttons which is fairly independent of
core interface code.
* interface_panel.c and interface_icons.c: not ported over, so no panels and
icons yet. Panels should probably become (free floating) regions?
* text.c: (formerly language.c) for drawing text and translation. this works
but is using bad globals still and could be cleaned up.
Header Files:
* ED_datafiles.h now has declarations for datatoc_ files, so those extern
declarations can be #included instead of repeated.
* The user interface code is in UI_interface.h and other UI_* files.
Core:
* The API for creating blocks, buttons, etc is nearly the same still. Blocks
are now created per region instead of per area.
* The code was made non-blocking, which means that any changes and redraws
should be possible while editing a button. That means though that we need
some sort of persistence even though the blender model is to recreate buttons
for each redraw. So when a new block is created, some matching happens to
find out which buttons correspond to buttons in the previously created block,
and for activated buttons some data is then copied over to the new button.
* Added UI_init/UI_init_userdef/UI_exit functions that should initialize code
in this module, instead of multiple function calls in the windowmanager.
* Removed most static/globals from interface.c.
* Removed UIafterfunc_ I don't think it's needed anymore, and not sure how it
would integrate here?
* Currently only full window redraws are used, this should become per region
and maybe per button later.
Operators:
* Events are currently handled through two operators: button activate and menu
handle. Operators may not be the best way to implement this, since there are
currently some issues with events being missed, but they can become a special
handler type instead, this should not be a big change.
* The button activate operator runs as long as a button is active, and will
handle all interaction with that button until the button is not activated
anymore. This means clicking, text editing, number dragging, opening menu
blocks, etc.
* Since this operator has to be non-blocking, the ui_do_but code needed to made
non-blocking. That means variables that were previously on the stack, now
need to be stored away in a struct such that they can be accessed again when
the operator receives more events.
* Additionally the place in the ui_do_but code indicated the state, now that
needs to be set explicit in order to handle the right events in the right
state. So an activated button can be in one of these states: init, highlight,
wait_flash, wait_release, wait_key_event, num_editing, text_editing,
text_selecting, block_open, exit.
* For each button type an ui_apply_but_* function has also been separated out
from ui_do_but. This makes it possible to continuously apply the button as
text is being typed for example, and there is an option in the code to enable
this. Since the code non-blocking and can deal with the button being deleted
even, it should be safe to do this.
* When editing text, dragging numbers, etc, the actual data (but->poin) is not
being edited, since that would mean data is being edited without correct
updates happening, while some other part of blender may be accessing that
data in the meantime. So data values, strings, vectors are written to a
temporary location and only flush in the apply function.
Regions:
* Menus, color chooser, tooltips etc all create screen level regions. Such menu
blocks give a handle to the button that creates it, which will contain the
results of the menu block once a MESSAGE event is received from that menu
block.
* For this type of menu block the coordinates used to be in window space. They
are still created that way and ui_positionblock still works with window
coordinates, but after that the block and buttons are brought back to region
coordinates since these are now contained in a region.
* The flush/overdraw frontbuffer drawing code was removed, the windowmanager
should have enough information with these screen level regions to have full
control over what gets drawn when and to then do correct compositing.
Testing:
* The header in the time space currently has some buttons to test the UI code.
2008-11-11 18:31:32 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "screen_intern.h"
|
|
|
|
|
2018-04-21 17:15:39 +02:00
|
|
|
enum RegionEmbossSide {
|
|
|
|
REGION_EMBOSS_LEFT = (1 << 0),
|
|
|
|
REGION_EMBOSS_TOP = (1 << 1),
|
|
|
|
REGION_EMBOSS_BOTTOM = (1 << 2),
|
|
|
|
REGION_EMBOSS_RIGHT = (1 << 3),
|
|
|
|
REGION_EMBOSS_ALL = REGION_EMBOSS_LEFT | REGION_EMBOSS_TOP | REGION_EMBOSS_RIGHT | REGION_EMBOSS_BOTTOM,
|
|
|
|
};
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* general area and region code */
|
|
|
|
|
2018-04-27 16:50:19 +02:00
|
|
|
static void region_draw_emboss(const ARegion *ar, const rcti *scirct, int sides)
|
|
|
|
{
|
|
|
|
rcti rect;
|
|
|
|
|
|
|
|
/* translate scissor rect to region space */
|
|
|
|
rect.xmin = scirct->xmin - ar->winrct.xmin;
|
|
|
|
rect.ymin = scirct->ymin - ar->winrct.ymin;
|
|
|
|
rect.xmax = scirct->xmax - ar->winrct.xmin;
|
|
|
|
rect.ymax = scirct->ymax - ar->winrct.ymin;
|
|
|
|
|
|
|
|
/* set transp line */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(true);
|
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
2018-04-27 16:50:19 +02:00
|
|
|
|
|
|
|
float color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
|
|
|
|
UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2018-04-27 16:50:19 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4fv(color);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_LINES, 8);
|
2018-04-27 16:50:19 +02:00
|
|
|
|
|
|
|
/* right */
|
|
|
|
if (sides & REGION_EMBOSS_RIGHT) {
|
|
|
|
immVertex2f(pos, rect.xmax, rect.ymax);
|
|
|
|
immVertex2f(pos, rect.xmax, rect.ymin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bottom */
|
|
|
|
if (sides & REGION_EMBOSS_BOTTOM) {
|
|
|
|
immVertex2f(pos, rect.xmax, rect.ymin);
|
|
|
|
immVertex2f(pos, rect.xmin, rect.ymin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* left */
|
|
|
|
if (sides & REGION_EMBOSS_LEFT) {
|
|
|
|
immVertex2f(pos, rect.xmin, rect.ymin);
|
|
|
|
immVertex2f(pos, rect.xmin, rect.ymax);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* top */
|
|
|
|
if (sides & REGION_EMBOSS_TOP) {
|
|
|
|
immVertex2f(pos, rect.xmin, rect.ymax);
|
|
|
|
immVertex2f(pos, rect.xmax, rect.ymax);
|
|
|
|
}
|
|
|
|
|
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2018-04-27 16:50:19 +02:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
void ED_region_pixelspace(ARegion *ar)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2014-09-10 13:24:31 +10:00
|
|
|
wmOrtho2_region_pixelspace(ar);
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_identity_set();
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
/* only exported for WM */
|
2018-07-04 15:14:57 +02:00
|
|
|
void ED_region_do_listen(wmWindow *win, ScrArea *sa, ARegion *ar, wmNotifier *note, const Scene *scene)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2008-01-10 17:38:17 +00:00
|
|
|
/* generic notes first */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (note->category) {
|
2009-02-07 10:00:46 +00:00
|
|
|
case NC_WM:
|
2012-05-08 15:43:59 +00:00
|
|
|
if (note->data == ND_FILEREAD)
|
2009-02-07 10:00:46 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
2008-12-27 16:09:56 +00:00
|
|
|
case NC_WINDOW:
|
2008-12-16 12:28:00 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2008-01-10 17:38:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-04-06 09:07:39 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar->type && ar->type->listener)
|
2018-07-04 15:14:57 +02:00
|
|
|
ar->type->listener(win, sa, ar, note, scene);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
/* only exported for WM */
|
2018-07-04 15:14:57 +02:00
|
|
|
void ED_area_do_listen(wmWindow *win, ScrArea *sa, wmNotifier *note, Scene *scene)
|
2009-01-04 17:45:54 +00:00
|
|
|
{
|
|
|
|
/* no generic notes? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->type && sa->type->listener) {
|
2018-07-04 15:14:57 +02:00
|
|
|
sa->type->listener(win, sa, note, scene);
|
2009-01-04 17:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only exported for WM */
|
|
|
|
void ED_area_do_refresh(bContext *C, ScrArea *sa)
|
|
|
|
{
|
|
|
|
/* no generic notes? */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->type && sa->type->refresh) {
|
2009-01-04 17:45:54 +00:00
|
|
|
sa->type->refresh(C, sa);
|
|
|
|
}
|
2014-04-01 11:34:00 +11:00
|
|
|
sa->do_refresh = false;
|
2009-01-04 17:45:54 +00:00
|
|
|
}
|
|
|
|
|
2014-10-14 15:05:44 -03:00
|
|
|
/**
|
|
|
|
* \brief Corner widget use for quitting fullscreen.
|
|
|
|
*/
|
|
|
|
static void area_draw_azone_fullscreen(short x1, short y1, short x2, short y2, float alpha)
|
|
|
|
{
|
|
|
|
int x = x2 - ((float) x2 - x1) * 0.5f / UI_DPI_FAC;
|
|
|
|
int y = y2 - ((float) y2 - y1) * 0.5f / UI_DPI_FAC;
|
|
|
|
|
|
|
|
/* adjust the icon distance from the corner */
|
|
|
|
x += 36.0f / UI_DPI_FAC;
|
|
|
|
y += 36.0f / UI_DPI_FAC;
|
|
|
|
|
|
|
|
/* draws from the left bottom corner of the icon */
|
|
|
|
x -= UI_DPI_ICON_SIZE;
|
|
|
|
y -= UI_DPI_ICON_SIZE;
|
|
|
|
|
|
|
|
alpha = min_ff(alpha, 0.75f);
|
|
|
|
|
2018-09-27 18:25:50 +02:00
|
|
|
UI_icon_draw_aspect(x, y, ICON_FULLSCREEN_EXIT, 0.7f / UI_DPI_FAC, alpha, NULL);
|
2014-10-14 15:05:44 -03:00
|
|
|
|
|
|
|
/* debug drawing :
|
|
|
|
* The click_rect is the same as defined in fullscreen_click_rcti_init
|
|
|
|
* Keep them both in sync */
|
|
|
|
|
2019-01-16 19:41:29 +01:00
|
|
|
if (G.debug_value == 101) {
|
2014-10-14 15:05:44 -03:00
|
|
|
rcti click_rect;
|
|
|
|
float icon_size = UI_DPI_ICON_SIZE + 7 * UI_DPI_FAC;
|
|
|
|
|
|
|
|
BLI_rcti_init(&click_rect, x, x + icon_size, y, y + icon_size);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
|
2018-05-07 13:46:00 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor4f(1.0f, 0.0f, 0.0f, alpha);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(pos, click_rect.xmin, click_rect.ymin, click_rect.xmax, click_rect.ymax);
|
2016-12-13 14:51:39 -05:00
|
|
|
|
2018-05-07 13:46:00 +02:00
|
|
|
immUniformColor4f(0.0f, 1.0f, 1.0f, alpha);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2016-12-13 14:51:39 -05:00
|
|
|
immVertex2f(pos, click_rect.xmin, click_rect.ymin);
|
|
|
|
immVertex2f(pos, click_rect.xmax, click_rect.ymax);
|
|
|
|
immVertex2f(pos, click_rect.xmin, click_rect.ymax);
|
|
|
|
immVertex2f(pos, click_rect.xmax, click_rect.ymin);
|
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
2014-10-14 15:05:44 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-11 00:05:57 +00:00
|
|
|
/**
|
|
|
|
* \brief Corner widgets use for dragging and splitting the view.
|
|
|
|
*/
|
2018-04-22 19:54:19 +02:00
|
|
|
static void area_draw_azone(short UNUSED(x1), short UNUSED(y1), short UNUSED(x2), short UNUSED(y2))
|
2009-04-30 02:14:03 +00:00
|
|
|
{
|
2018-04-22 19:54:19 +02:00
|
|
|
/* No drawing needed since all corners are action zone, and visually distinguishable. */
|
2011-11-16 20:36:06 +00:00
|
|
|
}
|
2009-09-12 23:56:30 +00:00
|
|
|
|
2018-12-21 09:08:21 +11:00
|
|
|
/**
|
|
|
|
* \brief Edge widgets to show hidden panels such as the toolbar and headers.
|
|
|
|
*/
|
|
|
|
static void draw_azone_arrow(float x1, float y1, float x2, float y2, AZEdge edge)
|
|
|
|
{
|
|
|
|
const float size = 0.2f * U.widget_unit;
|
|
|
|
const float l = 1.0f; /* arrow length */
|
|
|
|
const float s = 0.25f; /* arrow thickness */
|
|
|
|
const float hl = l / 2.0f;
|
|
|
|
const float points[6][2] = {{0, -hl}, {l, hl}, {l - s, hl + s}, {0, s + s - hl}, {s - l, hl + s}, {-l, hl}};
|
|
|
|
const float center[2] = {(x1 + x2) / 2, (y1 + y2) / 2};
|
|
|
|
|
|
|
|
int axis;
|
|
|
|
int sign;
|
|
|
|
switch (edge) {
|
|
|
|
case AE_BOTTOM_TO_TOPLEFT:
|
|
|
|
axis = 0;
|
|
|
|
sign = 1;
|
|
|
|
break;
|
|
|
|
case AE_TOP_TO_BOTTOMRIGHT:
|
|
|
|
axis = 0;
|
|
|
|
sign = -1;
|
|
|
|
break;
|
|
|
|
case AE_LEFT_TO_TOPRIGHT:
|
|
|
|
axis = 1;
|
|
|
|
sign = 1;
|
|
|
|
break;
|
|
|
|
case AE_RIGHT_TO_TOPLEFT:
|
|
|
|
axis = 1;
|
|
|
|
sign = -1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BLI_assert(0);
|
|
|
|
return;
|
|
|
|
}
|
2016-12-13 14:51:39 -05:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(true);
|
2016-12-13 14:51:39 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2016-12-14 02:43:26 -05:00
|
|
|
immUniformColor4f(0.8f, 0.8f, 0.8f, 0.4f);
|
2016-12-13 14:51:39 -05:00
|
|
|
|
2018-12-21 09:08:21 +11:00
|
|
|
immBegin(GPU_PRIM_TRI_FAN, 6);
|
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
if (axis == 0) {
|
|
|
|
immVertex2f(pos, center[0] + points[i][0] * size, center[1] + points[i][1] * sign * size);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
immVertex2f(pos, center[0] + points[i][1] * sign * size, center[1] + points[i][0] * size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
immEnd();
|
2016-12-13 14:51:39 -05:00
|
|
|
|
|
|
|
immUnbindProgram();
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2011-11-19 22:05:18 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 09:08:21 +11:00
|
|
|
static void region_draw_azone_tab_arrow(AZone *az)
|
2011-11-19 22:05:18 +00:00
|
|
|
{
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(true);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-11-19 22:05:18 +00:00
|
|
|
/* add code to draw region hidden as 'too small' */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (az->edge) {
|
2011-11-19 22:05:18 +00:00
|
|
|
case AE_TOP_TO_BOTTOMRIGHT:
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
case AE_BOTTOM_TO_TOPLEFT:
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
case AE_LEFT_TO_TOPRIGHT:
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT);
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
case AE_RIGHT_TO_TOPLEFT:
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-11-14 20:04:59 -05:00
|
|
|
float color[4] = {0.05f, 0.05f, 0.05f, 0.4f};
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_aa(true, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color);
|
2011-11-19 22:05:18 +00:00
|
|
|
|
2018-12-21 09:08:21 +11:00
|
|
|
draw_azone_arrow((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, az->edge);
|
2011-11-19 22:05:18 +00:00
|
|
|
}
|
|
|
|
|
2015-04-25 01:29:53 +02:00
|
|
|
static void area_azone_tag_update(ScrArea *sa)
|
|
|
|
{
|
|
|
|
sa->flag |= AREA_FLAG_ACTIONZONES_UPDATE;
|
|
|
|
}
|
|
|
|
|
2013-05-15 17:59:55 +00:00
|
|
|
static void region_draw_azones(ScrArea *sa, ARegion *ar)
|
2008-12-16 18:42:12 +00:00
|
|
|
{
|
2013-05-15 17:59:55 +00:00
|
|
|
AZone *az;
|
|
|
|
|
|
|
|
if (!sa)
|
|
|
|
return;
|
2008-12-16 18:42:12 +00:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
|
|
|
GPU_blend(true);
|
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
2013-05-15 17:59:55 +00:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_translate_2f(-ar->winrct.xmin, -ar->winrct.ymin);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-05-15 17:59:55 +00:00
|
|
|
for (az = sa->actionzones.first; az; az = az->next) {
|
|
|
|
/* test if action zone is over this region */
|
|
|
|
rcti azrct;
|
|
|
|
BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2);
|
|
|
|
|
|
|
|
if (BLI_rcti_isect(&ar->drawrct, &azrct, NULL)) {
|
|
|
|
if (az->type == AZONE_AREA) {
|
|
|
|
area_draw_azone(az->x1, az->y1, az->x2, az->y2);
|
|
|
|
}
|
|
|
|
else if (az->type == AZONE_REGION) {
|
|
|
|
if (az->ar) {
|
|
|
|
/* only display tab or icons when the region is hidden */
|
|
|
|
if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
|
2018-12-21 09:08:21 +11:00
|
|
|
region_draw_azone_tab_arrow(az);
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
}
|
2009-09-12 23:56:30 +00:00
|
|
|
}
|
2008-12-16 18:42:12 +00:00
|
|
|
}
|
2014-10-14 15:05:44 -03:00
|
|
|
else if (az->type == AZONE_FULLSCREEN) {
|
|
|
|
area_draw_azone_fullscreen(az->x1, az->y1, az->x2, az->y2, az->alpha);
|
2018-05-07 01:31:18 +02:00
|
|
|
}
|
2008-12-16 18:42:12 +00:00
|
|
|
}
|
2019-01-04 21:40:16 +01:00
|
|
|
if (!IS_EQF(az->alpha, 0.0f) && ELEM(az->type, AZONE_FULLSCREEN, AZONE_REGION_SCROLL)) {
|
|
|
|
area_azone_tag_update(sa);
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2013-05-15 17:59:55 +00:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2013-05-15 17:59:55 +00:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2008-11-24 10:45:36 +00:00
|
|
|
}
|
|
|
|
|
2018-08-15 14:47:48 +02:00
|
|
|
static void region_draw_status_text(ScrArea *sa, ARegion *ar)
|
|
|
|
{
|
|
|
|
bool overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
|
|
|
|
|
|
|
|
if (overlap) {
|
|
|
|
GPU_clear_color(0.0, 0.0, 0.0, 0.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_ThemeClearColor(TH_HEADER);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
int fontid = BLF_set_default();
|
|
|
|
|
|
|
|
const float width = BLF_width(fontid, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
const float x = UI_UNIT_X;
|
|
|
|
const float y = 0.4f * UI_UNIT_Y;
|
|
|
|
|
|
|
|
if (overlap) {
|
|
|
|
const float pad = 2.0f * UI_DPI_FAC;
|
|
|
|
const float x1 = x - (UI_UNIT_X - pad);
|
|
|
|
const float x2 = x + width + (UI_UNIT_X - pad);
|
|
|
|
const float y1 = pad;
|
|
|
|
const float y2 = ar->winy - pad;
|
|
|
|
|
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
float color[4] = {0.0f, 0.0f, 0.0f, 0.5f};
|
|
|
|
UI_GetThemeColor3fv(TH_BACK, color);
|
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
|
|
|
UI_draw_roundbox_aa(true, x1, y1, x2, y2, 4.0f, color);
|
|
|
|
|
|
|
|
UI_FontThemeColor(fontid, TH_TEXT);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_FontThemeColor(fontid, TH_TEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLF_position(fontid, x, y, 0.0f);
|
|
|
|
BLF_draw(fontid, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
}
|
|
|
|
|
2017-11-13 19:43:34 +11:00
|
|
|
/* Follow wmMsgNotifyFn spec */
|
|
|
|
void ED_region_do_msg_notify_tag_redraw(
|
|
|
|
bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)
|
|
|
|
{
|
|
|
|
ARegion *ar = msg_val->owner;
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
|
|
|
/* This avoids _many_ situations where header/properties control display settings.
|
|
|
|
* the common case is space properties in the header */
|
|
|
|
if (ELEM(ar->regiontype, RGN_TYPE_HEADER, RGN_TYPE_UI)) {
|
|
|
|
while (ar && ar->prev) {
|
|
|
|
ar = ar->prev;
|
|
|
|
}
|
|
|
|
for (; ar; ar = ar->next) {
|
|
|
|
if (ELEM(ar->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_CHANNELS)) {
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Follow wmMsgNotifyFn spec */
|
|
|
|
void ED_area_do_msg_notify_tag_refresh(
|
|
|
|
bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)
|
|
|
|
{
|
|
|
|
ScrArea *sa = msg_val->user_data;
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
}
|
2009-07-19 12:15:20 +00:00
|
|
|
|
2018-06-30 16:51:31 +02:00
|
|
|
/**
|
|
|
|
* Although there's no general support for minimizing areas, the status-bar can
|
|
|
|
* be snapped to be only a few pixels high. A few pixels rather than 0 so it
|
2019-04-10 00:06:53 +10:00
|
|
|
* can be un-minimized again. We consider it pseudo-minimized and don't draw
|
2018-06-30 16:51:31 +02:00
|
|
|
* it then.
|
|
|
|
*/
|
|
|
|
static bool area_is_pseudo_minimized(const ScrArea *area)
|
|
|
|
{
|
|
|
|
return (area->winx < 3) || (area->winy < 3);
|
|
|
|
}
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
/* only exported for WM */
|
|
|
|
void ED_region_do_layout(bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* This is optional, only needed for dynamically sized regions. */
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegionType *at = ar->type;
|
|
|
|
|
|
|
|
if (!at->layout) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-30 16:51:31 +02:00
|
|
|
if (at->do_lock || (sa && area_is_pseudo_minimized(sa))) {
|
2018-04-29 12:24:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->do_draw |= RGN_DRAWING;
|
|
|
|
|
|
|
|
UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
|
|
|
|
at->layout(C, ar);
|
|
|
|
}
|
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
/* only exported for WM */
|
2008-01-07 18:03:41 +00:00
|
|
|
void ED_region_do_draw(bContext *C, ARegion *ar)
|
|
|
|
{
|
2012-05-08 15:43:59 +00:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
ARegionType *at = ar->type;
|
2013-08-05 04:52:27 +00:00
|
|
|
|
2011-03-25 17:11:32 +00:00
|
|
|
/* see BKE_spacedata_draw_locks() */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (at->do_lock)
|
2011-03-25 17:11:32 +00:00
|
|
|
return;
|
2014-04-02 18:42:08 +11:00
|
|
|
|
2013-12-18 12:02:31 +01:00
|
|
|
ar->do_draw |= RGN_DRAWING;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-02-16 22:41:46 +01:00
|
|
|
/* Set viewport, scissor, ortho and ar->drawrct. */
|
|
|
|
wmPartialViewport(&ar->drawrct, &ar->winrct, &ar->drawrct);
|
2014-09-10 13:34:17 +10:00
|
|
|
|
2016-02-29 15:20:09 +01:00
|
|
|
wmOrtho2_region_pixelspace(ar);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2013-07-27 16:39:00 +00:00
|
|
|
UI_SetTheme(sa ? sa->spacetype : 0, at->regionid);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-06-30 16:51:31 +02:00
|
|
|
if (sa && area_is_pseudo_minimized(sa)) {
|
|
|
|
UI_ThemeClearColor(TH_EDITOR_OUTLINE);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
return;
|
|
|
|
}
|
2018-06-28 12:06:00 +02:00
|
|
|
/* optional header info instead? */
|
2018-06-30 16:51:31 +02:00
|
|
|
else if (ar->headerstr) {
|
2018-08-15 14:47:48 +02:00
|
|
|
region_draw_status_text(sa, ar);
|
2018-06-28 12:06:00 +02:00
|
|
|
}
|
|
|
|
else if (at->draw) {
|
2.5
Vertex Paint back!
Added WM level "paint cursor" system, which manages a custom painting
cursor for tools or modes.
- Activate it with WM_paint_cursor_activate(). That function wants two
callbacks, a poll(C) to check whether there's a cursor in given context
and ARegion, and a draw(C, x, y) which gets called when appropriate.
- While paintcursor is active, the WM handles necessary redrawing events
for all regions, also to nicely clear the cursor on region exit.
- WM_paint_cursor_activate returns a handle, which you have to use to
end the paint cursor. This handle also means you can register as many
custom cursors as you want.
At the moment, vertex paint mode registers only a mousemove handler,
all other events are still normally handled. This is stuff for the
future todo.
2009-01-09 13:55:45 +00:00
|
|
|
at->draw(C, ar);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2010-08-06 18:11:49 +00:00
|
|
|
|
2011-11-04 21:29:28 +00:00
|
|
|
/* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
|
|
|
|
ED_region_pixelspace(ar);
|
|
|
|
|
2010-08-06 18:11:49 +00:00
|
|
|
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
|
2012-03-06 14:48:11 +00:00
|
|
|
|
2013-05-15 17:59:55 +00:00
|
|
|
region_draw_azones(sa, ar);
|
|
|
|
|
2013-05-13 13:32:42 +00:00
|
|
|
/* for debugging unneeded area redraws and partial redraw */
|
|
|
|
#if 0
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(true);
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4f(drand48(), drand48(), drand48(), 0.1f);
|
|
|
|
immRectf(pos, ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin,
|
2013-05-14 06:58:35 +00:00
|
|
|
ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin);
|
2016-12-13 14:51:39 -05:00
|
|
|
immUnbindProgram();
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2013-05-13 13:32:42 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-06 14:48:11 +00:00
|
|
|
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_blocklist_free_inactive(C, &ar->uiblocks);
|
2011-11-04 21:29:28 +00:00
|
|
|
|
2018-04-27 16:50:19 +02:00
|
|
|
if (sa) {
|
|
|
|
const bScreen *screen = WM_window_get_active_screen(win);
|
|
|
|
|
2019-04-04 01:25:43 +02:00
|
|
|
/* Only region emboss for top-bar */
|
2018-04-27 16:50:19 +02:00
|
|
|
if ((screen->state != SCREENFULL) && ED_area_is_global(sa)) {
|
|
|
|
region_draw_emboss(ar, &ar->winrct, (REGION_EMBOSS_LEFT | REGION_EMBOSS_RIGHT));
|
|
|
|
}
|
|
|
|
else if ((ar->regiontype == RGN_TYPE_WINDOW) && (ar->alignment == RGN_ALIGN_QSPLIT)) {
|
2019-04-04 01:25:43 +02:00
|
|
|
|
|
|
|
/* draw separating lines between the quad views */
|
|
|
|
|
|
|
|
float color[4] = { 0.0f, 0.0f, 0.0f, 0.8f };
|
|
|
|
UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color);
|
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4fv(color);
|
|
|
|
GPU_line_width(1.0f);
|
|
|
|
imm_draw_box_wire_2d(pos, 0, 0, ar->winrct.xmax - ar->winrct.xmin + 1, ar->winrct.ymax - ar->winrct.ymin + 1);
|
|
|
|
immUnbindProgram();
|
2018-04-27 16:50:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-13 19:43:34 +11:00
|
|
|
/* We may want to detach message-subscriptions from drawing. */
|
|
|
|
{
|
|
|
|
WorkSpace *workspace = CTX_wm_workspace(C);
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
bScreen *screen = WM_window_get_active_screen(win);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
struct wmMsgBus *mbus = wm->message_bus;
|
|
|
|
WM_msgbus_clear_by_owner(mbus, ar);
|
|
|
|
|
|
|
|
/* Cheat, always subscribe to this space type properties.
|
|
|
|
*
|
|
|
|
* This covers most cases and avoids copy-paste similar code for each space type.
|
|
|
|
*/
|
|
|
|
if (ELEM(ar->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_CHANNELS, RGN_TYPE_UI, RGN_TYPE_TOOLS)) {
|
|
|
|
SpaceLink *sl = sa->spacedata.first;
|
|
|
|
|
|
|
|
PointerRNA ptr;
|
|
|
|
RNA_pointer_create(&screen->id, &RNA_Space, sl, &ptr);
|
|
|
|
|
|
|
|
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
|
|
|
|
.owner = ar,
|
|
|
|
.user_data = ar,
|
|
|
|
.notify = ED_region_do_msg_notify_tag_redraw,
|
|
|
|
};
|
|
|
|
/* All properties for this space type. */
|
|
|
|
WM_msg_subscribe_rna(mbus, &ptr, NULL, &msg_sub_value_region_tag_redraw, __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
ED_region_message_subscribe(C, workspace, scene, screen, sa, ar, mbus);
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-16 12:28:00 +00:00
|
|
|
/* **********************************
|
2012-03-03 16:31:46 +00:00
|
|
|
* maybe silly, but let's try for now
|
|
|
|
* to keep these tags protected
|
|
|
|
* ********************************** */
|
2008-12-16 12:28:00 +00:00
|
|
|
|
|
|
|
void ED_region_tag_redraw(ARegion *ar)
|
|
|
|
{
|
2013-12-18 12:02:31 +01:00
|
|
|
/* don't tag redraw while drawing, it shouldn't happen normally
|
|
|
|
* but python scripts can cause this to happen indirectly */
|
|
|
|
if (ar && !(ar->do_draw & RGN_DRAWING)) {
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
/* zero region means full region redraw */
|
2018-05-15 12:49:38 +02:00
|
|
|
ar->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD);
|
2014-07-19 08:11:52 +10:00
|
|
|
ar->do_draw |= RGN_DRAW;
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:58:32 +00:00
|
|
|
void ED_region_tag_redraw_overlay(ARegion *ar)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar)
|
2012-05-08 15:43:59 +00:00
|
|
|
ar->do_draw_overlay = RGN_DRAW;
|
2010-06-23 09:58:32 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 12:49:38 +02:00
|
|
|
void ED_region_tag_redraw_no_rebuild(ARegion *ar)
|
|
|
|
{
|
|
|
|
if (ar && !(ar->do_draw & (RGN_DRAWING | RGN_DRAW))) {
|
|
|
|
ar->do_draw &= ~RGN_DRAW_PARTIAL;
|
|
|
|
ar->do_draw |= RGN_DRAW_NO_REBUILD;
|
|
|
|
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-15 01:40:15 +10:00
|
|
|
void ED_region_tag_refresh_ui(ARegion *ar)
|
|
|
|
{
|
|
|
|
if (ar) {
|
|
|
|
ar->do_draw |= RGN_DRAW_REFRESH_UI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-30 15:31:55 +10:00
|
|
|
void ED_region_tag_redraw_partial(ARegion *ar, const rcti *rct)
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
{
|
2013-12-18 12:02:31 +01:00
|
|
|
if (ar && !(ar->do_draw & RGN_DRAWING)) {
|
2018-05-15 12:49:38 +02:00
|
|
|
if (!(ar->do_draw & (RGN_DRAW | RGN_DRAW_NO_REBUILD | RGN_DRAW_PARTIAL))) {
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
/* no redraw set yet, set partial region */
|
2014-07-19 08:11:52 +10:00
|
|
|
ar->do_draw |= RGN_DRAW_PARTIAL;
|
2012-05-08 15:43:59 +00:00
|
|
|
ar->drawrct = *rct;
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ar->drawrct.xmin != ar->drawrct.xmax) {
|
2016-07-18 14:37:04 +02:00
|
|
|
BLI_assert((ar->do_draw & RGN_DRAW_PARTIAL) != 0);
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
/* partial redraw already set, expand region */
|
2012-10-24 05:06:40 +00:00
|
|
|
BLI_rcti_union(&ar->drawrct, rct);
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
}
|
2016-07-18 14:37:04 +02:00
|
|
|
else {
|
2018-05-15 12:49:38 +02:00
|
|
|
BLI_assert((ar->do_draw & (RGN_DRAW | RGN_DRAW_NO_REBUILD)) != 0);
|
2016-07-18 14:37:04 +02:00
|
|
|
/* Else, full redraw is already requested, nothing to do here. */
|
|
|
|
}
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
}
|
2008-12-16 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_area_tag_redraw(ScrArea *sa)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa)
|
2012-05-08 15:43:59 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
2.5: WM Compositing
* Triple Buffer is now more complete:
- Proper handling of window resize, duplicate, etc.
- It now uses 3x3 textures (or less) if the power of two sizes
do not match well. That still has a worst case wast of 23.4%,
but better than 300%.
- It can also use the ARB/NV/EXT_texture_rectangle extension
now, which may be supported on hardware that does not support
ARB_texture_non_power_of_two.
- Gesture, menu and brushe redraws now require no redraws at all
from the area regions. So even on a high poly scene just moving
the paint cursor or opening a menu should be fast.
* Testing can be done by setting the "Window Draw Method" in the
User Preferences in the outliner. "Overlap" is still default,
since "Triple Buffer" has not been tested on computers other than
mine, would like to avoid crashing Blender on startup in case
there is a common bug, but it's ready for testing now.
- For reference "Full" draws the full window each time.
- "Triple Buffer" should work for both swap copy and swap exchange
systems, the latter still need the -E command line option for
"Overlap".
- Resizing and going fullscreen still gives flicker here but no
more than "Full" drawing.
* Partial Redraw was added. ED_region_tag_redraw_partial takes a
rect in window coordinates to define a subarea of the region.
On region draw it will then set glScissor to a smaller area, and
ar->drawrct will always be set to either the partial or full
window rect. The latter can then be used for clipping in the 3D
view or clipping interface drawing. Neither is implemented yet.
2009-01-23 03:52:52 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2008-12-16 12:28:00 +00:00
|
|
|
}
|
|
|
|
|
2018-05-22 14:41:49 +02:00
|
|
|
void ED_area_tag_redraw_no_rebuild(ScrArea *sa)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
|
|
|
|
if (sa)
|
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
|
|
|
ED_region_tag_redraw_no_rebuild(ar);
|
|
|
|
}
|
|
|
|
|
2010-10-20 04:12:01 +00:00
|
|
|
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa) {
|
2012-05-08 15:43:59 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar->regiontype == regiontype) {
|
2010-10-20 04:12:01 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
void ED_area_tag_refresh(ScrArea *sa)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa)
|
2014-04-01 11:34:00 +11:00
|
|
|
sa->do_refresh = true;
|
2009-01-04 17:45:54 +00:00
|
|
|
}
|
2008-12-16 12:28:00 +00:00
|
|
|
|
2008-12-21 17:18:36 +00:00
|
|
|
/* *************************************************************** */
|
|
|
|
|
|
|
|
/* use NULL to disable it */
|
2018-06-28 12:06:00 +02:00
|
|
|
void ED_area_status_text(ScrArea *sa, const char *str)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
|
2018-09-27 15:35:22 +02:00
|
|
|
/* happens when running transform operators in background mode */
|
2018-06-28 12:06:00 +02:00
|
|
|
if (sa == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
|
|
|
if (ar->regiontype == RGN_TYPE_HEADER) {
|
|
|
|
if (str) {
|
|
|
|
if (ar->headerstr == NULL)
|
|
|
|
ar->headerstr = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint");
|
|
|
|
BLI_strncpy(ar->headerstr, str, UI_MAX_DRAW_STR);
|
2018-08-15 14:47:48 +02:00
|
|
|
BLI_str_rstrip(ar->headerstr);
|
2018-06-28 12:06:00 +02:00
|
|
|
}
|
|
|
|
else if (ar->headerstr) {
|
|
|
|
MEM_freeN(ar->headerstr);
|
|
|
|
ar->headerstr = NULL;
|
|
|
|
}
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-26 17:19:25 +02:00
|
|
|
void ED_workspace_status_text(bContext *C, const char *str)
|
2008-12-21 17:18:36 +00:00
|
|
|
{
|
2018-06-26 17:19:25 +02:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
WorkSpace *workspace = CTX_wm_workspace(C);
|
2011-03-22 09:14:27 +00:00
|
|
|
|
2018-06-26 17:19:25 +02:00
|
|
|
/* Can be NULL when running operators in background mode. */
|
|
|
|
if (workspace == NULL)
|
2011-03-22 09:14:27 +00:00
|
|
|
return;
|
|
|
|
|
2018-06-26 17:19:25 +02:00
|
|
|
if (str) {
|
|
|
|
if (workspace->status_text == NULL)
|
|
|
|
workspace->status_text = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint");
|
|
|
|
BLI_strncpy(workspace->status_text, str, UI_MAX_DRAW_STR);
|
|
|
|
}
|
|
|
|
else if (workspace->status_text) {
|
|
|
|
MEM_freeN(workspace->status_text);
|
|
|
|
workspace->status_text = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Redraw status bar. */
|
|
|
|
for (ScrArea *sa = win->global_areas.areabase.first; sa; sa = sa->next) {
|
|
|
|
if (sa->spacetype == SPACE_STATUSBAR) {
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
break;
|
2008-12-21 17:18:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-16 12:28:00 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
/* ************************************************************ */
|
|
|
|
|
|
|
|
|
2017-05-02 09:58:01 +10:00
|
|
|
static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea *sa)
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
{
|
|
|
|
AZone *az;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-09-27 15:35:22 +02:00
|
|
|
/* reinitialize entirely, regions and fullscreen add azones too */
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
BLI_freelistN(&sa->actionzones);
|
2012-08-11 00:05:57 +00:00
|
|
|
|
2014-10-14 15:05:44 -03:00
|
|
|
if (screen->state != SCREENNORMAL) {
|
2012-08-11 00:05:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-12 12:30:58 +11:00
|
|
|
if (U.app_flag & USER_APP_LOCK_UI_LAYOUT) {
|
2018-01-11 16:08:55 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-21 10:06:12 +02:00
|
|
|
if (ED_area_is_global(sa)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-14 11:12:52 +11:00
|
|
|
if (screen->temp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-22 19:48:00 +02:00
|
|
|
float coords[4][4] = {
|
|
|
|
/* Bottom-left. */
|
2019-02-21 17:04:20 +01:00
|
|
|
{sa->totrct.xmin - U.pixelsize,
|
|
|
|
sa->totrct.ymin - U.pixelsize,
|
2019-01-23 14:44:40 +01:00
|
|
|
sa->totrct.xmin + AZONESPOTW,
|
|
|
|
sa->totrct.ymin + AZONESPOTH},
|
2018-04-22 19:48:00 +02:00
|
|
|
/* Bottom-right. */
|
2019-01-23 14:44:40 +01:00
|
|
|
{sa->totrct.xmax - AZONESPOTW,
|
2019-02-21 17:04:20 +01:00
|
|
|
sa->totrct.ymin - U.pixelsize,
|
|
|
|
sa->totrct.xmax + U.pixelsize,
|
2019-01-23 14:44:40 +01:00
|
|
|
sa->totrct.ymin + AZONESPOTH},
|
2018-04-22 19:48:00 +02:00
|
|
|
/* Top-left. */
|
2019-02-21 17:04:20 +01:00
|
|
|
{sa->totrct.xmin - U.pixelsize,
|
2019-01-23 14:44:40 +01:00
|
|
|
sa->totrct.ymax - AZONESPOTH,
|
|
|
|
sa->totrct.xmin + AZONESPOTW,
|
2019-02-21 17:04:20 +01:00
|
|
|
sa->totrct.ymax + U.pixelsize},
|
2018-04-22 19:48:00 +02:00
|
|
|
/* Top-right. */
|
2019-01-23 14:44:40 +01:00
|
|
|
{sa->totrct.xmax - AZONESPOTW,
|
|
|
|
sa->totrct.ymax - AZONESPOTH,
|
2019-02-21 17:04:20 +01:00
|
|
|
sa->totrct.xmax + U.pixelsize,
|
|
|
|
sa->totrct.ymax + U.pixelsize}};
|
2018-04-22 19:48:00 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2018-04-22 23:34:11 +02:00
|
|
|
/* can't click on bottom corners on OS X, already used for resizing */
|
|
|
|
#ifdef __APPLE__
|
|
|
|
if (!WM_window_is_fullscreen(win) &&
|
|
|
|
((coords[i][0] == 0 && coords[i][1] == 0) ||
|
2018-04-28 09:01:34 +02:00
|
|
|
(coords[i][0] == WM_window_pixels_x(win) && coords[i][1] == 0)))
|
|
|
|
{
|
2018-04-22 23:34:11 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
(void)win;
|
|
|
|
#endif
|
|
|
|
|
2014-02-27 23:39:40 +01:00
|
|
|
/* set area action zones */
|
|
|
|
az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
|
|
|
BLI_addtail(&(sa->actionzones), az);
|
|
|
|
az->type = AZONE_AREA;
|
2018-04-22 19:48:00 +02:00
|
|
|
az->x1 = coords[i][0];
|
|
|
|
az->y1 = coords[i][1];
|
|
|
|
az->x2 = coords[i][2];
|
|
|
|
az->y2 = coords[i][3];
|
2014-02-27 23:39:40 +01:00
|
|
|
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
|
|
|
|
}
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
|
2014-10-14 15:05:44 -03:00
|
|
|
static void fullscreen_azone_initialize(ScrArea *sa, ARegion *ar)
|
|
|
|
{
|
|
|
|
AZone *az;
|
|
|
|
|
2018-04-24 19:59:48 +02:00
|
|
|
if (ED_area_is_global(sa) || (ar->regiontype != RGN_TYPE_WINDOW))
|
2014-10-14 15:05:44 -03:00
|
|
|
return;
|
|
|
|
|
|
|
|
az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone");
|
|
|
|
BLI_addtail(&(sa->actionzones), az);
|
|
|
|
az->type = AZONE_FULLSCREEN;
|
|
|
|
az->ar = ar;
|
|
|
|
az->alpha = 0.0f;
|
|
|
|
|
|
|
|
az->x1 = ar->winrct.xmax - (AZONEFADEOUT - 1);
|
|
|
|
az->y1 = ar->winrct.ymax - (AZONEFADEOUT - 1);
|
|
|
|
az->x2 = ar->winrct.xmax;
|
|
|
|
az->y2 = ar->winrct.ymax;
|
|
|
|
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
|
|
|
|
}
|
|
|
|
|
2013-03-10 14:30:24 +00:00
|
|
|
#define AZONEPAD_EDGE (0.1f * U.widget_unit)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
#define AZONEPAD_ICON (0.45f * U.widget_unit)
|
2009-09-12 23:56:30 +00:00
|
|
|
static void region_azone_edge(AZone *az, ARegion *ar)
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (az->edge) {
|
2010-09-20 13:13:40 +00:00
|
|
|
case AE_TOP_TO_BOTTOMRIGHT:
|
2012-05-08 15:43:59 +00:00
|
|
|
az->x1 = ar->winrct.xmin;
|
|
|
|
az->y1 = ar->winrct.ymax - AZONEPAD_EDGE;
|
|
|
|
az->x2 = ar->winrct.xmax;
|
2013-03-10 14:30:24 +00:00
|
|
|
az->y2 = ar->winrct.ymax + AZONEPAD_EDGE;
|
2010-09-20 13:13:40 +00:00
|
|
|
break;
|
|
|
|
case AE_BOTTOM_TO_TOPLEFT:
|
2012-05-08 15:43:59 +00:00
|
|
|
az->x1 = ar->winrct.xmin;
|
|
|
|
az->y1 = ar->winrct.ymin + AZONEPAD_EDGE;
|
|
|
|
az->x2 = ar->winrct.xmax;
|
2013-03-10 14:30:24 +00:00
|
|
|
az->y2 = ar->winrct.ymin - AZONEPAD_EDGE;
|
2010-09-20 13:13:40 +00:00
|
|
|
break;
|
|
|
|
case AE_LEFT_TO_TOPRIGHT:
|
2013-03-10 14:30:24 +00:00
|
|
|
az->x1 = ar->winrct.xmin - AZONEPAD_EDGE;
|
2012-05-08 15:43:59 +00:00
|
|
|
az->y1 = ar->winrct.ymin;
|
|
|
|
az->x2 = ar->winrct.xmin + AZONEPAD_EDGE;
|
|
|
|
az->y2 = ar->winrct.ymax;
|
2010-09-20 13:13:40 +00:00
|
|
|
break;
|
|
|
|
case AE_RIGHT_TO_TOPLEFT:
|
2013-03-10 14:30:24 +00:00
|
|
|
az->x1 = ar->winrct.xmax + AZONEPAD_EDGE;
|
2012-05-08 15:43:59 +00:00
|
|
|
az->y1 = ar->winrct.ymin;
|
|
|
|
az->x2 = ar->winrct.xmax - AZONEPAD_EDGE;
|
|
|
|
az->y2 = ar->winrct.ymax;
|
2010-09-20 13:13:40 +00:00
|
|
|
break;
|
2009-09-12 23:56:30 +00:00
|
|
|
}
|
|
|
|
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
|
2009-09-12 23:56:30 +00:00
|
|
|
}
|
|
|
|
|
2011-11-19 22:05:18 +00:00
|
|
|
/* region already made zero sized, in shape of edge */
|
|
|
|
static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
|
|
|
|
{
|
|
|
|
AZone *azt;
|
2012-05-08 15:43:59 +00:00
|
|
|
int tot = 0, add;
|
2018-08-16 12:43:30 +10:00
|
|
|
/* Edge offset multiplied by the */
|
|
|
|
|
|
|
|
float edge_offset = 1.0f;
|
|
|
|
const float tab_size_x = 0.7f * U.widget_unit;
|
2018-12-21 09:08:21 +11:00
|
|
|
const float tab_size_y = 0.4f * U.widget_unit;
|
2018-08-16 12:43:30 +10:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
for (azt = sa->actionzones.first; azt; azt = azt->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (azt->edge == az->edge) tot++;
|
2011-11-19 22:05:18 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (az->edge) {
|
2011-11-19 22:05:18 +00:00
|
|
|
case AE_TOP_TO_BOTTOMRIGHT:
|
2015-04-06 16:40:26 +10:00
|
|
|
add = (ar->winrct.ymax == sa->totrct.ymin) ? 1 : 0;
|
2018-08-16 12:43:30 +10:00
|
|
|
az->x1 = ar->winrct.xmax - ((edge_offset + 1.0f) * tab_size_x);
|
2012-05-08 15:43:59 +00:00
|
|
|
az->y1 = ar->winrct.ymax - add;
|
2018-08-16 12:43:30 +10:00
|
|
|
az->x2 = ar->winrct.xmax - (edge_offset * tab_size_x);
|
|
|
|
az->y2 = ar->winrct.ymax - add + tab_size_y;
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
case AE_BOTTOM_TO_TOPLEFT:
|
2018-08-16 12:43:30 +10:00
|
|
|
az->x1 = ar->winrct.xmax - ((edge_offset + 1.0f) * tab_size_x);
|
|
|
|
az->y1 = ar->winrct.ymin - tab_size_y;
|
|
|
|
az->x2 = ar->winrct.xmax - (edge_offset * tab_size_x);
|
2012-05-08 15:43:59 +00:00
|
|
|
az->y2 = ar->winrct.ymin;
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
case AE_LEFT_TO_TOPRIGHT:
|
2018-08-16 12:43:30 +10:00
|
|
|
az->x1 = ar->winrct.xmin - tab_size_y;
|
|
|
|
az->y1 = ar->winrct.ymax - ((edge_offset + 1.0f) * tab_size_x);
|
2012-05-08 15:43:59 +00:00
|
|
|
az->x2 = ar->winrct.xmin;
|
2018-08-16 12:43:30 +10:00
|
|
|
az->y2 = ar->winrct.ymax - (edge_offset * tab_size_x);
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
case AE_RIGHT_TO_TOPLEFT:
|
2018-12-21 09:08:21 +11:00
|
|
|
az->x1 = ar->winrct.xmax;
|
2018-08-16 12:43:30 +10:00
|
|
|
az->y1 = ar->winrct.ymax - ((edge_offset + 1.0f) * tab_size_x);
|
2018-12-21 09:08:21 +11:00
|
|
|
az->x2 = ar->winrct.xmax + tab_size_y;
|
2018-08-16 12:43:30 +10:00
|
|
|
az->y2 = ar->winrct.ymax - (edge_offset * tab_size_x);
|
2011-11-19 22:05:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* rect needed for mouse pointer test */
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
|
2018-06-01 18:10:43 +02:00
|
|
|
}
|
2011-11-19 22:05:18 +00:00
|
|
|
|
2018-12-23 18:04:48 +01:00
|
|
|
static bool region_azone_edge_poll(const ARegion *ar, const bool is_fullscreen)
|
|
|
|
{
|
|
|
|
const bool is_hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
|
|
|
|
|
|
|
|
if (is_hidden && is_fullscreen) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!is_hidden && ar->regiontype == RGN_TYPE_HEADER) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-05-07 13:26:48 +02:00
|
|
|
static void region_azone_edge_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const bool is_fullscreen)
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
{
|
2018-05-07 13:26:48 +02:00
|
|
|
AZone *az = NULL;
|
|
|
|
const bool is_hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
|
2018-12-23 18:04:48 +01:00
|
|
|
if (!region_azone_edge_poll(ar, is_fullscreen)) {
|
2018-05-07 13:26:48 +02:00
|
|
|
return;
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 13:26:48 +02:00
|
|
|
az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
|
|
|
BLI_addtail(&(sa->actionzones), az);
|
|
|
|
az->type = AZONE_REGION;
|
|
|
|
az->ar = ar;
|
|
|
|
az->edge = edge;
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
|
2018-05-07 13:26:48 +02:00
|
|
|
if (is_hidden) {
|
|
|
|
region_azone_tab_plus(sa, az, ar);
|
2018-06-01 18:10:43 +02:00
|
|
|
}
|
2018-12-23 18:04:48 +01:00
|
|
|
else {
|
2009-09-12 23:56:30 +00:00
|
|
|
region_azone_edge(az, ar);
|
|
|
|
}
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 01:31:18 +02:00
|
|
|
static void region_azone_scrollbar_initialize(ScrArea *sa, ARegion *ar, AZScrollDirection direction)
|
|
|
|
{
|
|
|
|
rcti scroller_vert = (direction == AZ_SCROLL_VERT) ? ar->v2d.vert : ar->v2d.hor;
|
|
|
|
AZone *az = MEM_callocN(sizeof(*az), __func__);
|
|
|
|
|
|
|
|
BLI_addtail(&sa->actionzones, az);
|
|
|
|
az->type = AZONE_REGION_SCROLL;
|
|
|
|
az->ar = ar;
|
|
|
|
az->direction = direction;
|
|
|
|
|
|
|
|
if (direction == AZ_SCROLL_VERT) {
|
|
|
|
az->ar->v2d.alpha_vert = 0;
|
|
|
|
}
|
|
|
|
else if (direction == AZ_SCROLL_HOR) {
|
|
|
|
az->ar->v2d.alpha_hor = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_rcti_translate(&scroller_vert, ar->winrct.xmin, ar->winrct.ymin);
|
|
|
|
az->x1 = scroller_vert.xmin - AZONEFADEIN;
|
|
|
|
az->y1 = scroller_vert.ymin - AZONEFADEIN;
|
|
|
|
az->x2 = scroller_vert.xmax + AZONEFADEIN;
|
|
|
|
az->y2 = scroller_vert.ymax + AZONEFADEIN;
|
|
|
|
|
|
|
|
BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void region_azones_scrollbars_initialize(ScrArea *sa, ARegion *ar)
|
|
|
|
{
|
|
|
|
const View2D *v2d = &ar->v2d;
|
|
|
|
|
|
|
|
if ((v2d->scroll & V2D_SCROLL_VERTICAL) && ((v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) == 0)) {
|
|
|
|
region_azone_scrollbar_initialize(sa, ar, AZ_SCROLL_VERT);
|
|
|
|
}
|
|
|
|
if ((v2d->scroll & V2D_SCROLL_HORIZONTAL) && ((v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) == 0)) {
|
|
|
|
region_azone_scrollbar_initialize(sa, ar, AZ_SCROLL_HOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* *************************************************************** */
|
|
|
|
|
2018-05-07 01:31:18 +02:00
|
|
|
static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *ar, const int alignment)
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
{
|
2018-05-07 01:31:18 +02:00
|
|
|
const bool is_fullscreen = screen->state == SCREENFULL;
|
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
/* edge code (t b l r) is along which area edge azone will be drawn */
|
2019-04-03 14:53:57 +02:00
|
|
|
if (alignment == RGN_ALIGN_TOP)
|
2018-05-07 01:31:18 +02:00
|
|
|
region_azone_edge_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (alignment == RGN_ALIGN_BOTTOM)
|
2018-05-07 01:31:18 +02:00
|
|
|
region_azone_edge_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
else if (alignment == RGN_ALIGN_RIGHT)
|
2018-05-07 01:31:18 +02:00
|
|
|
region_azone_edge_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
else if (alignment == RGN_ALIGN_LEFT)
|
2018-05-07 01:31:18 +02:00
|
|
|
region_azone_edge_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
|
|
|
|
|
|
|
|
if (is_fullscreen) {
|
|
|
|
fullscreen_azone_initialize(sa, ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
region_azones_scrollbars_initialize(sa, ar);
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 15:59:43 +00:00
|
|
|
/* dir is direction to check, not the splitting edge direction! */
|
2015-06-30 15:31:55 +10:00
|
|
|
static int rct_fits(const rcti *rect, char dir, int size)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2012-05-08 15:43:59 +00:00
|
|
|
if (dir == 'h') {
|
2013-11-25 13:40:58 +01:00
|
|
|
return BLI_rcti_size_x(rect) + 1 - size;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2012-08-20 23:06:17 +00:00
|
|
|
else { /* 'v' */
|
2013-11-25 13:40:58 +01:00
|
|
|
return BLI_rcti_size_y(rect) + 1 - size;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* *************************************************************** */
|
|
|
|
|
2012-12-13 17:43:12 +00:00
|
|
|
/* ar should be overlapping */
|
|
|
|
/* function checks if some overlapping region was defined before - on same place */
|
2012-12-19 16:16:20 +00:00
|
|
|
static void region_overlap_fix(ScrArea *sa, ARegion *ar)
|
2012-12-13 17:43:12 +00:00
|
|
|
{
|
2014-08-15 15:36:25 +02:00
|
|
|
ARegion *ar1;
|
|
|
|
const int align = ar->alignment & ~RGN_SPLIT_PREV;
|
|
|
|
int align1 = 0;
|
|
|
|
|
2012-12-13 17:43:12 +00:00
|
|
|
/* find overlapping previous region on same place */
|
2014-08-15 15:36:25 +02:00
|
|
|
for (ar1 = ar->prev; ar1; ar1 = ar1->prev) {
|
2018-05-06 16:07:34 +02:00
|
|
|
if (ar1->flag & (RGN_FLAG_HIDDEN)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-08-15 15:36:25 +02:00
|
|
|
if (ar1->overlap && ((ar1->alignment & RGN_SPLIT_PREV) == 0)) {
|
2018-06-12 10:11:32 +02:00
|
|
|
if (ELEM(ar1->alignment, RGN_ALIGN_FLOAT)) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-08-15 15:36:25 +02:00
|
|
|
align1 = ar1->alignment;
|
|
|
|
if (BLI_rcti_isect(&ar1->winrct, &ar->winrct, NULL)) {
|
|
|
|
if (align1 != align) {
|
|
|
|
/* Left overlapping right or vice-versa, forbid this! */
|
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Else, we have our previous region on same side. */
|
|
|
|
break;
|
|
|
|
}
|
2012-12-13 17:43:12 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-15 15:36:25 +02:00
|
|
|
|
2012-12-19 16:16:20 +00:00
|
|
|
/* translate or close */
|
2012-12-13 17:43:12 +00:00
|
|
|
if (ar1) {
|
|
|
|
if (align1 == RGN_ALIGN_LEFT) {
|
2014-08-15 15:36:25 +02:00
|
|
|
if (ar->winrct.xmax + ar1->winx > sa->winx - U.widget_unit) {
|
2012-12-19 16:16:20 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
2014-08-15 15:36:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2012-12-19 16:16:20 +00:00
|
|
|
BLI_rcti_translate(&ar->winrct, ar1->winx, 0);
|
2014-08-15 15:36:25 +02:00
|
|
|
}
|
2012-12-13 17:43:12 +00:00
|
|
|
}
|
|
|
|
else if (align1 == RGN_ALIGN_RIGHT) {
|
2014-08-15 15:36:25 +02:00
|
|
|
if (ar->winrct.xmin - ar1->winx < U.widget_unit) {
|
2012-12-19 16:16:20 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
2014-08-15 15:36:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2012-12-19 16:16:20 +00:00
|
|
|
BLI_rcti_translate(&ar->winrct, -ar1->winx, 0);
|
2014-08-15 15:36:25 +02:00
|
|
|
}
|
2012-12-13 17:43:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-15 15:36:25 +02:00
|
|
|
/* At this point, 'ar' is in its final position and still open.
|
|
|
|
* Make a final check it does not overlap any previous 'other side' region. */
|
|
|
|
for (ar1 = ar->prev; ar1; ar1 = ar1->prev) {
|
2018-05-06 16:07:34 +02:00
|
|
|
if (ar1->flag & (RGN_FLAG_HIDDEN)) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-06-12 10:11:32 +02:00
|
|
|
if (ELEM(ar1->alignment, RGN_ALIGN_FLOAT)) {
|
|
|
|
continue;
|
|
|
|
}
|
2018-05-06 16:07:34 +02:00
|
|
|
|
2014-08-15 15:36:25 +02:00
|
|
|
if (ar1->overlap && (ar1->alignment & RGN_SPLIT_PREV) == 0) {
|
|
|
|
if ((ar1->alignment != align) && BLI_rcti_isect(&ar1->winrct, &ar->winrct, NULL)) {
|
|
|
|
/* Left overlapping right or vice-versa, forbid this! */
|
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-13 17:43:12 +00:00
|
|
|
}
|
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* overlapping regions only in the following restricted cases */
|
2018-06-01 15:04:51 +02:00
|
|
|
bool ED_region_is_overlap(int spacetype, int regiontype)
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
{
|
2018-06-13 09:27:40 +02:00
|
|
|
if (regiontype == RGN_TYPE_HUD) {
|
2018-11-28 06:26:10 +11:00
|
|
|
return true;
|
2018-06-13 09:27:40 +02:00
|
|
|
}
|
2013-07-08 18:27:32 +00:00
|
|
|
if (U.uiflag2 & USER_REGION_OVERLAP) {
|
2018-11-28 06:26:10 +11:00
|
|
|
if (spacetype == SPACE_NODE) {
|
|
|
|
if (regiontype == RGN_TYPE_TOOLS) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-27 10:00:20 +01:00
|
|
|
}
|
2019-02-23 06:16:52 -08:00
|
|
|
else if (ELEM(spacetype, SPACE_VIEW3D, SPACE_IMAGE)) {
|
2019-04-05 13:48:26 +02:00
|
|
|
if (ELEM(regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS, RGN_TYPE_HEADER, RGN_TYPE_FOOTER)) {
|
2018-11-28 06:26:10 +11:00
|
|
|
return true;
|
|
|
|
}
|
2013-07-08 18:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-28 06:26:10 +11:00
|
|
|
return false;
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-29 20:34:00 +02:00
|
|
|
static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rcti *overlap_remainder, int quad)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2012-05-08 15:43:59 +00:00
|
|
|
rcti *remainder_prev = remainder;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (ar == NULL)
|
2008-01-07 18:03:41 +00:00
|
|
|
return;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-08-17 20:14:06 +02:00
|
|
|
int prev_winx = ar->winx;
|
|
|
|
int prev_winy = ar->winy;
|
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
/* no returns in function, winrct gets set in the end again */
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(&ar->winrct, 0, 0, 0, 0);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-20 19:11:35 +00:00
|
|
|
/* for test; allow split of previously defined region */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar->alignment & RGN_SPLIT_PREV)
|
|
|
|
if (ar->prev)
|
2012-05-08 15:43:59 +00:00
|
|
|
remainder = &ar->prev->winrct;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-08-17 20:14:06 +02:00
|
|
|
int alignment = ar->alignment & ~RGN_SPLIT_PREV;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* set here, assuming userpref switching forces to call this again */
|
2018-06-01 15:04:51 +02:00
|
|
|
ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
|
2008-12-09 15:59:43 +00:00
|
|
|
/* clear state flags first */
|
2019-03-14 09:58:20 +11:00
|
|
|
ar->flag &= ~(RGN_FLAG_TOO_SMALL | RGN_FLAG_SIZE_CLAMP_X | RGN_FLAG_SIZE_CLAMP_Y);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
/* user errors */
|
2018-06-12 10:11:32 +02:00
|
|
|
if ((ar->next == NULL) && !ELEM(alignment, RGN_ALIGN_QSPLIT, RGN_ALIGN_FLOAT)) {
|
2012-05-08 15:43:59 +00:00
|
|
|
alignment = RGN_ALIGN_NONE;
|
2018-06-12 10:11:32 +02:00
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
/* prefsize, taking into account DPI */
|
2018-08-17 20:14:06 +02:00
|
|
|
int prefsizex = UI_DPI_FAC * ((ar->sizex > 1) ? ar->sizex + 0.5f : ar->type->prefsizex);
|
|
|
|
int prefsizey;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
if (ar->flag & RGN_FLAG_PREFSIZE_OR_HIDDEN) {
|
|
|
|
prefsizex = UI_DPI_FAC * ar->type->prefsizex;
|
|
|
|
prefsizey = UI_DPI_FAC * ar->type->prefsizey;
|
|
|
|
}
|
|
|
|
else if (ar->regiontype == RGN_TYPE_HEADER) {
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
prefsizey = ED_area_headersize();
|
2012-10-07 09:48:59 +00:00
|
|
|
}
|
2019-04-05 13:48:26 +02:00
|
|
|
else if (ar->regiontype == RGN_TYPE_FOOTER) {
|
|
|
|
prefsizey = ED_area_footersize();
|
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
else if (ED_area_is_global(sa)) {
|
|
|
|
prefsizey = ED_region_global_size_y();
|
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
|
|
|
|
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
|
2011-10-03 04:48:14 +00:00
|
|
|
}
|
2012-10-07 09:48:59 +00:00
|
|
|
else {
|
2012-12-19 15:44:47 +00:00
|
|
|
prefsizey = UI_DPI_FAC * (ar->sizey > 1 ? ar->sizey + 0.5f : ar->type->prefsizey);
|
2012-10-07 09:48:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ar->flag & RGN_FLAG_HIDDEN) {
|
|
|
|
/* hidden is user flag */
|
|
|
|
}
|
|
|
|
else if (alignment == RGN_ALIGN_FLOAT) {
|
2018-06-12 10:11:32 +02:00
|
|
|
/**
|
|
|
|
* \note Currently this window type is only used for #RGN_TYPE_HUD,
|
|
|
|
* We expect the panel to resize it's self to be larger.
|
|
|
|
*
|
|
|
|
* This aligns to the lower left of the area.
|
|
|
|
*/
|
2018-09-11 22:39:38 +10:00
|
|
|
const int size_min[2] = {UI_UNIT_X, UI_UNIT_Y};
|
2018-06-12 10:11:32 +02:00
|
|
|
rcti overlap_remainder_margin = *overlap_remainder;
|
|
|
|
BLI_rcti_resize(
|
|
|
|
&overlap_remainder_margin,
|
|
|
|
max_ii(0, BLI_rcti_size_x(overlap_remainder) - UI_UNIT_X / 2),
|
|
|
|
max_ii(0, BLI_rcti_size_y(overlap_remainder) - UI_UNIT_Y / 2));
|
|
|
|
ar->winrct.xmin = overlap_remainder_margin.xmin;
|
|
|
|
ar->winrct.ymin = overlap_remainder_margin.ymin;
|
2018-12-23 22:31:04 +01:00
|
|
|
ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1;
|
|
|
|
ar->winrct.ymax = ar->winrct.ymin + prefsizey - 1;
|
2018-06-12 10:11:32 +02:00
|
|
|
|
|
|
|
BLI_rcti_isect(&ar->winrct, &overlap_remainder_margin, &ar->winrct);
|
2018-09-11 22:39:38 +10:00
|
|
|
|
2019-03-14 09:58:20 +11:00
|
|
|
if (BLI_rcti_size_x(&ar->winrct) != prefsizex - 1) {
|
|
|
|
ar->flag |= RGN_FLAG_SIZE_CLAMP_X;
|
|
|
|
}
|
|
|
|
if (BLI_rcti_size_y(&ar->winrct) != prefsizey - 1) {
|
|
|
|
ar->flag |= RGN_FLAG_SIZE_CLAMP_Y;
|
|
|
|
}
|
|
|
|
|
2018-09-11 22:39:38 +10:00
|
|
|
/* We need to use a test that wont have been previously clamped. */
|
|
|
|
rcti winrct_test = {
|
|
|
|
.xmin = ar->winrct.xmin,
|
|
|
|
.ymin = ar->winrct.ymin,
|
|
|
|
.xmax = ar->winrct.xmin + size_min[0],
|
|
|
|
.ymax = ar->winrct.ymin + size_min[1],
|
|
|
|
};
|
|
|
|
BLI_rcti_isect(&winrct_test, &overlap_remainder_margin, &winrct_test);
|
|
|
|
if (BLI_rcti_size_x(&winrct_test) < size_min[0] ||
|
|
|
|
BLI_rcti_size_y(&winrct_test) < size_min[1])
|
2018-06-12 10:11:32 +02:00
|
|
|
{
|
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
2012-10-07 09:48:59 +00:00
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (rct_fits(remainder, 'v', 1) < 0 || rct_fits(remainder, 'h', 1) < 0) {
|
2012-10-07 09:48:59 +00:00
|
|
|
/* remainder is too small for any usage */
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (alignment == RGN_ALIGN_NONE) {
|
2008-01-07 18:03:41 +00:00
|
|
|
/* typically last region */
|
2012-05-08 15:43:59 +00:00
|
|
|
ar->winrct = *remainder;
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(remainder, 0, 0, 0, 0);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) {
|
2018-04-21 18:37:03 +02:00
|
|
|
rcti *winrct = (ar->overlap) ? overlap_remainder : remainder;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-21 18:37:03 +02:00
|
|
|
if (rct_fits(winrct, 'v', prefsizey) < 0) {
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
|
|
|
else {
|
2018-04-21 18:37:03 +02:00
|
|
|
int fac = rct_fits(winrct, 'v', prefsizey);
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (fac < 0)
|
2008-12-10 13:56:54 +00:00
|
|
|
prefsizey += fac;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-21 18:37:03 +02:00
|
|
|
ar->winrct = *winrct;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (alignment == RGN_ALIGN_TOP) {
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1;
|
2018-04-21 18:37:03 +02:00
|
|
|
winrct->ymax = ar->winrct.ymin - 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->winrct.ymax = ar->winrct.ymin + prefsizey - 1;
|
2018-04-21 18:37:03 +02:00
|
|
|
winrct->ymin = ar->winrct.ymax + 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
|
2018-04-21 18:37:03 +02:00
|
|
|
rcti *winrct = (ar->overlap) ? overlap_remainder : remainder;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-21 18:37:03 +02:00
|
|
|
if (rct_fits(winrct, 'h', prefsizex) < 0) {
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
|
|
|
else {
|
2018-04-21 18:37:03 +02:00
|
|
|
int fac = rct_fits(winrct, 'h', prefsizex);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (fac < 0)
|
2008-12-10 13:56:54 +00:00
|
|
|
prefsizex += fac;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-21 18:37:03 +02:00
|
|
|
ar->winrct = *winrct;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if (alignment == RGN_ALIGN_RIGHT) {
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1;
|
2018-04-21 18:37:03 +02:00
|
|
|
winrct->xmax = ar->winrct.xmin - 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1;
|
2018-04-21 18:37:03 +02:00
|
|
|
winrct->xmin = ar->winrct.xmax + 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) {
|
2008-01-07 18:03:41 +00:00
|
|
|
/* percentage subdiv*/
|
2012-05-08 15:43:59 +00:00
|
|
|
ar->winrct = *remainder;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (alignment == RGN_ALIGN_HSPLIT) {
|
|
|
|
if (rct_fits(remainder, 'h', prefsizex) > 4) {
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winrct.xmax = BLI_rcti_cent_x(remainder);
|
2012-05-08 15:43:59 +00:00
|
|
|
remainder->xmin = ar->winrct.xmax + 1;
|
2008-12-09 15:59:43 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(remainder, 0, 0, 0, 0);
|
2008-12-09 15:59:43 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-08 15:43:59 +00:00
|
|
|
if (rct_fits(remainder, 'v', prefsizey) > 4) {
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winrct.ymax = BLI_rcti_cent_y(remainder);
|
2012-05-08 15:43:59 +00:00
|
|
|
remainder->ymin = ar->winrct.ymax + 1;
|
2008-12-09 15:59:43 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(remainder, 0, 0, 0, 0);
|
2008-12-09 15:59:43 +00:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (alignment == RGN_ALIGN_QSPLIT) {
|
|
|
|
ar->winrct = *remainder;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
/* test if there's still 4 regions left */
|
2012-05-08 15:43:59 +00:00
|
|
|
if (quad == 0) {
|
|
|
|
ARegion *artest = ar->next;
|
|
|
|
int count = 1;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
while (artest) {
|
2012-05-08 15:43:59 +00:00
|
|
|
artest->alignment = RGN_ALIGN_QSPLIT;
|
|
|
|
artest = artest->next;
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (count != 4) {
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
/* let's stop adding regions */
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(remainder, 0, 0, 0, 0);
|
2012-03-31 00:59:17 +00:00
|
|
|
if (G.debug & G_DEBUG)
|
2010-01-22 06:48:29 +00:00
|
|
|
printf("region quadsplit failed\n");
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
|
|
|
quad = 1;
|
|
|
|
}
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (quad) {
|
2012-05-08 15:43:59 +00:00
|
|
|
if (quad == 1) { /* left bottom */
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winrct.xmax = BLI_rcti_cent_x(remainder);
|
|
|
|
ar->winrct.ymax = BLI_rcti_cent_y(remainder);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (quad == 2) { /* left top */
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winrct.xmax = BLI_rcti_cent_x(remainder);
|
|
|
|
ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1;
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else if (quad == 3) { /* right bottom */
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1;
|
|
|
|
ar->winrct.ymax = BLI_rcti_cent_y(remainder);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
else { /* right top */
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winrct.xmin = BLI_rcti_cent_x(remainder) + 1;
|
|
|
|
ar->winrct.ymin = BLI_rcti_cent_y(remainder) + 1;
|
2012-07-12 08:31:23 +00:00
|
|
|
BLI_rcti_init(remainder, 0, 0, 0, 0);
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
quad++;
|
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* for speedup */
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
|
|
|
|
ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-16 14:19:29 +00:00
|
|
|
/* if region opened normally, we store this for hide/reveal usage */
|
2012-12-19 15:44:47 +00:00
|
|
|
/* prevent rounding errors for UI_DPI_FAC mult and divide */
|
|
|
|
if (ar->winx > 1) ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC;
|
|
|
|
if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-19 16:16:20 +00:00
|
|
|
/* exception for multiple overlapping regions on same spot */
|
2018-12-01 19:36:57 +11:00
|
|
|
if (ar->overlap && (alignment != RGN_ALIGN_FLOAT)) {
|
2012-12-19 16:16:20 +00:00
|
|
|
region_overlap_fix(sa, ar);
|
2018-04-21 18:37:03 +02:00
|
|
|
}
|
2012-12-13 17:43:12 +00:00
|
|
|
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
/* set winrect for azones */
|
2012-05-08 15:43:59 +00:00
|
|
|
if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) {
|
2018-04-21 18:37:03 +02:00
|
|
|
ar->winrct = (ar->overlap) ? *overlap_remainder : *remainder;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-05-14 23:58:08 +02:00
|
|
|
switch (alignment) {
|
|
|
|
case RGN_ALIGN_TOP:
|
|
|
|
ar->winrct.ymin = ar->winrct.ymax;
|
|
|
|
break;
|
|
|
|
case RGN_ALIGN_BOTTOM:
|
|
|
|
ar->winrct.ymax = ar->winrct.ymin;
|
|
|
|
break;
|
|
|
|
case RGN_ALIGN_RIGHT:
|
|
|
|
ar->winrct.xmin = ar->winrct.xmax;
|
|
|
|
break;
|
|
|
|
case RGN_ALIGN_LEFT:
|
|
|
|
default:
|
|
|
|
/* prevent winrct to be valid */
|
|
|
|
ar->winrct.xmax = ar->winrct.xmin;
|
|
|
|
break;
|
|
|
|
}
|
2.5
First version of region-scaling. WIP commit, so bear with me a while!
- All fixed sized regions have a small 'drag' widget, on the left or top.
(not yet for free-sized regions, like 4-split).
- Mouse-over on widget changes cursor and allows drag.
- Click on widget hides/reveals.
- Fun for test; 3d view header, if high enough, draws more rows of
buttons when width is too small.
The WIP stuff;
- It doesn't save yet in files, using the "minsize" variable of region
definitions, also means other similar areas show same sizes now.
- Definitions for pref size, min/max will be added.
- Properties panel in Fcurve window draws widget on wrong place when
hidden (subdiv system needs tweak)
- Widgets don't draw perfect yet, also needs further tweaks.
But, in general it's quite fun and usable. :) Many variatians are possible,
like for real tabs, or little icons, or just click-drag on edge.
The reason to first try the widget/tab variation:
- it re-uses the "Area Action Zone" code, widgets for layouting Screens
- it's visible, hotkey-only options for screen layouts are not preferred.
- distinguish clearly area-edges from region-edges this way. Having the
cursor change shape on every edge (and block input) is probably annoying
too... but that can be tested.
Later more!
2009-05-24 13:29:29 +00:00
|
|
|
}
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
|
|
|
|
/* restore prev-split exception */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar->alignment & RGN_SPLIT_PREV) {
|
|
|
|
if (ar->prev) {
|
2012-05-08 15:43:59 +00:00
|
|
|
remainder = remainder_prev;
|
2012-09-15 11:48:20 +00:00
|
|
|
ar->prev->winx = BLI_rcti_size_x(&ar->prev->winrct) + 1;
|
|
|
|
ar->prev->winy = BLI_rcti_size_y(&ar->prev->winrct) + 1;
|
Todo item:
Closed regions didn't always draw the (+) icon right place, confusing
for users.
Next to that, I think this icon is using a bad metaphor or visual language,
Illustrated best if you close a header in outliner or buttons. Icons are
UI widgets, for screen/editor layouts different controls can be stylized.
My preference is something that aligns visually to the seperators between
regions; for testing and hacking pleasure I've added two quick versions,
a small tabbish thing and a triangle. Enable these with debug menu,
ALT+CTRL+D, values 1 or 2.
This is simply drawn with opengl now. An image for it can be made as well.
Previews:
http://www.blender.org/bf/closed_regions1.png
http://www.blender.org/bf/closed_regions2.png
http://www.blender.org/bf/closed_regions3.png
There's other design ideas to explore as well, like making region deviders
8-10 pixels wide, with a 'drag me' dot on it or so. That takes some screen
estate though, and will require to add big editor-dividers too...
Fun stuff for the mockup-mafia to check on, we have time :)
2011-06-30 15:02:03 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-21 18:37:03 +02:00
|
|
|
|
|
|
|
/* After non-overlapping region, all following overlapping regions
|
|
|
|
* fit within the remaining space again. */
|
|
|
|
if (!ar->overlap) {
|
|
|
|
*overlap_remainder = *remainder;
|
|
|
|
}
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
|
2018-06-29 20:34:00 +02:00
|
|
|
region_rect_recursive(sa, ar->next, remainder, overlap_remainder, quad);
|
2018-08-17 20:14:06 +02:00
|
|
|
|
|
|
|
/* Tag for redraw if size changes. */
|
|
|
|
if (ar->winx != prev_winx || ar->winy != prev_winy) {
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 22:38:25 +02:00
|
|
|
static void area_calc_totrct(ScrArea *sa, const rcti *window_rect)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
short px = (short)U.pixelsize;
|
|
|
|
|
|
|
|
sa->totrct.xmin = sa->v1->vec.x;
|
|
|
|
sa->totrct.xmax = sa->v4->vec.x;
|
|
|
|
sa->totrct.ymin = sa->v1->vec.y;
|
|
|
|
sa->totrct.ymax = sa->v2->vec.y;
|
|
|
|
|
|
|
|
/* scale down totrct by 1 pixel on all sides not matching window borders */
|
2018-05-23 22:38:25 +02:00
|
|
|
if (sa->totrct.xmin > window_rect->xmin) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
sa->totrct.xmin += px;
|
|
|
|
}
|
2018-05-23 22:38:25 +02:00
|
|
|
if (sa->totrct.xmax < (window_rect->xmax - 1)) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
sa->totrct.xmax -= px;
|
|
|
|
}
|
2018-05-23 22:38:25 +02:00
|
|
|
if (sa->totrct.ymin > window_rect->ymin) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
sa->totrct.ymin += px;
|
|
|
|
}
|
2018-05-23 22:38:25 +02:00
|
|
|
if (sa->totrct.ymax < (window_rect->ymax - 1)) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
sa->totrct.ymax -= px;
|
|
|
|
}
|
2018-05-02 18:22:09 +02:00
|
|
|
/* Although the following asserts are correct they lead to a very unstable Blender.
|
|
|
|
* And the asserts would fail even in 2.7x (they were added in 2.8x as part of the top-bar commit).
|
|
|
|
* For more details see T54864. */
|
|
|
|
#if 0
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
BLI_assert(sa->totrct.xmin >= 0);
|
|
|
|
BLI_assert(sa->totrct.xmax >= 0);
|
|
|
|
BLI_assert(sa->totrct.ymin >= 0);
|
|
|
|
BLI_assert(sa->totrct.ymax >= 0);
|
2018-05-02 18:22:09 +02:00
|
|
|
#endif
|
2009-05-22 15:02:32 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* for speedup */
|
2012-09-15 11:48:20 +00:00
|
|
|
sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
|
|
|
|
sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-16 18:42:12 +00:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* used for area initialize below */
|
2018-02-16 22:41:46 +01:00
|
|
|
static void region_subwindow(ARegion *ar)
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
{
|
2014-01-22 16:35:11 +01:00
|
|
|
bool hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) != 0;
|
|
|
|
|
|
|
|
if ((ar->alignment & RGN_SPLIT_PREV) && ar->prev)
|
|
|
|
hidden = hidden || (ar->prev->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
|
|
|
|
|
2018-02-16 22:41:46 +01:00
|
|
|
ar->visible = !hidden;
|
Various changes made in the process of working on the UI code:
* Added functions to generate Timer events. There was some unfinished code to
create one timer per window, this replaces that with a way to let operators
or other handlers add/remove their own timers as needed. This is currently
delivered as an event with the timer handle, perhaps this should be a notifier
instead? Also includes some fixes in ghost for timer events that were not
delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
operator. This is used in the UI code to communicate the results of opened
blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
operator or handler, so there were exceptions added for this, which is one
of the reasons they might work better as notifiers, but currently these
things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
not.
* Added a free() callback for area regions, and added a free function for
area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
last created region on top. These are useful for tooltips, menus, etc, and
are not saved to file. It's using the same ARegion struct as areas to avoid
code duplication, but perhaps that should be renamed then. Note that redraws
currently go correct, because only full window redraws are used, for partial
redraws without any frontbuffer drawing, the window manager needs to get
support for compositing subwindows.
* Minor changes in the subwindow code to retrieve the matrix, and moved
setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
with modal_handler.
* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
created in. This means for example that when a transform operator is invoked
from a region but registers a handler at the window level (since mouse motion
across areas should work), it will still get removed when the region is closed
while the operator is running.
2008-11-11 15:18:21 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 10:46:13 +11:00
|
|
|
/**
|
|
|
|
* \param ar: Region, may be NULL when adding handlers for \a sa.
|
|
|
|
*/
|
|
|
|
static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ARegion *ar, ListBase *handlers, int flag)
|
2008-12-10 13:56:54 +00:00
|
|
|
{
|
2018-11-14 10:46:13 +11:00
|
|
|
BLI_assert(ar ? (&ar->handlers == handlers) : (&sa->handlers == handlers));
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* note, add-handler checks if it already exists */
|
2016-09-21 14:35:02 +02:00
|
|
|
|
2012-07-07 22:51:57 +00:00
|
|
|
/* XXX it would be good to have boundbox checks for some of these... */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & ED_KEYMAP_UI) {
|
2018-08-31 13:36:14 +10:00
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "User Interface", 0, 0);
|
2016-09-21 14:35:02 +02:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
|
2009-11-27 06:24:09 +00:00
|
|
|
/* user interface widgets */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_region_handlers_add(handlers);
|
2008-12-10 13:56:54 +00:00
|
|
|
}
|
2018-11-12 18:47:24 +11:00
|
|
|
if (flag & ED_KEYMAP_GIZMO) {
|
2018-11-14 10:46:13 +11:00
|
|
|
BLI_assert(ar && ar->type->regionid == RGN_TYPE_WINDOW);
|
2018-11-12 18:47:24 +11:00
|
|
|
if (ar) {
|
|
|
|
/* Anything else is confusing, only allow this. */
|
|
|
|
BLI_assert(&ar->handlers == handlers);
|
|
|
|
if (ar->gizmo_map == NULL) {
|
|
|
|
ar->gizmo_map = WM_gizmomap_new_from_type(
|
2018-11-14 10:46:13 +11:00
|
|
|
&(const struct wmGizmoMapType_Params){sa->spacetype, ar->type->regionid});
|
2018-11-12 18:47:24 +11:00
|
|
|
}
|
|
|
|
WM_gizmomap_add_handlers(ar, ar->gizmo_map);
|
|
|
|
}
|
|
|
|
}
|
2019-02-20 14:29:29 +11:00
|
|
|
if (flag & ED_KEYMAP_TOOL) {
|
|
|
|
WM_event_add_keymap_handler_dynamic(&ar->handlers, WM_event_get_keymap_from_toolsystem, sa);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & ED_KEYMAP_VIEW2D) {
|
2009-11-27 06:24:09 +00:00
|
|
|
/* 2d-viewport handling+manipulation */
|
2018-08-31 13:36:14 +10:00
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D", 0, 0);
|
2008-12-10 13:56:54 +00:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & ED_KEYMAP_MARKERS) {
|
2009-11-27 06:24:09 +00:00
|
|
|
/* time-markers */
|
2018-08-31 13:36:14 +10:00
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Markers", 0, 0);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-04-20 17:17:10 +02:00
|
|
|
/* use a boundbox restricted map */
|
|
|
|
/* same local check for all areas */
|
|
|
|
static rcti rect = {0, 10000, 0, -1};
|
|
|
|
rect.ymax = UI_MARKER_MARGIN_Y;
|
2018-11-14 10:46:13 +11:00
|
|
|
BLI_assert(ar->type->regionid == RGN_TYPE_WINDOW);
|
|
|
|
WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
|
2008-12-10 13:56:54 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & ED_KEYMAP_ANIMATION) {
|
2009-11-27 06:24:09 +00:00
|
|
|
/* frame changing and timeline operators (for time spaces) */
|
2018-08-31 13:36:14 +10:00
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Animation", 0, 0);
|
2008-12-21 08:02:24 +00:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & ED_KEYMAP_FRAMES) {
|
2009-11-27 06:24:09 +00:00
|
|
|
/* frame changing/jumping (for all spaces) */
|
2018-08-31 13:36:14 +10:00
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Frames", 0, 0);
|
2009-01-23 14:43:25 +00:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
2018-11-12 18:47:24 +11:00
|
|
|
if (flag & ED_KEYMAP_HEADER) {
|
|
|
|
/* standard keymap for headers regions */
|
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Header", 0, 0);
|
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
2019-04-05 13:48:26 +02:00
|
|
|
if (flag & ED_KEYMAP_FOOTER) {
|
|
|
|
/* standard keymap for footer regions */
|
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "Footer", 0, 0);
|
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
2018-11-12 18:47:24 +11:00
|
|
|
|
|
|
|
/* Keep last because of LMB/RMB handling, see: T57527. */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & ED_KEYMAP_GPENCIL) {
|
2009-11-27 06:24:09 +00:00
|
|
|
/* grease pencil */
|
2018-07-31 10:22:19 +02:00
|
|
|
/* NOTE: This is now 4 keymaps - One for basic functionality,
|
|
|
|
* and others for special stroke modes (edit, paint and sculpt).
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
*
|
2018-07-31 10:22:19 +02:00
|
|
|
* For now, it's easier to just include all,
|
|
|
|
* since you hardly want one without the others.
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
*/
|
2018-08-31 13:36:14 +10:00
|
|
|
wmKeyMap *keymap_general = WM_keymap_ensure(wm->defaultconf, "Grease Pencil", 0, 0);
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_general);
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2018-08-31 13:40:10 +10:00
|
|
|
wmKeyMap *keymap_edit = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Edit Mode", 0, 0);
|
Grease Pencil - Storyboarding Features (merge from GPencil_EditStrokes branch)
This merge-commit brings in a number of new features and workflow/UI improvements for
working with Grease Pencil. While these were originally targetted at improving
the workflow for creating 3D storyboards in Blender using the Grease Pencil,
many of these changes should also prove useful in other workflows too.
The main highlights here are:
1) It is now possible to edit Grease Pencil strokes
- Use D Tab, or toggle the "Enable Editing" toggles in the Toolbar/Properties regions
to enter "Stroke Edit Mode". In this mode, many common editing tools will
operate on Grease Pencil stroke points instead.
- Tools implemented include Select, Select All/Border/Circle/Linked/More/Less,
Grab, Rotate, Scale, Bend, Shear, To Sphere, Mirror, Duplicate, Delete.
- Proportional Editing works when using the transform tools
2) Grease Pencil stroke settings can now be animated
NOTE: Currently drivers don't work, but if time allows, this may still be
added before the release.
3) Strokes can be drawn with "filled" interiors, using a separate set of
colour/opacity settings to the ones used for the lines themselves.
This makes use of OpenGL filled polys, which has the limitation of only
being able to fill convex shapes. Some artifacts may be visible on concave
shapes (e.g. pacman's mouth will be overdrawn)
4) "Volumetric Strokes" - An alternative drawing technique for stroke drawing
has been added which draws strokes as a series of screen-aligned discs.
While this was originally a partial experimental technique at getting better
quality 3D lines, the effects possible using this technique were interesting
enough to warrant making this a dedicated feature. Best results when partial
opacity and large stroke widths are used.
5) Improved Onion Skinning Support
- Different colours can be selected for the before/after ghosts. To do so,
enable the "colour wheel" toggle beside the Onion Skinning toggle, and set
the colours accordingly.
- Different numbers of ghosts can be shown before/after the current frame
6) Grease Pencil datablocks are now attached to the scene by default instead of
the active object.
- For a long time, the object-attachment has proved to be quite problematic
for users to keep track of. Now that this is done at scene level, it is
easier for most users to use.
- An exception for old files (and for any addons which may benefit from object
attachment instead), is that if the active object has a Grease Pencil datablock,
that will be used instead.
- It is not currently possible to choose object-attachment from the UI, but
it is simple to do this from the console instead, by doing:
context.active_object.grease_pencil = bpy.data.grease_pencil["blah"]
7) Various UI Cleanups
- The layers UI has been cleaned up to use a list instead of the nested-panels
design. Apart from saving space, this is also much nicer to look at now.
- The UI code is now all defined in Python. To support this, it has been necessary
to add some new context properties to make it easier to access these settings.
e.g. "gpencil_data" for the datablock
"active_gpencil_layer" and "active_gpencil_frame" for active data,
"editable_gpencil_strokes" for the strokes that can be edited
- The "stroke placement/alignment" settings (previously "Drawing Settings" at the
bottom of the Grease Pencil panel in the Properties Region) is now located in
the toolbar. These were more toolsettings than properties for how GPencil got drawn.
- "Use Sketching Sessions" has been renamed "Continuous Drawing", as per a
suggestion for an earlier discussion on developer.blender.org
- By default, the painting operator will wait for a mouse button to be pressed
before it starts creating the stroke. This is to make it easier to include
this operator in various toolbars/menus/etc. To get it immediately starting
(as when you hold down DKEy to draw), set "wait_for_input" to False.
- GPencil Layers can be rearranged in the "Grease Pencil" mode of the Action Editor
- Toolbar panels have been added to all the other editors which support these.
8) Pie menus for quick-access to tools
A set of experimental pie menus has been included for quick access to many
tools and settings. It is not necessary to use these to get things done,
but they have been designed to help make certain common tasks easier.
- Ctrl-D = The main pie menu. Reveals tools in a context sensitive and
spatially stable manner.
- D Q = "Quick Settings" pie. This allows quick access to the active
layer's settings. Notably, colours, thickness, and turning
onion skinning on/off.
2014-12-01 01:52:06 +13:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_edit);
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2018-08-31 13:40:10 +10:00
|
|
|
wmKeyMap *keymap_paint = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint Mode", 0, 0);
|
2018-07-31 10:22:19 +02:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_paint);
|
|
|
|
|
2018-08-31 13:40:10 +10:00
|
|
|
wmKeyMap *keymap_paint_draw = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint (Draw brush)", 0, 0);
|
2018-07-31 10:22:19 +02:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_paint_draw);
|
|
|
|
|
2018-08-31 13:40:10 +10:00
|
|
|
wmKeyMap *keymap_paint_erase = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint (Erase)", 0, 0);
|
2018-07-31 10:22:19 +02:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_paint_erase);
|
|
|
|
|
2018-08-31 13:40:10 +10:00
|
|
|
wmKeyMap *keymap_paint_fill = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Paint (Fill)", 0, 0);
|
2018-07-31 10:22:19 +02:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_paint_fill);
|
|
|
|
|
2018-08-31 13:40:10 +10:00
|
|
|
wmKeyMap *keymap_sculpt = WM_keymap_ensure(wm->defaultconf, "Grease Pencil Stroke Sculpt Mode", 0, 0);
|
2018-07-31 10:22:19 +02:00
|
|
|
WM_event_add_keymap_handler(handlers, keymap_sculpt);
|
2009-08-30 13:32:08 +00:00
|
|
|
}
|
2008-12-10 13:56:54 +00:00
|
|
|
}
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
{
|
2018-05-23 22:38:25 +02:00
|
|
|
rcti rect, overlap_rect;
|
|
|
|
rcti window_rect;
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
if (!(area->flag & AREA_FLAG_REGION_SIZE_UPDATE)) {
|
|
|
|
return;
|
|
|
|
}
|
2019-01-04 21:40:16 +01:00
|
|
|
const bScreen *screen = WM_window_get_active_screen(win);
|
2018-04-29 12:24:08 +02:00
|
|
|
|
2018-05-23 22:38:25 +02:00
|
|
|
WM_window_rect_calc(win, &window_rect);
|
|
|
|
area_calc_totrct(area, &window_rect);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
|
|
|
/* region rect sizes */
|
|
|
|
rect = area->totrct;
|
2018-04-21 18:37:03 +02:00
|
|
|
overlap_rect = rect;
|
2018-06-29 20:34:00 +02:00
|
|
|
region_rect_recursive(area, area->regionbase.first, &rect, &overlap_rect, 0);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2019-01-04 21:40:16 +01:00
|
|
|
/* Dynamically sized regions may have changed region sizes, so we have to force azone update. */
|
|
|
|
area_azone_initialize(win, screen, area);
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
|
|
|
|
region_subwindow(ar);
|
|
|
|
|
|
|
|
/* region size may have changed, init does necessary adjustments */
|
|
|
|
if (ar->type->init) {
|
|
|
|
ar->type->init(wm, ar);
|
|
|
|
}
|
2019-01-04 21:40:16 +01:00
|
|
|
|
|
|
|
/* Some AZones use View2D data which is only updated in region init, so call that first! */
|
|
|
|
region_azones_add(screen, area, ar, ar->alignment & ~RGN_SPLIT_PREV);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
}
|
2019-01-04 21:40:16 +01:00
|
|
|
ED_area_azones_update(area, &win->eventstate->x);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
|
|
|
area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
|
|
|
|
}
|
2008-12-10 13:56:54 +00:00
|
|
|
|
|
|
|
/* called in screen_refresh, or screens_init, also area size changes */
|
2008-01-07 18:03:41 +00:00
|
|
|
void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
|
|
|
|
{
|
2018-05-18 09:35:10 +02:00
|
|
|
WorkSpace *workspace = WM_window_get_active_workspace(win);
|
|
|
|
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
|
2018-07-04 13:00:46 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2008-01-07 18:03:41 +00:00
|
|
|
ARegion *ar;
|
2018-04-21 18:37:03 +02:00
|
|
|
rcti rect, overlap_rect;
|
2018-05-23 22:38:25 +02:00
|
|
|
rcti window_rect;
|
2018-04-24 19:59:48 +02:00
|
|
|
|
|
|
|
if (ED_area_is_global(sa) && (sa->global->flag & GLOBAL_AREA_IS_HIDDEN)) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-23 22:38:25 +02:00
|
|
|
WM_window_rect_calc(win, &window_rect);
|
2018-04-24 19:59:48 +02:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* set typedefinitions */
|
2012-05-08 15:43:59 +00:00
|
|
|
sa->type = BKE_spacetype_from_id(sa->spacetype);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
if (sa->type == NULL) {
|
2018-04-22 19:58:27 +02:00
|
|
|
sa->spacetype = SPACE_VIEW3D;
|
2012-05-08 15:43:59 +00:00
|
|
|
sa->type = BKE_spacetype_from_id(sa->spacetype);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
2018-04-22 19:58:27 +02:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
2018-06-12 17:26:38 +02:00
|
|
|
ar->type = BKE_regiontype_from_id_or_first(sa->type, ar->regiontype);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* area sizes */
|
2018-05-23 22:38:25 +02:00
|
|
|
area_calc_totrct(sa, &window_rect);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* region rect sizes */
|
2012-05-08 15:43:59 +00:00
|
|
|
rect = sa->totrct;
|
2018-04-21 18:37:03 +02:00
|
|
|
overlap_rect = rect;
|
2018-06-29 20:34:00 +02:00
|
|
|
region_rect_recursive(sa, sa->regionbase.first, &rect, &overlap_rect, 0);
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-04-09 13:16:17 +00:00
|
|
|
/* default area handlers */
|
2018-11-14 10:46:13 +11:00
|
|
|
ed_default_handlers(wm, sa, NULL, &sa->handlers, sa->type->keymapflag);
|
2008-12-10 13:56:54 +00:00
|
|
|
/* checks spacedata, adds own handlers */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->type->init)
|
2008-12-10 13:56:54 +00:00
|
|
|
sa->type->init(wm, sa);
|
2018-05-07 01:31:18 +02:00
|
|
|
|
2018-09-27 15:49:59 +02:00
|
|
|
/* clear all azones, add the area triangle widgets */
|
2018-05-07 01:31:18 +02:00
|
|
|
area_azone_initialize(win, screen, sa);
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* region windows, default and own handlers */
|
2012-05-08 15:43:59 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
2018-02-16 22:41:46 +01:00
|
|
|
region_subwindow(ar);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-02-16 22:41:46 +01:00
|
|
|
if (ar->visible) {
|
2010-04-09 13:16:17 +00:00
|
|
|
/* default region handlers */
|
2018-11-14 10:46:13 +11:00
|
|
|
ed_default_handlers(wm, sa, ar, &ar->handlers, ar->type->keymapflag);
|
2010-04-08 16:36:50 +00:00
|
|
|
/* own handlers */
|
2017-06-21 13:54:46 +10:00
|
|
|
if (ar->type->init) {
|
2009-02-17 15:53:52 +00:00
|
|
|
ar->type->init(wm, ar);
|
2017-06-21 13:54:46 +10:00
|
|
|
}
|
2009-02-17 15:53:52 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* prevent uiblocks to run */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_blocklist_free(NULL, &ar->uiblocks);
|
2009-02-17 15:53:52 +00:00
|
|
|
}
|
2018-05-07 01:31:18 +02:00
|
|
|
|
|
|
|
/* Some AZones use View2D data which is only updated in region init, so call that first! */
|
|
|
|
region_azones_add(screen, sa, ar, ar->alignment & ~RGN_SPLIT_PREV);
|
2008-12-10 13:56:54 +00:00
|
|
|
}
|
2018-05-18 09:35:10 +02:00
|
|
|
|
2018-11-28 13:41:36 +11:00
|
|
|
|
2018-11-28 13:50:15 +11:00
|
|
|
/* Avoid re-initializing tools while resizing the window. */
|
|
|
|
if ((G.moving & G_TRANSFORM_WM) == 0) {
|
|
|
|
if ((1 << sa->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) {
|
|
|
|
WM_toolsystem_refresh_screen_area(workspace, view_layer, sa);
|
|
|
|
sa->flag |= AREA_FLAG_ACTIVE_TOOL_UPDATE;
|
|
|
|
}
|
2018-11-28 14:11:10 +11:00
|
|
|
else {
|
|
|
|
sa->runtime.tool = NULL;
|
|
|
|
sa->runtime.is_tool_set = true;
|
|
|
|
}
|
2018-11-28 13:41:36 +11:00
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 18:42:08 +11:00
|
|
|
static void region_update_rect(ARegion *ar)
|
|
|
|
{
|
|
|
|
ar->winx = BLI_rcti_size_x(&ar->winrct) + 1;
|
|
|
|
ar->winy = BLI_rcti_size_y(&ar->winrct) + 1;
|
|
|
|
|
|
|
|
/* v2d mask is used to subtract scrollbars from a 2d view. Needs initialize here. */
|
|
|
|
BLI_rcti_init(&ar->v2d.mask, 0, ar->winx - 1, 0, ar->winy -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Call to move a popup window (keep OpenGL context free!)
|
|
|
|
*/
|
2018-06-12 07:59:27 +02:00
|
|
|
void ED_region_update_rect(ARegion *ar)
|
2014-04-02 18:42:08 +11:00
|
|
|
{
|
|
|
|
region_update_rect(ar);
|
|
|
|
}
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* externally called for floating regions like menus */
|
2018-06-12 07:59:27 +02:00
|
|
|
void ED_region_init(ARegion *ar)
|
2008-12-10 13:56:54 +00:00
|
|
|
{
|
|
|
|
/* refresh can be called before window opened */
|
2018-02-16 22:41:46 +01:00
|
|
|
region_subwindow(ar);
|
2016-02-02 14:13:57 +11:00
|
|
|
|
2014-04-02 18:42:08 +11:00
|
|
|
region_update_rect(ar);
|
2008-12-10 13:56:54 +00:00
|
|
|
}
|
|
|
|
|
2016-04-19 16:04:44 +02:00
|
|
|
void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
|
|
|
|
{
|
2016-04-19 22:51:46 +02:00
|
|
|
if (ar && sa && ar->type && ar->type->cursor) {
|
2016-04-19 16:04:44 +02:00
|
|
|
ar->type->cursor(win, sa, ar);
|
|
|
|
}
|
|
|
|
else {
|
2018-05-18 11:44:28 +02:00
|
|
|
if (WM_cursor_set_from_tool(win, sa, ar)) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-19 16:04:44 +02:00
|
|
|
WM_cursor_set(win, CURSOR_STD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-27 15:49:59 +02:00
|
|
|
/* for use after changing visibility of regions */
|
2018-04-20 12:14:07 +02:00
|
|
|
void ED_region_visibility_change_update(bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-20 12:14:07 +02:00
|
|
|
if (ar->flag & RGN_FLAG_HIDDEN)
|
|
|
|
WM_event_remove_handlers(C, &ar->handlers);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2018-04-20 12:14:07 +02:00
|
|
|
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
|
|
|
|
2012-12-13 12:17:57 +00:00
|
|
|
/* for quick toggle, can skip fades */
|
2014-04-03 09:24:09 +11:00
|
|
|
void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
|
2009-09-14 19:12:29 +00:00
|
|
|
{
|
2012-05-08 15:43:59 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-09-14 19:12:29 +00:00
|
|
|
ar->flag ^= RGN_FLAG_HIDDEN;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-13 12:17:57 +00:00
|
|
|
if (do_fade && ar->overlap) {
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
/* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */
|
|
|
|
region_blend_start(C, sa, ar);
|
|
|
|
}
|
|
|
|
else {
|
2018-04-20 12:14:07 +02:00
|
|
|
ED_region_visibility_change_update(C, ar);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
}
|
2009-09-14 19:12:29 +00:00
|
|
|
}
|
2008-12-09 15:59:43 +00:00
|
|
|
|
2012-12-13 12:17:57 +00:00
|
|
|
/* exported to all editors, uses fading default */
|
|
|
|
void ED_region_toggle_hidden(bContext *C, ARegion *ar)
|
|
|
|
{
|
2015-02-11 00:09:45 +01:00
|
|
|
region_toggle_hidden(C, ar, true);
|
2012-12-13 12:17:57 +00:00
|
|
|
}
|
|
|
|
|
2014-04-11 09:17:43 +10:00
|
|
|
/**
|
|
|
|
* we swap spaces for fullscreen to keep all allocated data area vertices were set
|
|
|
|
*/
|
2014-04-11 17:16:51 +10:00
|
|
|
void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
|
2008-01-07 18:03:41 +00:00
|
|
|
{
|
2009-01-19 18:50:35 +00:00
|
|
|
SpaceType *st;
|
2008-01-07 18:03:41 +00:00
|
|
|
ARegion *ar;
|
2014-04-11 17:16:51 +10:00
|
|
|
const char spacetype = sa_dst->spacetype;
|
2014-05-17 00:28:00 +10:00
|
|
|
const short flag_copy = HEADER_NO_PULLDOWN;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-04-11 17:16:51 +10:00
|
|
|
sa_dst->spacetype = sa_src->spacetype;
|
|
|
|
sa_dst->type = sa_src->type;
|
|
|
|
|
2014-05-17 00:28:00 +10:00
|
|
|
sa_dst->flag = (sa_dst->flag & ~flag_copy) | (sa_src->flag & flag_copy);
|
|
|
|
|
2014-04-11 17:16:51 +10:00
|
|
|
/* area */
|
|
|
|
if (do_free) {
|
|
|
|
BKE_spacedata_freelist(&sa_dst->spacedata);
|
2009-03-11 20:22:06 +00:00
|
|
|
}
|
2014-04-11 17:16:51 +10:00
|
|
|
BKE_spacedata_copylist(&sa_dst->spacedata, &sa_src->spacedata);
|
|
|
|
|
2009-02-08 12:16:35 +00:00
|
|
|
/* Note; SPACE_EMPTY is possible on new screens */
|
2014-04-11 17:16:51 +10:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
/* regions */
|
2014-04-11 17:16:51 +10:00
|
|
|
if (do_free) {
|
2014-04-11 09:17:43 +10:00
|
|
|
st = BKE_spacetype_from_id(spacetype);
|
2014-04-11 17:16:51 +10:00
|
|
|
for (ar = sa_dst->regionbase.first; ar; ar = ar->next)
|
2014-04-11 09:17:43 +10:00
|
|
|
BKE_area_region_free(st, ar);
|
2014-04-11 17:16:51 +10:00
|
|
|
BLI_freelistN(&sa_dst->regionbase);
|
2014-04-11 09:17:43 +10:00
|
|
|
}
|
2014-04-11 17:16:51 +10:00
|
|
|
st = BKE_spacetype_from_id(sa_src->spacetype);
|
|
|
|
for (ar = sa_src->regionbase.first; ar; ar = ar->next) {
|
|
|
|
ARegion *newar = BKE_area_region_copy(st, ar);
|
|
|
|
BLI_addtail(&sa_dst->regionbase, newar);
|
2009-03-11 20:22:06 +00:00
|
|
|
}
|
2014-04-11 17:16:51 +10:00
|
|
|
}
|
2014-04-11 09:17:43 +10:00
|
|
|
|
2014-04-11 17:16:51 +10:00
|
|
|
void ED_area_data_swap(ScrArea *sa_dst, ScrArea *sa_src)
|
|
|
|
{
|
2015-02-23 20:02:54 +11:00
|
|
|
SWAP(char, sa_dst->spacetype, sa_src->spacetype);
|
|
|
|
SWAP(SpaceType *, sa_dst->type, sa_src->type);
|
2014-04-11 17:16:51 +10:00
|
|
|
|
|
|
|
|
|
|
|
SWAP(ListBase, sa_dst->spacedata, sa_src->spacedata);
|
|
|
|
SWAP(ListBase, sa_dst->regionbase, sa_src->regionbase);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2009-01-06 18:14:37 +00:00
|
|
|
/* *********** Space switching code *********** */
|
2008-12-14 12:16:55 +00:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2)
|
|
|
|
{
|
2012-05-08 15:43:59 +00:00
|
|
|
ScrArea *tmp = MEM_callocN(sizeof(ScrArea), "addscrarea");
|
2009-03-11 20:22:06 +00:00
|
|
|
|
|
|
|
ED_area_exit(C, sa1);
|
|
|
|
ED_area_exit(C, sa2);
|
|
|
|
|
2014-04-11 17:16:51 +10:00
|
|
|
ED_area_data_copy(tmp, sa1, false);
|
|
|
|
ED_area_data_copy(sa1, sa2, true);
|
|
|
|
ED_area_data_copy(sa2, tmp, true);
|
2009-03-11 20:22:06 +00:00
|
|
|
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa1);
|
|
|
|
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa2);
|
|
|
|
|
|
|
|
BKE_screen_area_free(tmp);
|
|
|
|
MEM_freeN(tmp);
|
|
|
|
|
|
|
|
/* tell WM to refresh, cursor types etc */
|
|
|
|
WM_event_add_mousemove(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-03-11 20:22:06 +00:00
|
|
|
ED_area_tag_redraw(sa1);
|
|
|
|
ED_area_tag_refresh(sa1);
|
|
|
|
ED_area_tag_redraw(sa2);
|
|
|
|
ED_area_tag_refresh(sa2);
|
|
|
|
}
|
|
|
|
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
/**
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param skip_ar_exit: Skip calling area exit callback. Set for opening temp spaces.
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
*/
|
|
|
|
void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exit)
|
2008-12-12 10:18:26 +00:00
|
|
|
{
|
2018-04-22 19:58:27 +02:00
|
|
|
wmWindow *win = CTX_wm_window(C);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sa->spacetype != type) {
|
2008-12-14 13:59:34 +00:00
|
|
|
SpaceType *st;
|
|
|
|
SpaceLink *slold;
|
2008-12-12 10:18:26 +00:00
|
|
|
SpaceLink *sl;
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
/* store sa->type->exit callback */
|
|
|
|
void *sa_exit = sa->type ? sa->type->exit : NULL;
|
2018-12-14 08:43:14 +11:00
|
|
|
/* When the user switches between space-types from the type-selector,
|
|
|
|
* changing the header-type is jarring (especially when using Ctrl-MouseWheel).
|
|
|
|
*
|
2018-12-14 09:07:22 +11:00
|
|
|
* However, add-on install for example, forces the header to the top which shouldn't
|
2018-12-14 08:43:14 +11:00
|
|
|
* be applied back to the previous space type when closing - see: T57724
|
2018-12-14 09:07:22 +11:00
|
|
|
*
|
|
|
|
* Newly created windows wont have any space data, use the alignment
|
|
|
|
* the space type defaults to in this case instead
|
|
|
|
* (needed for preferences to have space-type on bottom).
|
2018-12-14 08:43:14 +11:00
|
|
|
*/
|
2018-12-14 09:07:22 +11:00
|
|
|
int header_alignment = ED_area_header_alignment_or_fallback(sa, -1);
|
|
|
|
const bool sync_header_alignment = (
|
|
|
|
(header_alignment != -1) &&
|
|
|
|
(sa->flag & AREA_FLAG_TEMP_TYPE) == 0);
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
|
|
|
|
/* in some cases (opening temp space) we don't want to
|
|
|
|
* call area exit callback, so we temporarily unset it */
|
|
|
|
if (skip_ar_exit && sa->type) {
|
|
|
|
sa->type->exit = NULL;
|
|
|
|
}
|
2008-12-14 13:59:34 +00:00
|
|
|
|
|
|
|
ED_area_exit(C, sa);
|
|
|
|
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
/* restore old area exit callback */
|
|
|
|
if (skip_ar_exit && sa->type) {
|
|
|
|
sa->type->exit = sa_exit;
|
|
|
|
}
|
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
st = BKE_spacetype_from_id(type);
|
|
|
|
slold = sa->spacedata.first;
|
2008-12-14 13:59:34 +00:00
|
|
|
|
2012-05-08 15:43:59 +00:00
|
|
|
sa->spacetype = type;
|
|
|
|
sa->type = st;
|
2018-04-21 22:03:04 +02:00
|
|
|
|
|
|
|
/* If st->new may be called, don't use context until then. The
|
|
|
|
* sa->type->context() callback has changed but data may be invalid
|
|
|
|
* (e.g. with properties editor) until space-data is properly created */
|
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
/* check previously stored space */
|
2012-05-08 15:43:59 +00:00
|
|
|
for (sl = sa->spacedata.first; sl; sl = sl->next)
|
|
|
|
if (sl->spacetype == type)
|
2008-12-12 10:18:26 +00:00
|
|
|
break;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
/* old spacedata... happened during work on 2.50, remove */
|
2014-02-08 06:07:10 +11:00
|
|
|
if (sl && BLI_listbase_is_empty(&sl->regionbase)) {
|
2008-12-12 10:18:26 +00:00
|
|
|
st->free(sl);
|
2008-12-23 01:08:02 +00:00
|
|
|
BLI_freelinkN(&sa->spacedata, sl);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (slold == sl) {
|
2012-05-08 15:43:59 +00:00
|
|
|
slold = NULL;
|
2011-03-31 04:55:57 +00:00
|
|
|
}
|
2012-05-08 15:43:59 +00:00
|
|
|
sl = NULL;
|
2008-12-12 10:18:26 +00:00
|
|
|
}
|
2018-05-06 20:20:40 +02:00
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
if (sl) {
|
|
|
|
/* swap regions */
|
2012-05-08 15:43:59 +00:00
|
|
|
slold->regionbase = sa->regionbase;
|
|
|
|
sa->regionbase = sl->regionbase;
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&sl->regionbase);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
/* put in front of list */
|
|
|
|
BLI_remlink(&sa->spacedata, sl);
|
|
|
|
BLI_addhead(&sa->spacedata, sl);
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2008-12-12 10:18:26 +00:00
|
|
|
else {
|
|
|
|
/* new space */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (st) {
|
2018-04-21 22:03:04 +02:00
|
|
|
/* Don't get scene from context here which may depend on space-data. */
|
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
|
|
|
sl = st->new(sa, scene);
|
2008-12-12 10:18:26 +00:00
|
|
|
BLI_addhead(&sa->spacedata, sl);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
/* swap regions */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (slold)
|
2012-05-08 15:43:59 +00:00
|
|
|
slold->regionbase = sa->regionbase;
|
|
|
|
sa->regionbase = sl->regionbase;
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&sl->regionbase);
|
2008-12-12 10:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-12-14 09:07:22 +11:00
|
|
|
/* Sync header alignment. */
|
|
|
|
if (sync_header_alignment) {
|
2019-04-05 13:48:26 +02:00
|
|
|
/* Spaces with footer. */
|
2019-04-09 08:44:06 +02:00
|
|
|
if (st->spaceid == SPACE_TEXT) {
|
2019-04-05 13:48:26 +02:00
|
|
|
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
|
|
|
|
if (ar->regiontype == RGN_TYPE_HEADER) {
|
|
|
|
ar->alignment = header_alignment;
|
|
|
|
}
|
|
|
|
if (ar->regiontype == RGN_TYPE_FOOTER) {
|
|
|
|
int footer_alignment = (header_alignment == RGN_ALIGN_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
|
|
|
|
ar->alignment = footer_alignment;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
|
|
|
|
if (ar->regiontype == RGN_TYPE_HEADER) {
|
|
|
|
ar->alignment = header_alignment;
|
|
|
|
break;
|
|
|
|
}
|
2018-12-14 09:07:22 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-21 22:03:04 +02:00
|
|
|
ED_area_initialize(CTX_wm_manager(C), win, sa);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-15 18:43:18 +00:00
|
|
|
/* tell WM to refresh, cursor types etc */
|
|
|
|
WM_event_add_mousemove(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-08-17 14:43:20 +00:00
|
|
|
/* send space change notifier */
|
2012-05-08 15:43:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-19 16:22:07 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
2008-12-12 10:18:26 +00:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2011-01-04 14:37:21 +00:00
|
|
|
/* also redraw when re-used */
|
|
|
|
ED_area_tag_redraw(sa);
|
2008-12-12 10:18:26 +00:00
|
|
|
}
|
|
|
|
|
2009-12-08 07:12:06 +00:00
|
|
|
void ED_area_prevspace(bContext *C, ScrArea *sa)
|
2009-01-06 14:42:54 +00:00
|
|
|
{
|
2015-02-23 21:06:55 +11:00
|
|
|
SpaceLink *sl = sa->spacedata.first;
|
2009-01-06 14:42:54 +00:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if (sl && sl->next) {
|
Fix a bunch of temp full-screen glitches
Steps to reproduce fixed glitches were:
* Change any editor to be file browser from menu, Ctrl+O *from the file browser area*, Esc -> area reset to what it was before changing to file browser initially
* Ctrl+O from any area, F12, Esc -> returns to initial editor in full-screen (expected is file browser in full-screen)
Fixes T46229
Core of the fix is removing old area from spacedata list when going back to previous area (see ED_area_prevspace -> BKE_spacedata_remove). Also, when creating a new temp area we now don't exit old area anymore (needed so SpaceFile->op is kept, but it also makes sense in general)
Aaand finally removes some ugly hacks.
Tested quite a bit, so I think it's safe to apply (besides of remark below), just would like to get things double checked and confirmed. After all, this full-screen stuff finally starts to feel like it's working :P
Note, there's still a memory leak when quitting Blender with temp area open. Haven't found out how to solve yet, but it's not that important for review anyway.
Reviewers: campbellbarton, brecht
Reviewed By: brecht
Subscribers: plyczkowski, Blendify
Maniphest Tasks: T46229
Differential Revision: https://developer.blender.org/D1531
2016-02-29 16:18:42 +01:00
|
|
|
ED_area_newspace(C, sa, sl->next->spacetype, false);
|
|
|
|
|
|
|
|
/* keep old spacedata but move it to end, so calling
|
|
|
|
* ED_area_prevspace once more won't open it again */
|
|
|
|
BLI_remlink(&sa->spacedata, sl);
|
|
|
|
BLI_addtail(&sa->spacedata, sl);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-10-27 15:27:27 +00:00
|
|
|
/* no change */
|
|
|
|
return;
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
2019-03-09 16:58:13 +01:00
|
|
|
sa->flag &= ~(AREA_FLAG_STACKED_FULLSCREEN | AREA_FLAG_TEMP_TYPE);
|
2015-01-28 02:32:52 +01:00
|
|
|
|
2009-01-06 18:14:37 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
Added a new notifyer, NC_SPACE_CHANGED, to signal an editor that
replaces another so it can do updates (e.g. dopesheet editor can
sync channel selection).
Also coded a simple optimization for allocating small objects,
based on mempools. It's #ifdef'd out, you can enabled it by
defining OPTIMIZE_SMALL_BLOCKS (e.g. adding -DDOPTIMIZE_SMALL_BLOCKS to
your compiler flags).
We suffer from a great deal of performance loss from the system allocator
(vgroups, ghash, edgehash, the singly-linked list implementation in blenlib,
editmesh, and likely a great many areas I'm forgetting), and this is the
common solution for handling the many-small-objects problem. It's not
really production-ready yet (it's long-term memory consequencers need to
be profiled first, and the implementation tweaked as necassary), but for
people on systems with slow system allocators it's worth trying.
Note that since this creates a guardedalloc<->blenlib link, the build systems
need to be updated accordingly (I've already done this for scons, though I'm
not sure if the player builds).
2010-01-21 03:08:57 +00:00
|
|
|
|
2012-08-17 14:43:20 +00:00
|
|
|
/* send space change notifier */
|
2012-05-08 15:43:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa);
|
2009-01-06 14:42:54 +00:00
|
|
|
}
|
|
|
|
|
2008-12-14 12:16:55 +00:00
|
|
|
/* returns offset for next button in header */
|
2009-07-23 20:40:51 +00:00
|
|
|
int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
|
2008-12-14 12:16:55 +00:00
|
|
|
{
|
2012-05-08 15:43:59 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2013-06-09 16:18:23 +00:00
|
|
|
bScreen *scr = CTX_wm_screen(C);
|
|
|
|
PointerRNA areaptr;
|
2012-12-18 20:00:52 +00:00
|
|
|
int xco = 0.4 * U.widget_unit;
|
2013-06-09 16:18:23 +00:00
|
|
|
|
|
|
|
RNA_pointer_create(&(scr->id), &RNA_Area, sa, &areaptr);
|
|
|
|
|
2017-03-17 16:47:19 +03:00
|
|
|
uiDefButR(block, UI_BTYPE_MENU, 0, "", xco, yco, 1.6 * U.widget_unit, U.widget_unit,
|
2018-05-29 09:19:06 +02:00
|
|
|
&areaptr, "ui_type", 0, 0.0f, 0.0f, 0.0f, 0.0f, "");
|
2013-06-09 16:18:23 +00:00
|
|
|
|
2012-12-18 20:00:52 +00:00
|
|
|
return xco + 1.7 * U.widget_unit;
|
2009-07-23 20:40:51 +00:00
|
|
|
}
|
|
|
|
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
/************************ standard UI regions ************************/
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
|
|
|
|
{
|
2018-04-21 10:06:12 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
switch (region->regiontype) {
|
|
|
|
case RGN_TYPE_HEADER:
|
2018-04-21 10:06:12 +02:00
|
|
|
if (ED_screen_area_active(C) || ED_area_is_global(area)) {
|
|
|
|
return TH_HEADER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return TH_HEADERDESEL;
|
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
case RGN_TYPE_PREVIEW:
|
|
|
|
return TH_PREVIEW_BACK;
|
|
|
|
default:
|
|
|
|
return TH_BACK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
static void region_clear_color(const bContext *C, const ARegion *ar, ThemeColorID colorid)
|
|
|
|
{
|
2018-06-12 10:11:32 +02:00
|
|
|
if (ar->alignment == RGN_ALIGN_FLOAT) {
|
|
|
|
/* handle our own drawing. */
|
|
|
|
}
|
|
|
|
else if (ar->overlap) {
|
2018-04-29 12:24:08 +02:00
|
|
|
/* view should be in pixelspace */
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
|
|
|
|
float back[4];
|
|
|
|
UI_GetThemeColor4fv(colorid, back);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_clear_color(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]);
|
|
|
|
GPU_clear(GPU_COLOR_BIT);
|
2018-04-29 12:24:08 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_ThemeClearColor(colorid);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_clear(GPU_COLOR_BIT);
|
2018-04-29 12:24:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-31 21:39:48 +02:00
|
|
|
BLI_INLINE bool streq_array_any(const char *s, const char *arr[])
|
|
|
|
{
|
|
|
|
for (uint i = 0; arr[i]; i++) {
|
|
|
|
if (STREQ(arr[i], s)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-14 22:44:53 +02:00
|
|
|
static void ed_panel_draw(
|
|
|
|
const bContext *C,
|
|
|
|
ScrArea *sa,
|
|
|
|
ARegion *ar,
|
|
|
|
ListBase *lb,
|
|
|
|
PanelType *pt,
|
|
|
|
Panel *panel,
|
|
|
|
int w,
|
|
|
|
int em,
|
|
|
|
bool vertical)
|
2018-06-03 13:32:36 +02:00
|
|
|
{
|
|
|
|
uiStyle *style = UI_style_get_dpi();
|
|
|
|
|
|
|
|
/* draw panel */
|
|
|
|
uiBlock *block = UI_block_begin(C, ar, pt->idname, UI_EMBOSS);
|
|
|
|
|
|
|
|
bool open;
|
|
|
|
panel = UI_panel_begin(sa, ar, lb, block, pt, panel, &open);
|
|
|
|
|
|
|
|
/* bad fixed values */
|
|
|
|
int xco, yco, h = 0;
|
|
|
|
|
2018-04-27 13:50:26 +02:00
|
|
|
if (pt->draw_header_preset && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
|
|
|
|
/* for preset menu */
|
|
|
|
panel->layout = UI_block_layout(
|
|
|
|
block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
|
|
|
|
0, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style);
|
|
|
|
|
|
|
|
pt->draw_header_preset(C, panel);
|
|
|
|
|
|
|
|
int headerend = w - UI_UNIT_X;
|
|
|
|
|
|
|
|
UI_block_layout_resolve(block, &xco, &yco);
|
|
|
|
UI_block_translate(block, headerend - xco, 0);
|
|
|
|
panel->layout = NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
|
2018-06-06 13:28:40 +02:00
|
|
|
int labelx, labely;
|
|
|
|
UI_panel_label_offset(block, &labelx, &labely);
|
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
/* for enabled buttons */
|
|
|
|
panel->layout = UI_block_layout(
|
|
|
|
block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
|
2018-06-06 13:28:40 +02:00
|
|
|
labelx, labely, UI_UNIT_Y, 1, 0, style);
|
2018-06-03 13:32:36 +02:00
|
|
|
|
|
|
|
pt->draw_header(C, panel);
|
|
|
|
|
|
|
|
UI_block_layout_resolve(block, &xco, &yco);
|
2018-06-06 13:28:40 +02:00
|
|
|
panel->labelofs = xco - labelx;
|
2018-06-03 13:32:36 +02:00
|
|
|
panel->layout = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
panel->labelofs = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (open) {
|
|
|
|
short panelContext;
|
|
|
|
|
|
|
|
/* panel context can either be toolbar region or normal panels region */
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
if (pt->flag & PNL_LAYOUT_VERT_BAR) {
|
|
|
|
panelContext = UI_LAYOUT_VERT_BAR;
|
|
|
|
}
|
|
|
|
else if (ar->regiontype == RGN_TYPE_TOOLS) {
|
2018-06-03 13:32:36 +02:00
|
|
|
panelContext = UI_LAYOUT_TOOLBAR;
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
}
|
|
|
|
else {
|
2018-06-03 13:32:36 +02:00
|
|
|
panelContext = UI_LAYOUT_PANEL;
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
}
|
2018-06-03 13:32:36 +02:00
|
|
|
|
|
|
|
panel->layout = UI_block_layout(
|
|
|
|
block, UI_LAYOUT_VERTICAL, panelContext,
|
UI: Vertical Properties Editor Tabs
Moves the Properties editor context switching to a vertical tabs region.
Design Task: T54951
Differential Revison: D3840
The tabs are regular widgets, unlike the 'old' toolshelf tabs. This means they
give mouse hover feedback, have tooltips, support the right-click menu, etc.
Also, when vertical screen space gets tight, the tabs can be scrolled, they
don't shrink like the toolshelf ones.
The tab region is slightly larger than the header. The tabs are scaled up
accordingly. This makes them nicely readable.
The header is quite empty now. As shown in T54951, we wanted to have a search
button there. This should be added next.
Implementation Notes:
* Added a new region type, RGN_TYPE_NAVIGATION.
* Having the tabs in a separate region allows scrolling of the tab-bar, unlike
the toolshelf tabs. We might want to remove the scrollbars though.
* Added a new region flag RGN_FLAG_PREFSIZE_OR_HIDDEN, to ensure the tab region
is either hidden or has a fixed size.
* Added some additional flags to support fine-tuning the layout in panel and
layout code.
* Bumps subversion.
2018-10-29 21:34:14 +01:00
|
|
|
(pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : style->panelspace, 0,
|
|
|
|
(pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : w - 2 * style->panelspace,
|
|
|
|
em, 0, style);
|
2018-06-03 13:32:36 +02:00
|
|
|
|
|
|
|
pt->draw(C, panel);
|
|
|
|
|
|
|
|
UI_block_layout_resolve(block, &xco, &yco);
|
|
|
|
panel->layout = NULL;
|
|
|
|
|
|
|
|
if (yco != 0) {
|
|
|
|
h = -yco + 2 * style->panelspace;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_block_end(C, block);
|
|
|
|
|
|
|
|
/* Draw child panels. */
|
|
|
|
if (open) {
|
|
|
|
for (LinkData *link = pt->children.first; link; link = link->next) {
|
|
|
|
PanelType *child_pt = link->data;
|
|
|
|
Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
|
|
|
|
|
|
|
|
if (child_pt->draw && (!child_pt->poll || child_pt->poll(C, child_pt))) {
|
|
|
|
ed_panel_draw(C, sa, ar, &panel->children, child_pt, child_panel, w, em, vertical);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_panel_end(block, w, h);
|
|
|
|
}
|
|
|
|
|
2018-05-31 21:39:48 +02:00
|
|
|
/**
|
|
|
|
* \param contexts: A NULL terminated array of context strings to match against.
|
|
|
|
* Matching against any of these strings will draw the panel.
|
|
|
|
* Can be NULL to skip context checks.
|
|
|
|
*/
|
2018-06-11 19:30:48 +02:00
|
|
|
void ED_region_panels_layout_ex(
|
2018-06-11 18:23:36 +02:00
|
|
|
const bContext *C, ARegion *ar,
|
|
|
|
const char *contexts[], int contextnr, const bool vertical)
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
{
|
2018-06-11 18:23:36 +02:00
|
|
|
ar->runtime.category = NULL;
|
|
|
|
|
2018-03-01 01:26:02 +11:00
|
|
|
const WorkSpace *workspace = CTX_wm_workspace(C);
|
2012-05-08 15:43:59 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
PanelType *pt;
|
2012-05-08 15:43:59 +00:00
|
|
|
View2D *v2d = &ar->v2d;
|
2018-06-03 13:32:36 +02:00
|
|
|
int x, y, w, em;
|
2013-11-26 06:39:14 +11:00
|
|
|
bool is_context_new = 0;
|
2012-12-26 13:05:39 +00:00
|
|
|
int scroll;
|
|
|
|
|
2018-05-31 21:45:26 +02:00
|
|
|
/* XXX, should use some better check? */
|
2018-11-29 11:30:56 +01:00
|
|
|
/* For now also has hardcoded check for clip editor until it supports actual toolbar. */
|
|
|
|
bool use_category_tabs = ((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) ||
|
|
|
|
(ar->regiontype == RGN_TYPE_TOOLS && sa->spacetype == SPACE_CLIP);
|
2013-12-17 03:21:55 +11:00
|
|
|
/* offset panels for small vertical tab area */
|
|
|
|
const char *category = NULL;
|
|
|
|
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
|
|
|
|
int margin_x = 0;
|
2018-06-12 10:11:32 +02:00
|
|
|
const bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2013-12-04 11:54:56 +11:00
|
|
|
BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *);
|
|
|
|
|
2014-02-01 01:45:09 +11:00
|
|
|
if (contextnr != -1)
|
2013-11-26 06:39:14 +11:00
|
|
|
is_context_new = UI_view2d_tab_set(v2d, contextnr);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-26 13:05:39 +00:00
|
|
|
/* before setting the view */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (vertical) {
|
2012-12-26 13:05:39 +00:00
|
|
|
/* only allow scrolling in vertical direction */
|
|
|
|
v2d->keepofs |= V2D_LOCKOFS_X | V2D_KEEPOFS_Y;
|
|
|
|
v2d->keepofs &= ~(V2D_LOCKOFS_Y | V2D_KEEPOFS_X);
|
|
|
|
v2d->scroll &= ~(V2D_SCROLL_BOTTOM);
|
|
|
|
v2d->scroll |= (V2D_SCROLL_RIGHT);
|
2009-05-19 17:13:33 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-12-26 13:05:39 +00:00
|
|
|
/* for now, allow scrolling in both directions (since layouts are optimized for vertical,
|
|
|
|
* they often don't fit in horizontal layout)
|
|
|
|
*/
|
|
|
|
v2d->keepofs &= ~(V2D_LOCKOFS_X | V2D_LOCKOFS_Y | V2D_KEEPOFS_X | V2D_KEEPOFS_Y);
|
|
|
|
v2d->scroll |= (V2D_SCROLL_BOTTOM);
|
|
|
|
v2d->scroll &= ~(V2D_SCROLL_RIGHT);
|
2009-05-19 17:13:33 +00:00
|
|
|
}
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2012-12-26 13:05:39 +00:00
|
|
|
scroll = v2d->scroll;
|
2013-12-04 11:54:56 +11:00
|
|
|
|
|
|
|
|
|
|
|
/* collect panels to draw */
|
|
|
|
for (pt = ar->type->paneltypes.last; pt; pt = pt->prev) {
|
2018-06-03 13:32:36 +02:00
|
|
|
/* Only draw top level panels. */
|
|
|
|
if (pt->parent) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-12-04 11:54:56 +11:00
|
|
|
/* verify context */
|
2018-05-31 21:39:48 +02:00
|
|
|
if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) {
|
2013-12-04 11:54:56 +11:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-03-01 01:26:02 +11:00
|
|
|
/* If we're tagged, only use compatible. */
|
|
|
|
if (pt->owner_id[0] && BKE_workspace_owner_id_check(workspace, pt->owner_id) == false) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-12-04 11:54:56 +11:00
|
|
|
/* draw panel */
|
|
|
|
if (pt->draw && (!pt->poll || pt->poll(C, pt))) {
|
|
|
|
BLI_SMALLSTACK_PUSH(pt_stack, pt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 03:21:55 +11:00
|
|
|
/* collect categories */
|
|
|
|
if (use_category_tabs) {
|
|
|
|
UI_panel_category_clear_all(ar);
|
|
|
|
|
|
|
|
/* gather unique categories */
|
|
|
|
BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt)
|
|
|
|
{
|
|
|
|
if (pt->category[0]) {
|
|
|
|
if (!UI_panel_category_find(ar, pt->category)) {
|
|
|
|
UI_panel_category_add(ar, pt->category);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BLI_SMALLSTACK_ITER_END;
|
|
|
|
|
|
|
|
if (!UI_panel_category_is_visible(ar)) {
|
|
|
|
use_category_tabs = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
category = UI_panel_category_active_get(ar, true);
|
|
|
|
margin_x = category_tabs_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
if (vertical) {
|
|
|
|
w = BLI_rctf_size_x(&v2d->cur);
|
|
|
|
em = (ar->type->prefsizex) ? 10 : 20; /* works out to 10*UI_UNIT_X or 20*UI_UNIT_X */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
w = UI_PANEL_WIDTH;
|
|
|
|
em = (ar->type->prefsizex) ? 10 : 20;
|
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
w -= margin_x;
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
/* create panels */
|
|
|
|
UI_panels_begin(C, ar);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
/* set view2d view matrix - UI_block_begin() stores it */
|
|
|
|
UI_view2d_view_ortho(v2d);
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt)
|
|
|
|
{
|
2018-06-03 13:32:36 +02:00
|
|
|
Panel *panel = UI_panel_find_by_type(&ar->panels, pt);
|
2018-04-27 00:49:00 +02:00
|
|
|
|
|
|
|
if (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) {
|
|
|
|
if ((panel == NULL) || ((panel->flag & PNL_PIN) == 0)) {
|
|
|
|
continue;
|
2013-12-17 03:21:55 +11:00
|
|
|
}
|
2018-04-27 00:49:00 +02:00
|
|
|
}
|
2013-12-17 03:21:55 +11:00
|
|
|
|
2018-06-03 13:32:36 +02:00
|
|
|
ed_panel_draw(C, sa, ar, &ar->panels, pt, panel, w, em, vertical);
|
2018-04-27 00:49:00 +02:00
|
|
|
}
|
|
|
|
BLI_SMALLSTACK_ITER_END;
|
2013-12-04 11:54:56 +11:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
/* align panels and return size */
|
|
|
|
UI_panels_end(C, ar, &x, &y);
|
2013-12-04 11:54:56 +11:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
/* before setting the view */
|
2018-06-12 10:11:32 +02:00
|
|
|
if (region_layout_based) {
|
|
|
|
/* XXX, only single panel support atm.
|
|
|
|
* Can't use x/y values calculated above because they're not using the real height of panels,
|
|
|
|
* instead they calculate offsets for the next panel to start drawing. */
|
|
|
|
Panel *panel = ar->panels.last;
|
2018-06-12 11:18:52 +02:00
|
|
|
if (panel != NULL) {
|
|
|
|
int size_dyn[2] = {
|
2018-12-23 22:31:04 +01:00
|
|
|
UI_UNIT_X * ((panel->flag & PNL_CLOSED) ? 8 : 14) / UI_DPI_FAC,
|
|
|
|
UI_panel_size_y(panel) / UI_DPI_FAC,
|
2018-06-12 11:18:52 +02:00
|
|
|
};
|
|
|
|
/* region size is layout based and needs to be updated */
|
|
|
|
if ((ar->sizex != size_dyn[0]) ||
|
|
|
|
(ar->sizey != size_dyn[1]))
|
|
|
|
{
|
|
|
|
ar->sizex = size_dyn[0];
|
|
|
|
ar->sizey = size_dyn[1];
|
|
|
|
sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
|
|
|
|
}
|
2018-12-23 22:31:04 +01:00
|
|
|
y = ABS(ar->sizey * UI_DPI_FAC - 1);
|
2018-06-12 10:11:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (vertical) {
|
2018-04-27 00:49:00 +02:00
|
|
|
/* we always keep the scroll offset - so the total view gets increased with the scrolled away part */
|
|
|
|
if (v2d->cur.ymax < -FLT_EPSILON) {
|
|
|
|
/* Clamp to lower view boundary */
|
|
|
|
if (v2d->tot.ymin < -v2d->winy) {
|
|
|
|
y = min_ii(y, 0);
|
2009-06-16 01:08:39 +00:00
|
|
|
}
|
2013-12-04 11:54:56 +11:00
|
|
|
else {
|
2018-04-27 00:49:00 +02:00
|
|
|
y = min_ii(y, v2d->cur.ymin);
|
2013-12-04 11:54:56 +11:00
|
|
|
}
|
2012-12-26 13:05:39 +00:00
|
|
|
}
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2018-04-27 00:49:00 +02:00
|
|
|
y = -y;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* don't jump back when panels close or hide */
|
|
|
|
if (!is_context_new) {
|
|
|
|
if (v2d->tot.xmax > v2d->winx) {
|
|
|
|
x = max_ii(x, 0);
|
2018-04-09 18:52:03 +02:00
|
|
|
}
|
2018-04-27 00:49:00 +02:00
|
|
|
else {
|
|
|
|
x = max_ii(x, v2d->cur.xmax);
|
2018-04-09 18:52:03 +02:00
|
|
|
}
|
2012-12-26 13:05:39 +00:00
|
|
|
}
|
2018-04-27 00:49:00 +02:00
|
|
|
|
|
|
|
y = -y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this also changes the 'cur' */
|
|
|
|
UI_view2d_totRect_set(v2d, x, y);
|
|
|
|
|
|
|
|
if (scroll != v2d->scroll) {
|
|
|
|
/* Note: this code scales fine, but because of rounding differences, positions of elements
|
|
|
|
* flip +1 or -1 pixel compared to redoing the entire layout again.
|
|
|
|
* Leaving in commented code for future tests */
|
2013-09-14 12:04:10 +00:00
|
|
|
#if 0
|
2018-04-27 00:49:00 +02:00
|
|
|
UI_panels_scale(ar, BLI_rctf_size_x(&v2d->cur));
|
|
|
|
break;
|
2013-09-14 12:04:10 +00:00
|
|
|
#endif
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
}
|
2014-07-12 16:48:52 +10:00
|
|
|
|
2018-06-11 18:23:36 +02:00
|
|
|
if (use_category_tabs) {
|
|
|
|
ar->runtime.category = category;
|
|
|
|
}
|
|
|
|
}
|
2018-06-12 18:38:05 +02:00
|
|
|
void ED_region_panels_layout(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
ED_region_panels_layout_ex(C, ar, NULL, -1, true);
|
|
|
|
}
|
2018-06-11 18:23:36 +02:00
|
|
|
|
|
|
|
void ED_region_panels_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
View2D *v2d = &ar->v2d;
|
|
|
|
|
2018-06-12 10:11:32 +02:00
|
|
|
if (ar->alignment != RGN_ALIGN_FLOAT) {
|
|
|
|
region_clear_color(C, ar, (ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2016-01-24 22:06:05 +11:00
|
|
|
/* reset line width for drawing tabs */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
/* set the view */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2019-01-04 21:40:16 +01:00
|
|
|
/* View2D matrix might have changed due to dynamic sized regions. */
|
|
|
|
UI_blocklist_update_window_matrix(C, &ar->uiblocks);
|
|
|
|
|
2011-11-20 14:31:01 +00:00
|
|
|
/* draw panels */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_panels_draw(C, ar);
|
2011-11-20 14:31:01 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
/* restore view matrix */
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
UI_view2d_view_restore(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-06-11 18:23:36 +02:00
|
|
|
/* Set in layout. */
|
|
|
|
if (ar->runtime.category) {
|
|
|
|
UI_panel_category_draw_all(ar, ar->runtime.category);
|
2013-12-17 03:21:55 +11:00
|
|
|
}
|
|
|
|
|
2009-07-14 10:59:21 +00:00
|
|
|
/* scrollers */
|
2018-10-22 16:41:18 +11:00
|
|
|
const rcti *mask = NULL;
|
|
|
|
rcti mask_buf;
|
|
|
|
if (ar->runtime.category && (ar->alignment == RGN_ALIGN_RIGHT)) {
|
|
|
|
UI_view2d_mask_from_win(v2d, &mask_buf);
|
|
|
|
mask_buf.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH;
|
|
|
|
mask = &mask_buf;
|
|
|
|
}
|
2018-06-11 18:23:36 +02:00
|
|
|
View2DScrollers *scrollers = UI_view2d_scrollers_calc(
|
2018-10-22 16:41:18 +11:00
|
|
|
C, v2d, mask, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
2009-07-14 10:59:21 +00:00
|
|
|
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
|
|
|
UI_view2d_scrollers_free(scrollers);
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 19:30:48 +02:00
|
|
|
void ED_region_panels_ex(
|
2018-06-11 18:23:36 +02:00
|
|
|
const bContext *C, ARegion *ar,
|
|
|
|
const char *contexts[], int contextnr, const bool vertical)
|
|
|
|
{
|
|
|
|
/* TODO: remove? */
|
2018-06-11 19:30:48 +02:00
|
|
|
ED_region_panels_layout_ex(C, ar, contexts, contextnr, vertical);
|
|
|
|
ED_region_panels_draw(C, ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_region_panels(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* TODO: remove? */
|
2018-06-12 18:38:05 +02:00
|
|
|
ED_region_panels_layout(C, ar);
|
2018-06-11 18:23:36 +02:00
|
|
|
ED_region_panels_draw(C, ar);
|
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2012-07-07 22:51:57 +00:00
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
|
|
|
|
|
2018-08-31 13:36:14 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
|
2009-05-19 17:13:33 +00:00
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
|
|
|
}
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
void ED_region_header_layout(const bContext *C, ARegion *ar)
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
uiStyle *style = UI_style_get_dpi();
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
uiBlock *block;
|
|
|
|
uiLayout *layout;
|
|
|
|
HeaderType *ht;
|
2011-03-05 10:29:10 +00:00
|
|
|
Header header = {NULL};
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2018-06-26 11:57:22 +02:00
|
|
|
/* Height of buttons and scaling needed to achieve it. */
|
|
|
|
const int buttony = min_ii(UI_UNIT_Y, ar->winy - 2 * UI_DPI_FAC);
|
|
|
|
const float buttony_scale = buttony / (float)UI_UNIT_Y;
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2018-06-26 11:57:22 +02:00
|
|
|
/* Vertically center buttons. */
|
|
|
|
int xco = UI_HEADER_OFFSET;
|
|
|
|
int yco = buttony + (ar->winy - buttony) / 2;
|
|
|
|
int maxco = xco;
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
/* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
|
2018-06-26 11:57:22 +02:00
|
|
|
if (!ELEM(CTX_wm_area(C)->spacetype, SPACE_TOPBAR, SPACE_STATUSBAR)) {
|
|
|
|
yco -= 1;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
}
|
|
|
|
|
2018-06-26 11:57:22 +02:00
|
|
|
/* set view2d view matrix for scrolling (without scrollers) */
|
|
|
|
UI_view2d_view_ortho(&ar->v2d);
|
|
|
|
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
/* draw all headers types */
|
2012-05-08 15:43:59 +00:00
|
|
|
for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
|
2018-10-29 22:55:54 +01:00
|
|
|
if (ht->poll && !ht->poll(C, ht)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS);
|
2018-06-26 11:57:22 +02:00
|
|
|
layout = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, buttony, 1, 0, style);
|
|
|
|
|
|
|
|
if (buttony_scale != 1.0f) {
|
|
|
|
uiLayoutSetScaleY(layout, buttony_scale);
|
|
|
|
}
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ht->draw) {
|
2012-05-08 15:43:59 +00:00
|
|
|
header.type = ht;
|
|
|
|
header.layout = layout;
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
ht->draw(C, &header);
|
2018-10-29 22:55:54 +01:00
|
|
|
if (ht->next) {
|
|
|
|
uiItemS(layout);
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-08-16 13:01:40 +00:00
|
|
|
/* for view2d */
|
2012-05-08 15:43:59 +00:00
|
|
|
xco = uiLayoutGetWidth(layout);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (xco > maxco)
|
2012-05-08 15:43:59 +00:00
|
|
|
maxco = xco;
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_layout_resolve(block, &xco, &yco);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-08-16 13:01:40 +00:00
|
|
|
/* for view2d */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (xco > maxco)
|
2012-05-08 15:43:59 +00:00
|
|
|
maxco = xco;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
2018-06-13 11:40:32 +02:00
|
|
|
int new_sizex = (maxco + UI_HEADER_OFFSET) / UI_DPI_FAC;
|
2018-04-29 12:24:08 +02:00
|
|
|
|
|
|
|
if (region_layout_based && (ar->sizex != new_sizex)) {
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
/* region size is layout based and needs to be updated */
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
ar->sizex = new_sizex;
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
|
|
|
|
}
|
2018-04-29 12:24:08 +02:00
|
|
|
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_end(C, block);
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
}
|
|
|
|
|
2018-06-13 11:40:32 +02:00
|
|
|
if (!region_layout_based) {
|
|
|
|
maxco += UI_HEADER_OFFSET;
|
|
|
|
}
|
|
|
|
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
/* always as last */
|
2018-06-26 11:57:22 +02:00
|
|
|
UI_view2d_totRect_set(&ar->v2d, maxco, ar->winy);
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
/* restore view matrix */
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_region_header_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* clear */
|
|
|
|
region_clear_color(C, ar, region_background_color_id(C, ar));
|
|
|
|
|
2018-06-13 11:32:46 +02:00
|
|
|
UI_view2d_view_ortho(&ar->v2d);
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
/* View2D matrix might have changed due to dynamic sized regions. */
|
|
|
|
UI_blocklist_update_window_matrix(C, &ar->uiblocks);
|
|
|
|
|
|
|
|
/* draw blocks */
|
|
|
|
UI_blocklist_draw(C, &ar->uiblocks);
|
|
|
|
|
|
|
|
/* restore view matrix */
|
UI: Layout Engine
* Buttons are now created first, and after that the layout is computed.
This means the layout engine now works at button level, and makes it
easier to write templates. Otherwise you had to store all info and
create the buttons later.
* Added interface_templates.c as a separate file to put templates in.
These can contain regular buttons, and can be put in a Free layout,
which means you can specify manual coordinates, but still get nested
correct inside other layouts.
* API was changed to allow better nesting. Previously items were added
in the last added layout specifier, i.e. one level up in the layout
hierarchy. This doesn't work well in always, so now when creating things
like rows or columns it always returns a layout which you have to add
the items in. All py scripts were updated to follow this.
* Computing the layout now goes in two passes, first estimating the
required width/height of all nested layouts, and then in the second
pass using the results of that to decide on the actual locations.
* Enum and array buttons now follow the direction of the layout, i.e.
they are vertical or horizontal depending if they are in a column or row.
* Color properties now get a color picker, and only get the additional
RGB sliders with Expand=True.
* File/directory string properties now get a button next to them for
opening the file browse, though this is not implemented yet.
* Layout items can now be aligned, set align=True when creating a column,
row, etc.
* Buttons now get a minimum width of one icon (avoids squashing icon
buttons).
* Moved some more space variables into Style.
2009-05-15 11:19:59 +00:00
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
}
|
|
|
|
|
2018-04-29 12:24:08 +02:00
|
|
|
void ED_region_header(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* TODO: remove? */
|
|
|
|
ED_region_header_layout(C, ar);
|
|
|
|
ED_region_header_draw(C, ar);
|
|
|
|
}
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
void ED_region_header_init(ARegion *ar)
|
|
|
|
{
|
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
|
|
|
|
}
|
|
|
|
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
int ED_area_headersize(void)
|
|
|
|
{
|
2019-02-21 17:34:48 +01:00
|
|
|
/* Accomodate widget and padding. */
|
|
|
|
return U.widget_unit + (int)(UI_DPI_FAC * HEADER_PADDING_Y);
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
}
|
2011-11-30 06:03:10 +00:00
|
|
|
|
2018-12-14 09:07:22 +11:00
|
|
|
int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback)
|
2018-05-06 18:36:54 +02:00
|
|
|
{
|
|
|
|
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
|
|
|
|
if (ar->regiontype == RGN_TYPE_HEADER) {
|
|
|
|
return ar->alignment;
|
|
|
|
}
|
|
|
|
}
|
2018-12-14 09:07:22 +11:00
|
|
|
return fallback;
|
|
|
|
}
|
2018-05-06 18:36:54 +02:00
|
|
|
|
2018-12-14 09:07:22 +11:00
|
|
|
int ED_area_header_alignment(const ScrArea *area)
|
|
|
|
{
|
2018-12-14 09:47:10 +11:00
|
|
|
return ED_area_header_alignment_or_fallback(
|
|
|
|
area, (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP);
|
2018-05-06 18:36:54 +02:00
|
|
|
}
|
|
|
|
|
2019-04-05 13:48:26 +02:00
|
|
|
int ED_area_footersize(void)
|
|
|
|
{
|
|
|
|
return ED_area_headersize();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_area_footer_alignment_or_fallback(const ScrArea *area, int fallback)
|
|
|
|
{
|
|
|
|
for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
|
|
|
|
if (ar->regiontype == RGN_TYPE_FOOTER) {
|
|
|
|
return ar->alignment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_area_footer_alignment(const ScrArea *area)
|
|
|
|
{
|
|
|
|
return ED_area_footer_alignment_or_fallback(
|
2019-04-09 08:44:06 +02:00
|
|
|
area, (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM);
|
2019-04-05 13:48:26 +02:00
|
|
|
}
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
/**
|
|
|
|
* \return the final height of a global \a area, accounting for DPI.
|
|
|
|
*/
|
|
|
|
int ED_area_global_size_y(const ScrArea *area)
|
|
|
|
{
|
|
|
|
BLI_assert(ED_area_is_global(area));
|
|
|
|
return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC);
|
|
|
|
}
|
2018-06-30 00:42:19 +02:00
|
|
|
int ED_area_global_min_size_y(const ScrArea *area)
|
|
|
|
{
|
|
|
|
BLI_assert(ED_area_is_global(area));
|
|
|
|
return round_fl_to_int(area->global->size_min * UI_DPI_FAC);
|
|
|
|
}
|
|
|
|
int ED_area_global_max_size_y(const ScrArea *area)
|
|
|
|
{
|
|
|
|
BLI_assert(ED_area_is_global(area));
|
|
|
|
return round_fl_to_int(area->global->size_max * UI_DPI_FAC);
|
|
|
|
}
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
|
|
|
|
bool ED_area_is_global(const ScrArea *area)
|
|
|
|
{
|
|
|
|
return area->global != NULL;
|
|
|
|
}
|
|
|
|
|
2018-04-24 19:59:48 +02:00
|
|
|
ScrArea *ED_screen_areas_iter_first(const wmWindow *win, const bScreen *screen)
|
|
|
|
{
|
|
|
|
ScrArea *global_area = win->global_areas.areabase.first;
|
|
|
|
|
|
|
|
if (!global_area) {
|
|
|
|
return screen->areabase.first;
|
|
|
|
}
|
|
|
|
else if ((global_area->global->flag & GLOBAL_AREA_IS_HIDDEN) == 0) {
|
|
|
|
return global_area;
|
|
|
|
}
|
|
|
|
/* Find next visible area. */
|
|
|
|
return ED_screen_areas_iter_next(screen, global_area);
|
|
|
|
}
|
|
|
|
ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area)
|
|
|
|
{
|
|
|
|
if (area->global) {
|
|
|
|
for (ScrArea *area_iter = area->next; area_iter; area_iter = area_iter->next) {
|
|
|
|
if ((area_iter->global->flag & GLOBAL_AREA_IS_HIDDEN) == 0) {
|
|
|
|
return area_iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* No visible next global area found, start iterating over layout areas. */
|
|
|
|
return screen->areabase.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
return area->next;
|
|
|
|
}
|
|
|
|
|
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users
* Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars.
* Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector.
* Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here.
* Individual sections of the topbar are individually scrollable.
* Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting.
* Top-bar should scale nicely with DPI.
* The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes).
* Info editors at the top of the window and using the full window width with be replaced by the top-bar.
* In fullscreen modes, no more info editor is added on top, the top-bar replaces it.
== Technical Features/Changes
* Adds initial support for global areas
A global area is part of the window, not part of the regular screen-layout.
I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas.
* Adds a TOPBAR editor type
The editor type is hidden in the UI editor type menu.
* Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY)
* Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar.
* Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds.
The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved.
* Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code.
Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being.
NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility.
== ToDo's
It's a bit hard to predict all the ToDo's here are the known main ones:
* Add options for the new active-tool system and for operator redo to the topbar.
* Automatically hide the top-bar in fullscreen modes.
* General visual polish.
* Top-bar drag & drop support (WIP in temp-tab_drag_drop).
* Improve dynamic regions (should also fix some layout glitches).
* Make internal terminology consistent.
* Enable topbar file writing once design is more advanced.
* Address TODO's and XXX's in code :)
Thanks @brecht for the review! And @sergey for the complaining ;)
Differential Revision: D2758
2018-04-20 17:14:03 +02:00
|
|
|
/**
|
|
|
|
* For now we just assume all global areas are made up out of horizontal bars
|
|
|
|
* with the same size. A fixed size could be stored in ARegion instead if needed.
|
|
|
|
*
|
|
|
|
* \return the DPI aware height of a single bar/region in global areas.
|
|
|
|
*/
|
|
|
|
int ED_region_global_size_y(void)
|
|
|
|
{
|
|
|
|
return ED_area_headersize(); /* same size as header */
|
|
|
|
}
|
|
|
|
|
2017-05-04 21:56:34 +02:00
|
|
|
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw)
|
2011-11-30 06:03:10 +00:00
|
|
|
{
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
const int header_height = UI_UNIT_Y;
|
2014-11-09 21:20:40 +01:00
|
|
|
uiStyle *style = UI_style_get_dpi();
|
2012-05-08 15:43:59 +00:00
|
|
|
int fontid = style->widget.uifont_id;
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2011-11-30 06:03:10 +00:00
|
|
|
rcti rect;
|
2017-05-04 21:56:34 +02:00
|
|
|
int num_lines = 0;
|
2011-11-30 06:03:10 +00:00
|
|
|
|
|
|
|
/* background box */
|
2012-12-18 13:59:47 +00:00
|
|
|
ED_region_visible_rect(ar, &rect);
|
2011-11-30 06:03:10 +00:00
|
|
|
|
2017-05-04 21:56:34 +02:00
|
|
|
/* Box fill entire width or just around text. */
|
|
|
|
if (!full_redraw) {
|
|
|
|
const char **text = &text_array[0];
|
|
|
|
while (*text) {
|
|
|
|
rect.xmax = min_ii(rect.xmax, rect.xmin + BLF_width(fontid, *text, BLF_DRAW_STR_DUMMY_MAX) + 1.2f * U.widget_unit);
|
|
|
|
text++;
|
|
|
|
num_lines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Just count the line number. */
|
|
|
|
else {
|
|
|
|
const char **text = &text_array[0];
|
|
|
|
while (*text) {
|
|
|
|
text++;
|
|
|
|
num_lines++;
|
|
|
|
}
|
|
|
|
}
|
2011-11-30 06:03:10 +00:00
|
|
|
|
2018-05-31 23:48:50 +02:00
|
|
|
rect.ymin = rect.ymax - header_height * num_lines;
|
2011-11-30 06:03:10 +00:00
|
|
|
|
2013-04-14 21:42:58 +00:00
|
|
|
/* setup scissor */
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_scissor_get_i(scissor);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_scissor(rect.xmin, rect.ymin,
|
2013-04-15 16:18:33 +00:00
|
|
|
BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1);
|
2013-04-14 21:42:58 +00:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(true);
|
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4fv(fill_color);
|
|
|
|
immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1);
|
|
|
|
immUnbindProgram();
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2011-11-30 06:03:10 +00:00
|
|
|
|
|
|
|
/* text */
|
2017-02-05 00:54:21 -05:00
|
|
|
UI_FontThemeColor(fontid, TH_TEXT_HI);
|
2013-01-23 14:05:08 +00:00
|
|
|
BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
BLF_enable(fontid, BLF_CLIPPING);
|
2017-05-04 21:56:34 +02:00
|
|
|
int offset = num_lines - 1;
|
|
|
|
{
|
|
|
|
const char **text = &text_array[0];
|
|
|
|
while (*text) {
|
|
|
|
BLF_position(fontid, rect.xmin + 0.6f * U.widget_unit, rect.ymin + 0.3f * U.widget_unit + offset * header_height, 0.0f);
|
|
|
|
BLF_draw(fontid, *text, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
text++;
|
|
|
|
offset--;
|
|
|
|
}
|
|
|
|
}
|
2013-01-23 14:05:08 +00:00
|
|
|
|
|
|
|
BLF_disable(fontid, BLF_CLIPPING);
|
2013-04-14 21:42:58 +00:00
|
|
|
|
|
|
|
/* restore scissor as it was before */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
2011-11-30 06:03:10 +00:00
|
|
|
}
|
2012-04-28 10:09:58 +00:00
|
|
|
|
2017-05-04 21:56:34 +02:00
|
|
|
void ED_region_info_draw(ARegion *ar, const char *text, float fill_color[4], const bool full_redraw)
|
|
|
|
{
|
|
|
|
ED_region_info_draw_multiline(ar, (const char *[2]){text, NULL}, fill_color, full_redraw);
|
|
|
|
}
|
|
|
|
|
2015-04-20 19:57:57 +02:00
|
|
|
#define MAX_METADATA_STR 1024
|
|
|
|
|
2015-05-05 05:17:25 +10:00
|
|
|
static const char *meta_data_list[] =
|
2015-04-20 19:57:57 +02:00
|
|
|
{
|
|
|
|
"File",
|
|
|
|
"Strip",
|
|
|
|
"Date",
|
|
|
|
"RenderTime",
|
2015-10-05 20:41:45 +11:00
|
|
|
"Note",
|
2015-04-20 19:57:57 +02:00
|
|
|
"Marker",
|
|
|
|
"Time",
|
|
|
|
"Frame",
|
|
|
|
"Camera",
|
2019-02-03 14:01:45 +11:00
|
|
|
"Scene",
|
2015-04-20 19:57:57 +02:00
|
|
|
};
|
|
|
|
|
2015-04-21 17:15:40 +02:00
|
|
|
BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int offset)
|
2015-04-20 19:57:57 +02:00
|
|
|
{
|
2018-04-05 16:27:15 +02:00
|
|
|
return (IMB_metadata_get_field(ibuf->metadata, meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) && r_str[0]);
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
|
2019-02-07 10:08:01 +01:00
|
|
|
BLI_INLINE bool metadata_is_custom_drawable(const char *field)
|
|
|
|
{
|
|
|
|
/* Metadata field stored by Blender for multilayer EXR images. Is rather
|
|
|
|
* useless to be viewed all the time. Can still be seen in the Metadata
|
|
|
|
* panel. */
|
|
|
|
if (STREQ(field, "BlenderMultiChannel")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/* Is almost always has value "scanlineimage", also useless to be seen
|
|
|
|
* all the time. */
|
|
|
|
if (STREQ(field, "type")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !BKE_stamp_is_known_field(field);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct MetadataCustomDrawContext {
|
|
|
|
int fontid;
|
|
|
|
int xmin, ymin;
|
|
|
|
int vertical_offset;
|
|
|
|
int current_y;
|
|
|
|
} MetadataCustomDrawContext;
|
|
|
|
|
|
|
|
static void metadata_custom_draw_fields(
|
|
|
|
const char *field,
|
|
|
|
const char *value,
|
|
|
|
void *ctx_v)
|
|
|
|
{
|
|
|
|
if (!metadata_is_custom_drawable(field)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MetadataCustomDrawContext *ctx = (MetadataCustomDrawContext *)ctx_v;
|
|
|
|
char temp_str[MAX_METADATA_STR];
|
|
|
|
BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: %s", field, value);
|
|
|
|
BLF_position(ctx->fontid, ctx->xmin, ctx->ymin + ctx->current_y, 0.0f);
|
|
|
|
BLF_draw(ctx->fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
ctx->current_y += ctx->vertical_offset;
|
|
|
|
}
|
|
|
|
|
2015-06-30 15:31:55 +10:00
|
|
|
static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
|
2015-04-20 19:57:57 +02:00
|
|
|
{
|
|
|
|
char temp_str[MAX_METADATA_STR];
|
2015-04-22 04:43:13 +10:00
|
|
|
int line_width;
|
2015-04-20 19:57:57 +02:00
|
|
|
int ofs_y = 0;
|
|
|
|
short i;
|
2015-04-21 17:15:40 +02:00
|
|
|
int len;
|
2015-04-22 04:43:13 +10:00
|
|
|
const float height = BLF_height_max(fontid);
|
2015-10-05 20:41:45 +11:00
|
|
|
const float margin = height / 8;
|
|
|
|
const float vertical_offset = (height + margin);
|
|
|
|
|
|
|
|
/* values taking margins into account */
|
|
|
|
const float descender = BLF_descender(fontid);
|
|
|
|
const float xmin = (rect->xmin + margin);
|
|
|
|
const float xmax = (rect->xmax - margin);
|
|
|
|
const float ymin = (rect->ymin + margin) - descender;
|
|
|
|
const float ymax = (rect->ymax - margin) - descender;
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-04-21 17:15:40 +02:00
|
|
|
if (is_top) {
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
/* first line */
|
|
|
|
if (i == 0) {
|
|
|
|
bool do_newline = false;
|
2015-04-22 05:37:22 +10:00
|
|
|
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, temp_str, 0, len)) {
|
2015-10-05 20:41:45 +11:00
|
|
|
BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
|
2015-04-21 17:15:40 +02:00
|
|
|
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
do_newline = true;
|
|
|
|
}
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-04-22 05:37:22 +10:00
|
|
|
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, temp_str, 1, len)) {
|
2015-04-22 04:43:13 +10:00
|
|
|
line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
2015-10-05 20:41:45 +11:00
|
|
|
BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
|
2015-04-21 17:15:40 +02:00
|
|
|
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
|
|
|
do_newline = true;
|
|
|
|
}
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-04-21 17:15:40 +02:00
|
|
|
if (do_newline)
|
2015-05-01 14:27:44 +02:00
|
|
|
ofs_y += vertical_offset;
|
2015-10-05 20:41:45 +11:00
|
|
|
} /* Strip */
|
|
|
|
else if (i == 1 || i == 2) {
|
2015-04-22 05:37:22 +10:00
|
|
|
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
|
2015-10-05 20:41:45 +11:00
|
|
|
BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
|
2015-04-21 17:15:40 +02:00
|
|
|
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
2015-05-01 14:27:44 +02:00
|
|
|
ofs_y += vertical_offset;
|
2015-04-21 17:15:40 +02:00
|
|
|
}
|
2015-10-05 20:41:45 +11:00
|
|
|
} /* Note (wrapped) */
|
|
|
|
else if (i == 3) {
|
|
|
|
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
|
|
|
|
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
|
|
|
|
struct ResultBLF info;
|
|
|
|
BLF_enable(fontid, BLF_WORD_WRAP);
|
|
|
|
BLF_wordwrap(fontid, ibuf->x - (margin * 2));
|
|
|
|
BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
|
|
|
|
BLF_draw_ex(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX, &info);
|
|
|
|
BLF_wordwrap(fontid, 0);
|
|
|
|
BLF_disable(fontid, BLF_WORD_WRAP);
|
|
|
|
ofs_y += vertical_offset * info.lines;
|
|
|
|
}
|
2015-04-21 17:15:40 +02:00
|
|
|
}
|
|
|
|
else {
|
2015-04-22 05:37:22 +10:00
|
|
|
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
|
2015-04-22 13:19:58 +02:00
|
|
|
line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
2015-10-05 20:41:45 +11:00
|
|
|
BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
|
2015-04-21 17:15:40 +02:00
|
|
|
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
2015-05-01 14:27:44 +02:00
|
|
|
ofs_y += vertical_offset;
|
2015-04-21 17:15:40 +02:00
|
|
|
}
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-21 17:15:40 +02:00
|
|
|
else {
|
2019-02-07 10:08:01 +01:00
|
|
|
MetadataCustomDrawContext ctx;
|
|
|
|
ctx.fontid = fontid;
|
|
|
|
ctx.xmin = xmin;
|
|
|
|
ctx.ymin = ymin;
|
|
|
|
ctx.vertical_offset = vertical_offset;
|
|
|
|
ctx.current_y = ofs_y;
|
|
|
|
ctx.vertical_offset = vertical_offset;
|
|
|
|
IMB_metadata_foreach(ibuf, metadata_custom_draw_fields, &ctx);
|
2015-04-20 19:57:57 +02:00
|
|
|
int ofs_x = 0;
|
2019-02-07 10:08:01 +01:00
|
|
|
ofs_y = ctx.current_y;
|
2015-04-20 19:57:57 +02:00
|
|
|
for (i = 5; i < 10; i++) {
|
2015-04-22 05:37:22 +10:00
|
|
|
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]);
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, temp_str, i, len)) {
|
2019-02-06 11:49:41 +01:00
|
|
|
BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f);
|
2015-04-20 19:57:57 +02:00
|
|
|
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-04-22 04:43:13 +10:00
|
|
|
ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X;
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-07 10:08:01 +01:00
|
|
|
typedef struct MetadataCustomCountContext {
|
|
|
|
int count;
|
|
|
|
} MetadataCustomCountContext;
|
|
|
|
|
|
|
|
static void metadata_custom_count_fields(
|
|
|
|
const char *field,
|
|
|
|
const char *UNUSED(value),
|
|
|
|
void *ctx_v)
|
|
|
|
{
|
|
|
|
if (!metadata_is_custom_drawable(field)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MetadataCustomCountContext *ctx = (MetadataCustomCountContext *)ctx_v;
|
|
|
|
ctx->count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-20 19:57:57 +02:00
|
|
|
static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
|
|
|
|
{
|
2015-10-05 20:41:45 +11:00
|
|
|
const float height = BLF_height_max(fontid);
|
|
|
|
const float margin = (height / 8);
|
2015-05-14 23:58:08 +02:00
|
|
|
char str[MAX_METADATA_STR] = "";
|
2015-04-22 13:19:58 +02:00
|
|
|
short i, count = 0;
|
2015-04-20 19:57:57 +02:00
|
|
|
|
|
|
|
if (is_top) {
|
2015-04-22 13:19:58 +02:00
|
|
|
if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) {
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
for (i = 2; i < 5; i++) {
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, str, i, 0)) {
|
2015-10-05 20:41:45 +11:00
|
|
|
if (i == 4) {
|
|
|
|
struct {
|
|
|
|
struct ResultBLF info;
|
|
|
|
rctf rect;
|
|
|
|
} wrap;
|
|
|
|
|
|
|
|
BLF_enable(fontid, BLF_WORD_WRAP);
|
|
|
|
BLF_wordwrap(fontid, ibuf->x - (margin * 2));
|
|
|
|
BLF_boundbox_ex(fontid, str, sizeof(str), &wrap.rect, &wrap.info);
|
|
|
|
BLF_wordwrap(fontid, 0);
|
|
|
|
BLF_disable(fontid, BLF_WORD_WRAP);
|
|
|
|
|
|
|
|
count += wrap.info.lines;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
count++;
|
|
|
|
}
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (i = 5; i < 10; i++) {
|
2015-04-21 17:15:40 +02:00
|
|
|
if (metadata_is_valid(ibuf, str, i, 0)) {
|
2015-04-22 13:19:58 +02:00
|
|
|
count = 1;
|
2019-02-06 11:49:41 +01:00
|
|
|
break;
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
}
|
2019-02-07 10:08:01 +01:00
|
|
|
MetadataCustomCountContext ctx;
|
|
|
|
ctx.count = 0;
|
|
|
|
IMB_metadata_foreach(ibuf, metadata_custom_count_fields, &ctx);
|
|
|
|
count += ctx.count;
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
|
2015-04-22 13:19:58 +02:00
|
|
|
if (count) {
|
2015-10-05 20:41:45 +11:00
|
|
|
return (height + margin) * count;
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef MAX_METADATA_STR
|
|
|
|
|
2015-10-05 20:46:53 +11:00
|
|
|
void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
|
2015-04-20 19:57:57 +02:00
|
|
|
{
|
|
|
|
float box_y;
|
2015-05-04 12:17:49 +02:00
|
|
|
rctf rect;
|
2015-05-01 14:27:44 +02:00
|
|
|
uiStyle *style = UI_style_get_dpi();
|
2015-04-20 19:57:57 +02:00
|
|
|
|
|
|
|
if (!ibuf->metadata)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* find window pixel coordinates of origin */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
2015-04-20 19:57:57 +02:00
|
|
|
|
|
|
|
/* offset and zoom using ogl */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_translate_2f(x, y);
|
|
|
|
GPU_matrix_scale_2f(zoomx, zoomy);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-10-05 20:41:45 +11:00
|
|
|
BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi);
|
2015-04-21 17:15:40 +02:00
|
|
|
|
2015-04-20 19:57:57 +02:00
|
|
|
/* *** upper box*** */
|
|
|
|
|
|
|
|
/* get needed box height */
|
2015-05-01 14:27:44 +02:00
|
|
|
box_y = metadata_box_height_get(ibuf, blf_mono_font, true);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
|
|
|
if (box_y) {
|
|
|
|
/* set up rect */
|
2015-10-05 20:46:53 +11:00
|
|
|
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
|
2015-04-20 19:57:57 +02:00
|
|
|
/* draw top box */
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformThemeColor(TH_METADATA_BG);
|
|
|
|
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
immUnbindProgram();
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-05-01 14:27:44 +02:00
|
|
|
BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
BLF_enable(blf_mono_font, BLF_CLIPPING);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2017-02-05 00:54:21 -05:00
|
|
|
UI_FontThemeColor(blf_mono_font, TH_METADATA_TEXT);
|
2015-06-30 15:31:55 +10:00
|
|
|
metadata_draw_imbuf(ibuf, &rect, blf_mono_font, true);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-05-01 14:27:44 +02:00
|
|
|
BLF_disable(blf_mono_font, BLF_CLIPPING);
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* *** lower box*** */
|
|
|
|
|
2015-05-01 14:27:44 +02:00
|
|
|
box_y = metadata_box_height_get(ibuf, blf_mono_font, false);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
|
|
|
if (box_y) {
|
|
|
|
/* set up box rect */
|
2015-10-05 20:46:53 +11:00
|
|
|
BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
|
2015-04-20 19:57:57 +02:00
|
|
|
/* draw top box */
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformThemeColor(TH_METADATA_BG);
|
|
|
|
immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
immUnbindProgram();
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-05-01 14:27:44 +02:00
|
|
|
BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
|
|
|
BLF_enable(blf_mono_font, BLF_CLIPPING);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2017-02-05 00:54:21 -05:00
|
|
|
UI_FontThemeColor(blf_mono_font, TH_METADATA_TEXT);
|
2015-06-30 15:31:55 +10:00
|
|
|
metadata_draw_imbuf(ibuf, &rect, blf_mono_font, false);
|
2015-04-20 19:57:57 +02:00
|
|
|
|
2015-05-01 14:27:44 +02:00
|
|
|
BLF_disable(blf_mono_font, BLF_CLIPPING);
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2015-04-20 19:57:57 +02:00
|
|
|
}
|
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
typedef struct MetadataPanelDrawContext {
|
|
|
|
uiLayout *layout;
|
|
|
|
} MetadataPanelDrawContext;
|
|
|
|
|
|
|
|
static void metadata_panel_draw_field(
|
|
|
|
const char *field,
|
|
|
|
const char *value,
|
|
|
|
void *ctx_v)
|
|
|
|
{
|
|
|
|
MetadataPanelDrawContext *ctx = (MetadataPanelDrawContext *)ctx_v;
|
|
|
|
uiLayout *row = uiLayoutRow(ctx->layout, false);
|
|
|
|
uiItemL(row, field, ICON_NONE);
|
|
|
|
uiItemL(row, value, ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_region_image_metadata_panel_draw(ImBuf *ibuf, uiLayout *layout)
|
|
|
|
{
|
|
|
|
MetadataPanelDrawContext ctx;
|
|
|
|
ctx.layout = layout;
|
|
|
|
IMB_metadata_foreach(ibuf, metadata_panel_draw_field, &ctx);
|
|
|
|
}
|
|
|
|
|
2012-04-28 10:09:58 +00:00
|
|
|
void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
|
|
|
|
{
|
|
|
|
float gridsize, gridstep = 1.0f / 32.0f;
|
|
|
|
float fac, blendfac;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
/* the image is located inside (0, 0), (1, 1) as set by view2d */
|
2014-04-21 16:47:16 +10:00
|
|
|
UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x1, &y1);
|
|
|
|
UI_view2d_view_to_region(&ar->v2d, 1.0f, 1.0f, &x2, &y2);
|
2016-11-15 18:28:37 -05:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2016-11-15 18:28:37 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformThemeColorShade(TH_BACK, 20);
|
|
|
|
immRectf(pos, x1, y1, x2, y2);
|
|
|
|
immUnbindProgram();
|
2012-04-28 10:09:58 +00:00
|
|
|
|
|
|
|
/* gridsize adapted to zoom level */
|
|
|
|
gridsize = 0.5f * (zoomx + zoomy);
|
|
|
|
if (gridsize <= 0.0f)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gridsize < 1.0f) {
|
|
|
|
while (gridsize < 1.0f) {
|
|
|
|
gridsize *= 4.0f;
|
|
|
|
gridstep *= 4.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (gridsize >= 4.0f) {
|
|
|
|
gridsize /= 4.0f;
|
|
|
|
gridstep /= 4.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
blendfac = 0.25f * gridsize - floorf(0.25f * gridsize);
|
|
|
|
CLAMP(blendfac, 0.0f, 1.0f);
|
2016-11-15 18:28:37 -05:00
|
|
|
|
|
|
|
int count_fine = 1.0f / gridstep;
|
|
|
|
int count_large = 1.0f / (4.0f * gridstep);
|
|
|
|
|
|
|
|
if (count_fine > 0) {
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_vertformat_clear(format);
|
|
|
|
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
unsigned color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2016-11-15 18:28:37 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large);
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2016-11-15 18:28:37 -05:00
|
|
|
float theme_color[3];
|
|
|
|
UI_GetThemeColorShade3fv(TH_BACK, (int)(20.0f * (1.0f - blendfac)), theme_color);
|
|
|
|
fac = 0.0f;
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2016-11-15 18:28:37 -05:00
|
|
|
/* the fine resolution level */
|
|
|
|
for (int i = 0; i < count_fine; i++) {
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x1, y1 * (1.0f - fac) + y2 * fac);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x2, y1 * (1.0f - fac) + y2 * fac);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x1 * (1.0f - fac) + x2 * fac, y1);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x1 * (1.0f - fac) + x2 * fac, y2);
|
|
|
|
fac += gridstep;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count_large > 0) {
|
|
|
|
UI_GetThemeColor3fv(TH_BACK, theme_color);
|
|
|
|
fac = 0.0f;
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2016-11-15 18:28:37 -05:00
|
|
|
/* the large resolution level */
|
|
|
|
for (int i = 0; i < count_large; i++) {
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x1, y1 * (1.0f - fac) + y2 * fac);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x2, y1 * (1.0f - fac) + y2 * fac);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x1 * (1.0f - fac) + x2 * fac, y1);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3fv(color, theme_color);
|
2016-11-15 18:28:37 -05:00
|
|
|
immVertex2f(pos, x1 * (1.0f - fac) + x2 * fac, y2);
|
|
|
|
fac += 4.0f * gridstep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
|
|
|
}
|
2012-04-28 10:09:58 +00:00
|
|
|
}
|
2012-12-16 09:37:15 +00:00
|
|
|
|
2012-12-18 13:59:47 +00:00
|
|
|
/* If the area has overlapping regions, it returns visible rect for Region *ar */
|
|
|
|
/* rect gets returned in local region coordinates */
|
|
|
|
void ED_region_visible_rect(ARegion *ar, rcti *rect)
|
2012-12-16 09:37:15 +00:00
|
|
|
{
|
|
|
|
ARegion *arn = ar;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-18 13:59:47 +00:00
|
|
|
/* allow function to be called without area */
|
2012-12-16 09:37:15 +00:00
|
|
|
while (arn->prev)
|
|
|
|
arn = arn->prev;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-18 13:59:47 +00:00
|
|
|
*rect = ar->winrct;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-12-16 09:37:15 +00:00
|
|
|
/* check if a region overlaps with the current one */
|
|
|
|
for (; arn; arn = arn->next) {
|
2012-12-18 13:59:47 +00:00
|
|
|
if (ar != arn && arn->overlap) {
|
|
|
|
if (BLI_rcti_isect(rect, &arn->winrct, NULL)) {
|
2018-05-16 08:32:02 +02:00
|
|
|
if (ELEM(arn->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
|
|
|
|
/* Overlap left, also check 1 pixel offset (2 regions on one side). */
|
|
|
|
if (ABS(rect->xmin - arn->winrct.xmin) < 2) {
|
|
|
|
rect->xmin = arn->winrct.xmax;
|
|
|
|
}
|
2013-02-23 14:31:46 +00:00
|
|
|
|
2018-05-16 08:32:02 +02:00
|
|
|
/* Overlap right. */
|
|
|
|
if (ABS(rect->xmax - arn->winrct.xmax) < 2) {
|
|
|
|
rect->xmax = arn->winrct.xmin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ELEM(arn->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
|
|
|
|
/* Same logic as above for vertical regions. */
|
|
|
|
if (ABS(rect->ymin - arn->winrct.ymin) < 2) {
|
|
|
|
rect->ymin = arn->winrct.ymax;
|
|
|
|
}
|
|
|
|
if (ABS(rect->ymax - arn->winrct.ymax) < 2) {
|
|
|
|
rect->ymax = arn->winrct.ymin;
|
|
|
|
}
|
|
|
|
}
|
2018-06-12 10:11:32 +02:00
|
|
|
else if (arn->alignment == RGN_ALIGN_FLOAT) {
|
|
|
|
/* Skip floating. */
|
|
|
|
}
|
2018-05-16 08:32:02 +02:00
|
|
|
else {
|
|
|
|
BLI_assert(!"Region overlap with unknown alignment");
|
|
|
|
}
|
2012-12-18 13:59:47 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-16 09:37:15 +00:00
|
|
|
}
|
2012-12-18 13:59:47 +00:00
|
|
|
BLI_rcti_translate(rect, -ar->winrct.xmin, -ar->winrct.ymin);
|
2012-12-16 09:37:15 +00:00
|
|
|
}
|
|
|
|
|
2014-04-02 16:50:06 +06:00
|
|
|
/* Cache display helpers */
|
|
|
|
|
|
|
|
void ED_region_cache_draw_background(const ARegion *ar)
|
|
|
|
{
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2016-12-13 14:51:39 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4ub(128, 128, 255, 64);
|
|
|
|
immRecti(pos, 0, 0, ar->winx, 8 * UI_DPI_FAC);
|
|
|
|
immUnbindProgram();
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y)
|
|
|
|
{
|
2014-11-09 21:20:40 +01:00
|
|
|
uiStyle *style = UI_style_get();
|
2014-04-02 16:50:06 +06:00
|
|
|
int fontid = style->widget.uifont_id;
|
|
|
|
char numstr[32];
|
|
|
|
float font_dims[2] = {0.0f, 0.0f};
|
|
|
|
|
|
|
|
/* frame number */
|
|
|
|
BLF_size(fontid, 11.0f * U.pixelsize, U.dpi);
|
|
|
|
BLI_snprintf(numstr, sizeof(numstr), "%d", framenr);
|
|
|
|
|
|
|
|
BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2017-01-15 23:48:46 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformThemeColor(TH_CFRAME);
|
|
|
|
immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);
|
|
|
|
immUnbindProgram();
|
2014-04-02 16:50:06 +06:00
|
|
|
|
2017-02-05 00:54:21 -05:00
|
|
|
UI_FontThemeColor(fontid, TH_TEXT);
|
2014-04-02 16:50:06 +06:00
|
|
|
BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f);
|
|
|
|
BLF_draw(fontid, numstr, sizeof(numstr));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_region_cache_draw_cached_segments(const ARegion *ar, const int num_segments, const int *points, const int sfra, const int efra)
|
|
|
|
{
|
|
|
|
if (num_segments) {
|
2018-07-18 00:12:21 +02:00
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2017-01-15 23:48:46 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4ub(128, 128, 255, 128);
|
2014-04-02 16:50:06 +06:00
|
|
|
|
2017-01-15 23:48:46 -05:00
|
|
|
for (int a = 0; a < num_segments; a++) {
|
|
|
|
float x1 = (float)(points[a * 2] - sfra) / (efra - sfra + 1) * ar->winx;
|
|
|
|
float x2 = (float)(points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * ar->winx;
|
2014-04-02 16:50:06 +06:00
|
|
|
|
2017-01-15 23:48:46 -05:00
|
|
|
immRecti(pos, x1, 0, x2, 8 * UI_DPI_FAC);
|
|
|
|
/* TODO(merwin): use primitive restart to draw multiple rects more efficiently */
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
2017-01-15 23:48:46 -05:00
|
|
|
|
|
|
|
immUnbindProgram();
|
2014-04-02 16:50:06 +06:00
|
|
|
}
|
|
|
|
}
|
2017-11-13 19:43:34 +11:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate subscriptions for this region.
|
|
|
|
*/
|
|
|
|
void ED_region_message_subscribe(
|
|
|
|
bContext *C,
|
|
|
|
struct WorkSpace *workspace, struct Scene *scene,
|
|
|
|
struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
|
|
|
|
struct wmMsgBus *mbus)
|
|
|
|
{
|
2018-07-14 23:49:00 +02:00
|
|
|
if (ar->gizmo_map != NULL) {
|
|
|
|
WM_gizmomap_message_subscribe(C, ar->gizmo_map, ar, mbus);
|
2017-11-13 19:43:34 +11:00
|
|
|
}
|
|
|
|
|
2018-10-19 14:45:11 +11:00
|
|
|
if (!BLI_listbase_is_empty(&ar->uiblocks)) {
|
2017-11-13 19:43:34 +11:00
|
|
|
UI_region_message_subscribe(ar, mbus);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ar->type->message_subscribe != NULL) {
|
|
|
|
ar->type->message_subscribe(C, workspace, scene, screen, sa, ar, mbus);
|
|
|
|
}
|
|
|
|
}
|
2018-04-26 12:01:44 +02:00
|
|
|
|
|
|
|
int ED_region_snap_size_test(const ARegion *ar)
|
|
|
|
{
|
|
|
|
/* Use a larger value because toggling scrollbars can jump in size. */
|
|
|
|
const int snap_match_threshold = 16;
|
|
|
|
if (ar->type->snap_size != NULL) {
|
|
|
|
return ((((ar->sizex - ar->type->snap_size(ar, ar->sizex, 0)) <= snap_match_threshold) << 0) |
|
|
|
|
(((ar->sizey - ar->type->snap_size(ar, ar->sizey, 1)) <= snap_match_threshold) << 1));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ED_region_snap_size_apply(ARegion *ar, int snap_flag)
|
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
if (ar->type->snap_size != NULL) {
|
|
|
|
if (snap_flag & (1 << 0)) {
|
|
|
|
short snap_size = ar->type->snap_size(ar, ar->sizex, 0);
|
|
|
|
if (snap_size != ar->sizex) {
|
|
|
|
ar->sizex = snap_size;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (snap_flag & (1 << 1)) {
|
|
|
|
short snap_size = ar->type->snap_size(ar, ar->sizey, 1);
|
|
|
|
if (snap_size != ar->sizey) {
|
|
|
|
ar->sizey = snap_size;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return changed;
|
|
|
|
}
|