Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_string_cursor_utf8.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_unit.h"
#include "DNA_scene_types.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_numinput.h"
#include "UI_interface.h"
Go to the source code of this file.
Macros | |
#define | USE_FAKE_EDIT |
Enumerations | |
enum | { NUM_EDIT_FULL = (1 << 9) , NUM_FAKE_EDITED = (1 << 10) } |
enum | { NUM_EDITED = (1 << 9) , NUM_INVALID = (1 << 10) , NUM_NEGATE = (1 << 11) , NUM_INVERSE = (1 << 12) } |
Functions | |
void | initNumInput (NumInput *n) |
void | outputNumInput (NumInput *n, char *str, UnitSettings *unit_settings) |
bool | hasNumInput (const NumInput *n) |
bool | applyNumInput (NumInput *n, float *vec) |
static void | value_to_editstr (NumInput *n, int idx) |
static bool | editstr_insert_at_cursor (NumInput *n, const char *buf, const int buf_len) |
bool | user_string_to_number (bContext *C, const char *str, const UnitSettings *unit, int type, double *r_value, const bool use_single_line_error, char **r_error) |
static bool | editstr_is_simple_numinput (const char ascii) |
bool | handleNumInput (bContext *C, NumInput *n, const wmEvent *event) |
#define USE_FAKE_EDIT |
Definition at line 35 of file numinput.c.
anonymous enum |
NumInput.flag (1 << 8) and below are reserved for public flags!
Enumerator | |
---|---|
NUM_EDIT_FULL | Enable full editing, with units and math operators support. |
NUM_FAKE_EDITED | Fake edited state (temp, avoids issue with backspace). |
Definition at line 41 of file numinput.c.
anonymous enum |
Definition at line 51 of file numinput.c.
Definition at line 189 of file numinput.c.
References NumInput::flag, floorf, hasNumInput(), NumInput::idx, NumInput::idx_max, NUM_AFFECT_ALL, NUM_EDITED, NUM_FAKE_EDITED, NUM_NO_FRACTION, NUM_NO_NEGATIVE, NUM_NO_ZERO, NUM_NULL_ONE, NumInput::val, NumInput::val_flag, and NumInput::val_org.
Referenced by applyBakeTime(), applyBevelWeight(), applyBoneEnvelope(), applyBoneRoll(), applyBoneSize(), applyCrease(), applyCurveShrinkFatten(), applyEdgeSlide(), applyGPOpacity(), applyGPShrinkFatten(), applyMaskShrinkFatten(), applyNormalRotation(), applyPushPull(), applyResize(), applyRotation(), applySeqSlide(), applyShear(), applyShrinkFatten(), applySkinResize(), applyTilt(), applyTimeScale(), applyTimeSlide(), applyTimeTranslate(), applyToSphere(), applyTrackball(), applyTranslation(), applyVertSlide(), Bend(), ed_marker_move_modal(), edbm_bevel_numinput_set_value(), edbm_inset_modal(), ElementResize(), gpencil_interpolate_modal(), gpencil_primitive_modal(), graph_slider_modal(), knifetool_modal(), loopcut_modal(), pose_slide_modal(), radial_control_modal(), and sequencer_slip_modal().
Definition at line 248 of file numinput.c.
References len, NUM_STR_REP_LEN, NumInput::str, and NumInput::str_cur.
Referenced by handleNumInput().
|
static |
Definition at line 300 of file numinput.c.
Referenced by handleNumInput().
Definition at line 311 of file numinput.c.
References ATTR_FALLTHROUGH, B_UNIT_ROTATION, BKE_report(), BLI_str_cursor_step_utf8(), BLI_str_utf8_size(), C, copy_v3_v3(), CTX_data_scene(), CTX_wm_reports(), DEG2RAD, editstr_insert_at_cursor(), editstr_is_simple_numinput(), ELEM, error(), EVT_BACKSPACEKEY, EVT_CKEY, EVT_DELKEY, EVT_ENDKEY, EVT_HOMEKEY, EVT_LEFTARROWKEY, EVT_MINUSKEY, EVT_MODAL_MAP, EVT_PADMINUS, EVT_PADPERIOD, EVT_PADSLASHKEY, EVT_PERIODKEY, EVT_RIGHTARROWKEY, EVT_SLASHKEY, EVT_TABKEY, EVT_VKEY, NumInput::flag, float(), NumInput::idx, NumInput::idx_max, IFACE_, CCL_NAMESPACE_BEGIN::isfinite(), KM_ALT, KM_CTRL, KM_SHIFT, MEM_freeN, wmEvent::modifier, NULL, NUM_EDIT_FULL, NUM_EDITED, NUM_FAKE_EDITED, NUM_INVALID, NUM_INVERSE, NUM_MODAL_INCREMENT_DOWN, NUM_MODAL_INCREMENT_UP, NUM_NEGATE, RAD2DEG, BPy_RunErrInfo::reports, RPT_ERROR, NumInput::str, NumInput::str_cur, STRCUR_DIR_NEXT, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM, STRCUR_JUMP_NONE, SWAP, wmEvent::type, Scene::unit, NumInput::unit_type, NumInput::unit_use_radians, UNLIKELY, USER_FLAG_NUMINPUT_ADVANCED, user_string_to_number(), wmEvent::utf8_buf, NumInput::val, wmEvent::val, NumInput::val_flag, NumInput::val_inc, NumInput::val_org, value_to_editstr(), WM_clipboard_text_get_firstline(), WM_clipboard_text_set(), and WM_event_utf8_to_ascii().
Definition at line 170 of file numinput.c.
References NumInput::flag, NumInput::idx_max, NUM_EDITED, NUM_FAKE_EDITED, and NumInput::val_flag.
Referenced by applyBakeTime(), applyBevelWeight(), applyBoneEnvelope(), applyBoneRoll(), applyCrease(), applyCurveShrinkFatten(), applyEdgeSlide(), applyGPOpacity(), applyGPShrinkFatten(), applyMaskShrinkFatten(), applyNumInput(), applyPushPull(), applyRotation(), applyShear(), applyShrinkFatten(), applyTilt(), applyToSphere(), applyTrackball(), applyVertSlide(), Bend(), blend_to_default_draw_status_header(), blend_to_neighbor_draw_status_header(), breakdown_draw_status_header(), constraints_rotation_impl(), decimate_draw_status(), ed_marker_move_modal(), ed_marker_move_update_header(), edbm_bevel_modal(), edbm_inset_modal(), edbm_inset_update_header(), gpencil_interpolate_modal(), gpencil_interpolate_status_indicators(), gpencil_primitive_modal(), gpencil_primitive_status_indicators(), graph_slider_modal(), headerBoneSize(), headerResize(), headerRotation(), headerSeqSlide(), headerTimeScale(), headerTimeSlide(), headerTimeTranslate(), headerTranslation(), knifetool_modal(), loopcut_modal(), pose_slide_draw_status(), pose_slide_modal(), radial_control_modal(), radial_control_update_header(), sequencer_slip_modal(), sequencer_slip_update_header(), and transformEvent().
There are important things to note here for code using numeric-input:
bool
returned by applyNumInput should be used to decide whether to apply numeric-input-specific post-process to data.drawstr
source or not (i.e. to call outputNumInput).Those two steps have to be separated (so do not use a common call to hasNumInput() to do both in the same time!).
Definition at line 69 of file numinput.c.
References B_UNIT_NONE, copy_vn_fl(), copy_vn_i(), copy_vn_short(), NumInput::flag, NumInput::idx, NumInput::idx_max, NUM_MAX_ELEMENTS, NumInput::str, NumInput::str_cur, NumInput::unit_sys, NumInput::unit_type, NumInput::unit_use_radians, USER_UNIT_NONE, NumInput::val, NumInput::val_flag, NumInput::val_inc, NumInput::val_org, and zero_v3().
Referenced by ed_marker_move_init(), edbm_bevel_init(), edbm_inset_init(), initTransInfo(), knifetool_init(), pose_slide_init(), radial_control_invoke(), ringsel_init(), and sequencer_slip_invoke().
void outputNumInput | ( | NumInput * | n, |
char * | str, | ||
struct UnitSettings * | unit_settings | ||
) |
str | Must be NUM_STR_REP_LEN * (idx_max + 1) length. |
Definition at line 87 of file numinput.c.
References B_UNIT_ROTATION, BKE_scene_unit_scale(), BKE_unit_value_as_string_adaptive(), BLI_snprintf(), BLI_str_utf8_invalid_strip(), BLI_strncpy(), NumInput::flag, float(), NumInput::idx, NumInput::idx_max, NUM_AFFECT_ALL, NUM_EDITED, NUM_INVALID, NUM_INVERSE, NUM_NEGATE, NUM_STR_REP_LEN, str, NumInput::str, NumInput::str_cur, UI_calc_float_precision(), NumInput::unit_sys, NumInput::unit_type, NumInput::unit_use_radians, NumInput::val, and NumInput::val_flag.
Referenced by applyBakeTime(), applyBevelWeight(), applyBoneEnvelope(), applyBoneRoll(), applyCrease(), applyCurveShrinkFatten(), applyEdgeSlide(), applyGPOpacity(), applyGPShrinkFatten(), applyMaskShrinkFatten(), applyPushPull(), applyShear(), applyShrinkFatten(), applyTilt(), applyToSphere(), applyTrackball(), applyVertSlide(), Bend(), blend_to_default_draw_status_header(), blend_to_neighbor_draw_status_header(), breakdown_draw_status_header(), decimate_draw_status(), ed_marker_move_update_header(), edbm_inset_update_header(), gpencil_interpolate_status_indicators(), gpencil_primitive_status_indicators(), headerBoneSize(), headerResize(), headerRotation(), headerSeqSlide(), headerTimeScale(), headerTimeSlide(), headerTimeTranslate(), headerTranslation(), loopcut_modal(), pose_slide_draw_status(), radial_control_update_header(), and sequencer_slip_update_header().
bool user_string_to_number | ( | bContext * | C, |
const char * | str, | ||
const UnitSettings * | unit, | ||
int | type, | ||
double * | r_value, | ||
const bool | use_single_line_error, | ||
char ** | r_error | ||
) |
Definition at line 265 of file numinput.c.
References BKE_scene_unit_scale(), BKE_unit_apply_preferred_unit(), BKE_unit_replace_string(), BKE_unit_string_contains_unit(), BLI_strncpy(), BPY_run_string_as_number(), C, NULL, str, UnitSettings::system, type, UNUSED_VARS, and BPy_RunErrInfo::use_single_line_error.
Referenced by handleNumInput().
Definition at line 235 of file numinput.c.
References BKE_unit_value_as_string_adaptive(), NUM_STR_REP_LEN, NumInput::str, NumInput::str_cur, NumInput::unit_sys, NumInput::unit_type, and NumInput::val.
Referenced by handleNumInput().