From 8856b598fdb411bac0dd65053a1d91093c8cac3b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 18 Feb 2011 13:57:54 +0000 Subject: Another small text space usability: option to show right margin (aka print marign) --- source/blender/editors/space_text/space_text.c | 1 + source/blender/editors/space_text/text_draw.c | 9 +++++++++ source/blender/makesdna/DNA_space_types.h | 4 ++++ source/blender/makesrna/intern/rna_space.c | 11 +++++++++++ 4 files changed, 25 insertions(+) (limited to 'source') diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 85b9f1b68e6..3a9b8924eed 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -71,6 +71,7 @@ static SpaceLink *text_new(const bContext *UNUSED(C)) stext->lheight= 12; stext->tabnumber= 4; + stext->margin_column= 80; /* header */ ar= MEM_callocN(sizeof(ARegion), "header for text"); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index bc0eb0a773f..b3e6920aa29 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1779,6 +1779,15 @@ void draw_text_main(SpaceText *st, ARegion *ar) wrap_skip= 0; } + if(st->flags&ST_SHOW_MARGIN) { + UI_ThemeColor(TH_HILITE); + + glBegin(GL_LINES); + glVertex2i(x+st->cwidth*st->margin_column, 0); + glVertex2i(x+st->cwidth*st->margin_column, ar->winy - 2); + glEnd(); + } + /* draw other stuff */ draw_brackets(st, ar); draw_markers(st, ar); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index d6dbabafb0e..a23aed505ae 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -327,6 +327,9 @@ typedef struct SpaceText { char findstr[256]; /* ST_MAX_FIND_STR */ char replacestr[256]; /* ST_MAX_FIND_STR */ + short margin_column; /* column number to show right margin at */ + char pad[6]; + void *drawcache; /* cache for faster drawing */ } SpaceText; @@ -817,6 +820,7 @@ enum { // execution (see BPY_main.c) #define ST_FIND_WRAP 0x0020 #define ST_FIND_ALL 0x0040 +#define ST_SHOW_MARGIN 0x0080 /* stext->findstr/replacestr */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e122f99776d..70c0b70e326 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1698,6 +1698,17 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, NULL); + prop= RNA_def_property(srna, "show_margin", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_SHOW_MARGIN); + RNA_def_property_ui_text(prop, "Show Margin", "Show right margin"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, NULL); + + prop= RNA_def_property(srna, "margin_column", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "margin_column"); + RNA_def_property_range(prop, 0, 1024); + RNA_def_property_ui_text(prop, "Margin Column", "Column number to show right margin at"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, NULL); + /* functionality options */ prop= RNA_def_property(srna, "use_overwrite", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "overwrite", 1); -- cgit v1.2.3