Compare commits
3 Commits
tmp-drw-sp
...
soc-2022-t
Author | SHA1 | Date | |
---|---|---|---|
422c330390 | |||
8cd76bff47 | |||
9d1cfd9dde |
@@ -5576,6 +5576,8 @@ def km_font(params):
|
|||||||
{"properties": [("delta", 1)]}),
|
{"properties": [("delta", 1)]}),
|
||||||
("font.change_character", {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
("font.change_character", {"type": 'DOWN_ARROW', "value": 'PRESS', "alt": True, "repeat": True},
|
||||||
{"properties": [("delta", -1)]}),
|
{"properties": [("delta", -1)]}),
|
||||||
|
("font.selection_set", {"type": 'LEFTMOUSE', "value": 'PRESS',"ctrl":True,"alt":True}, None),
|
||||||
|
("font.select_word", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK',"ctrl":True,"alt":True}, None),
|
||||||
("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
|
("font.select_all", {"type": 'A', "value": 'PRESS', "ctrl": True}, None),
|
||||||
("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
|
("font.text_copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
|
||||||
("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
|
("font.text_cut", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
|
||||||
|
@@ -357,12 +357,18 @@ class DATA_PT_font(CurveButtonsPanelText, Panel):
|
|||||||
|
|
||||||
if mode == 'EDIT_TEXT':
|
if mode == 'EDIT_TEXT':
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
if text.is_selected == False :
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(char, "use_bold", toggle=True)
|
row.prop(char, "use_bold", toggle=True)
|
||||||
row.prop(char, "use_italic", toggle=True)
|
row.prop(char, "use_italic", toggle=True)
|
||||||
row.prop(char, "use_underline", toggle=True)
|
row.prop(char, "use_underline", toggle=True)
|
||||||
row.prop(char, "use_small_caps", toggle=True)
|
row.prop(char, "use_small_caps", toggle=True)
|
||||||
|
else:
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.operator("font.style_toggle", text="Bold", icon='BOLD' , depress = text.select_is_bold).style = 'BOLD'
|
||||||
|
row.operator("font.style_toggle", text="Italic", icon='ITALIC' , depress = text.select_is_italics).style = 'ITALIC'
|
||||||
|
row.operator("font.style_toggle", text="Underline", icon='UNDERLINE' , depress = text.select_is_underline).style = 'UNDERLINE'
|
||||||
|
row.operator("font.style_toggle", text="Small Caps", icon='SMALL_CAPS' , depress = text.select_is_smallcaps).style = 'SMALL_CAPS'
|
||||||
|
|
||||||
|
|
||||||
class DATA_PT_font_transform(CurveButtonsPanelText, Panel):
|
class DATA_PT_font_transform(CurveButtonsPanelText, Panel):
|
||||||
|
@@ -41,8 +41,22 @@ typedef struct EditFont {
|
|||||||
* a copy of these is kept in Curve, but use these in editmode */
|
* a copy of these is kept in Curve, but use these in editmode */
|
||||||
int len, pos;
|
int len, pos;
|
||||||
int selstart, selend;
|
int selstart, selend;
|
||||||
|
char _pad6[7];
|
||||||
|
char select_is_underline;
|
||||||
|
char select_is_italics;
|
||||||
|
char _pad0[7];
|
||||||
|
char select_is_bold;
|
||||||
|
char _pad1[7];
|
||||||
|
char select_is_smallcaps;
|
||||||
|
char _pad2[7];
|
||||||
|
char is_selected;
|
||||||
|
|
||||||
/**
|
float _pad3[7];
|
||||||
|
float m_loc[3];
|
||||||
|
int _pad4[7];
|
||||||
|
int m_pos;
|
||||||
|
int _pad9[7];
|
||||||
|
/**
|
||||||
* ID data is older than edit-mode data.
|
* ID data is older than edit-mode data.
|
||||||
* Set #Main.is_memfile_undo_flush_needed when enabling.
|
* Set #Main.is_memfile_undo_flush_needed when enabling.
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +82,19 @@ bool BKE_vfont_to_curve_ex(struct Object *ob,
|
|||||||
bool *r_text_free,
|
bool *r_text_free,
|
||||||
struct CharTrans **r_chartransdata);
|
struct CharTrans **r_chartransdata);
|
||||||
bool BKE_vfont_to_curve_nubase(struct Object *ob, int mode, struct ListBase *r_nubase);
|
bool BKE_vfont_to_curve_nubase(struct Object *ob, int mode, struct ListBase *r_nubase);
|
||||||
|
|
||||||
|
bool BKE_vfont_to_curve_ex2(struct Object *ob,
|
||||||
|
struct Curve *cu,
|
||||||
|
int mode,
|
||||||
|
struct ListBase *r_nubase,
|
||||||
|
const char32_t **r_text,
|
||||||
|
int *r_text_len,
|
||||||
|
bool *r_text_free,
|
||||||
|
struct CharTrans **r_chartransdata,
|
||||||
|
float cursor_location[2], int *r_cursor_locaiton_pos);
|
||||||
|
|
||||||
|
bool BKE_vfont_to_curve_curloc(struct Object *ob, int mode,float cursor_location[2], int *r_cursor_locaiton_pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \warning Expects to have access to evaluated data (i.e. passed object should be evaluated one).
|
* \warning Expects to have access to evaluated data (i.e. passed object should be evaluated one).
|
||||||
*/
|
*/
|
||||||
|
@@ -765,7 +765,7 @@ static float vfont_descent(const VFontData *vfd)
|
|||||||
return vfd->em_height - vfont_ascent(vfd);
|
return vfd->em_height - vfont_ascent(vfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vfont_to_curve(Object *ob,
|
static bool vfont_to_curve_ex(Object *ob,
|
||||||
Curve *cu,
|
Curve *cu,
|
||||||
int mode,
|
int mode,
|
||||||
VFontToCurveIter *iter_data,
|
VFontToCurveIter *iter_data,
|
||||||
@@ -773,7 +773,8 @@ static bool vfont_to_curve(Object *ob,
|
|||||||
const char32_t **r_text,
|
const char32_t **r_text,
|
||||||
int *r_text_len,
|
int *r_text_len,
|
||||||
bool *r_text_free,
|
bool *r_text_free,
|
||||||
struct CharTrans **r_chartransdata)
|
struct CharTrans **r_chartransdata,
|
||||||
|
float cursor_location[2], int *r_cursor_locaiton_pos)
|
||||||
{
|
{
|
||||||
EditFont *ef = cu->editfont;
|
EditFont *ef = cu->editfont;
|
||||||
EditFontSelBox *selboxes = NULL;
|
EditFontSelBox *selboxes = NULL;
|
||||||
@@ -826,6 +827,14 @@ static bool vfont_to_curve(Object *ob,
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(cursor_location==NULL)
|
||||||
|
{
|
||||||
|
float cur_loc_temp[2];
|
||||||
|
cur_loc_temp[0]=0.0;
|
||||||
|
cur_loc_temp[1]=0.0;
|
||||||
|
cursor_location=cur_loc_temp;
|
||||||
|
}
|
||||||
|
|
||||||
vfd = vfont_get_data(vfont);
|
vfd = vfont_get_data(vfont);
|
||||||
|
|
||||||
/* The VFont Data can not be found */
|
/* The VFont Data can not be found */
|
||||||
@@ -873,8 +882,10 @@ static bool vfont_to_curve(Object *ob,
|
|||||||
if (BKE_vfont_select_get(ob, &selstart, &selend)) {
|
if (BKE_vfont_select_get(ob, &selstart, &selend)) {
|
||||||
ef->selboxes_len = (selend - selstart) + 1;
|
ef->selboxes_len = (selend - selstart) + 1;
|
||||||
ef->selboxes = MEM_calloc_arrayN(ef->selboxes_len, sizeof(EditFontSelBox), "font selboxes");
|
ef->selboxes = MEM_calloc_arrayN(ef->selboxes_len, sizeof(EditFontSelBox), "font selboxes");
|
||||||
|
ef->is_selected= true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ef->is_selected=false;
|
||||||
ef->selboxes_len = 0;
|
ef->selboxes_len = 0;
|
||||||
ef->selboxes = NULL;
|
ef->selboxes = NULL;
|
||||||
}
|
}
|
||||||
@@ -906,6 +917,13 @@ static bool vfont_to_curve(Object *ob,
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
int ret=-1;
|
||||||
|
float min_dist;
|
||||||
|
if(ef!=NULL && ob!=NULL)
|
||||||
|
{ float ffx=cursor_location[0];
|
||||||
|
float ffy=cursor_location[1];
|
||||||
|
min_dist=ffx*ffx+ffy*ffy;
|
||||||
|
}
|
||||||
while (i <= slen) {
|
while (i <= slen) {
|
||||||
/* Characters in the list */
|
/* Characters in the list */
|
||||||
info = &custrinfo[i];
|
info = &custrinfo[i];
|
||||||
@@ -1120,9 +1138,42 @@ static bool vfont_to_curve(Object *ob,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ct++;
|
ct++;
|
||||||
|
if (ef != NULL && ob != NULL){
|
||||||
|
float fx=cursor_location[0];
|
||||||
|
float fy=cursor_location[1];
|
||||||
|
float di= (fx-xof)*(fx-xof)+(fy-yof)*(fy-yof);
|
||||||
|
float di2=fx*fx+fy*fy;
|
||||||
|
|
||||||
|
if(di2<=min_dist && di2<di)
|
||||||
|
{
|
||||||
|
min_dist=di2;
|
||||||
|
ret=-1;
|
||||||
|
}
|
||||||
|
else if(di<min_dist)
|
||||||
|
{
|
||||||
|
min_dist=di;
|
||||||
|
ret=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (ef != NULL && ob != NULL)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(ret==-1)
|
||||||
|
{
|
||||||
|
ret++;
|
||||||
|
if(r_cursor_locaiton_pos)
|
||||||
|
*r_cursor_locaiton_pos=ret;
|
||||||
|
}
|
||||||
|
else if(ret>=0 && ret<=ef->len-1)
|
||||||
|
{
|
||||||
|
ret++;
|
||||||
|
if(r_cursor_locaiton_pos)
|
||||||
|
*r_cursor_locaiton_pos=ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
current_line_length += xof + twidth - MARGIN_X_MIN;
|
current_line_length += xof + twidth - MARGIN_X_MIN;
|
||||||
longest_line_length = MAX2(current_line_length, longest_line_length);
|
longest_line_length = MAX2(current_line_length, longest_line_length);
|
||||||
|
|
||||||
@@ -1135,7 +1186,27 @@ static bool vfont_to_curve(Object *ob,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line-data is now: width of line. */
|
bool is_bold=true;
|
||||||
|
bool is_italics=true;
|
||||||
|
bool is_underline=true;
|
||||||
|
bool is_smallcaps=true;
|
||||||
|
for(int k=selstart;k<=selend;k++)
|
||||||
|
{
|
||||||
|
|
||||||
|
info = &custrinfo[k];
|
||||||
|
is_bold = info->flag & CU_CHINFO_BOLD ? is_bold : false ;
|
||||||
|
is_italics = info->flag & CU_CHINFO_ITALIC ? is_italics : false ;
|
||||||
|
is_underline = info->flag & CU_CHINFO_UNDERLINE ? is_underline : false ;
|
||||||
|
is_smallcaps = info->flag & CU_CHINFO_SMALLCAPS ? is_smallcaps : false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ef != NULL && ob != NULL) {
|
||||||
|
ef->select_is_underline=is_underline;
|
||||||
|
ef->select_is_bold=is_bold;
|
||||||
|
ef->select_is_italics=is_italics;
|
||||||
|
ef->select_is_smallcaps=is_smallcaps;
|
||||||
|
}
|
||||||
|
/*TODO: Store the state of the text in one variable using flags*/
|
||||||
|
|
||||||
if (cu->spacemode != CU_ALIGN_X_LEFT) {
|
if (cu->spacemode != CU_ALIGN_X_LEFT) {
|
||||||
ct = chartransdata;
|
ct = chartransdata;
|
||||||
@@ -1703,6 +1774,20 @@ finally:
|
|||||||
#undef MARGIN_Y_MIN
|
#undef MARGIN_Y_MIN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool vfont_to_curve(Object *ob,
|
||||||
|
Curve *cu,
|
||||||
|
int mode,
|
||||||
|
VFontToCurveIter *iter_data,
|
||||||
|
ListBase *r_nubase,
|
||||||
|
const char32_t **r_text,
|
||||||
|
int *r_text_len,
|
||||||
|
bool *r_text_free,
|
||||||
|
struct CharTrans **r_chartransdata)
|
||||||
|
{
|
||||||
|
return vfont_to_curve_ex(ob,cu,mode,iter_data,r_nubase,r_text,r_text_len,r_text_free,r_chartransdata,NULL,NULL);
|
||||||
|
|
||||||
|
}
|
||||||
#undef DESCENT
|
#undef DESCENT
|
||||||
#undef ASCENT
|
#undef ASCENT
|
||||||
|
|
||||||
@@ -1724,8 +1809,34 @@ bool BKE_vfont_to_curve_ex(Object *ob,
|
|||||||
};
|
};
|
||||||
|
|
||||||
do {
|
do {
|
||||||
data.ok &= vfont_to_curve(
|
data.ok &= vfont_to_curve_ex(
|
||||||
ob, cu, mode, &data, r_nubase, r_text, r_text_len, r_text_free, r_chartransdata);
|
ob, cu, mode, &data, r_nubase, r_text, r_text_len, r_text_free, r_chartransdata,NULL,NULL);
|
||||||
|
} while (data.ok && ELEM(data.status, VFONT_TO_CURVE_SCALE_ONCE, VFONT_TO_CURVE_BISECT));
|
||||||
|
|
||||||
|
return data.ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BKE_vfont_to_curve_ex2(Object *ob,
|
||||||
|
Curve *cu,
|
||||||
|
int mode,
|
||||||
|
ListBase *r_nubase,
|
||||||
|
const char32_t **r_text,
|
||||||
|
int *r_text_len,
|
||||||
|
bool *r_text_free,
|
||||||
|
struct CharTrans **r_chartransdata,
|
||||||
|
float cursor_location[2], int *r_cursor_locaiton_pos)
|
||||||
|
{
|
||||||
|
VFontToCurveIter data = {
|
||||||
|
.iteraction = cu->totbox * FONT_TO_CURVE_SCALE_ITERATIONS,
|
||||||
|
.scale_to_fit = 1.0f,
|
||||||
|
.word_wrap = true,
|
||||||
|
.ok = true,
|
||||||
|
.status = VFONT_TO_CURVE_INIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
do {
|
||||||
|
data.ok &= vfont_to_curve_ex(
|
||||||
|
ob, cu, mode, &data, r_nubase, r_text, r_text_len, r_text_free, r_chartransdata,cursor_location,r_cursor_locaiton_pos);
|
||||||
} while (data.ok && ELEM(data.status, VFONT_TO_CURVE_SCALE_ONCE, VFONT_TO_CURVE_BISECT));
|
} while (data.ok && ELEM(data.status, VFONT_TO_CURVE_SCALE_ONCE, VFONT_TO_CURVE_BISECT));
|
||||||
|
|
||||||
return data.ok;
|
return data.ok;
|
||||||
@@ -1748,6 +1859,13 @@ bool BKE_vfont_to_curve(Object *ob, int mode)
|
|||||||
return BKE_vfont_to_curve_ex(ob, ob->data, mode, &cu->nurb, NULL, NULL, NULL, NULL);
|
return BKE_vfont_to_curve_ex(ob, ob->data, mode, &cu->nurb, NULL, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BKE_vfont_to_curve_curloc(Object *ob, int mode,float cursor_location[2], int *r_cursor_locaiton_pos)
|
||||||
|
{
|
||||||
|
Curve *cu = ob->data;
|
||||||
|
|
||||||
|
return BKE_vfont_to_curve_ex2(ob,ob->data,mode,&cu->nurb,NULL,NULL,NULL,NULL,cursor_location,r_cursor_locaiton_pos);
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name VFont Clipboard
|
/** \name VFont Clipboard
|
||||||
* \{ */
|
* \{ */
|
||||||
|
@@ -68,6 +68,9 @@ bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden);
|
|||||||
void FONT_OT_text_insert(struct wmOperatorType *ot);
|
void FONT_OT_text_insert(struct wmOperatorType *ot);
|
||||||
void FONT_OT_line_break(struct wmOperatorType *ot);
|
void FONT_OT_line_break(struct wmOperatorType *ot);
|
||||||
|
|
||||||
|
void FONT_OT_selection_set(struct wmOperatorType *ot);
|
||||||
|
void FONT_OT_select_word(struct wmOperatorType *ot);
|
||||||
|
|
||||||
void FONT_OT_case_toggle(struct wmOperatorType *ot);
|
void FONT_OT_case_toggle(struct wmOperatorType *ot);
|
||||||
void FONT_OT_case_set(struct wmOperatorType *ot);
|
void FONT_OT_case_set(struct wmOperatorType *ot);
|
||||||
void FONT_OT_style_toggle(struct wmOperatorType *ot);
|
void FONT_OT_style_toggle(struct wmOperatorType *ot);
|
||||||
|
@@ -28,6 +28,9 @@ void ED_operatortypes_curve(void)
|
|||||||
WM_operatortype_append(FONT_OT_text_insert);
|
WM_operatortype_append(FONT_OT_text_insert);
|
||||||
WM_operatortype_append(FONT_OT_line_break);
|
WM_operatortype_append(FONT_OT_line_break);
|
||||||
|
|
||||||
|
WM_operatortype_append(FONT_OT_selection_set);
|
||||||
|
WM_operatortype_append(FONT_OT_select_word);
|
||||||
|
|
||||||
WM_operatortype_append(FONT_OT_case_toggle);
|
WM_operatortype_append(FONT_OT_case_toggle);
|
||||||
WM_operatortype_append(FONT_OT_case_set);
|
WM_operatortype_append(FONT_OT_case_set);
|
||||||
WM_operatortype_append(FONT_OT_style_toggle);
|
WM_operatortype_append(FONT_OT_style_toggle);
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "BLI_math.h"
|
#include "BLI_math.h"
|
||||||
#include "BLI_string_cursor_utf8.h"
|
#include "BLI_string_cursor_utf8.h"
|
||||||
#include "BLI_utildefines.h"
|
#include "BLI_utildefines.h"
|
||||||
|
#include "BLI_math_geom.h"
|
||||||
|
|
||||||
#include "DNA_curve_types.h"
|
#include "DNA_curve_types.h"
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
@@ -422,6 +423,29 @@ static void text_update_edited(bContext *C, Object *obedit, int mode)
|
|||||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void text_update_edited_ex(bContext *C, Object *obedit, int mode,float cursor_location[2], int *r_cursor_locaiton_pos)
|
||||||
|
{
|
||||||
|
Curve *cu = obedit->data;
|
||||||
|
EditFont *ef = cu->editfont;
|
||||||
|
|
||||||
|
BLI_assert(ef->len >= 0);
|
||||||
|
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||||
|
BKE_vfont_to_curve_curloc(DEG_get_evaluated_object(depsgraph, obedit), mode,cursor_location,r_cursor_locaiton_pos);
|
||||||
|
|
||||||
|
cu->curinfo = ef->textbufinfo[ef->pos ? ef->pos - 1 : 0];
|
||||||
|
|
||||||
|
if (obedit->totcol > 0) {
|
||||||
|
obedit->actcol = cu->curinfo.mat_nr;
|
||||||
|
if (obedit->actcol < 1) {
|
||||||
|
obedit->actcol = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
|
||||||
|
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int kill_selection(Object *obedit, int ins) /* ins == new character len */
|
static int kill_selection(Object *obedit, int ins) /* ins == new character len */
|
||||||
{
|
{
|
||||||
Curve *cu = obedit->data;
|
Curve *cu = obedit->data;
|
||||||
@@ -1755,6 +1779,113 @@ void FONT_OT_text_insert(wmOperatorType *ot)
|
|||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Font Select Operator
|
||||||
|
* \{ */
|
||||||
|
static void font_cursor_set_apply(bContext *C, const wmEvent *event)
|
||||||
|
{
|
||||||
|
Object *obedit = CTX_data_active_object(C);
|
||||||
|
Curve *cu = obedit->data;
|
||||||
|
EditFont *ef = cu->editfont;
|
||||||
|
ARegion *region = CTX_wm_region(C);
|
||||||
|
int cur_loc_pos;
|
||||||
|
float rout[3];
|
||||||
|
float mal[2];
|
||||||
|
mal[0]=event->mval[0];
|
||||||
|
mal[1]=event->mval[1];
|
||||||
|
const float *co = obedit->obmat[3];
|
||||||
|
const float *no = obedit->obmat[2];
|
||||||
|
float plane[4];
|
||||||
|
plane_from_point_normal_v3(plane, co, no);
|
||||||
|
ED_view3d_win_to_3d_on_plane(region,plane,mal,true,rout);
|
||||||
|
mul_m4_v3(obedit->imat, rout);
|
||||||
|
float curs_loc[2];
|
||||||
|
curs_loc[0]=rout[0];
|
||||||
|
curs_loc[1]=rout[1];
|
||||||
|
|
||||||
|
text_update_edited_ex(C, obedit, FO_CURS,curs_loc,&cur_loc_pos);
|
||||||
|
if(cur_loc_pos<=ef->len)
|
||||||
|
{
|
||||||
|
if ((!ef->is_selected) && (ef->selstart==0)) {
|
||||||
|
if(ef->pos==0)
|
||||||
|
ef->selstart = ef->selend =1;
|
||||||
|
else
|
||||||
|
ef->selstart = ef->selend = cur_loc_pos+1;
|
||||||
|
}
|
||||||
|
ef->selend=cur_loc_pos;
|
||||||
|
ef->pos=cur_loc_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static int font_selection_set_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
|
{
|
||||||
|
Object *obedit = CTX_data_active_object(C);
|
||||||
|
Curve *cu = obedit->data;
|
||||||
|
EditFont *ef = cu->editfont;
|
||||||
|
|
||||||
|
font_cursor_set_apply(C, event);
|
||||||
|
ef->selstart=0;
|
||||||
|
ef->selend=0;
|
||||||
|
WM_event_add_modal_handler(C, op);
|
||||||
|
|
||||||
|
return OPERATOR_RUNNING_MODAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int font_selection_set_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (event->type) {
|
||||||
|
case LEFTMOUSE:
|
||||||
|
font_cursor_set_apply(C, event);
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
|
case MIDDLEMOUSE:
|
||||||
|
case RIGHTMOUSE:
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
|
case MOUSEMOVE:
|
||||||
|
font_cursor_set_apply(C, event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OPERATOR_RUNNING_MODAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FONT_OT_selection_set(struct wmOperatorType *ot)
|
||||||
|
{
|
||||||
|
/* identifiers */
|
||||||
|
ot->name = "Set Selection";
|
||||||
|
ot->idname = "FONT_OT_selection_set";
|
||||||
|
ot->description = "Set cursor selection";
|
||||||
|
/* api callbacks */
|
||||||
|
ot->invoke = font_selection_set_invoke;
|
||||||
|
ot->modal = font_selection_set_modal;
|
||||||
|
ot->poll = ED_operator_editfont;
|
||||||
|
}
|
||||||
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Select Word Operator
|
||||||
|
* \{ */
|
||||||
|
static int font_select_word_exec(bContext *C, wmOperator *UNUSED(op))
|
||||||
|
{
|
||||||
|
move_cursor(C,PREV_WORD,false);
|
||||||
|
move_cursor(C,NEXT_WORD,true);
|
||||||
|
return OPERATOR_FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FONT_OT_select_word(wmOperatorType *ot)
|
||||||
|
{
|
||||||
|
/* identifiers */
|
||||||
|
ot->name = "Select Word";
|
||||||
|
ot->idname = "FONT_OT_select_word";
|
||||||
|
ot->description = "Select word under cursor";
|
||||||
|
|
||||||
|
/* api callbacks */
|
||||||
|
ot->exec = font_select_word_exec;
|
||||||
|
ot->poll = ED_operator_editfont;
|
||||||
|
}
|
||||||
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Text-Box Add Operator
|
/** \name Text-Box Add Operator
|
||||||
* \{ */
|
* \{ */
|
||||||
|
@@ -837,6 +837,50 @@ static bool rna_Curve_is_editmode_get(PointerRNA *ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool rna_Curve_is_select_underline_get(PointerRNA *ptr)
|
||||||
|
{
|
||||||
|
Curve *cu= (Curve *)ptr->owner_id;
|
||||||
|
if(cu->editfont != NULL)
|
||||||
|
return cu->editfont->select_is_underline;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool rna_Curve_is_select_bold_get(PointerRNA *ptr)
|
||||||
|
{
|
||||||
|
Curve *cu= (Curve *)ptr->owner_id;
|
||||||
|
if(cu->editfont != NULL)
|
||||||
|
return cu->editfont->select_is_bold;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool rna_Curve_is_select_italics_get(PointerRNA *ptr)
|
||||||
|
{
|
||||||
|
Curve *cu= (Curve *)ptr->owner_id;
|
||||||
|
if(cu->editfont != NULL)
|
||||||
|
return cu->editfont->select_is_italics;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool rna_Curve_is_select_smallcaps_get(PointerRNA *ptr)
|
||||||
|
{
|
||||||
|
Curve *cu= (Curve *)ptr->owner_id;
|
||||||
|
if(cu->editfont != NULL)
|
||||||
|
return cu->editfont->select_is_smallcaps;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
static bool rna_Curve_is_selected(PointerRNA *ptr)
|
||||||
|
{
|
||||||
|
Curve *cu= (Curve *)ptr->owner_id;
|
||||||
|
if(cu->editfont != NULL)
|
||||||
|
return cu->editfont->is_selected;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static const float tilt_limit = DEG2RADF(21600.0f);
|
static const float tilt_limit = DEG2RADF(21600.0f);
|
||||||
@@ -1271,6 +1315,41 @@ static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
|
|||||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST);
|
RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST);
|
||||||
RNA_def_property_ui_text(prop, "Fast Editing", "Don't fill polygons while editing");
|
RNA_def_property_ui_text(prop, "Fast Editing", "Don't fill polygons while editing");
|
||||||
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "select_is_underline", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_select_underline_get", NULL);
|
||||||
|
RNA_def_property_ui_text(prop, "bold sig", "Checks for bold");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||||
|
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "select_is_bold", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_select_bold_get", NULL);
|
||||||
|
RNA_def_property_ui_text(prop, "bold sig", "Checks for bold");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||||
|
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "select_is_italics", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_select_italics_get", NULL);
|
||||||
|
RNA_def_property_ui_text(prop, "bold sig", "Checks for bold");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||||
|
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "select_is_smallcaps", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_select_smallcaps_get", NULL);
|
||||||
|
RNA_def_property_ui_text(prop, "bold sig", "Checks for bold");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||||
|
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "is_selected", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_funcs(prop, "rna_Curve_is_selected", NULL);
|
||||||
|
RNA_def_property_ui_text(prop, "bold sig", "Checks for bold");
|
||||||
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||||
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||||
|
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_def_textbox(BlenderRNA *brna)
|
static void rna_def_textbox(BlenderRNA *brna)
|
||||||
|
Reference in New Issue
Block a user