Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/util/numinput.c
| Show All 39 Lines | |||||
| #endif | #endif | ||||
| #include "ED_numinput.h" | #include "ED_numinput.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| /* Numeric input which isn't allowing full numeric editing. */ | /* Numeric input which isn't allowing full numeric editing. */ | ||||
| #define USE_FAKE_EDIT | #define USE_FAKE_EDIT | ||||
| /** #NumInput.flag | /** | ||||
| * #NumInput.flag | |||||
| * (1 << 8) and below are reserved for public flags! | * (1 << 8) and below are reserved for public flags! | ||||
| */ | */ | ||||
| enum { | enum { | ||||
| /** Enable full editing, with units and math operators support. */ | /** Enable full editing, with units and math operators support. */ | ||||
| NUM_EDIT_FULL = (1 << 9), | NUM_EDIT_FULL = (1 << 9), | ||||
| #ifdef USE_FAKE_EDIT | #ifdef USE_FAKE_EDIT | ||||
| /** Fake edited state (temp, avoids issue with backspace). */ | /** Fake edited state (temp, avoids issue with backspace). */ | ||||
| NUM_FAKE_EDITED = (1 << 10), | NUM_FAKE_EDITED = (1 << 10), | ||||
| ▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | #ifdef WITH_PYTHON | ||||
| } | } | ||||
| else { | else { | ||||
| int success = BPY_execute_string_as_number(C, NULL, str, true, r_value); | int success = BPY_execute_string_as_number(C, NULL, str, true, r_value); | ||||
| *r_value *= bUnit_PreferredInputUnitScalar(unit, type); | *r_value *= bUnit_PreferredInputUnitScalar(unit, type); | ||||
| *r_value /= unit_scale; | *r_value /= unit_scale; | ||||
| return success; | return success; | ||||
| } | } | ||||
| #else | #else | ||||
| UNUSED_VARS(C, unit, type); | |||||
| *r_value = atof(str); | *r_value = atof(str); | ||||
| return true; | return true; | ||||
| #endif | #endif | ||||
| } | } | ||||
| static bool editstr_is_simple_numinput(const char ascii) | static bool editstr_is_simple_numinput(const char ascii) | ||||
| { | { | ||||
| if (ascii >= '0' && ascii <= '9') { | if (ascii >= '0' && ascii <= '9') { | ||||
| ▲ Show 20 Lines • Show All 307 Lines • Show Last 20 Lines | |||||