2003-10-10 03:16:32 +00:00
/**
* header_text . c oct - 2003
*
* Functions to draw the " Text Editor " window header
* and handle user events sent to it .
*
* $ Id $
*
2008-04-16 22:40:48 +00:00
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
2003-10-10 03:16:32 +00:00
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
2008-04-16 22:40:48 +00:00
* of the License , or ( at your option ) any later version .
2003-10-10 03:16:32 +00:00
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
2003-10-11 20:56:26 +00:00
* Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
2003-10-10 03:16:32 +00:00
*
* The Original Code is Copyright ( C ) 2001 - 2002 by NaN Holding BV .
* All rights reserved .
*
* The Original Code is : all of this file .
*
* Contributor ( s ) : none yet .
*
2008-04-16 22:40:48 +00:00
* * * * * * END GPL LICENSE BLOCK * * * * *
2003-10-10 03:16:32 +00:00
*/
# include <stdlib.h>
# include <string.h>
2004-03-26 01:12:45 +00:00
# include <stdio.h>
2003-10-10 03:16:32 +00:00
# ifdef HAVE_CONFIG_H
# include <config.h>
# endif
# include "BMF_Api.h"
# include "BIF_language.h"
# include "BSE_headerbuttons.h"
# include "DNA_ID.h"
# include "DNA_screen_types.h"
# include "DNA_space_types.h"
# include "DNA_text_types.h"
2007-06-18 07:41:21 +00:00
# include "DNA_constraint_types.h"
# include "DNA_action_types.h"
2003-10-10 03:16:32 +00:00
# include "BIF_drawtext.h"
# include "BIF_interface.h"
# include "BIF_resources.h"
# include "BIF_screen.h"
# include "BIF_space.h"
2003-10-25 12:27:16 +00:00
# include "BIF_toolbox.h"
2007-06-18 07:41:21 +00:00
2003-10-10 03:16:32 +00:00
# include "BKE_global.h"
# include "BKE_library.h"
# include "BKE_main.h"
# include "BKE_sca.h"
# include "BKE_text.h"
2007-06-18 07:41:21 +00:00
# include "BKE_depsgraph.h"
2003-10-10 03:16:32 +00:00
# include "BSE_filesel.h"
2003-11-23 14:28:46 +00:00
# include "BPY_extern.h"
2007-02-21 11:17:17 +00:00
# include "BPY_menus.h"
2003-11-23 14:28:46 +00:00
2003-10-10 03:16:32 +00:00
# include "blendef.h"
# include "mydevice.h"
void do_text_buttons ( unsigned short event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
2003-10-11 20:56:26 +00:00
ID * id , * idtest ;
int nr = 1 ;
Text * text ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
2003-10-11 20:56:26 +00:00
switch ( event ) {
case B_TEXTBROWSE :
if ( st - > menunr = = - 2 ) {
activate_databrowse ( ( ID * ) st - > text , ID_TXT , 0 , B_TEXTBROWSE ,
& st - > menunr , do_text_buttons ) ;
break ;
}
if ( st - > menunr < 0 ) break ;
text = st - > text ;
nr = 1 ;
id = ( ID * ) text ;
if ( st - > menunr = = 32767 ) {
2007-03-11 16:25:17 +00:00
st - > text = ( Text * ) add_empty_text ( " Text " ) ;
2003-10-11 20:56:26 +00:00
st - > top = 0 ;
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
}
else if ( st - > menunr = = 32766 ) {
2003-12-14 13:25:38 +00:00
activate_fileselect ( FILE_SPECIAL , " Open Text File " , G . sce , add_text_fs ) ;
2003-10-11 20:56:26 +00:00
return ;
}
else {
idtest = G . main - > text . first ;
while ( idtest ) {
if ( nr = = st - > menunr ) {
break ;
}
nr + + ;
idtest = idtest - > next ;
}
if ( idtest = = 0 ) { /* new text */
2003-12-14 13:25:38 +00:00
activate_fileselect ( FILE_SPECIAL , " Open Text File " ,
2003-10-11 20:56:26 +00:00
G . sce , add_text_fs ) ;
return ;
}
if ( idtest ! = id ) {
st - > text = ( Text * ) idtest ;
st - > top = 0 ;
pop_space_text ( st ) ;
2007-12-22 17:16:06 +00:00
if ( st - > showsyntax ) get_format_string ( st ) ;
2003-10-11 20:56:26 +00:00
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
}
}
break ;
2006-05-16 22:54:55 +00:00
2003-10-11 20:56:26 +00:00
case B_TEXTDELETE :
2007-06-18 07:41:21 +00:00
{
text = st - > text ;
if ( ! text ) return ;
/* make the previous text active, if its not there make the next text active */
if ( st - > text - > id . prev ) {
st - > text = st - > text - > id . prev ;
pop_space_text ( st ) ;
} else if ( st - > text - > id . next ) {
st - > text = st - > text - > id . next ;
pop_space_text ( st ) ;
}
BPY_clear_bad_scriptlinks ( text ) ;
2008-02-24 06:38:42 +00:00
BPY_free_pyconstraint_links ( text ) ;
2007-06-18 07:41:21 +00:00
free_text_controllers ( text ) ;
unlink_text ( text ) ;
free_libblock ( & G . main - > text , text ) ;
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
/*for if any object constraints were changed.*/
allqueue ( REDRAWVIEW3D , 0 ) ;
allqueue ( REDRAWBUTSOBJECT , 0 ) ;
allqueue ( REDRAWBUTSEDIT , 0 ) ;
BIF_undo_push ( " Delete Text " ) ;
}
2003-10-11 20:56:26 +00:00
break ;
2003-10-10 03:16:32 +00:00
/*
2003-10-11 20:56:26 +00:00
case B_TEXTSTORE :
st - > text - > flags ^ = TXT_ISEXT ;
allqueue ( REDRAWHEADERS , 0 ) ;
break ;
*/
case B_TEXTLINENUM :
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
break ;
case B_TEXTFONT :
switch ( st - > font_id ) {
case 0 :
st - > lheight = 12 ; break ;
case 1 :
2004-10-14 23:37:04 +00:00
st - > lheight = 15 ;
break ;
2003-10-11 20:56:26 +00:00
}
2004-10-14 23:37:04 +00:00
2003-10-11 20:56:26 +00:00
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
2004-10-14 23:37:04 +00:00
break ;
case B_TAB_NUMBERS :
2007-12-22 17:16:06 +00:00
if ( st - > showsyntax ) get_format_string ( st ) ;
2005-05-13 16:11:28 +00:00
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
break ;
case B_SYNTAX :
if ( st - > showsyntax ) {
2007-12-22 17:16:06 +00:00
get_format_string ( st ) ;
2005-05-13 16:11:28 +00:00
}
2004-10-14 23:37:04 +00:00
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
2003-10-11 20:56:26 +00:00
break ;
}
2003-10-10 03:16:32 +00:00
}
2007-02-21 11:17:17 +00:00
static void do_text_template_scriptsmenu ( void * arg , int event )
{
BPY_menu_do_python ( PYMENU_SCRIPTTEMPLATE , event ) ;
allqueue ( REDRAWIMAGE , 0 ) ;
}
static uiBlock * text_template_scriptsmenu ( void * args_unused )
{
uiBlock * block ;
BPyMenu * pym ;
int i = 0 ;
short yco = 20 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " text_template_scriptsmenu " , UI_EMBOSSP , UI_HELV , G . curscreen - > mainwin ) ;
uiBlockSetButmFunc ( block , do_text_template_scriptsmenu , NULL ) ;
/* note that we acount for the N previous entries with i+20: */
for ( pym = BPyMenuTable [ PYMENU_SCRIPTTEMPLATE ] ; pym ; pym = pym - > next , i + + ) {
uiDefIconTextBut ( block , BUTM , 1 , ICON_PYTHON , pym - > name , 0 , yco - = 20 , menuwidth , 19 ,
NULL , 0.0 , 0.0 , 1 , i ,
pym - > tooltip ? pym - > tooltip : pym - > filename ) ;
}
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiTextBoundsBlock ( block , 60 ) ;
return block ;
}
2003-10-25 10:33:03 +00:00
/* action executed after clicking in File menu */
static void do_text_filemenu ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
Text * text ;
2003-10-25 10:33:03 +00:00
ScrArea * sa ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2003-10-25 10:33:03 +00:00
switch ( event ) {
case 1 :
2007-03-11 16:25:17 +00:00
st - > text = add_empty_text ( " Text " ) ;
2003-10-25 10:33:03 +00:00
st - > top = 0 ;
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
2003-10-25 10:33:03 +00:00
allqueue ( REDRAWTEXT , 0 ) ;
allqueue ( REDRAWHEADERS , 0 ) ;
break ;
case 2 :
2003-12-14 13:25:38 +00:00
activate_fileselect ( FILE_SPECIAL , " Open Text File " , G . sce , add_text_fs ) ;
2003-10-25 10:33:03 +00:00
break ;
case 3 :
if ( text - > compiled ) BPY_free_compiled_text ( text ) ;
text - > compiled = NULL ;
if ( okee ( " Reopen Text " ) ) {
if ( ! reopen_text ( text ) ) {
error ( " Could not reopen file " ) ;
}
2007-12-22 17:16:06 +00:00
if ( st - > showsyntax ) get_format_string ( st ) ;
2003-10-25 10:33:03 +00:00
}
break ;
case 5 :
text - > flags | = TXT_ISMEM ;
case 4 :
txt_write_file ( text ) ;
break ;
case 6 :
run_python_script ( st ) ;
break ;
2007-06-18 07:41:21 +00:00
case 7 :
{
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
Object * ob ;
2007-06-18 07:41:21 +00:00
bConstraint * con ;
short update ;
/* check all pyconstraints */
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
for ( ob = G . main - > object . first ; ob ; ob = ob - > id . next ) {
2007-06-18 07:41:21 +00:00
update = 0 ;
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
if ( ob - > type = = OB_ARMATURE & & ob - > pose ) {
2007-06-18 07:41:21 +00:00
bPoseChannel * pchan ;
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
for ( pchan = ob - > pose - > chanbase . first ; pchan ; pchan = pchan - > next ) {
for ( con = pchan - > constraints . first ; con ; con = con - > next ) {
2007-06-18 07:41:21 +00:00
if ( con - > type = = CONSTRAINT_TYPE_PYTHON ) {
bPythonConstraint * data = con - > data ;
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
if ( data - > text = = text ) BPY_pyconstraint_update ( ob , con ) ;
2007-06-18 07:41:21 +00:00
update = 1 ;
}
}
}
}
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
for ( con = ob - > constraints . first ; con ; con = con - > next ) {
2007-06-18 07:41:21 +00:00
if ( con - > type = = CONSTRAINT_TYPE_PYTHON ) {
bPythonConstraint * data = con - > data ;
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
if ( data - > text = = text ) BPY_pyconstraint_update ( ob , con ) ;
2007-06-18 07:41:21 +00:00
update = 1 ;
}
}
if ( update ) {
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
DAG_object_flush_update ( G . scene , ob , OB_RECALC_DATA ) ;
2007-06-18 07:41:21 +00:00
}
}
}
break ;
2003-10-25 10:33:03 +00:00
default :
break ;
}
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
SpaceText * st = sa - > spacedata . first ;
if ( st & & st - > spacetype = = SPACE_TEXT ) {
scrarea_queue_redraw ( sa ) ;
}
}
}
/* action executed after clicking in Edit menu */
static void do_text_editmenu ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
Text * text ;
2003-10-25 10:33:03 +00:00
ScrArea * sa ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2003-10-25 10:33:03 +00:00
switch ( event ) {
case 1 :
txt_do_undo ( text ) ;
break ;
case 2 :
txt_do_redo ( text ) ;
break ;
case 3 :
2008-03-04 00:41:30 +00:00
txt_copy_clipboard ( text ) ;
2003-10-25 10:33:03 +00:00
txt_cut_sel ( text ) ;
pop_space_text ( st ) ;
break ;
case 4 :
2008-03-04 00:41:30 +00:00
//txt_copy_sel(text);
txt_copy_clipboard ( text ) ;
2003-10-25 10:33:03 +00:00
break ;
case 5 :
2008-03-04 00:41:30 +00:00
txt_paste_clipboard ( text ) ;
2007-12-22 17:16:06 +00:00
if ( st - > showsyntax ) get_format_string ( st ) ;
2003-10-25 10:33:03 +00:00
break ;
case 6 :
txt_print_cutbuffer ( ) ;
break ;
case 7 :
jumptoline_interactive ( st ) ;
break ;
case 8 :
txt_find_panel ( st , 1 ) ;
break ;
case 9 :
txt_find_panel ( st , 0 ) ;
break ;
default :
break ;
}
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
SpaceText * st = sa - > spacedata . first ;
if ( st & & st - > spacetype = = SPACE_TEXT ) {
scrarea_queue_redraw ( sa ) ;
}
}
}
/* action executed after clicking in View menu */
static void do_text_editmenu_viewmenu ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
Text * text ;
2003-10-25 10:33:03 +00:00
ScrArea * sa ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2003-10-25 10:33:03 +00:00
switch ( event ) {
case 1 :
txt_move_bof ( text , 0 ) ;
pop_space_text ( st ) ;
break ;
case 2 :
txt_move_eof ( text , 0 ) ;
pop_space_text ( st ) ;
break ;
default :
break ;
}
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
SpaceText * st = sa - > spacedata . first ;
if ( st & & st - > spacetype = = SPACE_TEXT ) {
scrarea_queue_redraw ( sa ) ;
}
}
}
/* action executed after clicking in Select menu */
static void do_text_editmenu_selectmenu ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
Text * text ;
2003-10-25 10:33:03 +00:00
ScrArea * sa ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2003-10-25 10:33:03 +00:00
switch ( event ) {
case 1 :
txt_sel_all ( text ) ;
2004-11-14 13:37:29 +00:00
break ;
2003-10-25 10:33:03 +00:00
case 2 :
txt_sel_line ( text ) ;
break ;
2004-11-14 13:37:29 +00:00
default :
break ;
}
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
SpaceText * st = sa - > spacedata . first ;
if ( st & & st - > spacetype = = SPACE_TEXT ) {
scrarea_queue_redraw ( sa ) ;
}
}
}
/* action executed after clicking in Format menu */
static void do_text_formatmenu ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
Text * text ;
2004-11-14 13:37:29 +00:00
ScrArea * sa ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2004-11-14 13:37:29 +00:00
switch ( event ) {
2004-10-14 23:37:04 +00:00
case 3 :
if ( txt_has_sel ( text ) ) {
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
txt_order_cursors ( text ) ;
indent ( text ) ;
2004-10-14 23:37:04 +00:00
break ;
}
else {
txt_add_char ( text , ' \t ' ) ;
break ;
}
case 4 :
if ( txt_has_sel ( text ) ) {
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
txt_order_cursors ( text ) ;
2004-10-14 23:37:04 +00:00
unindent ( text ) ;
break ;
}
break ;
case 5 :
if ( txt_has_sel ( text ) ) {
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
txt_order_cursors ( text ) ;
2004-10-14 23:37:04 +00:00
comment ( text ) ;
2007-12-22 17:16:06 +00:00
if ( st - > showsyntax ) get_format_string ( st ) ;
2004-10-14 23:37:04 +00:00
break ;
}
break ;
case 6 :
if ( txt_has_sel ( text ) ) {
Bugfix for disappearing hilight bug and code re-org for text editor
from Ricki Myers (themyers).
Comes with nice juicy commit msg, too!
- source/blender/blenkernel/BKE_text.h
- Removed indent_paste, uncommen, unindent_lines, comment_paste,
uncomment_paste, uncomment, set_tabs.
All these functions cut and re-added text (I felt this was
unsafe). whicch is was caused the highlight loss.
- Now the only functions are Indent, Unindent, comment, uncomment,
setcurr_tab. All these functions only take one @parm (struct Text)
-indent(struct Text *text)
copy's the selected text in a MEM_mallocN line by line added a
tab at the begginning
- Unindent(struct Text *text)
Tests if current line starts with a tab.
if TAB remove it
- comment(struct Text *text)
copy's the selected text in a MEM_mallocN and adding a # at the begginning
- Uncomment(struct Text *text)
Tests if current line starts with a #.
if # remove it
- setcurr_tab (Text *text)
Checks for Tabs pri. to any text
if : is found and not in a comment then Tabs is increased by one
if "return", "break", "pass" is found then Tabs is decreased
- blender/source/blender/src/header_text.c
Changed: txt_cut_sel(text);
indent_paste(text);
TO:
txt_order_cursors(text);
indent(text);
* no more cutting of the text
- source/blender/src/drawtext.c
set_tabs(Text *text) just calls setcurr_tab(text);
2005-04-10 14:01:41 +00:00
txt_order_cursors ( text ) ;
2004-10-14 23:37:04 +00:00
uncomment ( text ) ;
2007-12-22 17:16:06 +00:00
if ( st - > showsyntax ) get_format_string ( st ) ;
2004-10-14 23:37:04 +00:00
break ;
}
break ;
2003-10-25 10:33:03 +00:00
default :
break ;
}
for ( sa = G . curscreen - > areabase . first ; sa ; sa = sa - > next ) {
SpaceText * st = sa - > spacedata . first ;
if ( st & & st - > spacetype = = SPACE_TEXT ) {
scrarea_queue_redraw ( sa ) ;
}
}
}
/* View menu */
static uiBlock * text_editmenu_viewmenu ( void * arg_unused )
{
uiBlock * block ;
short yco = 20 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " text_editmenu_viewmenu " , UI_EMBOSSP , UI_HELV , G . curscreen - > mainwin ) ;
uiBlockSetButmFunc ( block , do_text_editmenu_viewmenu , NULL ) ;
2003-10-25 13:08:15 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Top of File " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 1 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Bottom of File " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 2 , " " ) ;
2003-10-25 10:33:03 +00:00
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiTextBoundsBlock ( block , 60 ) ;
return block ;
}
/* Select menu */
static uiBlock * text_editmenu_selectmenu ( void * arg_unused )
{
uiBlock * block ;
short yco = 20 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " text_editmenu_selectmenu " , UI_EMBOSSP , UI_HELV , G . curscreen - > mainwin ) ;
uiBlockSetButmFunc ( block , do_text_editmenu_selectmenu , NULL ) ;
2003-10-25 13:08:15 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Select All|Ctrl A " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 1 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Select Line " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 2 , " " ) ;
2004-10-14 23:37:04 +00:00
2003-10-25 10:33:03 +00:00
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiTextBoundsBlock ( block , 60 ) ;
return block ;
}
2006-03-05 19:50:14 +00:00
void do_text_formatmenu_convert ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
2006-03-05 19:50:14 +00:00
switch ( event ) {
case 1 : convert_tabs ( st , 0 ) ; break ;
case 2 : convert_tabs ( st , 1 ) ; break ;
}
allqueue ( REDRAWVIEW3D , 0 ) ;
}
static uiBlock * text_formatmenu_convert ( void * arg_unused )
{
uiBlock * block ;
short yco = 20 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " do_text_formatmenu_convert " , UI_EMBOSSP , UI_HELV , G . curscreen - > mainwin ) ;
uiBlockSetButmFunc ( block , do_text_formatmenu_convert , NULL ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " To Spaces " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " Converts script whitespace to spaces based on Tab: " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " To Tabs " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " Converts script whitespace to tabs based on Tab: " ) ;
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiTextBoundsBlock ( block , 60 ) ;
return block ;
}
2004-11-14 13:37:29 +00:00
/* Format menu */
static uiBlock * text_formatmenu ( void * arg_unused )
{
uiBlock * block ;
short yco = 0 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " text_formatmenu " , UI_EMBOSSP , UI_HELV , curarea - > headwin ) ;
uiBlockSetButmFunc ( block , do_text_formatmenu , NULL ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Indent|Tab " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 3 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Unindent|Shift Tab " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 4 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Comment " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 5 , " " ) ;
2006-02-23 16:27:41 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Uncomment|Ctrl Shift D " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 6 , " " ) ;
2006-03-05 19:50:14 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefIconTextBlockBut ( block , text_formatmenu_convert , NULL , ICON_RIGHTARROW_THIN , " Convert whitespace " , 0 , yco - = 20 , menuwidth , 19 , " " ) ;
2004-11-14 13:37:29 +00:00
if ( curarea - > headertype = = HEADERTOP ) {
uiBlockSetDirection ( block , UI_DOWN ) ;
}
else {
uiBlockSetDirection ( block , UI_TOP ) ;
uiBlockFlipOrder ( block ) ;
}
uiTextBoundsBlock ( block , 50 ) ;
return block ;
}
2005-02-24 19:22:31 +00:00
/* action executed after clicking in Object to 3d Sub Menu */
void do_text_editmenu_to3dmenu ( void * arg , int event )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
Text * text ;
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2005-02-24 19:22:31 +00:00
switch ( event ) {
case 1 : txt_export_to_object ( text ) ; break ;
case 2 : txt_export_to_objects ( text ) ; break ;
}
allqueue ( REDRAWVIEW3D , 0 ) ;
}
/* Object to 3d Sub Menu */
static uiBlock * text_editmenu_to3dmenu ( void * arg_unused )
{
uiBlock * block ;
short yco = 20 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " do_text_editmenu_to3dmenu " , UI_EMBOSSP , UI_HELV , G . curscreen - > mainwin ) ;
uiBlockSetButmFunc ( block , do_text_editmenu_to3dmenu , NULL ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " One Object | Alt-M " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 1 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " One Object Per Line " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 1 , 2 , " " ) ;
uiBlockSetDirection ( block , UI_RIGHT ) ;
uiTextBoundsBlock ( block , 60 ) ;
return block ;
}
2003-10-25 10:33:03 +00:00
/* Edit menu */
static uiBlock * text_editmenu ( void * arg_unused )
{
uiBlock * block ;
short yco = 0 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " text_editmenu " , UI_EMBOSSP , UI_HELV , curarea - > headwin ) ;
uiBlockSetButmFunc ( block , do_text_editmenu , NULL ) ;
2004-11-14 13:37:29 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Undo|Ctrl Z " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 1 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Redo|Ctrl Shift Z " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 2 , " " ) ;
2003-10-25 10:33:03 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
2003-10-25 13:08:15 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Cut|Alt X " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 3 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Copy|Alt C " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 4 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Paste|Alt V " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 5 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Print Cut Buffer " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 6 , " " ) ;
2003-10-25 10:33:03 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
uiDefIconTextBlockBut ( block , text_editmenu_viewmenu , NULL , ICON_RIGHTARROW_THIN , " View|Alt Shift V " , 0 , yco - = 20 , 120 , 19 , " " ) ;
uiDefIconTextBlockBut ( block , text_editmenu_selectmenu , NULL , ICON_RIGHTARROW_THIN , " Select|Alt Shift S " , 0 , yco - = 20 , 120 , 19 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
2003-10-25 13:08:15 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Jump...|Alt J " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 7 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Find...|Alt Ctrl F " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 8 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Find Again|Alt F " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 9 , " " ) ;
2003-10-25 10:33:03 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
2005-02-24 19:22:31 +00:00
uiDefIconTextBlockBut ( block , text_editmenu_to3dmenu , NULL , ICON_RIGHTARROW_THIN , " Text to 3d Object " , 0 , yco - = 20 , 120 , 19 , " " ) ;
2003-10-25 10:33:03 +00:00
if ( curarea - > headertype = = HEADERTOP ) {
uiBlockSetDirection ( block , UI_DOWN ) ;
}
else {
uiBlockSetDirection ( block , UI_TOP ) ;
uiBlockFlipOrder ( block ) ;
}
uiTextBoundsBlock ( block , 50 ) ;
return block ;
}
/* File menu */
static uiBlock * text_filemenu ( void * arg_unused )
{
2007-12-22 17:16:06 +00:00
SpaceText * st = curarea - > spacedata . first ; /* bad but cant pass as an arg here */
2003-10-25 10:33:03 +00:00
Text * text = st - > text ;
uiBlock * block ;
short yco = 0 , menuwidth = 120 ;
block = uiNewBlock ( & curarea - > uiblocks , " text_filemenu " , UI_EMBOSSP , UI_HELV , curarea - > headwin ) ;
uiBlockSetButmFunc ( block , do_text_filemenu , NULL ) ;
2003-10-25 13:08:15 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " New|Alt N " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 1 , " " ) ;
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Open...|Alt O " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 2 , " " ) ;
2007-06-18 07:41:21 +00:00
2003-10-25 10:33:03 +00:00
if ( text ) {
2007-02-21 11:17:17 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Reopen|Alt R " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 3 , " " ) ;
2007-06-18 07:41:21 +00:00
2003-10-25 10:33:03 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
2007-06-18 07:41:21 +00:00
2003-10-25 13:08:15 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Save|Alt S " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 4 , " " ) ;
2003-12-14 13:25:38 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Save As... " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 5 , " " ) ;
2007-06-18 07:41:21 +00:00
2003-10-25 10:33:03 +00:00
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
2007-06-18 07:41:21 +00:00
2003-12-14 13:25:38 +00:00
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Run Python Script|Alt P " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 6 , " " ) ;
2007-06-18 07:41:21 +00:00
if ( BPY_is_pyconstraint ( text ) )
uiDefIconTextBut ( block , BUTM , 1 , ICON_BLANK1 , " Refresh All PyConstraints " , 0 , yco - = 20 , menuwidth , 19 , NULL , 0.0 , 0.0 , 0 , 7 , " " ) ;
uiDefBut ( block , SEPR , 0 , " " , 0 , yco - = 6 , menuwidth , 6 , NULL , 0.0 , 0.0 , 0 , 0 , " " ) ;
2003-10-25 10:33:03 +00:00
}
2007-02-21 11:17:17 +00:00
uiDefIconTextBlockBut ( block , text_template_scriptsmenu , NULL , ICON_RIGHTARROW_THIN , " Script Templates " , 0 , yco - = 20 , 120 , 19 , " " ) ;
2003-10-25 10:33:03 +00:00
if ( curarea - > headertype = = HEADERTOP ) {
uiBlockSetDirection ( block , UI_DOWN ) ;
}
else {
uiBlockSetDirection ( block , UI_TOP ) ;
uiBlockFlipOrder ( block ) ;
}
uiTextBoundsBlock ( block , 50 ) ;
return block ;
}
/* header */
2003-10-10 03:16:32 +00:00
void text_buttons ( void )
{
uiBlock * block ;
SpaceText * st = curarea - > spacedata . first ;
2007-12-22 17:16:06 +00:00
Text * text ;
2003-10-25 10:33:03 +00:00
short xco , xmax ;
2003-10-10 03:16:32 +00:00
char naam [ 256 ] ;
2007-12-22 17:16:06 +00:00
if ( st = = NULL | | st - > spacetype ! = SPACE_TEXT ) return ;
text = st - > text ;
2003-10-10 03:16:32 +00:00
sprintf ( naam , " header %d " , curarea - > headwin ) ;
Another mega commit... loadsof restructure, and a pretty good one! :)
- changed the BIF_DrawString() function. it used to work different for
AA fonts as for default fonts. Now it's identical. Setting color for fonts
can just be done with OpenGL, for both font types.
Removed: BIF_DrawStringRGB()
- added theme color options for Buttons
- recoded DefButton, so it automatically chooses the right color.
- had to remove a 1000 uiBlockSetCol() calls for that reason...
- uiBlockSetCol() still works, to override automatic color
- removed entirely the silly old color system (BIFColorID). All color
calls can now be done with a BIF_ThemeColor() call, including fonts and
buttons and opengl stuff
- all buttons in button header have headercolor by default
- recoded drawing icons, it was a really bad & old loop doing manually
colorshading and blending... which was per pixel a load of code!
Now it uses a single OpenGL call to blend or colorize. Quite faster!
- (as test, for review) icons don't colorize anymore with button color,
but have a different alpha to blend in (when not active)
- recoded the entire interface_draw.c file...:
- drawing buttons is separated in three parts:
1. main drawing function for text and icons
2. free definable callback for button itself
3. free definable callback for slider
- removed a load of redundant code for this!
- coded a minimal theme, and adjusted Matt's buttons to match new
callback system
- adding new drawing themes is piece of cake now
- for coders, default 'themes' to be aware of:
UI_EMBOSS : the themable drawing style
UI_EMBOSSP: the pulldown menu system (apart from color not themable)
UI_EMBOSSN: draw nothing, only text and/or icon
UI_EMBOSSM: minimal theme, still in use for Logic and Constraintsa
this can be set with uiBlockSetEmboss(block) or in the uiNewBlock() call.
TODO: make UI API call for button alignment
(plus removed another series of warnings from code...)
Plus: fixed bug in Matts commit: he used a 'short' button for an 'int'
2003-10-20 15:40:20 +00:00
block = uiNewBlock ( & curarea - > uiblocks , naam , UI_EMBOSS , UI_HELV , curarea - > headwin ) ;
if ( area_is_active_area ( curarea ) ) uiBlockSetCol ( block , TH_HEADER ) ;
else uiBlockSetCol ( block , TH_HEADERDESEL ) ;
2003-10-10 03:16:32 +00:00
curarea - > butspacetype = SPACE_TEXT ;
2003-10-15 13:47:15 +00:00
xco = 8 ;
uiDefIconTextButC ( block , ICONTEXTROW , B_NEWSPACE , ICON_VIEW3D , windowtype_pup ( ) , xco , 0 , XIC + 10 , YIC , & ( curarea - > butspacetype ) , 1.0 , SPACEICONMAX , 0 , 0 , " Displays Current Window Type. Click for menu of available types. " ) ;
2003-10-28 18:43:55 +00:00
xco + = XIC + 14 ;
2003-10-27 13:23:48 +00:00
uiBlockSetEmboss ( block , UI_EMBOSSN ) ;
if ( curarea - > flag & HEADER_NO_PULLDOWN ) {
2005-08-03 18:48:22 +00:00
uiDefIconButBitS ( block , TOG , HEADER_NO_PULLDOWN , B_FLIPINFOMENU , ICON_DISCLOSURE_TRI_RIGHT ,
2003-10-27 13:23:48 +00:00
xco , 2 , XIC , YIC - 2 ,
& ( curarea - > flag ) , 0 , 0 , 0 , 0 , " Enables display of pulldown menus " ) ;
} else {
2005-08-03 18:48:22 +00:00
uiDefIconButBitS ( block , TOG , HEADER_NO_PULLDOWN , B_FLIPINFOMENU , ICON_DISCLOSURE_TRI_DOWN ,
2003-10-27 13:23:48 +00:00
xco , 2 , XIC , YIC - 2 ,
& ( curarea - > flag ) , 0 , 0 , 0 , 0 , " Hides pulldown menus " ) ;
}
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
xco + = XIC ;
2003-10-10 03:16:32 +00:00
2003-10-25 10:33:03 +00:00
/* pull down menus */
2003-10-27 13:23:48 +00:00
if ( ( curarea - > flag & HEADER_NO_PULLDOWN ) = = 0 ) {
uiBlockSetEmboss ( block , UI_EMBOSSP ) ;
xmax = GetButStringLength ( " File " ) ;
2004-11-09 15:59:15 +00:00
uiDefPulldownBut ( block , text_filemenu , NULL , " File " , xco , 0 , xmax , 20 , " " ) ;
2003-10-27 13:23:48 +00:00
xco + = xmax ;
if ( text ) {
xmax = GetButStringLength ( " Edit " ) ;
2004-11-09 15:59:15 +00:00
uiDefPulldownBut ( block , text_editmenu , NULL , " Edit " , xco , 0 , xmax , 20 , " " ) ;
2003-10-27 13:23:48 +00:00
xco + = xmax ;
2004-11-14 13:37:29 +00:00
xmax = GetButStringLength ( " Format " ) ;
uiDefPulldownBut ( block , text_formatmenu , NULL , " Format " , xco , 0 , xmax , 20 , " " ) ;
xco + = xmax ;
2003-10-27 13:23:48 +00:00
}
2003-10-25 10:33:03 +00:00
}
2005-08-04 22:36:21 +00:00
uiBlockSetEmboss ( block , UI_EMBOSS ) ;
2003-10-25 10:33:03 +00:00
xco + = 10 ;
2003-10-10 03:16:32 +00:00
/* FULL WINDOW */
2006-01-15 13:30:56 +00:00
uiBlockBeginAlign ( block ) ;
2003-10-15 13:47:15 +00:00
if ( curarea - > full ) uiDefIconBut ( block , BUT , B_FULL , ICON_SPLITSCREEN , xco , 0 , XIC , YIC , 0 , 0 , 0 , 0 , 0 , " Returns to multiple views window (CTRL+Up arrow) " ) ;
else uiDefIconBut ( block , BUT , B_FULL , ICON_FULLSCREEN , xco , 0 , XIC , YIC , 0 , 0 , 0 , 0 , 0 , " Makes current window full screen (CTRL+Down arrow) " ) ;
2003-10-10 03:16:32 +00:00
2005-05-13 16:11:28 +00:00
uiDefIconButI ( block , ICONTOG , B_TEXTLINENUM , ICON_LONGDISPLAY , xco + = XIC , 0 , XIC , YIC , & st - > showlinenrs , 0 , 0 , 0 , 0 , " Displays line numbers " ) ;
2003-10-10 03:16:32 +00:00
2005-05-13 16:11:28 +00:00
uiDefIconButI ( block , ICONTOG , B_SYNTAX , ICON_SYNTAX , xco + = XIC , 0 , XIC , YIC , & st - > showsyntax , 0 , 0 , 0 , 0 , " Enables Syntax Highlighting " ) ;
2006-01-15 13:30:56 +00:00
uiBlockEndAlign ( block ) ;
2003-10-10 03:16:32 +00:00
/* STD TEXT BUTTONS */
2003-12-14 01:18:09 +00:00
xco + = 2 * XIC ;
More node goodies!
First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!
------ New Material integration ------
Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"
Best solution is to completely separate the two. This has been implemented
as follows now;
- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
'N' mark before the name. The 'data block' buttons display it with the
suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
that case the Material is being used itself for shading.
UI changes:
Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree
The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.
Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.
Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
2005-12-29 18:08:01 +00:00
xco = std_libbuttons ( block , xco , 0 , 0 , NULL , B_TEXTBROWSE , ID_TXT , 0 , ( ID * ) st - > text , 0 , & ( st - > menunr ) , 0 , 0 , B_TEXTDELETE , 0 , 0 ) ;
2003-12-14 01:18:09 +00:00
/*
if ( st - > text ) {
if ( st - > text - > flags & TXT_ISDIRTY & & ( st - > text - > flags & TXT_ISEXT | | ! ( st - > text - > flags & TXT_ISMEM ) ) )
uiDefIconBut ( block , BUT , 0 , ICON_ERROR , xco + = XIC , 0 , XIC , YIC , 0 , 0 , 0 , 0 , 0 , " The text has been changed " ) ;
if ( st - > text - > flags & TXT_ISEXT )
uiDefBut ( block , BUT , B_TEXTSTORE , ICON ( ) , xco + = XIC , 0 , XIC , YIC , 0 , 0 , 0 , 0 , 0 , " Stores text in project file " ) ;
else
uiDefBut ( block , BUT , B_TEXTSTORE , ICON ( ) , xco + = XIC , 0 , XIC , YIC , 0 , 0 , 0 , 0 , 0 , " Disables storing of text in project file " ) ;
xco + = 10 ;
2003-10-10 03:16:32 +00:00
}
2003-12-14 01:18:09 +00:00
*/
xco + = XIC ;
if ( st - > font_id > 1 ) st - > font_id = 0 ;
uiDefButI ( block , MENU , B_TEXTFONT , " Screen 12 %x0|Screen 15%x1 " , xco , 0 , 100 , YIC , & st - > font_id , 0 , 0 , 0 , 0 , " Displays available fonts " ) ;
2004-11-01 20:50:42 +00:00
xco + = 110 ;
2004-10-14 23:37:04 +00:00
2004-11-01 20:50:42 +00:00
uiDefButI ( block , NUM , B_TAB_NUMBERS , " Tab: " , xco , 0 , XIC + 50 , YIC , & st - > tabnumber , 2 , 8 , 0 , 0 , " Set spacing of Tab " ) ;
xco + = XIC + 50 ;
2004-10-14 23:37:04 +00:00
2003-10-10 03:16:32 +00:00
/* always as last */
curarea - > headbutlen = xco + 2 * XIC ;
uiDrawBlock ( block ) ;
}