Blender  V3.3
Macros | Enumerations | Functions
numinput.c File Reference
#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)
 

Macro Definition Documentation

◆ USE_FAKE_EDIT

#define USE_FAKE_EDIT

Definition at line 35 of file numinput.c.

Enumeration Type Documentation

◆ anonymous enum

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

anonymous enum
Enumerator
NUM_EDITED 

User has edited this value somehow.

NUM_INVALID 

Current expression for this value is invalid.

NUM_NEGATE 

Current expression's result has to be negated.

NUM_INVERSE 

Current expression's result has to be inverted.

Definition at line 51 of file numinput.c.

Function Documentation

◆ applyNumInput()

bool applyNumInput ( NumInput n,
float vec 
)

◆ editstr_insert_at_cursor()

static bool editstr_insert_at_cursor ( NumInput n,
const char *  buf,
const int  buf_len 
)
static

Definition at line 248 of file numinput.c.

References len, NUM_STR_REP_LEN, NumInput::str, and NumInput::str_cur.

Referenced by handleNumInput().

◆ editstr_is_simple_numinput()

static bool editstr_is_simple_numinput ( const char  ascii)
static

Definition at line 300 of file numinput.c.

Referenced by handleNumInput().

◆ handleNumInput()

bool handleNumInput ( bContext C,
NumInput n,
const wmEvent event 
)

◆ hasNumInput()

bool hasNumInput ( const NumInput n)

◆ initNumInput()

void initNumInput ( NumInput n)

There are important things to note here for code using numeric-input:

  • Values passed to applyNumInput() should be valid and are stored as default ones (val_org), if it is not EDITED.
  • bool returned by applyNumInput should be used to decide whether to apply numeric-input-specific post-process to data.
  • Once applyNumInput has been called, hasNumInput returns a valid value to decide whether to use numinput as 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().

◆ outputNumInput()

void outputNumInput ( NumInput n,
char *  str,
struct UnitSettings unit_settings 
)

◆ user_string_to_number()

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 
)

◆ value_to_editstr()

static void value_to_editstr ( NumInput n,
int  idx 
)
static