2011-02-23 10:52:22 +00: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
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
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
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup edinterface
|
2011-02-27 20:29:51 +00: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
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "DNA_color_types.h"
|
2020-06-24 11:50:01 -04:00
|
|
|
#include "DNA_curve_types.h"
|
2019-11-20 16:12:32 -05:00
|
|
|
#include "DNA_curveprofile_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_movieclip_types.h"
|
|
|
|
#include "DNA_screen_types.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
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_polyfill_2d.h"
|
2010-10-25 18:12:28 +00:00
|
|
|
#include "BLI_rect.h"
|
2011-09-26 16:53:04 +00:00
|
|
|
#include "BLI_string.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2019-11-20 16:12:32 -05:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.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
|
|
|
|
2017-12-07 15:36:26 +11:00
|
|
|
#include "BKE_colorband.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 "BKE_colortools.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_curveprofile.h"
|
2013-03-18 16:34:57 +00:00
|
|
|
#include "BKE_node.h"
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
#include "BKE_tracking.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_colormanagement.h"
|
2009-11-23 13:58:55 +00:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.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 "BIF_glutil.h"
|
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
#include "GPU_batch.h"
|
2018-07-15 10:34:31 +02:00
|
|
|
#include "GPU_batch_presets.h"
|
2016-08-11 01:06:17 -04:00
|
|
|
#include "GPU_immediate.h"
|
2017-04-05 18:30:14 +10:00
|
|
|
#include "GPU_immediate_util.h"
|
2017-02-07 00:24:44 +01:00
|
|
|
#include "GPU_matrix.h"
|
2022-01-12 11:28:07 +01:00
|
|
|
#include "GPU_shader_shared.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
2015-11-27 21:08:48 +01: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
|
|
|
#include "UI_interface.h"
|
|
|
|
|
2010-09-15 12:18:50 +00:00
|
|
|
/* own include */
|
2008-12-26 13:11:04 +00:00
|
|
|
#include "interface_intern.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
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
static int roundboxtype = UI_CNR_ALL;
|
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-11-09 21:20:40 +01:00
|
|
|
void UI_draw_roundbox_corner_set(int type)
|
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
|
|
|
{
|
|
|
|
/* Not sure the roundbox function is the best place to change this
|
2021-06-24 15:56:58 +10:00
|
|
|
* if this is undone, it's not that big a deal, only makes curves edges square. */
|
2012-03-30 01:51:25 +00:00
|
|
|
roundboxtype = type;
|
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
|
|
|
}
|
|
|
|
|
2017-04-06 19:15:26 -04:00
|
|
|
#if 0 /* unused */
|
2014-11-09 21:20:40 +01:00
|
|
|
int UI_draw_roundbox_corner_get(void)
|
2009-03-08 17:12:59 +00:00
|
|
|
{
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
return roundboxtype;
|
2009-03-08 17:12:59 +00:00
|
|
|
}
|
2017-04-06 19:15:26 -04:00
|
|
|
#endif
|
2009-03-08 17:12:59 +00:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
void UI_draw_roundbox_4fv_ex(const rctf *rect,
|
2021-01-23 13:10:07 -08:00
|
|
|
const float inner1[4],
|
|
|
|
const float inner2[4],
|
|
|
|
float shade_dir,
|
2021-01-25 18:02:55 +11:00
|
|
|
const float outline[4],
|
2021-01-23 13:10:07 -08:00
|
|
|
float outline_width,
|
|
|
|
float rad)
|
|
|
|
{
|
|
|
|
/* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space.
|
|
|
|
* If it has been scaled, then it's no longer valid. */
|
|
|
|
uiWidgetBaseParameters widget_params = {
|
2021-01-25 18:31:11 +11:00
|
|
|
.recti.xmin = rect->xmin + outline_width,
|
|
|
|
.recti.ymin = rect->ymin + outline_width,
|
|
|
|
.recti.xmax = rect->xmax - outline_width,
|
|
|
|
.recti.ymax = rect->ymax - outline_width,
|
|
|
|
.rect = *rect,
|
2021-01-23 13:10:07 -08:00
|
|
|
.radi = rad,
|
|
|
|
.rad = rad,
|
|
|
|
.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
|
|
|
|
.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
|
|
|
|
.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
|
|
|
|
.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f,
|
|
|
|
.color_inner1[0] = inner1 ? inner1[0] : 0.0f,
|
|
|
|
.color_inner1[1] = inner1 ? inner1[1] : 0.0f,
|
|
|
|
.color_inner1[2] = inner1 ? inner1[2] : 0.0f,
|
|
|
|
.color_inner1[3] = inner1 ? inner1[3] : 0.0f,
|
2021-07-30 16:19:19 +10:00
|
|
|
.color_inner2[0] = inner2 ? inner2[0] :
|
|
|
|
inner1 ? inner1[0] :
|
|
|
|
0.0f,
|
|
|
|
.color_inner2[1] = inner2 ? inner2[1] :
|
|
|
|
inner1 ? inner1[1] :
|
|
|
|
0.0f,
|
|
|
|
.color_inner2[2] = inner2 ? inner2[2] :
|
|
|
|
inner1 ? inner1[2] :
|
|
|
|
0.0f,
|
|
|
|
.color_inner2[3] = inner2 ? inner2[3] :
|
|
|
|
inner1 ? inner1[3] :
|
|
|
|
0.0f,
|
|
|
|
.color_outline[0] = outline ? outline[0] :
|
|
|
|
inner1 ? inner1[0] :
|
|
|
|
0.0f,
|
|
|
|
.color_outline[1] = outline ? outline[1] :
|
|
|
|
inner1 ? inner1[1] :
|
|
|
|
0.0f,
|
|
|
|
.color_outline[2] = outline ? outline[2] :
|
|
|
|
inner1 ? inner1[2] :
|
|
|
|
0.0f,
|
|
|
|
.color_outline[3] = outline ? outline[3] :
|
|
|
|
inner1 ? inner1[3] :
|
|
|
|
0.0f,
|
2021-01-23 13:10:07 -08:00
|
|
|
.shade_dir = shade_dir,
|
|
|
|
.alpha_discard = 1.0f,
|
|
|
|
};
|
|
|
|
GPUBatch *batch = ui_batch_roundbox_widget_get();
|
|
|
|
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
|
2021-03-04 16:57:30 +11:00
|
|
|
GPU_batch_uniform_4fv_array(batch, "parameters", 11, (const float(*)[4]) & widget_params);
|
2021-01-23 13:10:07 -08:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
|
|
|
GPU_batch_draw(batch);
|
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
|
|
|
}
|
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
void UI_draw_roundbox_3ub_alpha(
|
|
|
|
const rctf *rect, bool filled, float rad, const uchar col[3], uchar alpha)
|
2016-10-07 14:56:08 -04:00
|
|
|
{
|
2021-01-25 18:02:55 +11:00
|
|
|
float colv[4] = {
|
|
|
|
((float)col[0]) / 255,
|
|
|
|
((float)col[1]) / 255,
|
|
|
|
((float)col[2]) / 255,
|
|
|
|
((float)alpha) / 255,
|
|
|
|
};
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
|
2016-10-07 14:56:08 -04:00
|
|
|
}
|
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
void UI_draw_roundbox_3fv_alpha(
|
|
|
|
const rctf *rect, bool filled, float rad, const float col[3], float alpha)
|
2016-10-07 14:56:08 -04:00
|
|
|
{
|
2021-01-25 18:02:55 +11:00
|
|
|
float colv[4] = {col[0], col[1], col[2], alpha};
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
|
2016-10-07 14:56:08 -04:00
|
|
|
}
|
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
void UI_draw_roundbox_aa(const rctf *rect, bool filled, float rad, const float color[4])
|
2018-04-05 18:51:08 +02:00
|
|
|
{
|
2020-06-22 19:57:53 +02:00
|
|
|
/* XXX this is to emulate previous behavior of semitransparent fills but that's was a side effect
|
|
|
|
* of the previous AA method. Better fix the callers. */
|
2021-01-25 18:02:55 +11:00
|
|
|
float colv[4] = {color[0], color[1], color[2], color[3]};
|
2018-04-05 18:51:08 +02:00
|
|
|
if (filled) {
|
2021-01-25 18:02:55 +11:00
|
|
|
colv[3] *= 0.65f;
|
2018-04-05 18:51:08 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
|
2018-04-05 18:51:08 +02:00
|
|
|
}
|
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
void UI_draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
|
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
|
|
|
{
|
2020-06-22 19:57:53 +02:00
|
|
|
/* Exactly the same as UI_draw_roundbox_aa but does not do the legacy transparency. */
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_4fv_ex(rect, (filled) ? col : NULL, NULL, 1.0f, col, U.pixelsize, rad);
|
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
|
|
|
}
|
|
|
|
|
2017-02-06 16:54:26 +01:00
|
|
|
void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4])
|
2014-12-07 00:58:17 +01:00
|
|
|
{
|
2020-08-26 10:11:13 +10:00
|
|
|
const int ofs_y = 4 * U.pixelsize;
|
2017-02-06 16:54:26 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
2017-02-06 16:54:26 +01:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
immUniformColor4fv(color);
|
|
|
|
|
|
|
|
immRecti(pos, pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + (height * U.pixelsize));
|
|
|
|
immUnbindProgram();
|
2014-12-07 00:58:17 +01:00
|
|
|
}
|
|
|
|
|
2009-11-23 13:58:55 +00:00
|
|
|
/* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */
|
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-01-04 11:05:53 +11:00
|
|
|
void ui_draw_but_TAB_outline(const rcti *rect,
|
|
|
|
float rad,
|
|
|
|
uchar highlight[3],
|
|
|
|
uchar highlight_fade[3])
|
2017-03-17 17:08:20 +01:00
|
|
|
{
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
const uint col = GPU_vertformat_attr_add(
|
|
|
|
format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
2017-03-17 17:08:20 +01:00
|
|
|
/* add a 1px offset, looks nicer */
|
|
|
|
const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize;
|
|
|
|
const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize;
|
|
|
|
int a;
|
|
|
|
float vec[4][2] = {
|
2018-07-01 20:15:21 +02:00
|
|
|
{0.195, 0.02},
|
|
|
|
{0.55, 0.169},
|
|
|
|
{0.831, 0.45},
|
|
|
|
{0.98, 0.805},
|
2017-03-17 17:08:20 +01:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-07 12:55:19 +10:00
|
|
|
/* Multiply. */
|
2017-03-17 17:08:20 +01:00
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
mul_v2_fl(vec[a], rad);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBeginAtMost(GPU_PRIM_LINE_STRIP, 25);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3ubv(col, highlight);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
/* start with corner left-top */
|
|
|
|
if (roundboxtype & UI_CNR_TOP_LEFT) {
|
|
|
|
immVertex2f(pos, minx, maxy - rad);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
immVertex2f(pos, minx + vec[a][1], maxy - rad + vec[a][0]);
|
|
|
|
}
|
|
|
|
immVertex2f(pos, minx + rad, maxy);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
immVertex2f(pos, minx, maxy);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
/* corner right-top */
|
|
|
|
if (roundboxtype & UI_CNR_TOP_RIGHT) {
|
|
|
|
immVertex2f(pos, maxx - rad, maxy);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
immVertex2f(pos, maxx - rad + vec[a][0], maxy - vec[a][1]);
|
|
|
|
}
|
|
|
|
immVertex2f(pos, maxx, maxy - rad);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
immVertex2f(pos, maxx, maxy);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3ubv(col, highlight_fade);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
/* corner right-bottom */
|
|
|
|
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
|
|
|
|
immVertex2f(pos, maxx, miny + rad);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
immVertex2f(pos, maxx - vec[a][1], miny + rad - vec[a][0]);
|
|
|
|
}
|
|
|
|
immVertex2f(pos, maxx - rad, miny);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
immVertex2f(pos, maxx, miny);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
/* corner left-bottom */
|
|
|
|
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
|
|
|
|
immVertex2f(pos, minx + rad, miny);
|
|
|
|
for (a = 0; a < 4; a++) {
|
|
|
|
immVertex2f(pos, minx + rad - vec[a][0], miny + vec[a][1]);
|
|
|
|
}
|
|
|
|
immVertex2f(pos, minx, miny + rad);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
immVertex2f(pos, minx, miny);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr3ubv(col, highlight);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
/* back to corner left-top */
|
2018-12-01 19:55:37 +11:00
|
|
|
immVertex2f(pos, minx, (roundboxtype & UI_CNR_TOP_LEFT) ? (maxy - rad) : maxy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-03-17 17:08:20 +01:00
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_IMAGE(ARegion *UNUSED(region),
|
2019-01-04 09:58:03 +11:00
|
|
|
uiBut *but,
|
|
|
|
const uiWidgetColors *UNUSED(wcol),
|
|
|
|
const rcti *rect)
|
2009-11-23 13:58:55 +00:00
|
|
|
{
|
2011-06-05 07:55:18 +00:00
|
|
|
#ifdef WITH_HEADLESS
|
|
|
|
(void)rect;
|
2011-09-30 07:47:45 +00:00
|
|
|
(void)but;
|
2011-06-05 07:55:18 +00:00
|
|
|
#else
|
2012-03-30 01:51:25 +00:00
|
|
|
ImBuf *ibuf = (ImBuf *)but->poin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (!ibuf) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const int w = BLI_rcti_size_x(rect);
|
|
|
|
const int h = BLI_rcti_size_y(rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
/* scissor doesn't seem to be doing the right thing...? */
|
|
|
|
# if 0
|
2012-07-07 22:51:57 +00:00
|
|
|
/* prevent drawing outside widget area */
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_scissor(rect->xmin, rect->ymin, w, h);
|
2012-03-03 16:31:46 +00:00
|
|
|
# endif
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-14 11:05:09 -07:00
|
|
|
/* Combine with premultiplied alpha. */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
if (w != ibuf->x || h != ibuf->y) {
|
2020-03-14 11:05:09 -07:00
|
|
|
/* We scale the bitmap, rather than have OGL do a worse job. */
|
|
|
|
IMB_scaleImBuf(ibuf, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
float col[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
|
|
|
if (but->col[3] != 0) {
|
|
|
|
/* Optionally use uiBut's col to recolor the image. */
|
|
|
|
rgba_uchar_to_float(col, but->col);
|
Holiday coding log :)
Nice formatted version (pictures soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Usability
Short list of main changes:
- Transparent region option (over main region), added code to blend in/out such panels.
- Min size window now 640 x 480
- Fixed DPI for ui - lots of cleanup and changes everywhere. Icon image need correct size still, layer-in-use icon needs remake.
- Macbook retina support, use command line --no-native-pixels to disable it
- Timeline Marker label was drawing wrong
- Trackpad and magic mouse: supports zoom (hold ctrl)
- Fix for splash position: removed ghost function and made window size update after creation immediate
- Fast undo buffer save now adds UI as well. Could be checked for regular file save even...
Quit.blend and temp file saving use this now.
- Dixed filename in window on reading quit.blend or temp saves, and they now add a warning in window title: "(Recovered)"
- New Userpref option "Keep Session" - this always saves quit.blend, and loads on start.
This allows keeping UI and data without actual saves, until you actually save.
When you load startup.blend and quit, it recognises the quit.blend as a startup (no file name in header)
- Added 3D view copy/paste buffers (selected objects). Shortcuts ctrl-c, ctrl-v (OSX, cmd-c, cmd-v).
Coded partial file saving for it. Could be used for other purposes. Todo: use OS clipboards.
- User preferences (themes, keymaps, user settings) now can be saved as a separate file.
Old option is called "Save Startup File" the new one "Save User Settings".
To visualise this difference, the 'save startup file' button has been removed from user preferences window. That option is available as CTRL+U and in File menu still.
- OSX: fixed bug that stopped giving mouse events outside window.
This also fixes "Continuous Grab" for OSX. (error since 2009)
2012-12-12 18:58:11 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-11 16:30:00 +02:00
|
|
|
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
2018-07-01 20:15:21 +02:00
|
|
|
immDrawPixelsTex(&state,
|
|
|
|
(float)rect->xmin,
|
|
|
|
(float)rect->ymin,
|
|
|
|
ibuf->x,
|
|
|
|
ibuf->y,
|
2020-07-26 19:50:15 +02:00
|
|
|
GPU_RGBA8,
|
|
|
|
false,
|
2018-07-01 20:15:21 +02:00
|
|
|
ibuf->rect,
|
2020-03-14 11:05:09 -07:00
|
|
|
1.0f,
|
|
|
|
1.0f,
|
|
|
|
col);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
# if 0
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Restore scissor-test. */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
2012-03-03 16:31:46 +00:00
|
|
|
# endif
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2011-06-05 07:55:18 +00:00
|
|
|
#endif
|
2009-11-23 13:58:55 +00: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
|
|
|
|
2015-01-19 16:30:35 +11:00
|
|
|
void UI_draw_safe_areas(uint pos,
|
2021-01-25 18:31:11 +11:00
|
|
|
const rctf *rect,
|
2015-01-19 16:30:35 +11:00
|
|
|
const float title_aspect[2],
|
|
|
|
const float action_aspect[2])
|
|
|
|
{
|
2021-01-25 18:31:11 +11:00
|
|
|
const float size_x_half = (rect->xmax - rect->xmin) * 0.5f;
|
|
|
|
const float size_y_half = (rect->ymax - rect->ymin) * 0.5f;
|
2015-01-19 16:30:35 +11:00
|
|
|
|
|
|
|
const float *safe_areas[] = {title_aspect, action_aspect};
|
2016-12-14 02:43:26 -05:00
|
|
|
const int safe_len = ARRAY_SIZE(safe_areas);
|
2015-01-19 16:30:35 +11:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 0; i < safe_len; i++) {
|
2015-01-19 16:30:35 +11:00
|
|
|
if (safe_areas[i][0] || safe_areas[i][1]) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float margin_x = safe_areas[i][0] * size_x_half;
|
|
|
|
const float margin_y = safe_areas[i][1] * size_y_half;
|
2015-01-19 16:30:35 +11:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
const float minx = rect->xmin + margin_x;
|
|
|
|
const float miny = rect->ymin + margin_y;
|
|
|
|
const float maxx = rect->xmax - margin_x;
|
|
|
|
const float maxy = rect->ymax - margin_y;
|
2015-01-19 16:30:35 +11:00
|
|
|
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(pos, minx, miny, maxx, maxy);
|
2015-01-19 16:30:35 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-16 01:49:52 +02:00
|
|
|
static void draw_scope_end(const rctf *rect)
|
2010-04-09 00:44:35 +00:00
|
|
|
{
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2014-04-02 13:09:43 +02:00
|
|
|
|
2010-04-09 00:44:35 +00:00
|
|
|
/* outline */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2020-08-07 22:36:11 +10:00
|
|
|
const float color[4] = {0.0f, 0.0f, 0.0f, 0.5f};
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect->xmin - 1,
|
|
|
|
.xmax = rect->xmax + 1,
|
|
|
|
.ymin = rect->ymin,
|
|
|
|
.ymax = rect->ymax + 1,
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2010-04-09 00:44:35 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 03:13:47 +10:00
|
|
|
static void histogram_draw_one(float r,
|
|
|
|
float g,
|
|
|
|
float b,
|
|
|
|
float alpha,
|
2017-02-06 16:54:26 +01:00
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
float w,
|
|
|
|
float h,
|
|
|
|
const float *data,
|
|
|
|
int res,
|
|
|
|
const bool is_line,
|
2019-01-29 07:46:25 +11:00
|
|
|
uint pos_attr)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2020-08-07 22:36:11 +10:00
|
|
|
const float color[4] = {r, g, b, alpha};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-10 17:36:32 +01:00
|
|
|
/* that can happen */
|
2019-03-25 10:15:20 +11:00
|
|
|
if (res == 0) {
|
2017-02-10 17:36:32 +01:00
|
|
|
return;
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ADDITIVE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-06 16:54:26 +01:00
|
|
|
immUniformColor4fv(color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-22 02:44:33 -05:00
|
|
|
if (is_line) {
|
2012-06-10 12:09:25 +00:00
|
|
|
/* curve outline */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.5);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, res);
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 0; i < res; i++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float x2 = x + i * (w / (float)res);
|
2019-01-29 07:46:25 +11:00
|
|
|
immVertex2f(pos_attr, x2, y + (data[i] * h));
|
2012-06-10 12:09:25 +00:00
|
|
|
}
|
2017-02-06 16:54:26 +01:00
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2012-06-10 12:09:25 +00:00
|
|
|
else {
|
|
|
|
/* under the curve */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_TRI_STRIP, res * 2);
|
2019-01-29 07:46:25 +11:00
|
|
|
immVertex2f(pos_attr, x, y);
|
|
|
|
immVertex2f(pos_attr, x, y + (data[0] * h));
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 1; i < res; i++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float x2 = x + i * (w / (float)res);
|
2019-01-29 07:46:25 +11:00
|
|
|
immVertex2f(pos_attr, x2, y + (data[i] * h));
|
|
|
|
immVertex2f(pos_attr, x2, y);
|
2012-06-10 12:09:25 +00:00
|
|
|
}
|
2017-02-06 16:54:26 +01:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 12:09:25 +00:00
|
|
|
/* curve outline */
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, res);
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 0; i < res; i++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float x2 = x + i * (w / (float)res);
|
2019-01-29 07:46:25 +11:00
|
|
|
immVertex2f(pos_attr, x2, y + (data[i] * h));
|
2012-06-10 12:09:25 +00:00
|
|
|
}
|
2017-02-06 16:54:26 +01:00
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2010-01-19 01:32:06 +00:00
|
|
|
|
2012-07-26 09:06:23 +00:00
|
|
|
#define HISTOGRAM_TOT_GRID_LINES 4
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region),
|
2019-01-04 09:58:03 +11:00
|
|
|
uiBut *but,
|
|
|
|
const uiWidgetColors *UNUSED(wcol),
|
|
|
|
const rcti *recti)
|
2010-01-19 01:32:06 +00:00
|
|
|
{
|
|
|
|
Histogram *hist = (Histogram *)but->poin;
|
2020-08-26 10:11:13 +10:00
|
|
|
const int res = hist->x_resolution;
|
2014-01-28 03:52:21 +11:00
|
|
|
const bool is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
rctf rect = {
|
|
|
|
.xmin = (float)recti->xmin + 1,
|
|
|
|
.xmax = (float)recti->xmax - 1,
|
|
|
|
.ymin = (float)recti->ymin + 1,
|
2019-01-07 00:06:58 +11:00
|
|
|
.ymax = (float)recti->ymax - 1,
|
2016-01-16 02:17:05 -05:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const float w = BLI_rctf_size_x(&rect);
|
|
|
|
const float h = BLI_rctf_size_y(&rect) * hist->ymax;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-07 14:56:08 -04:00
|
|
|
float color[4];
|
|
|
|
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect.xmin - 1,
|
|
|
|
.xmax = rect.xmax + 1,
|
|
|
|
.ymin = rect.ymin - 1,
|
|
|
|
.ymax = rect.ymax + 1,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-02 19:25:32 +00:00
|
|
|
/* need scissor test, histogram can draw outside of boundary */
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2018-07-01 20:15:21 +02:00
|
|
|
GPU_scissor((rect.xmin - 1),
|
|
|
|
(rect.ymin - 1),
|
|
|
|
(rect.xmax + 1) - (rect.xmin - 1),
|
|
|
|
(rect.ymax + 1) - (rect.ymin - 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-06 16:54:26 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
|
2010-01-19 01:32:06 +00:00
|
|
|
/* draw grid lines here */
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) {
|
2012-07-26 09:06:23 +00:00
|
|
|
const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-26 09:06:23 +00:00
|
|
|
/* so we can tell the 1.0 color point */
|
|
|
|
if (i == HISTOGRAM_TOT_GRID_LINES) {
|
2017-02-06 16:54:26 +01:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f);
|
2012-07-26 09:06:23 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin, rect.ymin + fac * h);
|
|
|
|
immVertex2f(pos, rect.xmax, rect.ymin + fac * h);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + fac * w, rect.ymin);
|
|
|
|
immVertex2f(pos, rect.xmin + fac * w, rect.ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 12:33:27 +00:00
|
|
|
if (hist->mode == HISTO_MODE_LUMA) {
|
2017-02-06 16:54:26 +01:00
|
|
|
histogram_draw_one(
|
|
|
|
1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res, is_line, pos);
|
2012-06-10 12:33:27 +00:00
|
|
|
}
|
|
|
|
else if (hist->mode == HISTO_MODE_ALPHA) {
|
2017-02-06 16:54:26 +01:00
|
|
|
histogram_draw_one(
|
|
|
|
1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_a, res, is_line, pos);
|
2012-06-10 12:33:27 +00:00
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
else {
|
2020-11-06 12:30:59 +11:00
|
|
|
if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_R)) {
|
2017-02-06 16:54:26 +01:00
|
|
|
histogram_draw_one(
|
|
|
|
1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res, is_line, pos);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2020-11-06 12:30:59 +11:00
|
|
|
if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_G)) {
|
2017-02-06 16:54:26 +01:00
|
|
|
histogram_draw_one(
|
|
|
|
0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res, is_line, pos);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2020-11-06 12:30:59 +11:00
|
|
|
if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_B)) {
|
2017-02-06 16:54:26 +01:00
|
|
|
histogram_draw_one(
|
|
|
|
0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line, pos);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-06 16:54:26 +01:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 01:49:52 +02:00
|
|
|
/* Restore scissor test. */
|
|
|
|
GPU_scissor(UNPACK4(scissor));
|
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
/* outline */
|
2020-08-16 01:49:52 +02:00
|
|
|
draw_scope_end(&rect);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 09:06:23 +00:00
|
|
|
#undef HISTOGRAM_TOT_GRID_LINES
|
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
static void waveform_draw_one(float *waveform, int nbr, const float col[3])
|
|
|
|
{
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat format = {0};
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-07 00:24:44 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
|
|
|
|
GPU_vertbuf_data_alloc(vbo, nbr);
|
2017-02-07 00:24:44 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_vertbuf_attr_fill(vbo, pos_id, waveform);
|
2017-02-07 00:24:44 +01:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: store the #GPUBatch inside the scope. */
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO);
|
|
|
|
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f);
|
|
|
|
GPU_batch_draw(batch);
|
2017-02-07 00:24:44 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_batch_discard(batch);
|
2017-02-07 00:24:44 +01:00
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
|
2019-01-04 09:58:03 +11:00
|
|
|
uiBut *but,
|
|
|
|
const uiWidgetColors *UNUSED(wcol),
|
|
|
|
const rcti *recti)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
|
|
|
Scopes *scopes = (Scopes *)but->poin;
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2014-06-26 16:09:59 +10:00
|
|
|
float colors[3][3];
|
2020-08-07 22:36:11 +10:00
|
|
|
const float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
|
2019-01-15 23:24:20 +11:00
|
|
|
/* colors pre multiplied by alpha for speed up */
|
|
|
|
float colors_alpha[3][3], colorsycc_alpha[3][3];
|
2010-04-06 02:05:54 +00:00
|
|
|
float min, max;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (scopes == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
rctf rect = {
|
|
|
|
.xmin = (float)recti->xmin + 1,
|
|
|
|
.xmax = (float)recti->xmax - 1,
|
|
|
|
.ymin = (float)recti->ymin + 1,
|
2019-01-07 00:06:58 +11:00
|
|
|
.ymax = (float)recti->ymax - 1,
|
2016-01-16 02:17:05 -05:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (scopes->wavefrm_yfac < 0.5f) {
|
2012-03-30 01:51:25 +00:00
|
|
|
scopes->wavefrm_yfac = 0.98f;
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2020-08-26 10:11:13 +10:00
|
|
|
const float w = BLI_rctf_size_x(&rect) - 7;
|
|
|
|
const float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
|
|
|
|
const float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) * 0.5f;
|
|
|
|
const float w3 = w / 3.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* log scale for alpha */
|
2020-08-26 10:11:13 +10:00
|
|
|
const float alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-06-26 16:09:59 +10:00
|
|
|
unit_m3(colors);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int c = 0; c < 3; c++) {
|
|
|
|
for (int i = 0; i < 3; i++) {
|
2010-04-06 02:05:54 +00:00
|
|
|
colors_alpha[c][i] = colors[c][i] * alpha;
|
|
|
|
colorsycc_alpha[c][i] = colorsycc[c][i] * alpha;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-07 14:03:32 +02:00
|
|
|
/* Flush text cache before changing scissors. */
|
|
|
|
BLF_batch_draw_flush();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-07 14:56:08 -04:00
|
|
|
float color[4];
|
|
|
|
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect.xmin - 1,
|
|
|
|
.xmax = rect.xmax + 1,
|
|
|
|
.ymin = rect.ymin - 1,
|
|
|
|
.ymax = rect.ymax + 1,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-09 00:44:35 +00:00
|
|
|
/* need scissor test, waveform can draw outside of boundary */
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2018-07-01 20:15:21 +02:00
|
|
|
GPU_scissor((rect.xmin - 1),
|
|
|
|
(rect.ymin - 1),
|
|
|
|
(rect.xmax + 1) - (rect.xmin - 1),
|
|
|
|
(rect.ymax + 1) - (rect.ymin - 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
/* draw scale numbers first before binding any shader */
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2010-04-06 02:05:54 +00:00
|
|
|
char str[4];
|
2012-03-30 01:51:25 +00:00
|
|
|
BLI_snprintf(str, sizeof(str), "%-3d", i * 20);
|
|
|
|
str[3] = '\0';
|
2017-02-08 01:43:53 -05:00
|
|
|
BLF_color4f(BLF_default(), 1.0f, 1.0f, 1.0f, 0.08f);
|
|
|
|
BLF_draw_default(rect.xmin + 1, yofs - 5 + (i * 0.2f) * h, 0, str, sizeof(str) - 1);
|
2017-02-07 00:24:44 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-07 14:03:32 +02:00
|
|
|
/* Flush text cache before drawing things on top. */
|
|
|
|
BLF_batch_draw_flush();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
/* draw grid lines here */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 12);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h);
|
|
|
|
immVertex2f(pos, rect.xmax + 1, yofs + (i * 0.2f) * h);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* 3 vertical separation */
|
2012-03-30 01:51:25 +00:00
|
|
|
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 1; i < 3; i++) {
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + i * w3, rect.ymin);
|
|
|
|
immVertex2f(pos, rect.xmin + i * w3, rect.ymax);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* separate min max zone on the right */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + w, rect.ymin);
|
|
|
|
immVertex2f(pos, rect.xmin + w, rect.ymax);
|
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* 16-235-240 level in case of ITU-R BT601/709 */
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 8);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f);
|
|
|
|
immVertex2f(pos, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + 22, yofs + h * 235.0f / 255.0f);
|
|
|
|
immVertex2f(pos, rect.xmin + w3, yofs + h * 235.0f / 255.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f);
|
|
|
|
immVertex2f(pos, rect.xmax + 1, yofs + h * 235.0f / 255.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + w3, yofs + h * 240.0f / 255.0f);
|
|
|
|
immVertex2f(pos, rect.xmax + 1, yofs + h * 240.0f / 255.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2010-04-09 00:44:35 +00:00
|
|
|
/* 7.5 IRE black point level for NTSC */
|
2017-02-23 02:52:36 -03:00
|
|
|
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin, yofs + h * 0.075f);
|
|
|
|
immVertex2f(pos, rect.xmax + 1, yofs + h * 0.075f);
|
|
|
|
immEnd();
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-10 01:46:44 +00:00
|
|
|
if (scopes->ok && scopes->waveform_1 != NULL) {
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ADDITIVE);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_point_size(1.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
/* LUMA (1 channel) */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float col[3] = {alpha, alpha, alpha};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_translate_2f(rect.xmin, yofs);
|
|
|
|
GPU_matrix_scale_2f(w, h);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-10 01:46:44 +00:00
|
|
|
/* min max */
|
2017-02-07 00:24:44 +01:00
|
|
|
immUniformColor3f(0.5f, 0.5f, 0.5f);
|
2012-03-30 01:51:25 +00:00
|
|
|
min = yofs + scopes->minmax[0][0] * h;
|
|
|
|
max = yofs + scopes->minmax[0][1] * h;
|
2010-04-09 00:44:35 +00:00
|
|
|
CLAMP(min, rect.ymin, rect.ymax);
|
|
|
|
CLAMP(max, rect.ymin, rect.ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmax - 3, min);
|
|
|
|
immVertex2f(pos, rect.xmax - 3, max);
|
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2016-07-18 15:28:56 +02:00
|
|
|
/* RGB (3 channel) */
|
|
|
|
else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_translate_2f(rect.xmin, yofs);
|
|
|
|
GPU_matrix_scale_2f(w, h);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]);
|
|
|
|
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]);
|
|
|
|
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, colors_alpha[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2016-07-18 15:28:56 +02:00
|
|
|
}
|
|
|
|
/* PARADE / YCC (3 channels) */
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (ELEM(scopes->wavefrm_mode,
|
2016-07-18 15:28:56 +02:00
|
|
|
SCOPES_WAVEFRM_RGB_PARADE,
|
2014-07-20 01:30:29 +10:00
|
|
|
SCOPES_WAVEFRM_YCC_601,
|
|
|
|
SCOPES_WAVEFRM_YCC_709,
|
2016-07-18 15:28:56 +02:00
|
|
|
SCOPES_WAVEFRM_YCC_JPEG)) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_translate_2f(rect.xmin, yofs);
|
|
|
|
GPU_matrix_scale_2f(w3, h);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
waveform_draw_one(
|
|
|
|
scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_translate_2f(1.0f, 0.0f);
|
2017-02-07 00:24:44 +01:00
|
|
|
waveform_draw_one(
|
|
|
|
scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_translate_2f(1.0f, 0.0f);
|
2017-02-07 00:24:44 +01:00
|
|
|
waveform_draw_one(
|
|
|
|
scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2016-07-18 15:28:56 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-07-18 15:28:56 +02:00
|
|
|
/* min max */
|
|
|
|
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int c = 0; c < 3; c++) {
|
2019-03-25 10:15:20 +11:00
|
|
|
if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB_PARADE, SCOPES_WAVEFRM_RGB)) {
|
2017-02-07 00:24:44 +01:00
|
|
|
immUniformColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-02-07 00:24:44 +01:00
|
|
|
immUniformColor3f(
|
|
|
|
colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
min = yofs + scopes->minmax[c][0] * h;
|
|
|
|
max = yofs + scopes->minmax[c][1] * h;
|
2010-05-10 01:46:44 +00:00
|
|
|
CLAMP(min, rect.ymin, rect.ymax);
|
|
|
|
CLAMP(max, rect.ymin, rect.ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, rect.xmin + w + 2 + c * 2, min);
|
|
|
|
immVertex2f(pos, rect.xmin + w + 2 + c * 2, max);
|
|
|
|
immEnd();
|
2010-05-10 01:46:44 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 01:49:52 +02:00
|
|
|
/* Restore scissor test. */
|
|
|
|
GPU_scissor(UNPACK4(scissor));
|
|
|
|
|
2014-04-02 13:09:43 +02:00
|
|
|
/* outline */
|
2020-08-16 01:49:52 +02:00
|
|
|
draw_scope_end(&rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static float polar_to_x(float center, float diam, float ampli, float angle)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2014-04-20 22:05:05 +10:00
|
|
|
return center + diam * ampli * cosf(angle);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
static float polar_to_y(float center, float diam, float ampli, float angle)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2014-04-20 22:05:05 +10:00
|
|
|
return center + diam * ampli * sinf(angle);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 11:05:53 +11:00
|
|
|
static void vectorscope_draw_target(
|
|
|
|
uint pos, float centerx, float centery, float diam, const float colf[3])
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
float y, u, v;
|
2017-02-08 01:43:53 -05:00
|
|
|
float tangle = 0.0f, tampli;
|
2010-04-06 02:05:54 +00:00
|
|
|
float dangle, dampli, dangle2, dampli2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-29 18:00:45 -04:00
|
|
|
rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v, BLI_YUV_ITU_BT709);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (u > 0 && v >= 0) {
|
|
|
|
tangle = atanf(v / u);
|
|
|
|
}
|
|
|
|
else if (u > 0 && v < 0) {
|
|
|
|
tangle = atanf(v / u) + 2.0f * (float)M_PI;
|
|
|
|
}
|
|
|
|
else if (u < 0) {
|
|
|
|
tangle = atanf(v / u) + (float)M_PI;
|
|
|
|
}
|
|
|
|
else if (u == 0 && v > 0.0f) {
|
|
|
|
tangle = M_PI_2;
|
|
|
|
}
|
|
|
|
else if (u == 0 && v < 0.0f) {
|
|
|
|
tangle = -M_PI_2;
|
|
|
|
}
|
2012-03-30 01:51:25 +00:00
|
|
|
tampli = sqrtf(u * u + v * v);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* small target vary by 2.5 degree and 2.5 IRE unit */
|
2017-02-07 00:24:44 +01:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f);
|
2012-03-30 01:51:25 +00:00
|
|
|
dangle = DEG2RADF(2.5f);
|
|
|
|
dampli = 2.5f / 200.0f;
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_LOOP, 4);
|
2017-02-07 00:24:44 +01:00
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli, tangle + dangle),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos,
|
2017-02-07 00:24:44 +01:00
|
|
|
polar_to_x(centerx, diam, tampli - dampli, tangle + dangle),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos,
|
2017-02-07 00:24:44 +01:00
|
|
|
polar_to_x(centerx, diam, tampli - dampli, tangle - dangle),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli, tangle - dangle),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
|
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
/* big target vary by 10 degree and 20% amplitude */
|
2017-02-07 00:24:44 +01:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f);
|
2012-03-30 01:51:25 +00:00
|
|
|
dangle = DEG2RADF(10.0f);
|
|
|
|
dampli = 0.2f * tampli;
|
|
|
|
dangle2 = DEG2RADF(5.0f);
|
|
|
|
dampli2 = 0.5f * dampli;
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
2017-02-07 00:24:44 +01:00
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli, tangle + dangle),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2));
|
|
|
|
immEnd();
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
2017-02-07 00:24:44 +01:00
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli - dampli, tangle + dangle),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2));
|
|
|
|
immEnd();
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
2017-02-07 00:24:44 +01:00
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli - dampli, tangle - dangle),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2),
|
|
|
|
polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2));
|
|
|
|
immEnd();
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
2017-02-07 00:24:44 +01:00
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli, tangle - dangle),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
|
|
|
|
immVertex2f(pos,
|
|
|
|
polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2),
|
|
|
|
polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2));
|
|
|
|
immEnd();
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
|
2019-01-04 09:58:03 +11:00
|
|
|
uiBut *but,
|
|
|
|
const uiWidgetColors *UNUSED(wcol),
|
|
|
|
const rcti *recti)
|
2010-04-06 02:05:54 +00:00
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
const float skin_rad = DEG2RADF(123.0f); /* angle in radians of the skin tone line */
|
2010-04-06 02:05:54 +00:00
|
|
|
Scopes *scopes = (Scopes *)but->poin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-18 17:17:32 +02:00
|
|
|
const float colors[6][3] = {
|
|
|
|
{0.75, 0.0, 0.0},
|
|
|
|
{0.75, 0.75, 0.0},
|
|
|
|
{0.0, 0.75, 0.0},
|
|
|
|
{0.0, 0.75, 0.75},
|
|
|
|
{0.0, 0.0, 0.75},
|
|
|
|
{0.75, 0.0, 0.75},
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
rctf rect = {
|
|
|
|
.xmin = (float)recti->xmin + 1,
|
|
|
|
.xmax = (float)recti->xmax - 1,
|
|
|
|
.ymin = (float)recti->ymin + 1,
|
2019-01-07 00:06:58 +11:00
|
|
|
.ymax = (float)recti->ymax - 1,
|
2016-01-16 02:17:05 -05:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const float w = BLI_rctf_size_x(&rect);
|
|
|
|
const float h = BLI_rctf_size_y(&rect);
|
|
|
|
const float centerx = rect.xmin + w * 0.5f;
|
|
|
|
const float centery = rect.ymin + h * 0.5f;
|
|
|
|
const float diam = (w < h) ? w : h;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-10-07 14:56:08 -04:00
|
|
|
float color[4];
|
|
|
|
UI_GetThemeColor4fv(TH_PREVIEW_BACK, color);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect.xmin - 1,
|
|
|
|
.xmax = rect.xmax + 1,
|
|
|
|
.ymin = rect.ymin - 1,
|
|
|
|
.ymax = rect.ymax + 1,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* need scissor test, hvectorscope can draw outside of boundary */
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2018-07-01 20:15:21 +02:00
|
|
|
GPU_scissor((rect.xmin - 1),
|
|
|
|
(rect.ymin - 1),
|
|
|
|
(rect.xmax + 1) - (rect.xmin - 1),
|
|
|
|
(rect.ymax + 1) - (rect.ymin - 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f);
|
2010-04-06 02:05:54 +00:00
|
|
|
/* draw grid elements */
|
|
|
|
/* cross */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery);
|
|
|
|
immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(pos, centerx, centery - (diam * 0.5f) - 5);
|
|
|
|
immVertex2f(pos, centerx, centery + (diam * 0.5f) + 5);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* circles */
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int j = 0; j < 5; j++) {
|
2016-01-16 01:17:51 -05:00
|
|
|
const int increment = 15;
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_LOOP, (int)(360 / increment));
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int i = 0; i <= 360 - increment; i += increment) {
|
2012-03-30 01:51:25 +00:00
|
|
|
const float a = DEG2RADF((float)i);
|
2017-02-08 01:43:53 -05:00
|
|
|
const float r = (j + 1) * 0.1f;
|
2017-02-07 00:24:44 +01:00
|
|
|
immVertex2f(pos, polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a));
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
2017-02-07 00:24:44 +01:00
|
|
|
immEnd();
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
/* skin tone line */
|
2017-02-10 17:36:32 +01:00
|
|
|
immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-02-23 02:52:36 -03:00
|
|
|
immVertex2f(
|
|
|
|
pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad));
|
|
|
|
immVertex2f(
|
|
|
|
pos, polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad));
|
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
/* saturation points */
|
2019-03-25 10:15:20 +11:00
|
|
|
for (int i = 0; i < 6; i++) {
|
2017-02-07 00:24:44 +01:00
|
|
|
vectorscope_draw_target(pos, centerx, centery, diam, colors[i]);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-05-10 01:46:44 +00:00
|
|
|
if (scopes->ok && scopes->vecscope != NULL) {
|
|
|
|
/* pixel point cloud */
|
2020-08-07 22:36:11 +10:00
|
|
|
const float col[3] = {alpha, alpha, alpha};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ADDITIVE);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_point_size(1.0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_translate_2f(centerx, centery);
|
|
|
|
GPU_matrix_scale_1f(diam);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2010-05-06 19:54:43 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 00:24:44 +01:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 01:49:52 +02:00
|
|
|
/* Restore scissor test. */
|
|
|
|
GPU_scissor(UNPACK4(scissor));
|
2014-04-02 13:09:43 +02:00
|
|
|
/* outline */
|
2020-08-16 01:49:52 +02:00
|
|
|
draw_scope_end(&rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 11:05:53 +11:00
|
|
|
static void ui_draw_colorband_handle_tri_hlight(
|
|
|
|
uint pos, float x1, float y1, float halfwidth, float height)
|
2014-03-29 15:26:29 +11:00
|
|
|
{
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
2017-02-07 13:04:08 +01:00
|
|
|
immVertex2f(pos, x1 + halfwidth, y1);
|
|
|
|
immVertex2f(pos, x1, y1 + height);
|
|
|
|
immVertex2f(pos, x1 - halfwidth, y1);
|
|
|
|
immEnd();
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2014-03-29 15:26:29 +11:00
|
|
|
}
|
|
|
|
|
2019-01-04 11:05:53 +11:00
|
|
|
static void ui_draw_colorband_handle_tri(
|
|
|
|
uint pos, float x1, float y1, float halfwidth, float height, bool fill)
|
2014-03-29 15:26:29 +11:00
|
|
|
{
|
2019-03-23 23:43:26 +01:00
|
|
|
if (fill) {
|
|
|
|
GPU_polygon_smooth(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_line_smooth(true);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(fill ? GPU_PRIM_TRIS : GPU_PRIM_LINE_LOOP, 3);
|
2017-02-07 13:04:08 +01:00
|
|
|
immVertex2f(pos, x1 + halfwidth, y1);
|
|
|
|
immVertex2f(pos, x1, y1 + height);
|
|
|
|
immVertex2f(pos, x1 - halfwidth, y1);
|
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-23 23:43:26 +01:00
|
|
|
if (fill) {
|
|
|
|
GPU_polygon_smooth(false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GPU_line_smooth(false);
|
|
|
|
}
|
2014-03-29 15:26:29 +11:00
|
|
|
}
|
|
|
|
|
2019-01-04 11:05:53 +11:00
|
|
|
static void ui_draw_colorband_handle_box(
|
|
|
|
uint pos, float x1, float y1, float x2, float y2, bool fill)
|
2014-03-29 15:26:29 +11:00
|
|
|
{
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(fill ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4);
|
2017-02-07 13:04:08 +01:00
|
|
|
immVertex2f(pos, x1, y1);
|
|
|
|
immVertex2f(pos, x1, y2);
|
|
|
|
immVertex2f(pos, x2, y2);
|
|
|
|
immVertex2f(pos, x2, y1);
|
|
|
|
immEnd();
|
2014-03-29 15:26:29 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ui_draw_colorband_handle(uint shdr_pos,
|
2017-04-29 12:57:14 +02:00
|
|
|
const rcti *rect,
|
|
|
|
float x,
|
2014-03-29 15:26:29 +11:00
|
|
|
const float rgb[3],
|
|
|
|
struct ColorManagedDisplay *display,
|
|
|
|
bool active)
|
|
|
|
{
|
|
|
|
const float sizey = BLI_rcti_size_y(rect);
|
|
|
|
const float min_width = 3.0f;
|
|
|
|
float colf[3] = {UNPACK3(rgb)};
|
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const float half_width = floorf(sizey / 3.5f);
|
|
|
|
const float height = half_width * 1.4f;
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
float y1 = rect->ymin + (sizey * 0.16f);
|
2020-08-26 10:11:13 +10:00
|
|
|
const float y2 = rect->ymax;
|
2014-03-29 15:26:29 +11:00
|
|
|
|
|
|
|
/* align to pixels */
|
|
|
|
x = floorf(x + 0.5f);
|
|
|
|
y1 = floorf(y1 + 0.5f);
|
|
|
|
|
|
|
|
if (active || half_width < min_width) {
|
2017-04-29 12:57:14 +02:00
|
|
|
immUnbindProgram();
|
|
|
|
|
2017-07-13 16:44:02 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2017-04-29 12:57:14 +02:00
|
|
|
|
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2017-04-29 12:57:14 +02:00
|
|
|
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 2); /* "advanced" mode */
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniformArray4fv(
|
|
|
|
"colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2);
|
2017-04-29 12:57:14 +02:00
|
|
|
immUniform1f("dash_width", active ? 4.0f : 2.0f);
|
2019-06-21 08:24:58 +10:00
|
|
|
immUniform1f("dash_factor", 0.5f);
|
2017-02-07 13:04:08 +01:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x, y1);
|
|
|
|
immVertex2f(shdr_pos, x, y2);
|
2017-02-07 13:04:08 +01:00
|
|
|
immEnd();
|
2017-04-29 12:57:14 +02:00
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
|
|
|
/* hide handles when zoomed out too far */
|
|
|
|
if (half_width < min_width) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* shift handle down */
|
2016-01-16 02:17:05 -05:00
|
|
|
y1 -= half_width;
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(0, 0, 0);
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_box(
|
|
|
|
shdr_pos, x - half_width, y1 - 1, x + half_width, y1 + height, false);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
|
|
|
/* draw all triangles blended */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (active) {
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(196, 196, 196);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(96, 96, 96);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_tri(shdr_pos, x, y1 + height, half_width, half_width, true);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (active) {
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(255, 255, 255);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(128, 128, 128);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_tri_hlight(
|
|
|
|
shdr_pos, x, y1 + height - 1, (half_width - 1), (half_width - 1));
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(0, 0, 0);
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_tri_hlight(shdr_pos, x, y1 + height, half_width, half_width);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3ub(128, 128, 128);
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_box(
|
|
|
|
shdr_pos, x - (half_width - 1), y1, x + (half_width - 1), y1 + height, true);
|
2014-03-29 15:26:29 +11:00
|
|
|
|
|
|
|
if (display) {
|
|
|
|
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
|
|
|
}
|
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniformColor3fv(colf);
|
2017-04-29 12:57:14 +02:00
|
|
|
ui_draw_colorband_handle_box(
|
|
|
|
shdr_pos, x - (half_width - 2), y1 + 1, x + (half_width - 2), y1 + height - 2, true);
|
2014-03-29 15:26:29 +11:00
|
|
|
}
|
|
|
|
|
2019-01-04 09:58:03 +11:00
|
|
|
void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const rcti *rect)
|
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
|
|
|
{
|
2018-12-13 15:59:58 +01:00
|
|
|
struct ColorManagedDisplay *display = ui_block_cm_display_get(but->block);
|
2018-07-08 12:48:04 +02:00
|
|
|
uint pos_id, col_id;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-13 22:00:50 -04:00
|
|
|
uiButColorBand *but_coba = (uiButColorBand *)but;
|
|
|
|
ColorBand *coba = (but_coba->edit_coba == NULL) ? (ColorBand *)but->poin : but_coba->edit_coba;
|
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (coba == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const float x1 = rect->xmin;
|
|
|
|
const float sizex = rect->xmax - x1;
|
|
|
|
const float sizey = BLI_rcti_size_y(rect);
|
|
|
|
const float sizey_solid = sizey * 0.25f;
|
|
|
|
const float y1 = rect->ymin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-07-25 17:06:53 -03:00
|
|
|
/* exit early if too narrow */
|
|
|
|
if (sizex <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-07 13:04:08 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
/* Drawing the checkerboard. */
|
2019-05-01 10:46:37 +02:00
|
|
|
const float checker_dark = UI_ALPHA_CHECKER_DARK / 255.0f;
|
|
|
|
const float checker_light = UI_ALPHA_CHECKER_LIGHT / 255.0f;
|
|
|
|
immUniform4f("color1", checker_dark, checker_dark, checker_dark, 1.0f);
|
|
|
|
immUniform4f("color2", checker_light, checker_light, checker_light, 1.0f);
|
2017-02-07 13:04:08 +01:00
|
|
|
immUniform1i("size", 8);
|
2018-07-08 12:48:04 +02:00
|
|
|
immRectf(pos_id, x1, y1, x1 + sizex, rect->ymax);
|
2017-02-07 13:04:08 +01:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
/* New format */
|
|
|
|
format = immVertexFormat();
|
2018-07-18 00:12:21 +02:00
|
|
|
pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
2017-02-07 13:04:08 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
/* layer: color ramp */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
CBData *cbd = coba->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
float v1[2], v2[2];
|
|
|
|
float colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
v1[1] = y1 + sizey_solid;
|
|
|
|
v2[1] = rect->ymax;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int a = 0; a <= sizex; a++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float pos = ((float)a) / sizex;
|
2017-12-07 15:52:59 +11:00
|
|
|
BKE_colorband_evaluate(coba, pos, colf);
|
2019-03-25 10:15:20 +11:00
|
|
|
if (display) {
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
v1[0] = v2[0] = x1 + a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4fv(col_id, colf);
|
2018-07-08 12:48:04 +02:00
|
|
|
immVertex2fv(pos_id, v1);
|
|
|
|
immVertex2fv(pos_id, v2);
|
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
|
|
|
}
|
2017-02-07 13:04:08 +01:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
/* layer: color ramp without alpha for reference when manipulating ramp properties */
|
|
|
|
v1[1] = y1;
|
|
|
|
v2[1] = y1 + sizey_solid;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2);
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int a = 0; a <= sizex; a++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float pos = ((float)a) / sizex;
|
2017-12-07 15:52:59 +11:00
|
|
|
BKE_colorband_evaluate(coba, pos, colf);
|
2019-03-25 10:15:20 +11:00
|
|
|
if (display) {
|
2014-03-29 15:26:29 +11:00
|
|
|
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
v1[0] = v2[0] = x1 + a;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4f(col_id, colf[0], colf[1], colf[2], 1.0f);
|
2018-07-08 12:48:04 +02:00
|
|
|
immVertex2fv(pos_id, v1);
|
|
|
|
immVertex2fv(pos_id, v2);
|
2014-03-29 15:26:29 +11:00
|
|
|
}
|
2017-02-07 13:04:08 +01:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
/* New format */
|
|
|
|
format = immVertexFormat();
|
2018-07-18 00:12:21 +02:00
|
|
|
pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-07 13:04:08 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
/* layer: box outline */
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
2018-07-08 12:48:04 +02:00
|
|
|
imm_draw_box_wire_2d(pos_id, x1, y1, x1 + sizex, rect->ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
/* layer: box outline */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2018-07-08 12:48:04 +02:00
|
|
|
immVertex2f(pos_id, x1, y1);
|
|
|
|
immVertex2f(pos_id, x1 + sizex, y1);
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 01:43:53 -05:00
|
|
|
immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2018-07-08 12:48:04 +02:00
|
|
|
immVertex2f(pos_id, x1, y1 - 1);
|
|
|
|
immVertex2f(pos_id, x1 + sizex, y1 - 1);
|
2017-02-23 02:52:36 -03:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
/* layer: draw handles */
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int a = 0; a < coba->tot; a++, cbd++) {
|
2014-03-29 15:26:29 +11:00
|
|
|
if (a != coba->cur) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float pos = x1 + cbd->pos * (sizex - 1) + 1;
|
2018-07-08 12:48:04 +02:00
|
|
|
ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, false);
|
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-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2014-03-29 15:26:29 +11:00
|
|
|
/* layer: active handle */
|
2014-08-29 16:56:19 +10:00
|
|
|
if (coba->tot != 0) {
|
|
|
|
cbd = &coba->data[coba->cur];
|
2020-08-26 10:11:13 +10:00
|
|
|
const float pos = x1 + cbd->pos * (sizex - 1) + 1;
|
2018-07-08 12:48:04 +02:00
|
|
|
ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, true);
|
2017-02-07 13:04:08 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUnbindProgram();
|
|
|
|
}
|
|
|
|
|
2021-11-24 21:04:29 +01:00
|
|
|
void ui_draw_but_UNITVEC(uiBut *but,
|
|
|
|
const uiWidgetColors *wcol,
|
|
|
|
const rcti *rect,
|
|
|
|
const float radius)
|
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
|
|
|
{
|
2017-02-07 13:04:08 +01:00
|
|
|
/* sphere color */
|
2020-08-07 22:36:11 +10:00
|
|
|
const float diffuse[3] = {1.0f, 1.0f, 1.0f};
|
2017-02-07 13:04:08 +01:00
|
|
|
float light[3];
|
2020-02-04 22:17:01 +11:00
|
|
|
const float size = 0.5f * min_ff(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect));
|
2019-04-17 06:17:24 +02: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
|
|
|
/* backdrop */
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2020-02-15 10:45:46 +11:00
|
|
|
UI_draw_roundbox_3ub_alpha(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect->xmin,
|
|
|
|
.xmax = rect->xmax,
|
|
|
|
.ymin = rect->ymin,
|
|
|
|
.ymax = rect->ymax,
|
|
|
|
},
|
|
|
|
true,
|
2021-11-24 21:04:29 +01:00
|
|
|
radius,
|
2021-01-25 18:31:11 +11:00
|
|
|
wcol->inner,
|
|
|
|
255);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-17 20:04:37 +02:00
|
|
|
GPU_face_culling(GPU_CULL_BACK);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-11-27 21:08:48 +01:00
|
|
|
/* setup lights */
|
2017-02-07 13:04:08 +01:00
|
|
|
ui_but_v3_get(but, light);
|
2019-04-17 06:17:24 +02: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
|
|
|
/* transform to button */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const bool use_project_matrix = (size >= -GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT);
|
2020-02-04 22:17:01 +11:00
|
|
|
if (use_project_matrix) {
|
|
|
|
GPU_matrix_push_projection();
|
|
|
|
GPU_matrix_ortho_set_z(-size, size);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect),
|
|
|
|
rect->ymin + 0.5f * BLI_rcti_size_y(rect));
|
|
|
|
GPU_matrix_scale_1f(size);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUBatch *sphere = GPU_batch_preset_sphere(2);
|
2022-01-12 11:28:07 +01:00
|
|
|
struct SimpleLightingData simple_lighting_data;
|
|
|
|
copy_v4_fl4(simple_lighting_data.color, diffuse[0], diffuse[1], diffuse[2], 1.0f);
|
|
|
|
copy_v3_v3(simple_lighting_data.light, light);
|
|
|
|
GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(
|
|
|
|
sizeof(struct SimpleLightingData), &simple_lighting_data, __func__);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING);
|
2022-01-12 11:28:07 +01:00
|
|
|
GPU_batch_uniformbuf_bind(sphere, "simple_lighting_data", ubo);
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_batch_draw(sphere);
|
2022-01-12 11:28:07 +01:00
|
|
|
GPU_uniformbuf_free(ubo);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Restore. */
|
2020-07-17 20:04:37 +02:00
|
|
|
GPU_face_culling(GPU_CULL_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-05-20 14:32:15 +00:00
|
|
|
/* AA circle */
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-07 13:04:08 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-08-06 04:20:17 +10:00
|
|
|
immUniformColor3ubv(wcol->inner);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(true);
|
2017-09-14 00:39:28 +10:00
|
|
|
imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, 1.0f, 32);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-04 22:17:01 +11:00
|
|
|
if (use_project_matrix) {
|
|
|
|
GPU_matrix_pop_projection();
|
|
|
|
}
|
|
|
|
|
2009-05-20 14:32:15 +00:00
|
|
|
/* matrix after circle */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-07 13:04:08 +01:00
|
|
|
immUnbindProgram();
|
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
|
|
|
}
|
|
|
|
|
2020-08-28 15:22:36 -05:00
|
|
|
static void ui_draw_but_curve_grid(const uint pos,
|
|
|
|
const rcti *rect,
|
|
|
|
const float zoom_x,
|
|
|
|
const float zoom_y,
|
|
|
|
const float offset_x,
|
|
|
|
const float offset_y,
|
|
|
|
const float step)
|
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
|
|
|
{
|
2020-08-28 15:22:36 -05:00
|
|
|
const float start_x = (ceilf(offset_x / step) * step - offset_x) * zoom_x + rect->xmin;
|
|
|
|
const float start_y = (ceilf(offset_y / step) * step - offset_y) * zoom_y + rect->ymin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-28 15:22:36 -05:00
|
|
|
const int line_count_x = ceilf((rect->xmax - start_x) / (step * zoom_x));
|
|
|
|
const int line_count_y = ceilf((rect->ymax - start_y) / (step * zoom_y));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-28 15:22:36 -05:00
|
|
|
if (line_count_x + line_count_y == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-28 15:22:36 -05:00
|
|
|
immBegin(GPU_PRIM_LINES, (line_count_x + line_count_y) * 2);
|
|
|
|
for (int i = 0; i < line_count_x; i++) {
|
|
|
|
const float x = start_x + i * step * zoom_x;
|
|
|
|
immVertex2f(pos, x, rect->ymin);
|
|
|
|
immVertex2f(pos, x, rect->ymax);
|
2017-02-08 12:01:03 +01:00
|
|
|
}
|
2020-08-28 15:22:36 -05:00
|
|
|
for (int i = 0; i < line_count_y; i++) {
|
|
|
|
const float y = start_y + i * step * zoom_y;
|
|
|
|
immVertex2f(pos, rect->xmin, y);
|
|
|
|
immVertex2f(pos, rect->xmax, y);
|
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
|
|
|
}
|
2017-02-08 12:01:03 +01:00
|
|
|
immEnd();
|
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-15 11:58:36 +11:00
|
|
|
static void gl_shaded_color_get(const uchar color[3], int shade, uchar r_color[3])
|
|
|
|
{
|
|
|
|
r_color[0] = color[0] - shade > 0 ? color[0] - shade : 0;
|
|
|
|
r_color[1] = color[1] - shade > 0 ? color[1] - shade : 0;
|
|
|
|
r_color[2] = color[2] - shade > 0 ? color[2] - shade : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gl_shaded_color_get_fl(const uchar *color, int shade, float r_color[3])
|
|
|
|
{
|
|
|
|
uchar color_shaded[3];
|
|
|
|
gl_shaded_color_get(color, shade, color_shaded);
|
|
|
|
rgb_uchar_to_float(r_color, color_shaded);
|
|
|
|
}
|
|
|
|
|
2019-08-06 04:20:17 +10:00
|
|
|
static void gl_shaded_color(const uchar *color, int shade)
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
{
|
2019-02-15 11:58:36 +11:00
|
|
|
uchar color_shaded[3];
|
|
|
|
gl_shaded_color_get(color, shade, color_shaded);
|
|
|
|
immUniformColor3ubv(color_shaded);
|
2.5
Summary of ain features:
- Themes and Styles are now editable.
- CTRL+U "Save user defaults" now goes to new .B25.blend, so you
can use 2.4x and 2.5x next to each other. If B25 doesn't exist, it
reads the regular .B.blend
- Press Tkey in 3d window for (unfinished) toolbar WIP. It now only
shows the last operator, if appropriate.
Nkey properties moved to the other side.
A lot of work was done on removing old themes for good and properly
getting it work with the 2.5 region system. Here's some notes;
- Buttons now all have a complete set of colors, based on button classifications
(See outliner -> user prefs -> Interface
- Theme colors have been extended with basic colors for region types.
Currently colors are defined for Window, Header, List/Channels and
for Button/Tool views.
The screen manager handles this btw, so a TH_BACK will always pick the
right backdrop color.
- Menu backdrops are in in Button theme colors. Floating Panels will be in
the per-space type Themes.
- Styles were added in RNA too, but only for the font settings now.
Only Panel font, widget font and widget-label work now. The 'group label'
will be for templates mostly.
Style settings will be expanded with spacing defaults, label conventions,
etc.
- Label text colors are stored in per-space Theme too, to make sure they fit.
Same goes for Panel title color.
Note that 'shadow' for fonts can conflict with text colors; shadow color is
currently stored in Style... shadow code needs a bit of work still.
2009-04-27 13:44:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, const rcti *rect)
|
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
|
|
|
{
|
2020-08-13 21:33:47 -04:00
|
|
|
uiButCurveMapping *but_cumap = (uiButCurveMapping *)but;
|
|
|
|
CurveMapping *cumap = (but_cumap->edit_cumap == NULL) ? (CurveMapping *)but->poin :
|
|
|
|
but_cumap->edit_cumap;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const float clip_size_x = BLI_rctf_size_x(&cumap->curr);
|
|
|
|
const float clip_size_y = BLI_rctf_size_y(&cumap->curr);
|
2019-10-01 12:26:38 -03:00
|
|
|
|
|
|
|
/* zero-sized curve */
|
|
|
|
if (clip_size_x == 0.0f || clip_size_y == 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-23 13:13:11 +02:00
|
|
|
/* calculate offset and zoom */
|
2020-08-26 10:11:13 +10:00
|
|
|
const float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / clip_size_x;
|
|
|
|
const float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / clip_size_y;
|
|
|
|
const float offsx = cumap->curr.xmin - (1.0f / zoomx);
|
|
|
|
const float offsy = cumap->curr.ymin - (1.0f / zoomy);
|
2019-04-23 13:13:11 +02:00
|
|
|
|
|
|
|
/* exit early if too narrow */
|
|
|
|
if (zoomx == 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
CurveMap *cuma = &cumap->cm[cumap->cur];
|
2019-04-17 06:17:24 +02: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
|
|
|
/* need scissor test, curve can draw outside of boundary */
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2016-01-16 02:17:05 -05:00
|
|
|
rcti scissor_new = {
|
2018-04-27 10:22:37 +02:00
|
|
|
.xmin = rect->xmin,
|
|
|
|
.ymin = rect->ymin,
|
|
|
|
.xmax = rect->xmax,
|
2019-01-07 00:06:58 +11:00
|
|
|
.ymax = rect->ymax,
|
2016-01-16 02:17:05 -05:00
|
|
|
};
|
2020-08-26 10:11:13 +10:00
|
|
|
const rcti scissor_region = {0, region->winx, 0, region->winy};
|
2018-04-27 10:22:37 +02:00
|
|
|
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
|
2018-07-01 20:15:21 +02:00
|
|
|
GPU_scissor(scissor_new.xmin,
|
|
|
|
scissor_new.ymin,
|
|
|
|
BLI_rcti_size_x(&scissor_new),
|
|
|
|
BLI_rcti_size_y(&scissor_new));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 12:01:03 +01:00
|
|
|
/* Do this first to not mess imm context */
|
2020-09-04 19:26:12 +02:00
|
|
|
if (but_cumap->gradient_type == UI_GRAD_H) {
|
2012-06-21 15:03:30 +00:00
|
|
|
/* magic trigger for curve backgrounds */
|
2020-08-07 22:36:11 +10:00
|
|
|
const float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
rcti grid = {
|
|
|
|
.xmin = rect->xmin + zoomx * (-offsx),
|
|
|
|
.xmax = grid.xmin + zoomx,
|
|
|
|
.ymin = rect->ymin + zoomy * (-offsy),
|
2019-01-07 00:06:58 +11:00
|
|
|
.ymax = grid.ymin + zoomy,
|
2016-01-16 02:17:05 -05:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-21 15:03:30 +00:00
|
|
|
ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f);
|
2017-02-08 12:01:03 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-08 12:01:03 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 12:01:03 +01:00
|
|
|
/* backdrop */
|
2019-02-15 11:58:36 +11:00
|
|
|
float color_backdrop[4] = {0, 0, 0, 1};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-04 19:26:12 +02:00
|
|
|
if (but_cumap->gradient_type == UI_GRAD_H) {
|
2012-06-21 15:03:30 +00:00
|
|
|
/* grid, hsv uses different grid */
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-02-15 11:58:36 +11:00
|
|
|
ARRAY_SET_ITEMS(color_backdrop, 0, 0, 0, 48.0 / 255.0);
|
|
|
|
immUniformColor4fv(color_backdrop);
|
2017-02-08 12:01:03 +01:00
|
|
|
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.1666666f);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
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
|
|
|
}
|
|
|
|
else {
|
2012-06-21 15:03:30 +00:00
|
|
|
if (cumap->flag & CUMA_DO_CLIP) {
|
2019-08-06 04:20:17 +10:00
|
|
|
gl_shaded_color_get_fl(wcol->inner, -20, color_backdrop);
|
2019-02-15 11:58:36 +11:00
|
|
|
immUniformColor3fv(color_backdrop);
|
2017-02-08 12:01:03 +01:00
|
|
|
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
2019-08-06 04:20:17 +10:00
|
|
|
immUniformColor3ubv(wcol->inner);
|
2018-07-01 20:15:21 +02:00
|
|
|
immRectf(pos,
|
|
|
|
rect->xmin + zoomx * (cumap->clipr.xmin - offsx),
|
|
|
|
rect->ymin + zoomy * (cumap->clipr.ymin - offsy),
|
|
|
|
rect->xmin + zoomx * (cumap->clipr.xmax - offsx),
|
|
|
|
rect->ymin + zoomy * (cumap->clipr.ymax - offsy));
|
2010-01-21 00:00:45 +00:00
|
|
|
}
|
2012-06-21 15:03:30 +00:00
|
|
|
else {
|
2019-08-06 04:20:17 +10:00
|
|
|
rgb_uchar_to_float(color_backdrop, wcol->inner);
|
2019-02-15 11:58:36 +11:00
|
|
|
immUniformColor3fv(color_backdrop);
|
2017-02-08 12:01:03 +01:00
|
|
|
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
2012-06-21 15:03:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-21 15:03:30 +00:00
|
|
|
/* grid, every 0.25 step */
|
2019-08-06 04:20:17 +10:00
|
|
|
gl_shaded_color(wcol->inner, -16);
|
2017-02-08 12:01:03 +01:00
|
|
|
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.25f);
|
2012-06-21 15:03:30 +00:00
|
|
|
/* grid, every 1.0 step */
|
2019-08-06 04:20:17 +10:00
|
|
|
gl_shaded_color(wcol->inner, -24);
|
2017-02-08 12:01:03 +01:00
|
|
|
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f);
|
2012-06-21 15:03:30 +00:00
|
|
|
/* axes */
|
2019-08-06 04:20:17 +10:00
|
|
|
gl_shaded_color(wcol->inner, -50);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2017-02-08 12:01:03 +01:00
|
|
|
immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy));
|
|
|
|
immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy));
|
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymin);
|
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymax);
|
|
|
|
immEnd();
|
2010-01-21 00:00:45 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
/* cfra option */
|
2012-03-03 16:31:46 +00:00
|
|
|
/* XXX 2.48 */
|
|
|
|
#if 0
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->flag & CUMA_DRAW_CFRA) {
|
2017-02-10 17:36:32 +01:00
|
|
|
immUniformColor3ub(0x60, 0xc0, 0x40);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2017-02-10 17:36:32 +01:00
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
|
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
|
|
|
|
immEnd();
|
2012-03-03 16:31:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
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
|
|
|
/* sample option */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap->flag & CUMA_DRAW_SAMPLE) {
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2); /* will draw one of the following 3 lines */
|
2020-09-04 19:26:12 +02:00
|
|
|
if (but_cumap->gradient_type == UI_GRAD_H) {
|
2012-06-21 14:37:56 +00:00
|
|
|
float tsample[3];
|
|
|
|
float hsv[3];
|
|
|
|
linearrgb_to_srgb_v3_v3(tsample, cumap->sample);
|
|
|
|
rgb_to_hsv_v(tsample, hsv);
|
2017-02-08 12:01:03 +01:00
|
|
|
immUniformColor3ub(240, 240, 240);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 12:01:03 +01:00
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin);
|
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax);
|
2012-06-21 14:37:56 +00:00
|
|
|
}
|
|
|
|
else if (cumap->cur == 3) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float lum = IMB_colormanagement_get_luminance(cumap->sample);
|
2017-02-08 12:01:03 +01:00
|
|
|
immUniformColor3ub(240, 240, 240);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 12:01:03 +01:00
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymin);
|
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (lum - offsx), rect->ymax);
|
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
|
|
|
}
|
|
|
|
else {
|
2019-03-25 10:15:20 +11:00
|
|
|
if (cumap->cur == 0) {
|
2017-02-08 12:01:03 +01:00
|
|
|
immUniformColor3ub(240, 100, 100);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else if (cumap->cur == 1) {
|
2017-02-08 12:01:03 +01:00
|
|
|
immUniformColor3ub(100, 240, 100);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-02-08 12:01:03 +01:00
|
|
|
immUniformColor3ub(100, 100, 240);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 12:01:03 +01:00
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
|
|
|
|
immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
|
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
|
|
|
}
|
2017-02-08 12:01:03 +01:00
|
|
|
immEnd();
|
2012-03-03 16:31:46 +00:00
|
|
|
}
|
2018-11-02 18:56:45 +00:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (cuma->table == NULL) {
|
2019-08-07 03:21:55 +10:00
|
|
|
BKE_curvemapping_changed(cumap, false);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
CurveMapPoint *cmp = cuma->table;
|
2018-11-05 13:04:43 +11:00
|
|
|
rctf line_range;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-05 13:04:43 +11:00
|
|
|
/* First curve point. */
|
2019-11-01 12:09:55 +01:00
|
|
|
if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
|
2018-11-05 13:04:43 +11:00
|
|
|
line_range.xmin = rect->xmin;
|
|
|
|
line_range.ymin = rect->ymin + zoomy * (cmp[0].y - offsy);
|
2012-08-21 15:14:29 +00: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
|
|
|
else {
|
2018-11-05 13:04:43 +11:00
|
|
|
line_range.xmin = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
|
|
|
|
line_range.ymin = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
|
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
|
|
|
}
|
2018-11-05 13:04:43 +11:00
|
|
|
/* Last curve point. */
|
2019-11-01 12:09:55 +01:00
|
|
|
if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
|
2018-11-05 13:04:43 +11:00
|
|
|
line_range.xmax = rect->xmax;
|
|
|
|
line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy);
|
2012-08-21 15:14:29 +00: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
|
|
|
else {
|
2018-11-05 13:04:43 +11:00
|
|
|
line_range.xmax = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
|
|
|
|
line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
|
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-04-17 06:17:24 +02:00
|
|
|
|
2018-11-05 13:04:43 +11:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-05 13:04:43 +11:00
|
|
|
/* Curve filled. */
|
2019-08-06 04:20:17 +10:00
|
|
|
immUniformColor3ubvAlpha(wcol->item, 128);
|
2018-11-05 13:04:43 +11:00
|
|
|
immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4);
|
|
|
|
immVertex2f(pos, line_range.xmin, rect->ymin);
|
|
|
|
immVertex2f(pos, line_range.xmin, line_range.ymin);
|
|
|
|
for (int a = 0; a <= CM_TABLE; a++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
|
|
|
|
const float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
|
2018-11-05 13:04:43 +11:00
|
|
|
immVertex2f(pos, fx, rect->ymin);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
immVertex2f(pos, line_range.xmax, rect->ymin);
|
2019-03-22 03:48:41 +01:00
|
|
|
immVertex2f(pos, line_range.xmax, line_range.ymax);
|
2017-02-08 12:01:03 +01:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-05 13:04:43 +11:00
|
|
|
/* Curve line. */
|
|
|
|
GPU_line_width(1.0f);
|
2019-08-06 04:20:17 +10:00
|
|
|
immUniformColor3ubvAlpha(wcol->item, 255);
|
2018-11-05 13:04:43 +11:00
|
|
|
GPU_line_smooth(true);
|
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
|
|
|
|
immVertex2f(pos, line_range.xmin, line_range.ymin);
|
|
|
|
for (int a = 0; a <= CM_TABLE; a++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
|
|
|
|
const float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
|
2018-11-05 13:04:43 +11:00
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
immVertex2f(pos, line_range.xmax, line_range.ymax);
|
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-05 13:04:43 +11:00
|
|
|
/* Reset state for fill & line. */
|
|
|
|
GPU_line_smooth(false);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2017-02-08 12:01:03 +01:00
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-05 13:04:43 +11:00
|
|
|
/* The points, use aspect to make them visible on edges. */
|
2017-02-08 12:01:03 +01:00
|
|
|
format = immVertexFormat();
|
2018-07-18 00:12:21 +02:00
|
|
|
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
2017-02-08 12:01:03 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-15 11:58:36 +11:00
|
|
|
/* Calculate vertex colors based on text theme. */
|
|
|
|
float color_vert[4], color_vert_select[4];
|
|
|
|
UI_GetThemeColor4fv(TH_TEXT_HI, color_vert);
|
|
|
|
UI_GetThemeColor4fv(TH_TEXT, color_vert_select);
|
|
|
|
if (len_squared_v3v3(color_vert, color_vert_select) < 0.1f) {
|
|
|
|
interp_v3_v3v3(color_vert, color_vert_select, color_backdrop, 0.75f);
|
|
|
|
}
|
|
|
|
if (len_squared_v3(color_vert) > len_squared_v3(color_vert_select)) {
|
|
|
|
/* Ensure brightest text color is used for selection. */
|
|
|
|
swap_v3_v3(color_vert, color_vert_select);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-30 01:51:25 +00:00
|
|
|
cmp = cuma->curve;
|
2018-11-12 19:36:18 +03:00
|
|
|
GPU_point_size(max_ff(1.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f)));
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, cuma->totpoint);
|
2016-01-16 02:17:05 -05:00
|
|
|
for (int a = 0; a < cuma->totpoint; a++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
|
|
|
|
const float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
|
2019-02-15 11:58:36 +11:00
|
|
|
immAttr4fv(col, (cmp[a].flag & CUMA_SELECT) ? color_vert_select : color_vert);
|
2017-02-08 12:01:03 +01:00
|
|
|
immVertex2f(pos, fx, fy);
|
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
|
|
|
}
|
2017-02-08 12:01:03 +01:00
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Restore scissor-test. */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
2019-04-17 06:17:24 +02: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
|
|
|
/* outline */
|
2017-02-08 12:01:03 +01:00
|
|
|
format = immVertexFormat();
|
2018-07-18 00:12:21 +02:00
|
|
|
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2017-02-08 12:01:03 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-08-06 04:20:17 +10:00
|
|
|
immUniformColor3ubv(wcol->outline);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-08 12:01:03 +01:00
|
|
|
immUnbindProgram();
|
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
|
|
|
}
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/**
|
|
|
|
* Helper for #ui_draw_but_CURVEPROFILE. Used to tell whether to draw a control point's handles.
|
|
|
|
*/
|
|
|
|
static bool point_draw_handles(CurveProfilePoint *point)
|
|
|
|
{
|
|
|
|
return (point->flag & PROF_SELECT &&
|
|
|
|
(ELEM(point->h1, HD_FREE, HD_ALIGN) || ELEM(point->h2, HD_FREE, HD_ALIGN))) ||
|
|
|
|
ELEM(point->flag, PROF_H1_SELECT, PROF_H2_SELECT);
|
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_CURVEPROFILE(ARegion *region,
|
2019-11-20 16:12:32 -05:00
|
|
|
uiBut *but,
|
|
|
|
const uiWidgetColors *wcol,
|
|
|
|
const rcti *rect)
|
|
|
|
{
|
|
|
|
float fx, fy;
|
2020-08-13 21:00:54 -04:00
|
|
|
|
|
|
|
uiButCurveProfile *but_profile = (uiButCurveProfile *)but;
|
|
|
|
CurveProfile *profile = (but_profile->edit_profile == NULL) ? (CurveProfile *)but->poin :
|
|
|
|
but_profile->edit_profile;
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Calculate offset and zoom. */
|
2020-08-26 10:11:13 +10:00
|
|
|
const float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&profile->view_rect);
|
|
|
|
const float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&profile->view_rect);
|
|
|
|
const float offsx = profile->view_rect.xmin - (1.0f / zoomx);
|
|
|
|
const float offsy = profile->view_rect.ymin - (1.0f / zoomy);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Exit early if too narrow. */
|
2019-11-20 16:12:32 -05:00
|
|
|
if (zoomx == 0.0f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Test needed because path can draw outside of boundary. */
|
2019-11-20 16:12:32 -05:00
|
|
|
int scissor[4];
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2019-11-20 16:12:32 -05:00
|
|
|
rcti scissor_new = {
|
|
|
|
.xmin = rect->xmin,
|
|
|
|
.ymin = rect->ymin,
|
|
|
|
.xmax = rect->xmax,
|
|
|
|
.ymax = rect->ymax,
|
|
|
|
};
|
2020-08-26 10:11:13 +10:00
|
|
|
const rcti scissor_region = {0, region->winx, 0, region->winy};
|
2019-11-20 16:12:32 -05:00
|
|
|
BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new);
|
|
|
|
GPU_scissor(scissor_new.xmin,
|
|
|
|
scissor_new.ymin,
|
|
|
|
BLI_rcti_size_x(&scissor_new),
|
|
|
|
BLI_rcti_size_y(&scissor_new));
|
|
|
|
|
|
|
|
GPU_line_width(1.0f);
|
|
|
|
|
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Draw the backdrop. */
|
2019-11-20 16:12:32 -05:00
|
|
|
float color_backdrop[4] = {0, 0, 0, 1};
|
|
|
|
if (profile->flag & PROF_USE_CLIP) {
|
|
|
|
gl_shaded_color_get_fl((uchar *)wcol->inner, -20, color_backdrop);
|
|
|
|
immUniformColor3fv(color_backdrop);
|
|
|
|
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
|
|
|
immUniformColor3ubv((uchar *)wcol->inner);
|
|
|
|
immRectf(pos,
|
|
|
|
rect->xmin + zoomx * (profile->clip_rect.xmin - offsx),
|
|
|
|
rect->ymin + zoomy * (profile->clip_rect.ymin - offsy),
|
|
|
|
rect->xmin + zoomx * (profile->clip_rect.xmax - offsx),
|
|
|
|
rect->ymin + zoomy * (profile->clip_rect.ymax - offsy));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rgb_uchar_to_float(color_backdrop, (uchar *)wcol->inner);
|
|
|
|
immUniformColor3fv(color_backdrop);
|
|
|
|
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
|
|
|
}
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* 0.25 step grid. */
|
2019-11-20 16:12:32 -05:00
|
|
|
gl_shaded_color((uchar *)wcol->inner, -16);
|
|
|
|
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.25f);
|
2020-06-24 11:50:01 -04:00
|
|
|
/* 1.0 step grid. */
|
2019-11-20 16:12:32 -05:00
|
|
|
gl_shaded_color((uchar *)wcol->inner, -24);
|
|
|
|
ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f);
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Draw the path's fill. */
|
2019-11-20 16:12:32 -05:00
|
|
|
if (profile->table == NULL) {
|
2020-06-24 11:50:01 -04:00
|
|
|
BKE_curveprofile_update(profile, PROF_UPDATE_NONE);
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
CurveProfilePoint *pts = profile->table;
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Also add the last points on the right and bottom edges to close off the fill polygon. */
|
2020-08-26 10:11:13 +10:00
|
|
|
const bool add_left_tri = profile->view_rect.xmin < 0.0f;
|
|
|
|
const bool add_bottom_tri = profile->view_rect.ymin < 0.0f;
|
2021-10-03 20:28:31 -05:00
|
|
|
int tot_points = BKE_curveprofile_table_size(profile) + 1 + add_left_tri + add_bottom_tri;
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint tot_triangles = tot_points - 2;
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Create array of the positions of the table's points. */
|
2019-11-20 16:12:32 -05:00
|
|
|
float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords");
|
2021-10-03 18:54:52 -05:00
|
|
|
for (uint i = 0; i < (uint)BKE_curveprofile_table_size(profile); i++) {
|
|
|
|
/* Only add the points from the table here. */
|
2019-11-20 16:12:32 -05:00
|
|
|
table_coords[i][0] = pts[i].x;
|
|
|
|
table_coords[i][1] = pts[i].y;
|
|
|
|
}
|
2021-01-04 15:10:21 -06:00
|
|
|
/* Using some extra margin (-1.0f) for the coordinates used to complete the polygon
|
|
|
|
* avoids the profile line crossing itself in some common situations, which can lead to
|
|
|
|
* incorrect triangulation. See T841183. */
|
2019-11-20 16:12:32 -05:00
|
|
|
if (add_left_tri && add_bottom_tri) {
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Add left side, bottom left corner, and bottom side points. */
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 3][0] = profile->view_rect.xmin - 1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
table_coords[tot_points - 3][1] = 1.0f;
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 2][0] = profile->view_rect.xmin - 1.0f;
|
|
|
|
table_coords[tot_points - 2][1] = profile->view_rect.ymin - 1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
table_coords[tot_points - 1][0] = 1.0f;
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 1][1] = profile->view_rect.ymin - 1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
else if (add_left_tri) {
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Add the left side and bottom left corner points. */
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 2][0] = profile->view_rect.xmin - 1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
table_coords[tot_points - 2][1] = 1.0f;
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 1][0] = profile->view_rect.xmin - 1.0f;
|
|
|
|
table_coords[tot_points - 1][1] = -1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
else if (add_bottom_tri) {
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Add the bottom side and bottom left corner points. */
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 2][0] = -1.0f;
|
|
|
|
table_coords[tot_points - 2][1] = profile->view_rect.ymin - 1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
table_coords[tot_points - 1][0] = 1.0f;
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 1][1] = profile->view_rect.ymin - 1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
else {
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Just add the bottom corner point. Side points would be redundant anyway. */
|
2021-01-04 15:10:21 -06:00
|
|
|
table_coords[tot_points - 1][0] = -1.0f;
|
|
|
|
table_coords[tot_points - 1][1] = -1.0f;
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Calculate the table point indices of the triangles for the profile's fill. */
|
2021-10-03 20:28:31 -05:00
|
|
|
if (tot_triangles > 0) {
|
|
|
|
uint(*tri_indices)[3] = MEM_mallocN(sizeof(*tri_indices) * tot_triangles, __func__);
|
|
|
|
BLI_polyfill_calc(table_coords, tot_points, -1, tri_indices);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2021-10-03 20:28:31 -05:00
|
|
|
/* Draw the triangles for the profile fill. */
|
|
|
|
immUniformColor3ubvAlpha((const uchar *)wcol->item, 128);
|
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
|
|
|
GPU_polygon_smooth(false);
|
|
|
|
immBegin(GPU_PRIM_TRIS, 3 * tot_triangles);
|
|
|
|
for (uint i = 0; i < tot_triangles; i++) {
|
|
|
|
for (uint j = 0; j < 3; j++) {
|
|
|
|
uint *tri = tri_indices[i];
|
|
|
|
fx = rect->xmin + zoomx * (table_coords[tri[j]][0] - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (table_coords[tri[j]][1] - offsy);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
2021-10-03 20:28:31 -05:00
|
|
|
immEnd();
|
|
|
|
MEM_freeN(tri_indices);
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Draw the profile's path so the edge stands out a bit. */
|
2019-11-20 16:12:32 -05:00
|
|
|
tot_points -= (add_left_tri + add_left_tri);
|
2021-10-03 20:28:31 -05:00
|
|
|
const int edges_len = tot_points - 1;
|
|
|
|
if (edges_len > 0) {
|
|
|
|
GPU_line_width(1.0f);
|
|
|
|
immUniformColor3ubvAlpha((const uchar *)wcol->item, 255);
|
|
|
|
GPU_line_smooth(true);
|
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, tot_points);
|
|
|
|
for (int i = 0; i < tot_points; i++) {
|
|
|
|
fx = rect->xmin + zoomx * (table_coords[i][0] - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (table_coords[i][1] - offsy);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
immEnd();
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
2021-10-03 20:28:31 -05:00
|
|
|
|
|
|
|
MEM_SAFE_FREE(table_coords);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Draw the handles for the selected control points. */
|
|
|
|
pts = profile->path;
|
2021-10-03 20:28:31 -05:00
|
|
|
const int path_len = tot_points = (uint)profile->path_len;
|
2020-06-24 11:50:01 -04:00
|
|
|
int selected_free_points = 0;
|
2021-10-03 20:28:31 -05:00
|
|
|
for (int i = 0; i < path_len; i++) {
|
2020-06-24 11:50:01 -04:00
|
|
|
if (point_draw_handles(&pts[i])) {
|
|
|
|
selected_free_points++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Draw the lines to the handles from the points. */
|
|
|
|
if (selected_free_points > 0) {
|
|
|
|
GPU_line_width(1.0f);
|
|
|
|
gl_shaded_color((uchar *)wcol->inner, -24);
|
|
|
|
GPU_line_smooth(true);
|
|
|
|
immBegin(GPU_PRIM_LINES, selected_free_points * 4);
|
|
|
|
float ptx, pty;
|
2021-10-03 20:28:31 -05:00
|
|
|
for (int i = 0; i < path_len; i++) {
|
2020-06-24 11:50:01 -04:00
|
|
|
if (point_draw_handles(&pts[i])) {
|
|
|
|
ptx = rect->xmin + zoomx * (pts[i].x - offsx);
|
|
|
|
pty = rect->ymin + zoomy * (pts[i].y - offsy);
|
|
|
|
|
|
|
|
fx = rect->xmin + zoomx * (pts[i].h1_loc[0] - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (pts[i].h1_loc[1] - offsy);
|
|
|
|
immVertex2f(pos, ptx, pty);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
|
|
|
|
fx = rect->xmin + zoomx * (pts[i].h2_loc[0] - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (pts[i].h2_loc[1] - offsy);
|
|
|
|
immVertex2f(pos, ptx, pty);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
immEnd();
|
|
|
|
}
|
|
|
|
immUnbindProgram();
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
/* New GPU instructions for control points and sampled points. */
|
|
|
|
format = immVertexFormat();
|
|
|
|
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
2019-11-20 16:12:32 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
|
|
|
|
|
|
|
/* Calculate vertex colors based on text theme. */
|
|
|
|
float color_vert[4], color_vert_select[4], color_sample[4];
|
|
|
|
UI_GetThemeColor4fv(TH_TEXT_HI, color_vert);
|
|
|
|
UI_GetThemeColor4fv(TH_TEXT, color_vert_select);
|
|
|
|
color_sample[0] = (float)wcol->item[0] / 255.0f;
|
|
|
|
color_sample[1] = (float)wcol->item[1] / 255.0f;
|
|
|
|
color_sample[2] = (float)wcol->item[2] / 255.0f;
|
|
|
|
color_sample[3] = (float)wcol->item[3] / 255.0f;
|
|
|
|
if (len_squared_v3v3(color_vert, color_vert_select) < 0.1f) {
|
|
|
|
interp_v3_v3v3(color_vert, color_vert_select, color_backdrop, 0.75f);
|
|
|
|
}
|
|
|
|
if (len_squared_v3(color_vert) > len_squared_v3(color_vert_select)) {
|
|
|
|
/* Ensure brightest text color is used for selection. */
|
|
|
|
swap_v3_v3(color_vert, color_vert_select);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the control points. */
|
|
|
|
GPU_line_smooth(false);
|
2021-10-03 20:28:31 -05:00
|
|
|
if (path_len > 0) {
|
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
|
|
|
GPU_point_size(max_ff(3.0f, min_ff(UI_DPI_FAC / but->block->aspect * 5.0f, 5.0f)));
|
|
|
|
immBegin(GPU_PRIM_POINTS, path_len);
|
|
|
|
for (int i = 0; i < path_len; i++) {
|
|
|
|
fx = rect->xmin + zoomx * (pts[i].x - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (pts[i].y - offsy);
|
|
|
|
immAttr4fv(col, (pts[i].flag & PROF_SELECT) ? color_vert_select : color_vert);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
immEnd();
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
|
2020-06-24 11:50:01 -04:00
|
|
|
/* Draw the handle points. */
|
|
|
|
if (selected_free_points > 0) {
|
|
|
|
GPU_line_smooth(false);
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2020-06-24 11:50:01 -04:00
|
|
|
GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f)));
|
|
|
|
immBegin(GPU_PRIM_POINTS, selected_free_points * 2);
|
2021-10-03 20:28:31 -05:00
|
|
|
for (int i = 0; i < path_len; i++) {
|
2020-06-24 11:50:01 -04:00
|
|
|
if (point_draw_handles(&pts[i])) {
|
|
|
|
fx = rect->xmin + zoomx * (pts[i].h1_loc[0] - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (pts[i].h1_loc[1] - offsy);
|
|
|
|
immAttr4fv(col, (pts[i].flag & PROF_H1_SELECT) ? color_vert_select : color_vert);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
|
|
|
|
fx = rect->xmin + zoomx * (pts[i].h2_loc[0] - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (pts[i].h2_loc[1] - offsy);
|
|
|
|
immAttr4fv(col, (pts[i].flag & PROF_H2_SELECT) ? color_vert_select : color_vert);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
immEnd();
|
|
|
|
}
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
/* Draw the sampled points in addition to the control points if they have been created */
|
|
|
|
pts = profile->segments;
|
2021-10-03 20:28:31 -05:00
|
|
|
const int segments_len = (uint)profile->segments_len;
|
|
|
|
if (segments_len > 0 && pts) {
|
2019-11-20 16:12:32 -05:00
|
|
|
GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 3.0f, 3.0f)));
|
2021-10-03 20:28:31 -05:00
|
|
|
immBegin(GPU_PRIM_POINTS, segments_len);
|
|
|
|
for (int i = 0; i < segments_len; i++) {
|
2019-11-20 16:12:32 -05:00
|
|
|
fx = rect->xmin + zoomx * (pts[i].x - offsx);
|
|
|
|
fy = rect->ymin + zoomy * (pts[i].y - offsy);
|
|
|
|
immAttr4fv(col, color_sample);
|
|
|
|
immVertex2f(pos, fx, fy);
|
|
|
|
}
|
|
|
|
immEnd();
|
|
|
|
}
|
|
|
|
immUnbindProgram();
|
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Restore scissor-test. */
|
2019-11-20 16:12:32 -05:00
|
|
|
GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
|
|
|
|
|
|
|
/* Outline */
|
|
|
|
format = immVertexFormat();
|
|
|
|
pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
|
|
immUniformColor3ubv((const uchar *)wcol->outline);
|
|
|
|
imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
|
|
|
immUnbindProgram();
|
|
|
|
}
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region),
|
2019-01-04 09:58:03 +11:00
|
|
|
uiBut *but,
|
|
|
|
const uiWidgetColors *UNUSED(wcol),
|
|
|
|
const rcti *recti)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2014-04-11 11:25:41 +10:00
|
|
|
bool ok = false;
|
2011-11-07 12:55:18 +00:00
|
|
|
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
rctf rect = {
|
|
|
|
.xmin = (float)recti->xmin + 1,
|
|
|
|
.xmax = (float)recti->xmax - 1,
|
|
|
|
.ymin = (float)recti->ymin + 1,
|
2019-01-07 00:06:58 +11:00
|
|
|
.ymax = (float)recti->ymax - 1,
|
2016-01-16 02:17:05 -05:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-26 10:11:13 +10:00
|
|
|
const int width = BLI_rctf_size_x(&rect) + 1;
|
|
|
|
const int height = BLI_rctf_size_y(&rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* need scissor test, preview image can draw outside of boundary */
|
2018-06-27 19:07:23 -06:00
|
|
|
int scissor[4];
|
2020-08-16 01:49:52 +02:00
|
|
|
GPU_scissor_get(scissor);
|
2018-07-01 20:15:21 +02:00
|
|
|
GPU_scissor((rect.xmin - 1),
|
|
|
|
(rect.ymin - 1),
|
|
|
|
(rect.xmax + 1) - (rect.xmin - 1),
|
|
|
|
(rect.ymax + 1) - (rect.ymin - 1));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scopes->track_disabled) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float color[4] = {0.7f, 0.3f, 0.3f, 0.3f};
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect.xmin - 1,
|
|
|
|
.xmax = rect.xmax + 1,
|
|
|
|
.ymin = rect.ymin,
|
|
|
|
.ymax = rect.ymax + 1,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
ok = true;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
else if ((scopes->track_search) &&
|
|
|
|
((!scopes->track_preview) ||
|
2012-06-10 19:59:02 +00:00
|
|
|
(scopes->track_preview->x != width || scopes->track_preview->y != height))) {
|
2019-03-25 10:15:20 +11:00
|
|
|
if (scopes->track_preview) {
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
IMB_freeImBuf(scopes->track_preview);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-01 19:57:31 +02:00
|
|
|
ImBuf *tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width,
|
|
|
|
scopes->frame_height,
|
|
|
|
scopes->track_search,
|
|
|
|
scopes->track,
|
|
|
|
&scopes->undist_marker,
|
|
|
|
true,
|
|
|
|
scopes->use_track_mask,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
scopes->track_pos);
|
2012-11-07 11:18:42 +00:00
|
|
|
if (tmpibuf) {
|
2019-03-25 10:15:20 +11:00
|
|
|
if (tmpibuf->rect_float) {
|
2012-11-07 11:18:42 +00:00
|
|
|
IMB_rect_from_float(tmpibuf);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (tmpibuf->rect) {
|
2012-11-07 11:18:42 +00:00
|
|
|
scopes->track_preview = tmpibuf;
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2012-11-07 11:18:42 +00:00
|
|
|
IMB_freeImBuf(tmpibuf);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2012-11-07 11:18:42 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
|
|
|
if (!ok && scopes->track_preview) {
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* draw content of pattern area */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (width > 0 && height > 0) {
|
2016-01-16 02:17:05 -05:00
|
|
|
ImBuf *drawibuf = scopes->track_preview;
|
2017-02-10 17:36:32 +01:00
|
|
|
float col_sel[4], col_outline[4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-12 11:13:53 +00:00
|
|
|
if (scopes->use_track_mask) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect.xmin - 1,
|
|
|
|
.xmax = rect.xmax + 1,
|
|
|
|
.ymin = rect.ymin,
|
|
|
|
.ymax = rect.ymax + 1,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2012-06-12 11:13:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-11 16:30:00 +02:00
|
|
|
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
|
|
|
immDrawPixelsTex(&state,
|
|
|
|
rect.xmin,
|
|
|
|
rect.ymin + 1,
|
|
|
|
drawibuf->x,
|
|
|
|
drawibuf->y,
|
2020-07-26 19:50:15 +02:00
|
|
|
GPU_RGBA8,
|
|
|
|
true,
|
2017-04-11 16:30:00 +02:00
|
|
|
drawibuf->rect,
|
|
|
|
1.0f,
|
|
|
|
1.0f,
|
|
|
|
NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
/* draw cross for pixel position */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_translate_2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
|
2018-07-01 20:15:21 +02:00
|
|
|
GPU_scissor(rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
|
2017-02-10 17:36:32 +01:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-10 17:36:32 +01:00
|
|
|
UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel);
|
|
|
|
UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-10 17:36:32 +01:00
|
|
|
/* Do stipple cross with geometry */
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 7 * 2 * 2);
|
2020-08-07 22:36:11 +10:00
|
|
|
const float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f};
|
2019-09-08 00:12:26 +10:00
|
|
|
for (int axe = 0; axe < 2; axe++) {
|
|
|
|
for (int i = 0; i < 7; i++) {
|
2020-08-26 10:11:13 +10:00
|
|
|
const float x1 = pos_sel[i] * (1 - axe);
|
|
|
|
const float y1 = pos_sel[i] * axe;
|
|
|
|
const float x2 = pos_sel[i + 1] * (1 - axe);
|
|
|
|
const float y2 = pos_sel[i + 1] * axe;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (i % 2 == 1) {
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4fv(col, col_sel);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4fv(col, col_outline);
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-10 17:36:32 +01:00
|
|
|
immVertex2f(pos, x1, y1);
|
|
|
|
immVertex2f(pos, x2, y2);
|
2012-01-30 09:05:26 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-02-10 17:36:32 +01:00
|
|
|
immEnd();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-10 17:36:32 +01:00
|
|
|
immUnbindProgram();
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
ok = true;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ok) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f};
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
2017-04-06 19:15:26 -04:00
|
|
|
UI_draw_roundbox_4fv(
|
2021-01-25 18:31:11 +11:00
|
|
|
&(const rctf){
|
|
|
|
.xmin = rect.xmin - 1,
|
|
|
|
.xmax = rect.xmax + 1,
|
|
|
|
.ymin = rect.ymin,
|
|
|
|
.ymax = rect.ymax + 1,
|
|
|
|
},
|
|
|
|
true,
|
|
|
|
3.0f,
|
|
|
|
color);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 01:49:52 +02:00
|
|
|
/* Restore scissor test. */
|
|
|
|
GPU_scissor(UNPACK4(scissor));
|
2014-04-02 13:09:43 +02:00
|
|
|
/* outline */
|
2020-08-16 01:49:52 +02:00
|
|
|
draw_scope_end(&rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2009-01-04 00:05:40 +00:00
|
|
|
|
2009-04-06 15:44:30 +00: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
|
|
|
|
2021-07-05 12:47:46 +10:00
|
|
|
/* TODO(merwin): high quality UI drop shadows using GLSL shader and single draw call
|
|
|
|
* would replace / modify the following 3 functions. */
|
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
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
static void ui_shadowbox(const rctf *rect, uint pos, uint color, float shadsize, uchar alpha)
|
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
|
|
|
{
|
2018-09-02 18:28:27 +10:00
|
|
|
/**
|
|
|
|
* <pre>
|
|
|
|
* v1-_
|
2017-04-10 15:16:59 +02:00
|
|
|
* | -_v2
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* | |
|
|
|
|
* v7_______v3____v4
|
|
|
|
* \ | /
|
|
|
|
* \ | _v5
|
|
|
|
* v8______v6_-
|
2018-09-02 18:28:27 +10:00
|
|
|
* </pre>
|
2017-04-10 15:16:59 +02:00
|
|
|
*/
|
2021-01-25 18:31:11 +11:00
|
|
|
const float v1[2] = {rect->xmax, rect->ymax - 0.3f * shadsize};
|
|
|
|
const float v2[2] = {rect->xmax + shadsize, rect->ymax - 0.75f * shadsize};
|
|
|
|
const float v3[2] = {rect->xmax, rect->ymin};
|
|
|
|
const float v4[2] = {rect->xmax + shadsize, rect->ymin};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
const float v5[2] = {rect->xmax + 0.7f * shadsize, rect->ymin - 0.7f * shadsize};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
const float v6[2] = {rect->xmax, rect->ymin - shadsize};
|
|
|
|
const float v7[2] = {rect->xmin + 0.3f * shadsize, rect->ymin};
|
|
|
|
const float v8[2] = {rect->xmin + 0.5f * shadsize, rect->ymin - shadsize};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-06 15:44:30 +00:00
|
|
|
/* right quad */
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, alpha);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v3);
|
|
|
|
immVertex2fv(pos, v1);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, 0);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v2);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v2);
|
|
|
|
immVertex2fv(pos, v4);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, alpha);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v3);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-10 15:16:59 +02:00
|
|
|
/* corner shape */
|
2021-08-12 14:34:41 +10:00
|
|
|
// immAttr4ub(color, 0, 0, 0, alpha); /* Not needed, done above in previous tri. */
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v3);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, 0);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v4);
|
|
|
|
immVertex2fv(pos, v5);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v5);
|
|
|
|
immVertex2fv(pos, v6);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, alpha);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v3);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-10 15:16:59 +02:00
|
|
|
/* bottom quad */
|
2021-08-12 14:34:41 +10:00
|
|
|
// immAttr4ub(color, 0, 0, 0, alpha); /* Not needed, done above in previous tri. */
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v3);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, 0);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v6);
|
|
|
|
immVertex2fv(pos, v8);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v8);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ub(color, 0, 0, 0, alpha);
|
2017-04-10 15:16:59 +02:00
|
|
|
immVertex2fv(pos, v7);
|
|
|
|
immVertex2fv(pos, v3);
|
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
|
|
|
}
|
|
|
|
|
2021-01-25 18:31:11 +11:00
|
|
|
void UI_draw_box_shadow(const rctf *rect, uchar alpha)
|
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
|
|
|
{
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2016-08-11 01:06:17 -04:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
2020-08-26 10:11:13 +10:00
|
|
|
const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2018-07-18 00:12:21 +02:00
|
|
|
uint color = GPU_vertformat_attr_add(
|
|
|
|
format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
2016-08-11 01:06:17 -04:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_TRIS, 54);
|
2016-01-16 01:17:51 -05:00
|
|
|
|
2009-04-06 15:44:30 +00:00
|
|
|
/* accumulated outline boxes to make shade not linear, is more pleasant */
|
2021-01-25 18:31:11 +11:00
|
|
|
ui_shadowbox(rect, pos, color, 11.0, (20 * alpha) >> 8);
|
|
|
|
ui_shadowbox(rect, pos, color, 7.0, (40 * alpha) >> 8);
|
|
|
|
ui_shadowbox(rect, pos, color, 5.0, (80 * alpha) >> 8);
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2016-08-11 01:06:17 -04:00
|
|
|
immEnd();
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
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-11-09 21:20:40 +01:00
|
|
|
void ui_draw_dropshadow(
|
|
|
|
const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
|
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
|
|
|
{
|
|
|
|
float rad;
|
2018-05-23 10:47:12 +02:00
|
|
|
|
2019-03-25 10:15:20 +11:00
|
|
|
if (radius > (BLI_rctf_size_y(rct) - 10.0f) * 0.5f) {
|
2017-02-08 01:43:53 -05:00
|
|
|
rad = (BLI_rctf_size_y(rct) - 10.0f) * 0.5f;
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2012-03-30 01:51:25 +00:00
|
|
|
rad = radius;
|
2019-03-25 10:15:20 +11:00
|
|
|
}
|
2011-01-23 11:42:29 +00:00
|
|
|
|
2016-01-16 02:17:05 -05:00
|
|
|
int a, i = 12;
|
2011-05-01 10:14:09 +00:00
|
|
|
#if 0
|
2012-03-24 06:38:07 +00:00
|
|
|
if (select) {
|
2012-03-30 01:51:25 +00:00
|
|
|
a = i * aspect; /* same as below */
|
2011-05-01 10:14:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2012-03-30 01:51:25 +00:00
|
|
|
a = i * aspect;
|
2011-05-01 10:14:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_ALPHA);
|
2016-01-16 02:17:05 -05:00
|
|
|
const float dalpha = alpha * 2.0f / 255.0f;
|
|
|
|
float calpha = dalpha;
|
2018-04-06 10:09:23 +02:00
|
|
|
float visibility = 1.0f;
|
|
|
|
for (; i--;) {
|
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
|
|
|
/* alpha ranges from 2 to 20 or so */
|
2018-04-06 10:09:23 +02:00
|
|
|
#if 0 /* Old Method (pre 2.8) */
|
2016-10-07 14:56:08 -04:00
|
|
|
float color[4] = {0.0f, 0.0f, 0.0f, calpha};
|
2019-04-17 08:24:14 +02:00
|
|
|
UI_draw_roundbox_4fv(
|
|
|
|
true, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a, color);
|
2018-04-06 10:09:23 +02:00
|
|
|
#endif
|
|
|
|
/* Compute final visibility to match old method result. */
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: we could just find a better fit function inside the shader instead of this. */
|
2018-04-06 10:09:23 +02:00
|
|
|
visibility = visibility * (1.0f - calpha);
|
2012-06-01 14:42:21 +00:00
|
|
|
calpha += dalpha;
|
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-04-17 06:17:24 +02:00
|
|
|
|
2018-04-06 10:09:23 +02:00
|
|
|
uiWidgetBaseParameters widget_params = {
|
|
|
|
.recti.xmin = rct->xmin,
|
|
|
|
.recti.ymin = rct->ymin,
|
|
|
|
.recti.xmax = rct->xmax,
|
|
|
|
.recti.ymax = rct->ymax - 10.0f,
|
|
|
|
.rect.xmin = rct->xmin - a,
|
|
|
|
.rect.ymin = rct->ymin - a,
|
|
|
|
.rect.xmax = rct->xmax + a,
|
|
|
|
.rect.ymax = rct->ymax - 10.0f + a,
|
|
|
|
.radi = rad,
|
|
|
|
.rad = rad + a,
|
|
|
|
.round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f : 0.0f,
|
|
|
|
.round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f : 0.0f,
|
|
|
|
.round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 0.0f,
|
|
|
|
.round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 0.0f,
|
2018-05-03 09:56:20 +02:00
|
|
|
.alpha_discard = 1.0f,
|
2018-04-06 10:09:23 +02:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUBatch *batch = ui_batch_roundbox_shadow_get();
|
|
|
|
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
|
2021-03-04 16:57:30 +11:00
|
|
|
GPU_batch_uniform_4fv_array(batch, "parameters", 4, (const float(*)[4]) & widget_params);
|
2018-07-18 00:12:21 +02:00
|
|
|
GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility);
|
|
|
|
GPU_batch_draw(batch);
|
2019-04-17 06:17:24 +02: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
|
|
|
/* outline emphasis */
|
2020-08-07 22:36:11 +10:00
|
|
|
const float color[4] = {0.0f, 0.0f, 0.0f, 0.4f};
|
2021-01-25 18:31:11 +11:00
|
|
|
UI_draw_roundbox_4fv(
|
|
|
|
&(const rctf){
|
|
|
|
.xmin = rct->xmin - 0.5f,
|
|
|
|
.xmax = rct->xmax + 0.5f,
|
|
|
|
.ymin = rct->ymin - 0.5f,
|
|
|
|
.ymax = rct->ymax + 0.5f,
|
|
|
|
},
|
|
|
|
false,
|
|
|
|
radius + 0.5f,
|
|
|
|
color);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-16 15:38:34 +02:00
|
|
|
GPU_blend(GPU_BLEND_NONE);
|
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
|
|
|
}
|