2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +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.
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edutil
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "MEM_guardedalloc.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "BLI_math.h"
|
2012-01-11 12:33:51 +00:00
|
|
|
#include "BLI_string.h"
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "BLI_string_cursor_utf8.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_string_utf8.h"
|
|
|
|
|
#include "BLI_utildefines.h"
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
|
2020-07-27 13:46:58 +10:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "BKE_context.h"
|
2014-08-26 20:52:07 +10:00
|
|
|
#include "BKE_scene.h"
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "BKE_unit.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "WM_api.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#ifdef WITH_PYTHON
|
2020-08-17 17:46:06 +10:00
|
|
|
# include "BPY_extern_run.h"
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-02-20 20:29:09 +00:00
|
|
|
#include "ED_numinput.h"
|
2014-01-08 17:04:10 +01:00
|
|
|
#include "UI_interface.h"
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2018-07-10 14:56:40 +02:00
|
|
|
/* Numeric input which isn't allowing full numeric editing. */
|
2018-07-11 15:22:57 +02:00
|
|
|
#define USE_FAKE_EDIT
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
|
2019-11-25 01:14:39 +11:00
|
|
|
/**
|
|
|
|
|
* #NumInput.flag
|
2019-01-15 23:24:20 +11:00
|
|
|
* (1 << 8) and below are reserved for public flags!
|
|
|
|
|
*/
|
2014-02-22 15:02:49 +01:00
|
|
|
enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
/** Enable full editing, with units and math operators support. */
|
|
|
|
|
NUM_EDIT_FULL = (1 << 9),
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
/** Fake edited state (temp, avoids issue with backspace). */
|
|
|
|
|
NUM_FAKE_EDITED = (1 << 10),
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2014-02-22 15:02:49 +01:00
|
|
|
};
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
/* NumInput.val_flag[] */
|
|
|
|
|
enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* (1 << 8) and below are reserved for public flags! */
|
|
|
|
|
/** User has edited this value somehow. */
|
|
|
|
|
NUM_EDITED = (1 << 9),
|
|
|
|
|
/** Current expression for this value is invalid. */
|
|
|
|
|
NUM_INVALID = (1 << 10),
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
/** Current expression's result has to be negated. */
|
|
|
|
|
NUM_NEGATE = (1 << 11),
|
|
|
|
|
/** Current expression's result has to be inverted. */
|
|
|
|
|
NUM_INVERSE = (1 << 12),
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
};
|
|
|
|
|
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
/* ************************** Functions *************************** */
|
|
|
|
|
|
|
|
|
|
/* ************************** NUMINPUT **************************** */
|
|
|
|
|
|
|
|
|
|
void initNumInput(NumInput *n)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
n->idx_max = 0;
|
|
|
|
|
n->unit_sys = USER_UNIT_NONE;
|
|
|
|
|
copy_vn_i(n->unit_type, NUM_MAX_ELEMENTS, B_UNIT_NONE);
|
|
|
|
|
n->unit_use_radians = false;
|
|
|
|
|
|
|
|
|
|
n->flag = 0;
|
|
|
|
|
copy_vn_short(n->val_flag, NUM_MAX_ELEMENTS, 0);
|
|
|
|
|
zero_v3(n->val);
|
|
|
|
|
copy_vn_fl(n->val_org, NUM_MAX_ELEMENTS, 0.0f);
|
|
|
|
|
copy_vn_fl(n->val_inc, NUM_MAX_ELEMENTS, 1.0f);
|
|
|
|
|
|
|
|
|
|
n->idx = 0;
|
|
|
|
|
n->str[0] = '\0';
|
|
|
|
|
n->str_cur = 0;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
/* str must be NUM_STR_REP_LEN * (idx_max + 1) length. */
|
2014-08-26 12:04:24 +02:00
|
|
|
void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
short j;
|
|
|
|
|
const int ln = NUM_STR_REP_LEN;
|
|
|
|
|
int prec = 2; /* draw-only, and avoids too much issues with radian->degrees conversion. */
|
|
|
|
|
|
|
|
|
|
for (j = 0; j <= n->idx_max; j++) {
|
|
|
|
|
/* if AFFECTALL and no number typed and cursor not on number, use first number */
|
|
|
|
|
const short i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ?
|
|
|
|
|
0 :
|
|
|
|
|
j;
|
|
|
|
|
|
|
|
|
|
/* Use scale_length if needed! */
|
|
|
|
|
const float fac = (float)BKE_scene_unit_scale(unit_settings, n->unit_type[j], 1.0);
|
|
|
|
|
|
|
|
|
|
if (n->val_flag[i] & NUM_EDITED) {
|
|
|
|
|
/* Get the best precision, allows us to draw '10.0001' as '10' instead! */
|
|
|
|
|
prec = UI_calc_float_precision(prec, (double)n->val[i]);
|
|
|
|
|
if (i == n->idx) {
|
|
|
|
|
const char *heading_exp = "", *trailing_exp = "";
|
|
|
|
|
char before_cursor[NUM_STR_REP_LEN];
|
|
|
|
|
char val[16];
|
2014-01-07 22:23:03 +01:00
|
|
|
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->val_flag[i] & NUM_NEGATE) {
|
|
|
|
|
heading_exp = (n->val_flag[i] & NUM_INVERSE) ? "-1/(" : "-(";
|
|
|
|
|
trailing_exp = ")";
|
|
|
|
|
}
|
|
|
|
|
else if (n->val_flag[i] & NUM_INVERSE) {
|
|
|
|
|
heading_exp = "1/(";
|
|
|
|
|
trailing_exp = ")";
|
|
|
|
|
}
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2014-01-07 22:23:03 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->val_flag[i] & NUM_INVALID) {
|
|
|
|
|
BLI_strncpy(val, "Invalid", sizeof(val));
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-09-09 08:41:15 -05:00
|
|
|
BKE_unit_value_as_string_adaptive(val,
|
|
|
|
|
sizeof(val),
|
|
|
|
|
(double)(n->val[i] * fac),
|
|
|
|
|
prec,
|
|
|
|
|
n->unit_sys,
|
|
|
|
|
n->unit_type[i],
|
|
|
|
|
true,
|
|
|
|
|
false);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* +1 because of trailing '\0' */
|
|
|
|
|
BLI_strncpy(before_cursor, n->str, n->str_cur + 1);
|
|
|
|
|
BLI_snprintf(&str[j * ln],
|
|
|
|
|
ln,
|
|
|
|
|
"[%s%s|%s%s] = %s",
|
|
|
|
|
heading_exp,
|
|
|
|
|
before_cursor,
|
|
|
|
|
&n->str[n->str_cur],
|
|
|
|
|
trailing_exp,
|
|
|
|
|
val);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const char *cur = (i == n->idx) ? "|" : "";
|
|
|
|
|
if (n->unit_use_radians && n->unit_type[i] == B_UNIT_ROTATION) {
|
|
|
|
|
/* Radian exception... */
|
|
|
|
|
BLI_snprintf(&str[j * ln], ln, "%s%.6gr%s", cur, n->val[i], cur);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
char tstr[NUM_STR_REP_LEN];
|
2020-09-09 08:41:15 -05:00
|
|
|
BKE_unit_value_as_string_adaptive(
|
2019-04-17 06:17:24 +02:00
|
|
|
tstr, ln, (double)n->val[i], prec, n->unit_sys, n->unit_type[i], true, false);
|
|
|
|
|
BLI_snprintf(&str[j * ln], ln, "%s%s%s", cur, tstr, cur);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
const char *cur = (i == n->idx) ? "|" : "";
|
|
|
|
|
BLI_snprintf(&str[j * ln], ln, "%sNONE%s", cur, cur);
|
|
|
|
|
}
|
|
|
|
|
/* We might have cut some multi-bytes utf8 chars
|
|
|
|
|
* (e.g. trailing '°' of degrees values can become only 'A')... */
|
|
|
|
|
BLI_utf8_invalid_strip(&str[j * ln], strlen(&str[j * ln]));
|
|
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-23 06:48:36 +00:00
|
|
|
bool hasNumInput(const NumInput *n)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
short i;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->flag & NUM_FAKE_EDITED) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2014-03-22 23:20:14 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (i = 0; i <= n->idx_max; i++) {
|
|
|
|
|
if (n->val_flag[i] & NUM_EDITED) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-26 03:47:20 +00:00
|
|
|
/**
|
|
|
|
|
* \warning \a vec must be set beforehand otherwise we risk uninitialized vars.
|
|
|
|
|
*/
|
2014-03-22 23:20:14 +01:00
|
|
|
bool applyNumInput(NumInput *n, float *vec)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
short i, j;
|
|
|
|
|
float val;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (hasNumInput(n)) {
|
|
|
|
|
for (j = 0; j <= n->idx_max; j++) {
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->flag & NUM_FAKE_EDITED) {
|
|
|
|
|
val = n->val[j];
|
|
|
|
|
}
|
|
|
|
|
else
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
|
/* if AFFECTALL and no number typed and cursor not on number, use first number */
|
|
|
|
|
i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ? 0 : j;
|
|
|
|
|
val = (!(n->val_flag[i] & NUM_EDITED) && n->val_flag[i] & NUM_NULL_ONE) ? 1.0f : n->val[i];
|
|
|
|
|
|
|
|
|
|
if (n->val_flag[i] & NUM_NO_NEGATIVE && val < 0.0f) {
|
|
|
|
|
val = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
if (n->val_flag[i] & NUM_NO_FRACTION && val != floorf(val)) {
|
|
|
|
|
val = floorf(val + 0.5f);
|
|
|
|
|
if (n->val_flag[i] & NUM_NO_ZERO && val == 0.0f) {
|
|
|
|
|
val = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (n->val_flag[i] & NUM_NO_ZERO && val == 0.0f) {
|
|
|
|
|
val = 0.0001f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vec[j] = val;
|
|
|
|
|
}
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
n->flag &= ~NUM_FAKE_EDITED;
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
|
|
|
|
|
/* Else, we set the 'org' values for numinput! */
|
|
|
|
|
for (j = 0; j <= n->idx_max; j++) {
|
|
|
|
|
n->val[j] = n->val_org[j] = vec[j];
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
return false;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
static void value_to_editstr(NumInput *n, int idx)
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const int prec = 6; /* editing, higher precision needed. */
|
2020-09-09 08:41:15 -05:00
|
|
|
n->str_cur = BKE_unit_value_as_string_adaptive(n->str,
|
|
|
|
|
NUM_STR_REP_LEN,
|
|
|
|
|
(double)n->val[idx],
|
|
|
|
|
prec,
|
|
|
|
|
n->unit_sys,
|
|
|
|
|
n->unit_type[idx],
|
|
|
|
|
true,
|
|
|
|
|
false);
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
}
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
static bool editstr_insert_at_cursor(NumInput *n, const char *buf, const int buf_len)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
int cur = n->str_cur;
|
|
|
|
|
int len = strlen(&n->str[cur]) + 1; /* +1 for the trailing '\0'. */
|
|
|
|
|
int n_cur = cur + buf_len;
|
2010-01-22 02:50:40 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n_cur + len >= NUM_STR_REP_LEN) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
memmove(&n->str[n_cur], &n->str[cur], len);
|
|
|
|
|
memcpy(&n->str[cur], buf, sizeof(char) * buf_len);
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
n->str_cur = n_cur;
|
|
|
|
|
return true;
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-27 13:46:58 +10:00
|
|
|
bool user_string_to_number(bContext *C,
|
|
|
|
|
const char *str,
|
|
|
|
|
const UnitSettings *unit,
|
|
|
|
|
int type,
|
|
|
|
|
const char *error_prefix,
|
|
|
|
|
double *r_value)
|
2018-10-03 10:20:16 +02:00
|
|
|
{
|
|
|
|
|
#ifdef WITH_PYTHON
|
2019-04-17 06:17:24 +02:00
|
|
|
double unit_scale = BKE_scene_unit_scale(unit, type, 1.0);
|
2020-09-09 08:41:15 -05:00
|
|
|
if (BKE_unit_string_contains_unit(str, type)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
char str_unit_convert[256];
|
|
|
|
|
BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert));
|
2020-09-09 08:41:15 -05:00
|
|
|
BKE_unit_replace_string(
|
2019-04-17 06:17:24 +02:00
|
|
|
str_unit_convert, sizeof(str_unit_convert), str, unit_scale, unit->system, type);
|
|
|
|
|
|
2020-08-17 17:46:06 +10:00
|
|
|
return BPY_run_string_as_number(C, NULL, str_unit_convert, error_prefix, r_value);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
|
2020-08-17 17:46:06 +10:00
|
|
|
int success = BPY_run_string_as_number(C, NULL, str, error_prefix, r_value);
|
2020-09-09 08:41:15 -05:00
|
|
|
*r_value = BKE_unit_apply_preferred_unit(unit, type, *r_value);
|
2020-07-03 17:30:31 +02:00
|
|
|
*r_value /= unit_scale;
|
|
|
|
|
return success;
|
|
|
|
|
|
2018-10-03 10:20:16 +02:00
|
|
|
#else
|
2019-11-25 15:45:03 +11:00
|
|
|
UNUSED_VARS(C, unit, type);
|
2019-04-17 06:17:24 +02:00
|
|
|
*r_value = atof(str);
|
|
|
|
|
return true;
|
2018-10-03 10:20:16 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-20 16:11:36 +11:00
|
|
|
static bool editstr_is_simple_numinput(const char ascii)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ascii >= '0' && ascii <= '9') {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
if (ascii == '.') {
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
return false;
|
2014-02-20 16:11:36 +11:00
|
|
|
}
|
|
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const char *utf8_buf = NULL;
|
|
|
|
|
char ascii[2] = {'\0', '\0'};
|
|
|
|
|
bool updated = false;
|
|
|
|
|
short idx = n->idx, idx_max = n->idx_max;
|
|
|
|
|
short dir = STRCUR_DIR_NEXT, mode = STRCUR_JUMP_NONE;
|
|
|
|
|
int cur;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
|
2018-07-11 16:31:28 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
if (U.flag & USER_FLAG_NUMINPUT_ADVANCED)
|
2018-07-11 16:31:28 +02:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
|
|
|
|
if ((event->ctrl == 0) && (event->alt == 0) && (event->ascii != '\0') &&
|
|
|
|
|
strchr("01234567890@%^&*-+/{}()[]<>.|", event->ascii)) {
|
|
|
|
|
if (!(n->flag & NUM_EDIT_FULL)) {
|
|
|
|
|
n->flag |= NUM_EDITED;
|
|
|
|
|
n->flag |= NUM_EDIT_FULL;
|
|
|
|
|
n->val_flag[idx] |= NUM_EDITED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 12:42:37 +01:00
|
|
|
#ifdef USE_FAKE_EDIT
|
|
|
|
|
/* XXX Hack around keyboards without direct access to '=' nor '*'... */
|
|
|
|
|
if (ELEM(event->ascii, '=', '*')) {
|
|
|
|
|
if (!(n->flag & NUM_EDIT_FULL)) {
|
|
|
|
|
n->flag |= NUM_EDIT_FULL;
|
|
|
|
|
n->val_flag[idx] |= NUM_EDITED;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2020-07-03 17:30:31 +02:00
|
|
|
if (event->ctrl) {
|
2020-03-26 12:42:37 +01:00
|
|
|
n->flag &= ~NUM_EDIT_FULL;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (event->type) {
|
|
|
|
|
case EVT_MODAL_MAP:
|
|
|
|
|
if (ELEM(event->val, NUM_MODAL_INCREMENT_UP, NUM_MODAL_INCREMENT_DOWN)) {
|
|
|
|
|
n->val[idx] += (event->val == NUM_MODAL_INCREMENT_UP) ? n->val_inc[idx] : -n->val_inc[idx];
|
|
|
|
|
value_to_editstr(n, idx);
|
|
|
|
|
n->val_flag[idx] |= NUM_EDITED;
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* might be a char too... */
|
|
|
|
|
utf8_buf = event->utf8_buf;
|
|
|
|
|
ascii[0] = event->ascii;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_BACKSPACEKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Part specific to backspace... */
|
|
|
|
|
if (!(n->val_flag[idx] & NUM_EDITED)) {
|
|
|
|
|
copy_v3_v3(n->val, n->val_org);
|
|
|
|
|
n->val_flag[0] &= ~NUM_EDITED;
|
|
|
|
|
n->val_flag[1] &= ~NUM_EDITED;
|
|
|
|
|
n->val_flag[2] &= ~NUM_EDITED;
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
n->flag |= NUM_FAKE_EDITED;
|
2018-07-10 14:56:40 +02:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
n->flag |= NUM_EDIT_FULL;
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
updated = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (event->shift || !n->str[0]) {
|
|
|
|
|
n->val[idx] = n->val_org[idx];
|
|
|
|
|
n->val_flag[idx] &= ~NUM_EDITED;
|
|
|
|
|
n->str[0] = '\0';
|
|
|
|
|
n->str_cur = 0;
|
|
|
|
|
updated = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* Else, common behavior with DELKEY,
|
|
|
|
|
* only difference is remove char(s) before/after the cursor. */
|
|
|
|
|
dir = STRCUR_DIR_PREV;
|
|
|
|
|
ATTR_FALLTHROUGH;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_DELKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((n->val_flag[idx] & NUM_EDITED) && n->str[0]) {
|
|
|
|
|
int t_cur = cur = n->str_cur;
|
|
|
|
|
if (event->ctrl) {
|
|
|
|
|
mode = STRCUR_JUMP_DELIM;
|
|
|
|
|
}
|
|
|
|
|
BLI_str_cursor_step_utf8(n->str, strlen(n->str), &t_cur, dir, mode, true);
|
|
|
|
|
if (t_cur != cur) {
|
|
|
|
|
if (t_cur < cur) {
|
|
|
|
|
SWAP(int, t_cur, cur);
|
|
|
|
|
n->str_cur = cur;
|
|
|
|
|
}
|
|
|
|
|
/* +1 for trailing '\0'. */
|
|
|
|
|
memmove(&n->str[cur], &n->str[t_cur], strlen(&n->str[t_cur]) + 1);
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
if (!n->str[0]) {
|
|
|
|
|
n->val[idx] = n->val_org[idx];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_LEFTARROWKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
dir = STRCUR_DIR_PREV;
|
|
|
|
|
ATTR_FALLTHROUGH;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_RIGHTARROWKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
cur = n->str_cur;
|
|
|
|
|
if (event->ctrl) {
|
|
|
|
|
mode = STRCUR_JUMP_DELIM;
|
|
|
|
|
}
|
|
|
|
|
BLI_str_cursor_step_utf8(n->str, strlen(n->str), &cur, dir, mode, true);
|
|
|
|
|
if (cur != n->str_cur) {
|
|
|
|
|
n->str_cur = cur;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_HOMEKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->str[0]) {
|
|
|
|
|
n->str_cur = 0;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_ENDKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->str[0]) {
|
|
|
|
|
n->str_cur = strlen(n->str);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_TABKEY:
|
2018-07-10 14:56:40 +02:00
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
n->val_flag[idx] &= ~(NUM_NEGATE | NUM_INVERSE);
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2010-02-20 20:29:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
idx = (idx + idx_max + (event->ctrl ? 0 : 2)) % (idx_max + 1);
|
|
|
|
|
n->idx = idx;
|
|
|
|
|
if (n->val_flag[idx] & NUM_EDITED) {
|
|
|
|
|
value_to_editstr(n, idx);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
n->str[0] = '\0';
|
|
|
|
|
n->str_cur = 0;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_PADPERIOD:
|
|
|
|
|
case EVT_PERIODKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Force numdot, some OSs/countries generate a comma char in this case,
|
|
|
|
|
* sic... (T37992) */
|
|
|
|
|
ascii[0] = '.';
|
|
|
|
|
utf8_buf = ascii;
|
|
|
|
|
break;
|
2015-08-06 12:34:31 +10:00
|
|
|
#if 0
|
2019-04-22 00:18:34 +10:00
|
|
|
/* Those keys are not directly accessible in all layouts,
|
|
|
|
|
* preventing to generate matching events.
|
2019-04-17 06:17:24 +02:00
|
|
|
* So we use a hack (ascii value) instead, see below.
|
|
|
|
|
*/
|
|
|
|
|
case EQUALKEY:
|
|
|
|
|
case PADASTERKEY:
|
|
|
|
|
if (!(n->flag & NUM_EDIT_FULL)) {
|
|
|
|
|
n->flag |= NUM_EDIT_FULL;
|
|
|
|
|
n->val_flag[idx] |= NUM_EDITED;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (event->ctrl) {
|
|
|
|
|
n->flag &= ~NUM_EDIT_FULL;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-03-21 12:05:13 +01:00
|
|
|
#endif
|
2018-07-10 14:56:40 +02:00
|
|
|
|
|
|
|
|
#ifdef USE_FAKE_EDIT
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_PADMINUS:
|
|
|
|
|
case EVT_MINUSKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
|
|
|
|
|
n->val_flag[idx] ^= NUM_NEGATE;
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_PADSLASHKEY:
|
|
|
|
|
case EVT_SLASHKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if (event->ctrl || !(n->flag & NUM_EDIT_FULL)) {
|
|
|
|
|
n->val_flag[idx] ^= NUM_INVERSE;
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_CKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if (event->ctrl) {
|
|
|
|
|
/* Copy current str to the copypaste buffer. */
|
|
|
|
|
WM_clipboard_text_set(n->str, 0);
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_VKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
if (event->ctrl) {
|
|
|
|
|
/* extract the first line from the clipboard */
|
|
|
|
|
int pbuf_len;
|
|
|
|
|
char *pbuf = WM_clipboard_text_get_firstline(false, &pbuf_len);
|
|
|
|
|
|
|
|
|
|
if (pbuf) {
|
|
|
|
|
const bool success = editstr_insert_at_cursor(n, pbuf, pbuf_len);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(pbuf);
|
|
|
|
|
if (!success) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
n->val_flag[idx] |= NUM_EDITED;
|
|
|
|
|
}
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!updated && !utf8_buf && (event->utf8_buf[0] || event->ascii)) {
|
|
|
|
|
utf8_buf = event->utf8_buf;
|
|
|
|
|
ascii[0] = event->ascii;
|
|
|
|
|
}
|
2014-03-21 12:05:13 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Up to this point, if we have a ctrl modifier, skip.
|
|
|
|
|
* This allows to still access most of modals' shortcuts even in numinput mode.
|
|
|
|
|
*/
|
|
|
|
|
if (!updated && event->ctrl) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((!utf8_buf || !utf8_buf[0]) && ascii[0]) {
|
|
|
|
|
/* Fallback to ascii. */
|
|
|
|
|
utf8_buf = ascii;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utf8_buf && utf8_buf[0]) {
|
|
|
|
|
if (!(n->flag & NUM_EDIT_FULL)) {
|
|
|
|
|
/* In simple edit mode, we only keep a few chars as valid! */
|
|
|
|
|
/* no need to decode unicode, ascii is first char only */
|
|
|
|
|
if (!editstr_is_simple_numinput(utf8_buf[0])) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!editstr_insert_at_cursor(n, utf8_buf, BLI_str_utf8_size(utf8_buf))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
n->val_flag[idx] |= NUM_EDITED;
|
|
|
|
|
}
|
|
|
|
|
else if (!updated) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* At this point, our value has changed, try to interpret it with python
|
|
|
|
|
* (if str is not empty!). */
|
|
|
|
|
if (n->str[0]) {
|
|
|
|
|
const float val_prev = n->val[idx];
|
|
|
|
|
Scene *sce = CTX_data_scene(C);
|
|
|
|
|
|
|
|
|
|
double val;
|
2020-07-27 13:46:58 +10:00
|
|
|
int success = user_string_to_number(
|
|
|
|
|
C, n->str, &sce->unit, n->unit_type[idx], IFACE_("Numeric input evaluation"), &val);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
n->val[idx] = (float)val;
|
|
|
|
|
n->val_flag[idx] &= ~NUM_INVALID;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
n->val_flag[idx] |= NUM_INVALID;
|
|
|
|
|
}
|
2018-07-10 14:56:40 +02:00
|
|
|
|
|
|
|
|
#ifdef USE_FAKE_EDIT
|
2019-04-17 06:17:24 +02:00
|
|
|
if (n->val_flag[idx] & NUM_NEGATE) {
|
|
|
|
|
n->val[idx] = -n->val[idx];
|
|
|
|
|
}
|
|
|
|
|
if (n->val_flag[idx] & NUM_INVERSE) {
|
|
|
|
|
val = n->val[idx];
|
|
|
|
|
/* If we invert on radians when user is in degrees,
|
|
|
|
|
* you get unexpected results... See T53463. */
|
|
|
|
|
if (!n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION) {
|
|
|
|
|
val = RAD2DEG(val);
|
|
|
|
|
}
|
|
|
|
|
val = 1.0 / val;
|
|
|
|
|
if (!n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION) {
|
|
|
|
|
val = DEG2RAD(val);
|
|
|
|
|
}
|
|
|
|
|
n->val[idx] = (float)val;
|
|
|
|
|
}
|
2018-07-10 14:56:40 +02:00
|
|
|
#endif
|
2016-02-19 10:19:19 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (UNLIKELY(!isfinite(n->val[idx]))) {
|
|
|
|
|
n->val[idx] = val_prev;
|
|
|
|
|
n->val_flag[idx] |= NUM_INVALID;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-22 23:25:34 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* REDRAW SINCE NUMBERS HAVE CHANGED */
|
|
|
|
|
return true;
|
2.5
Transform:
First working port of the transform code:
- Object mode only (other conversions need to be ported)
- Contraints (global and local only) working
- Snap (no edit mode, obviously) working
- Numinput working
- Gears (Ctrl and Shift) working
- Only grap, rotate, scale, shear, warp and to sphere have been added as hotkey, but the rest should work too once accessible
- No manipulator
- No drawn feedback other than moving stuff and header print (no constraint line, snap circle, ...)
- No NDOF support
I've only tested Scons support, though Makefil *should* work, I *think*.
Misc:
-QuatIsNull function in arith
-Exporting project_* and view[line|ray] functions from view3d
2008-12-29 01:41:28 +00:00
|
|
|
}
|