2008-01-07 18:03:41 +00:00
|
|
|
/**
|
|
|
|
* $Id:
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
#include "BLI_rand.h"
|
|
|
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
#include "ED_area.h"
|
|
|
|
#include "ED_screen.h"
|
2008-01-17 05:33:54 +00:00
|
|
|
#include "ED_screen_types.h"
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
#include "wm_subwindow.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
#include "UI_interface.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-11-24 21:57:58 +00:00
|
|
|
#ifndef DISABLE_PYTHON
|
2008-01-07 18:03:41 +00:00
|
|
|
#include "BPY_extern.h"
|
2008-11-24 21:57:58 +00:00
|
|
|
#endif
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
#include "screen_intern.h"
|
|
|
|
|
|
|
|
/* general area and region code */
|
|
|
|
|
|
|
|
static void region_draw_emboss(ARegion *ar)
|
|
|
|
{
|
|
|
|
short winx, winy;
|
|
|
|
|
|
|
|
winx= ar->winrct.xmax-ar->winrct.xmin;
|
|
|
|
winy= ar->winrct.ymax-ar->winrct.ymin;
|
|
|
|
|
|
|
|
/* set transp line */
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
|
|
|
|
/* right */
|
|
|
|
glColor4ub(0,0,0, 50);
|
|
|
|
sdrawline(winx, 0, winx, winy);
|
|
|
|
|
|
|
|
/* bottom */
|
|
|
|
glColor4ub(0,0,0, 80);
|
|
|
|
sdrawline(0, 0, winx, 0);
|
|
|
|
|
|
|
|
/* top */
|
|
|
|
glColor4ub(255,255,255, 60);
|
|
|
|
sdrawline(0, winy, winx, winy);
|
|
|
|
|
|
|
|
/* left */
|
|
|
|
glColor4ub(255,255,255, 50);
|
|
|
|
sdrawline(0, 0, 0, winy);
|
|
|
|
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
|
2008-12-03 19:33:42 +00:00
|
|
|
void ED_region_pixelspace(const bContext *C, 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
|
|
|
{
|
|
|
|
int width= ar->winrct.xmax-ar->winrct.xmin+1;
|
|
|
|
int height= ar->winrct.ymax-ar->winrct.ymin+1;
|
|
|
|
|
|
|
|
wmOrtho2(C->window, -0.375, (float)width-0.375, -0.375, (float)height-0.375);
|
2008-12-10 17:58:18 +00:00
|
|
|
wmLoadIdentity(C->window);
|
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
|
|
|
|
|
|
|
void ED_region_do_listen(ARegion *ar, wmNotifier *note)
|
|
|
|
{
|
|
|
|
|
2008-01-10 17:38:17 +00:00
|
|
|
/* generic notes first */
|
|
|
|
switch(note->type) {
|
|
|
|
case WM_NOTE_WINDOW_REDRAW:
|
2.5: gesture code in WM
- Simplified and cleaned previous border code
It was a bit too complex, too many data manipulations
Original idea was to have WM API calls to manage border, circle, lines,
lasso, etc. This now means that WM provides callbacks for custom operators,
so it's very easy to make them. Check bottom of screen_edit.c for an
example.
Currently two borders were coded; with and without cross hair.
Press Bkey in any area-region to test it (note: time window has wrong matrix!)
Some specs to note:
- gestures are in region space, and draw 'over'. That latter still needs some
work when we do real composites.
- only the active region is redrawn.
- on todo is the generic gesture engine for 'tweak' or like how currently grab
gestures in Blender work. These will be configurable per area-region, and WM
then will send the proper "Gesture Event" with properties (N, S, E, W, etc)
to which you then can assign operators. Such events will be generated with low
priority, so other handlers who swallowed mouse events have preference.
2008-11-19 13:16:05 +00:00
|
|
|
case WM_NOTE_AREA_REDRAW:
|
|
|
|
case WM_NOTE_REGION_REDRAW:
|
|
|
|
case WM_NOTE_GESTURE_REDRAW:
|
2008-01-10 17:38:17 +00:00
|
|
|
case WM_NOTE_SCREEN_CHANGED:
|
2008-12-10 13:56:54 +00:00
|
|
|
ar->do_draw= 1;
|
2008-01-10 17:38:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if(ar->type->listener)
|
|
|
|
ar->type->listener(ar, note);
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 10:45:36 +00:00
|
|
|
/* only internal decoration, AZone for now */
|
|
|
|
void ED_area_do_draw(bContext *C, ScrArea *sa)
|
|
|
|
{
|
|
|
|
AZone *az;
|
|
|
|
|
|
|
|
/* hrmf, screenspace for zones */
|
|
|
|
wm_subwindow_set(C->window, C->window->screen->mainwin);
|
|
|
|
|
|
|
|
/* temporary viz for 'action corner' */
|
|
|
|
for(az= sa->actionzones.first; az; az= az->next) {
|
|
|
|
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glColor4ub(0, 0, 0, 80);
|
|
|
|
if(az->type==AZONE_TRI) sdrawtrifill(az->x1, az->y1, az->x2, az->y2);
|
|
|
|
//if(az->type==AZONE_TRI) sdrawtri(az->x1, az->y1, az->x2, az->y2);
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
void ED_region_do_draw(bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
ARegionType *at= ar->type;
|
|
|
|
|
|
|
|
wm_subwindow_set(C->window, ar->swinid);
|
|
|
|
|
|
|
|
if(ar->swinid && at->draw) {
|
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
|
|
|
UI_SetTheme(C->area);
|
2008-01-07 18:03:41 +00:00
|
|
|
at->draw(C, ar);
|
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
|
|
|
UI_SetTheme(NULL);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float fac= 0.1*ar->swinid;
|
|
|
|
|
2008-11-27 17:58:46 +00:00
|
|
|
fac= fac - (int)fac;
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
glClearColor(0.5, fac, 1.0f-fac, 0.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
2008-11-24 10:45:36 +00:00
|
|
|
/* swapbuffers indicator */
|
2008-01-07 18:03:41 +00:00
|
|
|
fac= BLI_frand();
|
|
|
|
glColor3f(fac, fac, fac);
|
2008-11-24 10:45:36 +00:00
|
|
|
glRecti(20, 2, 30, 12);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
UI: don't use operators anymore for handling user interface events, but rather
a special UI handler which makes the code clearer. This UI handler is attached
to the region along with other handlers, and also gets a callback when all
handlers for the region are removed to ensure things are properly cleaned up.
This should fix XXX's in the UI code related to events and context switching.
Most of the changes are in interface_handlers.c, which was renamed from
interface_ops.c, to convert operators to the UI handler. UI code notes:
* uiBeginBlock/uiEndBlock/uiFreeBlocks now takes a context argument, this is
required to properly cancel things like timers or tooltips when the region
gets removed.
* UI_add_region_handlers will add the region level UI handlers, to be used
when adding keymap handlers etc. This replaces the UI keymap.
* When the UI code starts a modal interaction (number sliding, text editing,
opening a menu, ..), it will add an UI handler at the window level which
will block events.
Windowmanager changes:
* Added an UI handler next to the existing keymap and operator modal handlers.
It has an event handling and remove callback, and like operator modal handlers
will remember the area and region if it is registered at the window level.
* Removed the MESSAGE event.
* Operator cancel and UI handler remove callbacks now get the
window/area/region restored in the context, like the operator modal and UI
handler event callbacks.
* Regions now receive MOUSEMOVE events for the mouse going outside of the
region. This was already happening for areas, but UI buttons are at the region
level so we need it there.
Issues:
* Tooltips and menus stay open when switching to another window, and button
highlight doesn't work without moving the mouse first when Blender starts up.
I tried using some events like Q_FIRSTTIME, WINTHAW, but those don't seem to
arrive..
* Timeline header buttons seem to be moving one pixel or so sometimes when
interacting with them.
* Seems not due to this commit, but UI and keymap handlers are leaking. It
seems that handlers are being added to regions in all screens, also in regions
of areas that are not visible, but these handlers are not removed. Probably
there should only be handlers in visible regions?
2008-12-10 04:36:33 +00:00
|
|
|
|
|
|
|
if(C->area)
|
|
|
|
region_draw_emboss(ar);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
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
|
|
|
/* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */
|
|
|
|
ED_region_pixelspace(C, ar);
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->do_draw= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* *************************************************************** */
|
|
|
|
|
2008-12-09 15:59:43 +00:00
|
|
|
/* dir is direction to check, not the splitting edge direction! */
|
2008-01-07 18:03:41 +00:00
|
|
|
static int rct_fits(rcti *rect, char dir, int size)
|
|
|
|
{
|
|
|
|
if(dir=='h') {
|
|
|
|
return rect->xmax-rect->xmin - size;
|
|
|
|
}
|
|
|
|
else { // 'v'
|
|
|
|
return rect->ymax-rect->ymin - size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void region_rect_recursive(ARegion *ar, rcti *remainder)
|
|
|
|
{
|
2008-12-10 13:56:54 +00:00
|
|
|
int prefsizex, prefsizey;
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
if(ar==NULL)
|
|
|
|
return;
|
|
|
|
|
2008-12-09 15:59:43 +00:00
|
|
|
/* clear state flags first */
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag &= ~RGN_FLAG_TOO_SMALL;
|
2008-12-09 15:59:43 +00:00
|
|
|
if(ar->next==NULL)
|
|
|
|
ar->alignment= RGN_ALIGN_NONE;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
prefsizex= ar->type->minsizex;
|
|
|
|
prefsizey= ar->type->minsizey;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
/* hidden is user flag */
|
|
|
|
if(ar->flag & RGN_FLAG_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
|
|
|
/* XXX floating area region, not handled yet here */
|
|
|
|
else if(ar->alignment == RGN_ALIGN_FLOAT);
|
2008-01-07 18:03:41 +00:00
|
|
|
/* remainder is too small for any usage */
|
2008-12-09 15:59:43 +00:00
|
|
|
else if( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) {
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
|
|
|
else if(ar->alignment==RGN_ALIGN_NONE) {
|
|
|
|
/* typically last region */
|
|
|
|
ar->winrct= *remainder;
|
|
|
|
BLI_init_rcti(remainder, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
else if(ar->alignment==RGN_ALIGN_TOP || ar->alignment==RGN_ALIGN_BOTTOM) {
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
if( rct_fits(remainder, 'v', prefsizey) < 0 ) {
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
|
|
|
else {
|
2008-12-10 13:56:54 +00:00
|
|
|
int fac= rct_fits(remainder, '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
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
if(fac < 0 )
|
2008-12-10 13:56:54 +00:00
|
|
|
prefsizey += fac;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
ar->winrct= *remainder;
|
|
|
|
|
|
|
|
if(ar->alignment==RGN_ALIGN_TOP) {
|
2008-12-12 16:29:33 +00:00
|
|
|
ar->winrct.ymin= ar->winrct.ymax - prefsizey + 1;
|
|
|
|
remainder->ymax= ar->winrct.ymin - 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-12-12 16:29:33 +00:00
|
|
|
ar->winrct.ymax= ar->winrct.ymin + prefsizey - 1;
|
|
|
|
remainder->ymin= ar->winrct.ymax + 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ar->alignment==RGN_ALIGN_LEFT || ar->alignment==RGN_ALIGN_RIGHT) {
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
if( rct_fits(remainder, 'h', prefsizex) < 0 ) {
|
2008-01-07 18:03:41 +00:00
|
|
|
ar->flag |= RGN_FLAG_TOO_SMALL;
|
|
|
|
}
|
|
|
|
else {
|
2008-12-10 13:56:54 +00:00
|
|
|
int fac= rct_fits(remainder, 'h', prefsizex);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
if(fac < 0 )
|
2008-12-10 13:56:54 +00:00
|
|
|
prefsizex += fac;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
ar->winrct= *remainder;
|
|
|
|
|
|
|
|
if(ar->alignment==RGN_ALIGN_RIGHT) {
|
2008-12-12 16:29:33 +00:00
|
|
|
ar->winrct.xmin= ar->winrct.xmax - prefsizex + 1;
|
|
|
|
remainder->xmax= ar->winrct.xmin - 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-12-12 16:29:33 +00:00
|
|
|
ar->winrct.xmax= ar->winrct.xmin + prefsizex - 1;
|
|
|
|
remainder->xmin= ar->winrct.xmax + 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* percentage subdiv*/
|
|
|
|
ar->winrct= *remainder;
|
|
|
|
|
|
|
|
if(ar->alignment==RGN_ALIGN_HSPLIT) {
|
2008-12-10 13:56:54 +00:00
|
|
|
if( rct_fits(remainder, 'h', prefsizex) > 4) {
|
2008-12-09 15:59:43 +00:00
|
|
|
ar->winrct.xmax= (remainder->xmin+remainder->xmax)/2;
|
|
|
|
remainder->xmin= ar->winrct.xmax+1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_init_rcti(remainder, 0, 0, 0, 0);
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2008-12-10 13:56:54 +00:00
|
|
|
if( rct_fits(remainder, 'v', prefsizey) > 4) {
|
2008-12-09 15:59:43 +00:00
|
|
|
ar->winrct.ymax= (remainder->ymin+remainder->ymax)/2;
|
|
|
|
remainder->ymin= ar->winrct.ymax+1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_init_rcti(remainder, 0, 0, 0, 0);
|
|
|
|
}
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-10 13:56:54 +00:00
|
|
|
/* for speedup */
|
|
|
|
ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1;
|
|
|
|
ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1;
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
region_rect_recursive(ar->next, remainder);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
|
|
|
|
{
|
|
|
|
|
|
|
|
if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1;
|
|
|
|
else sa->totrct.xmin= sa->v1->vec.x;
|
|
|
|
if(sa->v4->vec.x<sizex-1) sa->totrct.xmax= sa->v4->vec.x-1;
|
|
|
|
else sa->totrct.xmax= sa->v4->vec.x;
|
|
|
|
|
|
|
|
if(sa->v1->vec.y>0) sa->totrct.ymin= sa->v1->vec.y+1;
|
|
|
|
else sa->totrct.ymin= sa->v1->vec.y;
|
|
|
|
if(sa->v2->vec.y<sizey-1) sa->totrct.ymax= sa->v2->vec.y-1;
|
|
|
|
else sa->totrct.ymax= sa->v2->vec.y;
|
|
|
|
|
|
|
|
/* for speedup */
|
|
|
|
sa->winx= sa->totrct.xmax-sa->totrct.xmin+1;
|
|
|
|
sa->winy= sa->totrct.ymax-sa->totrct.ymin+1;
|
|
|
|
}
|
|
|
|
|
2008-01-20 21:10:55 +00:00
|
|
|
#define AZONESPOT 12
|
2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
design, which should make a design based on user-less exec() first, then
wrap invoke() and modal() around it. The exec() should be callable with
only Context and properties.
- split now works again; and inversed as previously, if you drag from a
triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
which can be handled by others (so other gestures can be added in action zone
too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier?
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
2008-11-17 18:54:03 +00:00
|
|
|
void area_azone_initialize(ScrArea *sa)
|
|
|
|
{
|
2008-01-17 05:33:54 +00:00
|
|
|
AZone *az;
|
|
|
|
if(sa->actionzones.first==NULL) {
|
|
|
|
/* set action zones - should these actually be ARegions? With these we can easier check area hotzones */
|
2.5 getting-back-into-coding commit :)
- cleaned up join and split operations. Most noticable is operator callback
design, which should make a design based on user-less exec() first, then
wrap invoke() and modal() around it. The exec() should be callable with
only Context and properties.
- split now works again; and inversed as previously, if you drag from a
triangle (action zone) inside area it subdivides area as expected.
- dragging from triangle outside area, over an edge, joins areas
- split has been simplified, it had too many options... it could just work
simpler (now)
- 'action zone' now is an operator itself, a widget sending an ACTIONZONE event,
which can be handled by others (so other gestures can be added in action zone
too)
Still evaluating:
- context gets set where?
- code structure confuses... what are proper functions for operators?
- what is WM... should low level screen stuff more there?
- when do you send event, notifier?
- files grow to large, will clean
Oh yeah and docs, docs, docs. Coming! :)
2008-11-17 18:54:03 +00:00
|
|
|
/* (ton) for time being just area, ARegion split is not foreseen on user level */
|
2008-01-17 05:33:54 +00:00
|
|
|
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
|
|
|
BLI_addtail(&(sa->actionzones), az);
|
|
|
|
az->type= AZONE_TRI;
|
|
|
|
az->pos= AZONE_SW;
|
|
|
|
|
|
|
|
az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
|
|
|
|
BLI_addtail(&(sa->actionzones), az);
|
|
|
|
az->type= AZONE_TRI;
|
|
|
|
az->pos= AZONE_NE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(az= sa->actionzones.first; az; az= az->next) {
|
|
|
|
if(az->pos==AZONE_SW) {
|
|
|
|
az->x1= sa->v1->vec.x+1;
|
|
|
|
az->y1= sa->v1->vec.y+1;
|
2008-01-17 23:03:37 +00:00
|
|
|
az->x2= sa->v1->vec.x+AZONESPOT;
|
|
|
|
az->y2= sa->v1->vec.y+AZONESPOT;
|
2008-11-24 10:45:36 +00:00
|
|
|
}
|
|
|
|
else if (az->pos==AZONE_NE) {
|
|
|
|
az->x1= sa->v3->vec.x;
|
|
|
|
az->y1= sa->v3->vec.y;
|
2008-01-17 23:03:37 +00:00
|
|
|
az->x2= sa->v3->vec.x-AZONESPOT;
|
|
|
|
az->y2= sa->v3->vec.y-AZONESPOT;
|
2008-01-17 05:33:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* used for area initialize below */
|
|
|
|
static void region_subwindow(wmWindowManager *wm, wmWindow *win, 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
|
|
|
{
|
|
|
|
if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
|
|
|
|
if(ar->swinid)
|
|
|
|
wm_subwindow_close(win, ar->swinid);
|
|
|
|
ar->swinid= 0;
|
|
|
|
}
|
|
|
|
else if(ar->swinid==0)
|
|
|
|
ar->swinid= wm_subwindow_open(win, &ar->winrct);
|
|
|
|
else
|
|
|
|
wm_subwindow_position(win, ar->swinid, &ar->winrct);
|
|
|
|
}
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
static void ed_default_handlers(wmWindowManager *wm, ListBase *handlers, int flag)
|
|
|
|
{
|
|
|
|
/* note, add-handler checks if it already exists */
|
|
|
|
|
|
|
|
if(flag & ED_KEYMAP_UI) {
|
|
|
|
UI_add_region_handlers(handlers);
|
|
|
|
}
|
|
|
|
if(flag & ED_KEYMAP_VIEW2D) {
|
|
|
|
ListBase *keymap= WM_keymap_listbase(wm, "View2D", 0, 0);
|
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
|
|
|
if(flag & ED_KEYMAP_MARKERS) {
|
|
|
|
ListBase *keymap= WM_keymap_listbase(wm, "Markers", 0, 0);
|
|
|
|
WM_event_add_keymap_handler(handlers, keymap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
rcti rect;
|
|
|
|
|
|
|
|
/* set typedefinitions */
|
|
|
|
sa->type= BKE_spacetype_from_id(sa->spacetype);
|
2008-12-10 13:56:54 +00:00
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
if(sa->type==NULL) {
|
|
|
|
sa->spacetype= SPACE_VIEW3D;
|
|
|
|
sa->type= BKE_spacetype_from_id(sa->spacetype);
|
|
|
|
}
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
|
|
|
ar->type= ED_regiontype_from_id(sa->type, ar->regiontype);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* area sizes */
|
|
|
|
area_calc_totrct(sa, win->sizex, win->sizey);
|
2008-01-07 18:03:41 +00:00
|
|
|
|
|
|
|
/* region rect sizes */
|
|
|
|
rect= sa->totrct;
|
|
|
|
region_rect_recursive(sa->regionbase.first, &rect);
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* default area handlers */
|
|
|
|
ed_default_handlers(wm, &sa->handlers, sa->type->keymapflag);
|
|
|
|
/* checks spacedata, adds own handlers */
|
|
|
|
if(sa->type->init)
|
|
|
|
sa->type->init(wm, sa);
|
2008-01-17 05:33:54 +00:00
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* region windows, default and own handlers */
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
region_subwindow(wm, win, ar);
|
|
|
|
|
|
|
|
/* default region handlers */
|
|
|
|
ed_default_handlers(wm, &ar->handlers, ar->type->keymapflag);
|
|
|
|
|
|
|
|
if(ar->type->init)
|
|
|
|
ar->type->init(wm, ar);
|
|
|
|
|
|
|
|
}
|
2008-01-17 05:33:54 +00:00
|
|
|
area_azone_initialize(sa);
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-10 13:56:54 +00:00
|
|
|
/* externally called for floating regions like menus */
|
|
|
|
void ED_region_init(bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
// ARegionType *at= ar->type;
|
|
|
|
|
|
|
|
/* refresh can be called before window opened */
|
|
|
|
region_subwindow(C->wm, C->window, ar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-12-09 15:59:43 +00:00
|
|
|
|
|
|
|
ARegion *ED_region_copy(ARegion *ar)
|
|
|
|
{
|
|
|
|
ARegion *newar= MEM_dupallocN(ar);
|
|
|
|
|
|
|
|
newar->handlers.first= newar->handlers.last= NULL;
|
|
|
|
newar->uiblocks.first= newar->uiblocks.last= NULL;
|
|
|
|
newar->swinid= 0;
|
|
|
|
|
|
|
|
/* XXX regiondata */
|
|
|
|
if(ar->regiondata)
|
|
|
|
newar->regiondata= MEM_dupallocN(ar->regiondata);
|
|
|
|
|
|
|
|
return newar;
|
|
|
|
}
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
/* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
|
|
|
|
/* area vertices were set */
|
|
|
|
void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
|
|
|
|
{
|
|
|
|
Panel *pa1, *pa2, *patab;
|
|
|
|
ARegion *ar;
|
|
|
|
|
|
|
|
sa1->headertype= sa2->headertype;
|
|
|
|
sa1->spacetype= sa2->spacetype;
|
|
|
|
|
|
|
|
if(swap_space) {
|
|
|
|
SWAP(ListBase, sa1->spacedata, sa2->spacedata);
|
|
|
|
/* exception: ensure preview is reset */
|
|
|
|
// if(sa1->spacetype==SPACE_VIEW3D)
|
|
|
|
// XXX BIF_view3d_previewrender_free(sa1->spacedata.first);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_spacedata_freelist(&sa1->spacedata);
|
|
|
|
BKE_spacedata_copylist(&sa1->spacedata, &sa2->spacedata);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&sa1->panels);
|
|
|
|
BLI_duplicatelist(&sa1->panels, &sa2->panels);
|
|
|
|
|
|
|
|
/* copy panel pointers */
|
|
|
|
for(pa1= sa1->panels.first; pa1; pa1= pa1->next) {
|
|
|
|
|
|
|
|
patab= sa1->panels.first;
|
|
|
|
pa2= sa2->panels.first;
|
|
|
|
while(patab) {
|
|
|
|
if( pa1->paneltab == pa2) {
|
|
|
|
pa1->paneltab = patab;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
patab= patab->next;
|
|
|
|
pa2= pa2->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* regions */
|
|
|
|
BLI_freelistN(&sa1->regionbase);
|
2008-12-09 15:59:43 +00:00
|
|
|
|
|
|
|
for(ar= sa2->regionbase.first; ar; ar= ar->next) {
|
|
|
|
ARegion *newar= ED_region_copy(ar);
|
|
|
|
BLI_addtail(&sa1->regionbase, newar);
|
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
|
|
|
}
|
2008-01-17 08:26:58 +00:00
|
|
|
|
2008-11-24 21:57:58 +00:00
|
|
|
#ifndef DISABLE_PYTHON
|
2008-01-07 18:03:41 +00:00
|
|
|
/* scripts */
|
|
|
|
BPY_free_scriptlink(&sa1->scriptlink);
|
|
|
|
sa1->scriptlink= sa2->scriptlink;
|
|
|
|
BPY_copy_scriptlink(&sa1->scriptlink); /* copies internal pointers */
|
2008-11-24 21:57:58 +00:00
|
|
|
#endif
|
2008-01-07 18:03:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
void ED_newspace(ScrArea *sa, int type)
|
|
|
|
{
|
|
|
|
if(sa->spacetype != type) {
|
|
|
|
SpaceType *st= BKE_spacetype_from_id(type);
|
|
|
|
SpaceLink *slold= sa->spacedata.first;
|
|
|
|
SpaceLink *sl;
|
|
|
|
|
|
|
|
sa->spacetype= type;
|
|
|
|
sa->butspacetype= type;
|
|
|
|
|
|
|
|
/* check previously stored space */
|
|
|
|
for (sl= sa->spacedata.first; sl; sl= sl->next)
|
|
|
|
if(sl->spacetype==type)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* old spacedata... happened during work on 2.50, remove */
|
|
|
|
if(sl && sl->regionbase.first==NULL) {
|
|
|
|
st->free(sl);
|
|
|
|
MEM_freeN(sl);
|
|
|
|
sl= NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sl) {
|
|
|
|
|
|
|
|
/* swap regions */
|
|
|
|
slold->regionbase= sa->regionbase;
|
|
|
|
sa->regionbase= sl->regionbase;
|
|
|
|
sl->regionbase.first= sl->regionbase.last= NULL;
|
|
|
|
|
|
|
|
/* put in front of list */
|
|
|
|
BLI_remlink(&sa->spacedata, sl);
|
|
|
|
BLI_addhead(&sa->spacedata, sl);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* new space */
|
|
|
|
if(st) {
|
|
|
|
sl= st->new();
|
|
|
|
BLI_addhead(&sa->spacedata, sl);
|
|
|
|
|
|
|
|
/* swap regions */
|
|
|
|
slold->regionbase= sa->regionbase;
|
|
|
|
sa->regionbase= sl->regionbase;
|
|
|
|
sl->regionbase.first= sl->regionbase.last= NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 16:29:33 +00:00
|
|
|
|
2008-12-12 10:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-07 18:03:41 +00:00
|
|
|
|