2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
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
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup editorui
|
2022-02-09 18:31:42 +11:00
|
|
|
* Generic 2D view with should allow drawing grids,
|
|
|
|
|
* panning, zooming, scrolling, .. etc.
|
2011-02-21 07:25:24 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
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
|
|
|
|
2014-04-21 16:47:16 +10:00
|
|
|
#include "BLI_compiler_attrs.h"
|
2021-08-24 17:45:40 +01:00
|
|
|
#include "BLI_rect.h"
|
2014-04-21 16:47:16 +10:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name General Defines
|
|
|
|
|
* \{ */
|
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
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** Generic value to use when coordinate lies out of view when converting. */
|
2012-05-12 20:39:39 +00:00
|
|
|
#define V2D_IS_CLIPPED 12000
|
2008-11-30 06:15:33 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/**
|
|
|
|
|
* Common View2D view types.
|
|
|
|
|
*
|
|
|
|
|
* \note only define a type here if it completely sets all (+/- a few) of the relevant flags and
|
|
|
|
|
* settings for a View2D region, and that set of settings is used in more than one specific place.
|
2008-12-17 10:25:02 +00:00
|
|
|
*/
|
2013-03-22 05:46:39 +00:00
|
|
|
enum eView2D_CommonViewTypes {
|
2022-10-07 16:05:17 +11:00
|
|
|
/** custom view type (region has defined all necessary flags already). */
|
2008-12-17 10:25:02 +00:00
|
|
|
V2D_COMMONVIEW_CUSTOM = -1,
|
2022-10-07 16:05:17 +11:00
|
|
|
/** standard (only use this when setting up a new view, as a sensible base for most settings). */
|
2008-12-17 10:25:02 +00:00
|
|
|
V2D_COMMONVIEW_STANDARD,
|
2022-10-07 16:05:17 +11:00
|
|
|
/** List-view (i.e. Outliner). */
|
2008-12-15 11:58:57 +00:00
|
|
|
V2D_COMMONVIEW_LIST,
|
2022-10-07 16:05:17 +11:00
|
|
|
/** Stack-view (this is basically a list where new items are added at the top). */
|
2009-05-29 12:26:47 +00:00
|
|
|
V2D_COMMONVIEW_STACK,
|
2022-10-07 16:05:17 +11:00
|
|
|
/** headers (this is basically the same as list-view, but no Y-panning). */
|
2008-12-15 11:58:57 +00:00
|
|
|
V2D_COMMONVIEW_HEADER,
|
2022-10-07 16:05:17 +11:00
|
|
|
/** UI region containing panels. */
|
2019-02-03 14:01:45 +11:00
|
|
|
V2D_COMMONVIEW_PANELS_UI,
|
2013-03-22 05:46:39 +00:00
|
|
|
};
|
2008-12-07 06:21:06 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
2008-12-15 11:58:57 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Defines for Scroll Bars
|
|
|
|
|
* \{ */
|
2008-12-15 11:58:57 +00:00
|
|
|
|
2019-06-04 10:53:12 +10:00
|
|
|
/** Scroll bar area. */
|
2022-06-27 06:45:49 -07:00
|
|
|
|
|
|
|
|
/* Maximum has to include outline which varies with line width. */
|
|
|
|
|
#define V2D_SCROLL_HEIGHT ((0.45f * U.widget_unit) + (2.0f * U.pixelsize))
|
|
|
|
|
#define V2D_SCROLL_WIDTH ((0.45f * U.widget_unit) + (2.0f * U.pixelsize))
|
|
|
|
|
|
2022-09-19 14:47:27 +10:00
|
|
|
/* Alpha of scroll-bar when at minimum size. */
|
2022-06-27 06:45:49 -07:00
|
|
|
#define V2D_SCROLL_MIN_ALPHA (0.4f)
|
|
|
|
|
|
|
|
|
|
/* Minimum size needs to include outline which varies with line width. */
|
2023-03-17 04:19:05 +01:00
|
|
|
#define V2D_SCROLL_MIN_WIDTH ((5.0f * UI_SCALE_FAC) + (2.0f * U.pixelsize))
|
2022-06-27 06:45:49 -07:00
|
|
|
|
|
|
|
|
/* When to start showing the full-width scroller. */
|
2023-03-17 04:19:05 +01:00
|
|
|
#define V2D_SCROLL_HIDE_WIDTH (AREAMINX * UI_SCALE_FAC)
|
|
|
|
|
#define V2D_SCROLL_HIDE_HEIGHT (HEADERY * UI_SCALE_FAC)
|
2022-06-27 06:45:49 -07:00
|
|
|
|
2019-06-04 10:53:12 +10:00
|
|
|
/** Scroll bars with 'handles' used for scale (zoom). */
|
|
|
|
|
#define V2D_SCROLL_HANDLE_HEIGHT (0.6f * U.widget_unit)
|
|
|
|
|
#define V2D_SCROLL_HANDLE_WIDTH (0.6f * U.widget_unit)
|
2008-12-15 11:58:57 +00:00
|
|
|
|
2019-06-04 10:53:12 +10:00
|
|
|
/** Scroll bar with 'handles' hot-spot radius for cursor proximity. */
|
|
|
|
|
#define V2D_SCROLL_HANDLE_SIZE_HOTSPOT (0.6f * U.widget_unit)
|
2008-11-30 06:15:33 +00:00
|
|
|
|
2019-06-04 10:53:12 +10:00
|
|
|
/** Don't allow scroll thumb to show below this size (so it's never too small to click on). */
|
2023-03-17 04:19:05 +01:00
|
|
|
#define V2D_SCROLL_THUMB_SIZE_MIN (30.0 * UI_SCALE_FAC)
|
2019-06-03 18:13:52 +02:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Define for #UI_view2d_sync
|
|
|
|
|
* \{ */
|
2008-12-15 18:09:55 +00:00
|
|
|
|
2008-12-16 12:28:00 +00:00
|
|
|
/* means copy it from another v2d */
|
2012-05-12 20:39:39 +00:00
|
|
|
#define V2D_LOCK_SET 0
|
2008-12-16 12:28:00 +00:00
|
|
|
/* means copy it to the other v2ds */
|
2012-05-12 20:39:39 +00:00
|
|
|
#define V2D_LOCK_COPY 1
|
2008-12-15 18:09:55 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Macros
|
|
|
|
|
* \{ */
|
2008-11-28 04:01:35 +00:00
|
|
|
|
2022-09-19 14:47:27 +10:00
|
|
|
/* Test if mouse in a scroll-bar (assume that scroller availability has been tested). */
|
2012-08-23 18:25:45 +00:00
|
|
|
#define IN_2D_VERT_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->vert, co))
|
|
|
|
|
#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->hor, co))
|
2008-11-28 04:01:35 +00:00
|
|
|
|
2019-04-23 16:43:50 +10:00
|
|
|
#define IN_2D_VERT_SCROLL_RECT(v2d, rct) (BLI_rcti_isect(&v2d->vert, rct, NULL))
|
|
|
|
|
#define IN_2D_HORIZ_SCROLL_RECT(v2d, rct) (BLI_rcti_isect(&v2d->hor, rct, NULL))
|
|
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2022-10-10 11:21:53 +11:00
|
|
|
/** \name Forward Declarations
|
2022-10-07 16:05:17 +11:00
|
|
|
* \{ */
|
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
|
|
|
|
|
|
|
|
struct View2D;
|
2008-11-30 06:15:33 +00:00
|
|
|
struct View2DScrollers;
|
|
|
|
|
|
2019-01-28 21:08:24 +11:00
|
|
|
struct ARegion;
|
2012-12-14 08:05:56 +00:00
|
|
|
struct Scene;
|
2008-12-21 11:56:42 +00:00
|
|
|
struct ScrArea;
|
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
|
|
|
struct bContext;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct bScreen;
|
2009-01-02 00:56:48 +00:00
|
|
|
struct rctf;
|
2021-06-16 18:17:07 +01:00
|
|
|
struct rcti;
|
|
|
|
|
struct wmEvent;
|
2019-05-31 21:45:28 +10:00
|
|
|
struct wmGizmoGroupType;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct wmKeyConfig;
|
2021-06-16 18:17:07 +01:00
|
|
|
struct wmOperator;
|
|
|
|
|
struct wmOperatorType;
|
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
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Prototypes
|
|
|
|
|
* \{ */
|
2008-11-28 04:01:35 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Refresh and validation (of view rects).
|
|
|
|
|
*
|
|
|
|
|
* Initialize all relevant View2D data (including view rects if first time)
|
|
|
|
|
* and/or refresh mask sizes after view resize.
|
|
|
|
|
*
|
|
|
|
|
* - For some of these presets, it is expected that the region will have defined some
|
|
|
|
|
* additional settings necessary for the customization of the 2D viewport to its requirements
|
|
|
|
|
* - This function should only be called from region init() callbacks, where it is expected that
|
|
|
|
|
* this is called before #UI_view2d_size_update(),
|
|
|
|
|
* as this one checks that the rects are properly initialized.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy);
|
2008-12-15 11:58:57 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_curRect_validate(View2D *v2d);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot).
|
|
|
|
|
* This does not take into account if zooming the view on an axis
|
|
|
|
|
* will improve the view (if allowed).
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_curRect_reset(View2D *v2d);
|
|
|
|
|
bool UI_view2d_area_supports_sync(ScrArea *area);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Called by menus to activate it, or by view2d operators
|
|
|
|
|
* to make sure 'related' views stay in synchrony.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag);
|
2008-12-15 11:58:57 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Perform all required updates after `v2d->cur` as been modified.
|
2020-08-17 12:34:05 +10:00
|
|
|
* This includes like validation view validation (#UI_view2d_curRect_validate).
|
2020-08-12 12:36:19 +02:00
|
|
|
*
|
2021-12-09 00:55:11 +11:00
|
|
|
* Current intent is to use it from user code, such as view navigation and zoom operations.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_curRect_changed(const bContext *C, View2D *v2d);
|
2020-08-12 12:36:19 +02:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_totRect_set(View2D *v2d, int width, int height);
|
2009-07-29 22:57:53 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_mask_from_win(const View2D *v2d, rcti *r_mask);
|
2018-10-22 16:41:18 +11:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_zoom_cache_reset();
|
2014-01-20 12:43:56 +11:00
|
|
|
|
2023-07-19 16:12:15 +02:00
|
|
|
/**
|
|
|
|
|
* Clamp view2d area to what's visible, preventing
|
|
|
|
|
* scrolling vertically to infinity.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_curRect_clamp_y(View2D *v2d);
|
2023-07-19 16:12:15 +02:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name View Matrix Operations
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Set view matrices to use 'cur' rect as viewing frame for View2D drawing.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_view_ortho(const View2D *v2d);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Set view matrices to only use one axis of 'cur' only
|
|
|
|
|
*
|
|
|
|
|
* \param xaxis: if non-zero, only use cur x-axis,
|
|
|
|
|
* otherwise use cur-yaxis (mostly this will be used for x).
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_view_orthoSpecial(ARegion *region, View2D *v2d, bool xaxis);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Restore view matrices after drawing.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_view_restore(const bContext *C);
|
2008-12-01 00:20:19 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Grid Drawing
|
|
|
|
|
* \{ */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw a multi-level grid in given 2d-region.
|
|
|
|
|
*/
|
2013-03-18 16:34:57 +00:00
|
|
|
void UI_view2d_multi_grid_draw(
|
2023-08-04 22:15:25 -04:00
|
|
|
const View2D *v2d, int colorid, float step, int level_size, int totlevels);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Draw a multi-level grid of dots, with a dynamic number of levels based on the fading.
|
|
|
|
|
*
|
|
|
|
|
* \param grid_color_id: The theme color used for the points. Faded dynamically based on zoom.
|
|
|
|
|
* \param min_step: The base size of the grid. At different zoom levels, the visible grid may have
|
|
|
|
|
* a larger step size.
|
2022-03-30 21:21:57 +02:00
|
|
|
* \param grid_subdivisions: The maximum number of sub-levels drawn at once.
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_dot_grid_draw(const View2D *v2d,
|
2021-10-25 21:46:39 -05:00
|
|
|
int grid_color_id,
|
2021-12-14 18:35:23 +11:00
|
|
|
float min_step,
|
2022-03-30 21:21:57 +02:00
|
|
|
int grid_subdivisions);
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_lines_y__values(const View2D *v2d);
|
|
|
|
|
void UI_view2d_draw_lines_x__values(const View2D *v2d);
|
|
|
|
|
void UI_view2d_draw_lines_x__discrete_values(const View2D *v2d, bool display_minor_lines);
|
|
|
|
|
void UI_view2d_draw_lines_x__discrete_time(const View2D *v2d,
|
|
|
|
|
const Scene *scene,
|
2021-07-29 11:35:48 +02:00
|
|
|
bool display_minor_lines);
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const View2D *v2d,
|
|
|
|
|
const Scene *scene,
|
2021-07-29 11:35:48 +02:00
|
|
|
bool display_seconds,
|
|
|
|
|
bool display_minor_lines);
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_lines_x__frames_or_seconds(const View2D *v2d,
|
|
|
|
|
const Scene *scene,
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
bool display_seconds);
|
|
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
float UI_view2d_grid_resolution_x__frames_or_seconds(const View2D *v2d,
|
|
|
|
|
const Scene *scene,
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
bool display_seconds);
|
2023-08-04 22:15:25 -04:00
|
|
|
float UI_view2d_grid_resolution_y__values(const View2D *v2d);
|
Refactor grid and scale indicator text drawing
This affects the timeline, dopesheet, graph editor, sequencer,
clip editor and nla editor.
Removed structs and enums: `V2D_ARG_DUMMY`, `eView2D_Units`,
`eView2D_Clamp`, `eView2D_Gridlines`, `View2DGrid`.
A main goal of this refactor is to get rid of the very generic
`View2DGrid` struct. The drawing code became very complex
because there were many different combinations of settings.
This refactor implements a different approach.
Instead of one very generic API, there are many slighly
different functions that do exactly, what we need in the
different editors. Only very little code is duplicated,
because the API functions compose some shared low level code.
This structure makes the code much easier to debug and change,
because every function has much fewer responsibilities.
Additionally, this refactor fixes some long standing bugs.
E.g. when `Show Seconds` is enabled, you zoom in and pan the view.
Or that the step size between displayed frame numbers was
always `>= 2`, no matter how close you zoom in.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4776
2019-05-02 12:00:12 +02:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Scale indicator text drawing.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_scale_y__values(const ARegion *region,
|
|
|
|
|
const View2D *v2d,
|
|
|
|
|
const rcti *rect,
|
2019-05-03 15:09:28 +02:00
|
|
|
int colorid);
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_scale_y__block(const ARegion *region,
|
|
|
|
|
const View2D *v2d,
|
|
|
|
|
const rcti *rect,
|
2019-05-03 15:09:28 +02:00
|
|
|
int colorid);
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const ARegion *region,
|
|
|
|
|
const View2D *v2d,
|
|
|
|
|
const rcti *rect,
|
|
|
|
|
const Scene *scene,
|
2019-05-03 15:09:28 +02:00
|
|
|
bool display_seconds,
|
|
|
|
|
int colorid);
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_draw_scale_x__frames_or_seconds(const ARegion *region,
|
|
|
|
|
const View2D *v2d,
|
|
|
|
|
const rcti *rect,
|
|
|
|
|
const Scene *scene,
|
2019-05-03 15:09:28 +02:00
|
|
|
bool display_seconds,
|
|
|
|
|
int colorid);
|
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
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Scroll-bar Drawing
|
|
|
|
|
* \{ */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw scroll-bars in the given 2D-region.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_scrollers_draw_ex(View2D *v2d, const rcti *mask_custom, bool use_full_hide);
|
|
|
|
|
void UI_view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom);
|
2008-11-28 04:01:35 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name List View Tools
|
|
|
|
|
* \{ */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the 'cell' (row, column) that the given 2D-view coordinates
|
|
|
|
|
* (i.e. in 'tot' rect space) lie in.
|
|
|
|
|
*
|
|
|
|
|
* \param columnwidth, rowheight: size of each 'cell'
|
|
|
|
|
* \param startx, starty: coordinates (in 'tot' rect space) that the list starts from.
|
|
|
|
|
* This should be (0,0) for most views. However, for those where the starting row was offsetted
|
|
|
|
|
* (like for Animation Editor channel lists, to make the first entry more visible), these will be
|
|
|
|
|
* the min-coordinates of the first item.
|
|
|
|
|
* \param viewx, viewy: 2D-coordinates (in 2D-view / 'tot' rect space) to get the cell for
|
2021-12-14 18:35:23 +11:00
|
|
|
* \param r_column, r_row: The 'coordinates' of the relevant 'cell'.
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2019-05-03 13:00:18 +02:00
|
|
|
void UI_view2d_listview_view_to_cell(float columnwidth,
|
2013-06-04 20:26:58 +00:00
|
|
|
float rowheight,
|
2012-09-15 11:48:20 +00:00
|
|
|
float startx,
|
|
|
|
|
float starty,
|
|
|
|
|
float viewx,
|
|
|
|
|
float viewy,
|
2021-12-14 18:35:23 +11:00
|
|
|
int *r_column,
|
|
|
|
|
int *r_row);
|
2008-12-31 10:44:00 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Coordinate Conversion
|
|
|
|
|
* \{ */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
float UI_view2d_region_to_view_x(const View2D *v2d, float x);
|
|
|
|
|
float UI_view2d_region_to_view_y(const View2D *v2d, float y);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Convert from screen/region space to 2d-View space
|
|
|
|
|
*
|
|
|
|
|
* \param x, y: coordinates to convert
|
|
|
|
|
* \param r_view_x, r_view_y: resultant coordinates
|
|
|
|
|
*/
|
2018-11-13 13:28:43 +11:00
|
|
|
void UI_view2d_region_to_view(
|
2023-08-04 22:15:25 -04:00
|
|
|
const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL();
|
|
|
|
|
void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst)
|
|
|
|
|
ATTR_NONNULL();
|
2018-11-13 13:28:43 +11:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
float UI_view2d_view_to_region_x(const View2D *v2d, float x);
|
|
|
|
|
float UI_view2d_view_to_region_y(const View2D *v2d, float y);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Convert from 2d-View space to screen/region space
|
|
|
|
|
* \note Coordinates are clamped to lie within bounds of region
|
|
|
|
|
*
|
|
|
|
|
* \param x, y: Coordinates to convert.
|
|
|
|
|
* \param r_region_x, r_region_y: Resultant coordinates.
|
|
|
|
|
*/
|
2018-11-13 13:28:43 +11:00
|
|
|
bool UI_view2d_view_to_region_clip(
|
2023-08-04 22:15:25 -04:00
|
|
|
const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-07-12 19:39:57 +10:00
|
|
|
bool UI_view2d_view_to_region_segment_clip(const View2D *v2d,
|
|
|
|
|
const float xy_a[2],
|
|
|
|
|
const float xy_b[2],
|
|
|
|
|
int r_region_a[2],
|
|
|
|
|
int r_region_b[2]) ATTR_NONNULL();
|
|
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Convert from 2d-view space to screen/region space
|
|
|
|
|
*
|
|
|
|
|
* \note Coordinates are NOT clamped to lie within bounds of region.
|
|
|
|
|
*
|
|
|
|
|
* \param x, y: Coordinates to convert.
|
|
|
|
|
* \param r_region_x, r_region_y: Resultant coordinates.
|
|
|
|
|
*/
|
2014-04-21 16:47:16 +10:00
|
|
|
void UI_view2d_view_to_region(
|
2023-08-04 22:15:25 -04:00
|
|
|
const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL();
|
|
|
|
|
void UI_view2d_view_to_region_fl(
|
|
|
|
|
const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL();
|
|
|
|
|
void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) ATTR_NONNULL();
|
|
|
|
|
void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
|
|
|
|
|
ATTR_NONNULL();
|
|
|
|
|
bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
|
|
|
|
|
ATTR_NONNULL();
|
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
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Utilities
|
|
|
|
|
* \{ */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* View2D data by default resides in region, so get from region stored in context.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
View2D *UI_view2d_fromcontext(const bContext *C);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Same as above, but it returns region-window. Utility for pull-downs or buttons.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
View2D *UI_view2d_fromcontext_rwin(const bContext *C);
|
2008-12-23 11:02:39 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
2022-09-19 14:47:27 +10:00
|
|
|
* Get scroll-bar sizes of the current 2D view.
|
|
|
|
|
* The size will be zero if the view has its scroll-bars disabled.
|
2022-06-27 06:45:49 -07:00
|
|
|
*
|
|
|
|
|
* \param mapped: whether to use view2d_scroll_mapped which changes flags
|
2021-12-09 00:55:11 +11:00
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_scroller_size_get(const View2D *v2d, bool mapped, float *r_x, float *r_y);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Calculate the scale per-axis of the drawing-area
|
|
|
|
|
*
|
|
|
|
|
* Is used to inverse correct drawing of icons, etc. that need to follow view
|
|
|
|
|
* but not be affected by scale
|
|
|
|
|
*
|
|
|
|
|
* \param r_x, r_y: scale on each axis
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_scale_get(const View2D *v2d, float *r_x, float *r_y);
|
|
|
|
|
float UI_view2d_scale_get_x(const View2D *v2d);
|
|
|
|
|
float UI_view2d_scale_get_y(const View2D *v2d);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Same as `UI_view2d_scale_get() - 1.0f / x, y`.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y);
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Simple functions for consistent center offset access.
|
|
|
|
|
* Used by node editor to shift view center for each individual node tree.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_center_get(const View2D *v2d, float *r_x, float *r_y);
|
|
|
|
|
void UI_view2d_center_set(View2D *v2d, float x, float y);
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Simple pan function
|
|
|
|
|
* (0.0, 0.0) bottom left
|
|
|
|
|
* (0.5, 0.5) center
|
|
|
|
|
* (1.0, 1.0) top right.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_offset(View2D *v2d, float xfac, float yfac);
|
2014-02-22 13:07:02 +11:00
|
|
|
|
2023-07-03 15:15:18 +02:00
|
|
|
/**
|
|
|
|
|
* Scrolls the view so that the upper edge is at a multiple of the page size.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_offset_y_snap_to_closest_page(View2D *v2d);
|
2023-07-03 15:15:18 +02:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Check if mouse is within scrollers
|
|
|
|
|
*
|
2021-12-14 18:35:23 +11:00
|
|
|
* \param xy: Mouse coordinates in screen (not region) space.
|
|
|
|
|
* \param r_scroll: Return argument for the mapped view2d scroll flag.
|
2021-12-09 00:55:11 +11:00
|
|
|
*
|
|
|
|
|
* \return appropriate code for match.
|
|
|
|
|
* - 'h' = in horizontal scroller.
|
|
|
|
|
* - 'v' = in vertical scroller.
|
|
|
|
|
* - 0 = not in scroller.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
char UI_view2d_mouse_in_scrollers_ex(const ARegion *region,
|
|
|
|
|
const View2D *v2d,
|
2021-10-20 20:49:02 -03:00
|
|
|
const int xy[2],
|
|
|
|
|
int *r_scroll) ATTR_NONNULL(1, 2, 3, 4);
|
2023-08-04 22:15:25 -04:00
|
|
|
char UI_view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2])
|
|
|
|
|
ATTR_NONNULL(1, 2, 3);
|
|
|
|
|
char UI_view2d_rect_in_scrollers_ex(const ARegion *region,
|
|
|
|
|
const View2D *v2d,
|
|
|
|
|
const rcti *rect,
|
2021-10-20 20:49:02 -03:00
|
|
|
int *r_scroll) ATTR_NONNULL(1, 2, 3);
|
2023-08-04 22:15:25 -04:00
|
|
|
char UI_view2d_rect_in_scrollers(const ARegion *region, const View2D *v2d, const rcti *rect)
|
|
|
|
|
ATTR_NONNULL(1, 2, 3);
|
2008-12-23 11:02:39 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Cached text drawing in v2d, to allow pixel-aligned draw as post process.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_text_cache_add(
|
|
|
|
|
View2D *v2d, float x, float y, const char *str, size_t str_len, const unsigned char col[4]);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* No clip (yet).
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_text_cache_add_rectf(View2D *v2d,
|
|
|
|
|
const rctf *rect_view,
|
2014-04-21 18:46:52 +10:00
|
|
|
const char *str,
|
|
|
|
|
size_t str_len,
|
2020-03-16 11:53:08 +11:00
|
|
|
const unsigned char col[4]);
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_text_cache_draw(ARegion *region);
|
2008-12-23 11:02:39 +00:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Operators
|
|
|
|
|
* \{ */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_operatortypes_view2d();
|
|
|
|
|
void ED_keymap_view2d(wmKeyConfig *keyconf);
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Will start timer if appropriate.
|
|
|
|
|
* the arguments are the desired situation.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_smooth_view(const bContext *C, ARegion *region, const rctf *cur, int smooth_viewtx);
|
2019-05-07 15:09:14 +02:00
|
|
|
|
2023-03-17 04:19:05 +01:00
|
|
|
#define UI_MARKER_MARGIN_Y (42 * UI_SCALE_FAC)
|
|
|
|
|
#define UI_TIME_SCRUB_MARGIN_Y (23 * UI_SCALE_FAC)
|
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
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Gizmo Types
|
|
|
|
|
* \{ */
|
2019-05-31 21:45:28 +10:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `view2d_gizmo_navigate.cc` */
|
2021-12-09 00:55:11 +11:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Caller defines the name for gizmo group.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void VIEW2D_GGT_navigate_impl(wmGizmoGroupType *gzgt, const char *idname);
|
2019-05-31 21:45:28 +10:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Edge Pan
|
|
|
|
|
* \{ */
|
2021-06-16 18:17:07 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom-data for view panning operators.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
struct View2DEdgePanData {
|
2021-06-16 18:17:07 +01:00
|
|
|
/** Screen where view pan was initiated. */
|
2023-08-04 22:47:22 -04:00
|
|
|
bScreen *screen;
|
2021-06-16 18:17:07 +01:00
|
|
|
/** Area where view pan was initiated. */
|
2023-08-04 22:47:22 -04:00
|
|
|
ScrArea *area;
|
2021-06-16 18:17:07 +01:00
|
|
|
/** Region where view pan was initiated. */
|
2023-08-04 22:47:22 -04:00
|
|
|
ARegion *region;
|
2021-06-16 18:17:07 +01:00
|
|
|
/** View2d we're operating in. */
|
2023-08-04 22:47:22 -04:00
|
|
|
View2D *v2d;
|
2022-04-05 07:39:40 +10:00
|
|
|
/** Limit maximum pannable area. */
|
2022-04-04 14:25:13 +02:00
|
|
|
struct rctf limit;
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2021-10-26 13:42:19 +02:00
|
|
|
/** Panning should only start once being in the inside rect once (e.g. adding nodes can happen
|
|
|
|
|
* outside). */
|
|
|
|
|
bool enabled;
|
2021-06-16 18:17:07 +01:00
|
|
|
/** Inside distance in UI units from the edge of the region within which to start panning. */
|
|
|
|
|
float inside_pad;
|
|
|
|
|
/** Outside distance in UI units from the edge of the region at which to stop panning. */
|
|
|
|
|
float outside_pad;
|
|
|
|
|
/**
|
|
|
|
|
* Width of the zone in UI units where speed increases with distance from the edge.
|
|
|
|
|
* At the end of this zone max speed is reached.
|
|
|
|
|
*/
|
|
|
|
|
float speed_ramp;
|
|
|
|
|
/** Maximum speed in UI units per second. */
|
|
|
|
|
float max_speed;
|
|
|
|
|
/** Delay in seconds before maximum speed is reached. */
|
|
|
|
|
float delay;
|
2023-05-27 15:10:58 +10:00
|
|
|
/**
|
|
|
|
|
* Influence factor for view zoom:
|
|
|
|
|
* - 0 = Constant speed in UI units.
|
|
|
|
|
* - 1 = Constant speed in view space, UI speed slows down when zooming out.
|
2021-08-24 17:45:40 +01:00
|
|
|
*/
|
|
|
|
|
float zoom_influence;
|
|
|
|
|
|
|
|
|
|
/** Initial view rect. */
|
|
|
|
|
rctf initial_rect;
|
2021-06-16 18:17:07 +01:00
|
|
|
|
|
|
|
|
/** Amount to move view relative to zoom. */
|
|
|
|
|
float facx, facy;
|
|
|
|
|
|
|
|
|
|
/* Timers. */
|
|
|
|
|
double edge_pan_last_time;
|
|
|
|
|
double edge_pan_start_time_x, edge_pan_start_time_y;
|
2023-08-04 22:15:25 -04:00
|
|
|
};
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_init(bContext *C,
|
|
|
|
|
View2DEdgePanData *vpd,
|
2021-06-16 18:17:07 +01:00
|
|
|
float inside_pad,
|
|
|
|
|
float outside_pad,
|
|
|
|
|
float speed_ramp,
|
|
|
|
|
float max_speed,
|
2021-08-24 17:45:40 +01:00
|
|
|
float delay,
|
|
|
|
|
float zoom_influence);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2022-04-04 14:25:13 +02:00
|
|
|
/**
|
|
|
|
|
* Set area which can be panned
|
|
|
|
|
*/
|
|
|
|
|
void UI_view2d_edge_pan_set_limits(
|
2023-08-04 22:15:25 -04:00
|
|
|
View2DEdgePanData *vpd, float xmin, float xmax, float ymin, float ymax);
|
2022-04-04 14:25:13 +02:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_reset(View2DEdgePanData *vpd);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Apply transform to view (i.e. adjust 'cur' rect).
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[2])
|
2021-10-20 20:49:02 -03:00
|
|
|
ATTR_NONNULL(1, 2, 3);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Apply transform to view using mouse events.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_apply_event(bContext *C, View2DEdgePanData *vpd, const wmEvent *event);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_cancel(bContext *C, View2DEdgePanData *vpd);
|
2021-08-24 17:45:40 +01:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_operator_properties(wmOperatorType *ot);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_operator_properties_ex(wmOperatorType *ot,
|
2021-06-16 18:17:07 +01:00
|
|
|
float inside_pad,
|
|
|
|
|
float outside_pad,
|
|
|
|
|
float speed_ramp,
|
|
|
|
|
float max_speed,
|
2021-08-24 17:45:40 +01:00
|
|
|
float delay,
|
|
|
|
|
float zoom_influence);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Initialize panning data with operator settings.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void UI_view2d_edge_pan_operator_init(bContext *C, View2DEdgePanData *vpd, wmOperator *op);
|
2021-06-16 18:17:07 +01:00
|
|
|
|
2022-10-07 16:05:17 +11:00
|
|
|
/** \} */
|