- converted constraint buttons, they're a Panel in Object main menu

- converted sound buttons, part of Scene
- special request Matt: headers of windows 2 pixels higher! (test)
- special request Stefano: icons instead of menu for buttons-header
- 'data browse' buttons now almost all in buttonswindow.
- almost all buttons have been panelized now.

next stage: cleaning up usage of color in Blender, to allow presests!
This commit is contained in:
Ton Roosendaal 2003-10-13 23:46:08 +00:00
parent 5caf1e6bfd
commit 44b32134ae
11 changed files with 959 additions and 1089 deletions

View File

@ -56,10 +56,12 @@ extern void render_panels(void);
extern void do_render_panels(unsigned short event);
extern void anim_panels(void);
extern void sound_panels(void);
extern void do_soundbuts(unsigned short event);
/* object */
extern void object_panels(void);
extern void do_object_panels(unsigned short event);
extern void do_constraintbuts(unsigned short event);
/* editing */

View File

@ -123,7 +123,7 @@ typedef struct ScrArea {
#define EDGEWIDTH2 0
#define AREAGRID 4
#define AREAMINX 32
#define HEADERY 24
#define HEADERY 26
#define AREAMINY (HEADERY+EDGEWIDTH)
#define HEADERDOWN 1

View File

@ -305,10 +305,10 @@ void do_butspace(unsigned short event)
do_scriptbuts(event);
}
else if(event<=B_SOUNDBUTS) {
//do_soundbuts(event);
do_soundbuts(event);
}
else if(event<=B_CONSTRAINTBUTS) {
//do_constraintbuts(event);
do_constraintbuts(event);
}
else if(event>=REDRAWVIEW3D) allqueue(event, 0);
}

View File

@ -229,487 +229,6 @@ static int packdummy = 0;
/* ****************************** MATERIAL ************************ */
/* ************************ SOUND *************************** */
static void load_new_sample(char *str) /* called from fileselect */
{
char name[FILE_MAXDIR+FILE_MAXFILE];
bSound *sound;
bSample *sample, *newsample;
sound = G.buts->lockpoin;
if (sound) {
// save values
sample = sound->sample;
strcpy(name, sound->sample->name);
strcpy(sound->name, str);
sound_set_sample(sound, NULL);
sound_initialize_sample(sound);
if (sound->sample->type == SAMPLE_INVALID) {
error("Not a valid sample: %s", str);
newsample = sound->sample;
// restore values
strcpy(sound->name, name);
sound_set_sample(sound, sample);
// remove invalid sample
sound_free_sample(newsample);
BLI_remlink(samples, newsample);
MEM_freeN(newsample);
}
}
allqueue(REDRAWBUTSSOUND, 0);
if (curarea) BIF_preview_changed(G.buts);
}
void do_soundbuts(unsigned short event)
{
char name[FILE_MAXDIR+FILE_MAXFILE];
bSound *sound;
bSample *sample;
bSound* tempsound;
ID *id;
sound = G.buts->lockpoin;
switch(event)
{
case B_SOUND_REDRAW:
{
allqueue(REDRAWBUTSSOUND, 0);
break;
}
case B_SOUND_LOAD_SAMPLE:
{
if (sound) strcpy(name, sound->name);
else strcpy(name, U.sounddir);
activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
break;
}
case B_SOUND_PLAY_SAMPLE:
{
if (sound)
{
if (sound->sample->type != SAMPLE_INVALID)
{
sound_play_sound(sound);
allqueue(REDRAWBUTSSOUND, 0);
}
}
break;
}
case B_SOUND_MENU_SAMPLE:
{
if (G.buts->menunr == -2) {
if (sound) {
activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts);
}
} else if (G.buts->menunr > 0) {
sample = BLI_findlink(samples, G.buts->menunr - 1);
if (sample && sound) {
BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
sound_set_sample(sound, sample);
do_soundbuts(B_SOUND_REDRAW);
}
}
break;
}
case B_SOUND_NAME_SAMPLE:
{
load_new_sample(sound->name);
break;
}
case B_SOUND_UNPACK_SAMPLE:
if(sound && sound->sample) {
sample = sound->sample;
if (sample->packedfile) {
if (G.fileflags & G_AUTOPACK) {
if (okee("Disable AutoPack ?")) {
G.fileflags &= ~G_AUTOPACK;
}
}
if ((G.fileflags & G_AUTOPACK) == 0) {
unpackSample(sample, PF_ASK);
}
} else {
sound_set_packedfile(sample, newPackedFile(sample->name));
}
allqueue(REDRAWHEADERS, 0);
do_soundbuts(B_SOUND_REDRAW);
}
break;
case B_SOUND_COPY_SOUND:
{
if (sound)
{
tempsound = sound_make_copy(sound);
sound = tempsound;
id = &sound->id;
G.buts->lockpoin = (bSound*)id;
do_soundbuts(B_SOUND_REDRAW);
}
break;
}
case B_SOUND_RECALC:
{
waitcursor(1);
sound = G.main->sound.first;
while (sound)
{
MEM_freeN(sound->stream);
sound->stream = 0;
audio_makestream(sound);
sound = (bSound *) sound->id.next;
}
waitcursor(0);
allqueue(REDRAWSEQ, 0);
break;
}
case B_SOUND_RATECHANGED:
{
allqueue(REDRAWBUTSSOUND, 0);
allqueue(REDRAWSEQ, 0);
break;
}
case B_SOUND_MIXDOWN:
{
audio_mixdown();
break;
}
case B_SOUND_LOOPSTART:
{
#ifdef SOUND_UNDER_DEVELOPMENT
/* if (sound->loopstart > sound->loopend)
sound->loopstart = sound->loopend;*/
#endif
allqueue(REDRAWBUTSSOUND, 0);
BIF_preview_changed(G.buts);
break;
}
case B_SOUND_LOOPEND:
{
#ifdef SOUND_UNDER_DEVELOPMENT
/* if (sound->loopend < sound->loopstart)
sound->loopend = sound->loopstart;*/
#endif
allqueue(REDRAWBUTSSOUND, 0);
BIF_preview_changed(G.buts);
break;
}
default:
{
if (G.f & G_DEBUG)
{
printf("do_soundbuts: unhandled event %d\n", event);
}
break;
}
}
}
void soundbuts(void)
{
short xco, yco, xcostart = 20;
bSound *sound;
bSample *sample;
uiBlock *block;
char *strp, str[32];
ID *id;
char ch[20];
char sampleinfo[200];
char mixrateinfo[50];
int mixrate;
sound = G.buts->lockpoin;
if ((sound) && (sound->flags & SOUND_FLAGS_SEQUENCE)) sound = 0;
yco = 195;
xco = xcostart;
sprintf(str, "buttonswin %d", curarea->win);
block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win);
if (sound)
{
sound_initialize_sample(sound);
sample = sound->sample;
uiSetButLock(sound->id.lib!=0, "Can't edit library data");
/* sound settings ------------------------------------------------------------------ */
uiDefBut(block, LABEL, 0, "Game sounds",xco,yco,195,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiBlockSetCol(block, BUTGREEN);
uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play", xco, yco, 195, 24, 0, 0.0, 0, 0, 0,
"Playback sample using settings below");
uiBlockSetCol(block, BUTGREY);
xco += 225;
if (sound->sample && sound->sample->len)
{
if (sound->sample->channels == 1)
strcpy(ch, "Mono");
else if (sound->sample->channels == 2)
strcpy(ch, "Stereo");
else
strcpy(ch, "Unknown");
uiDefBut(block, LABEL, 0, "Sample: ",xco,yco,195,20, 0, 0, 0, 0, 0, "");
xco +=55;
sprintf(sampleinfo, "%s, %d bit, %d Hz, %d samples", ch, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels));
uiDefBut(block, LABEL, 0, sampleinfo,xco,yco,295,20, 0, 0, 0, 0, 0, "");
}
else
{
uiDefBut(block, LABEL, 0, "No sample info available.",xco,yco,195,20, 0, 0, 0, 0, 0, "");
xco +=55;
}
xco += 314;
uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound",
xco,yco,95,24, 0, 0, 0, 0, 0, "Make a copy of the current sound");
/*
xco += 25;
if (sample->channels > 1)
{
xco += 100;
uiDefButC(block, ROW, B_SOUND_REDRAW, "Left", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_LEFT, 0, 0, "");
xco += 100;
uiDefButC(block, ROW, B_SOUND_REDRAW, "Stereo", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_STEREO, 0, 0, "");
xco += 100;
uiDefButC(block, ROW, B_SOUND_REDRAW, "Right", xco, yco, 95, 20, &sound->channels, 1.0, (float)SOUND_CHANNELS_RIGHT, 0, 0, "");
}
*/
xco = xcostart;
yco -= 30;
uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample",
xco, yco,195,24, 0, 0, 0, 0, 0, "Load a different sample");
uiBlockSetCol(block, BUTGREY);
id= (ID *)sound->sample;
IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr));
if (strp[0]) {
xco += 200;
uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp,xco,yco,23,24, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
}
MEM_freeN(strp);
xco += 25;
uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",xco,yco,412,24, sound->name, 0.0, 79.0, 0, 0, "The sample used by this sound");
sprintf(str, "1");
// sprintf(str, "%d", tex->ima->id.us);
xco += 415;
uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str,xco,yco,23,24, 0, 0, 0, 0, 0, "The number of users");
if (sound->sample->packedfile)
packdummy = 1;
else
packdummy = 0;
xco += 25;
uiDefIconButI(block, TOG|BIT|0, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
xco, yco,24,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
/*
xco += 25;
uiDefBut(block, BUT, B_SOUND_RELOAD_SAMPLE, "Reload",xco, yco,68,24, 0, 0, 0, 0, 0, "");
*/
/* parameters settings ------------------------------------------------------------------ */
xco = xcostart;
yco -= 45;
uiDefBut(block, LABEL, 0, "Game sound settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiBlockSetCol(block, BUTGREY);
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
xco,yco,195,24,&sound->volume, 0.0, 1.0, 0, 0, "Set the volume of this sound");
xco += 200;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
xco,yco,195,24,&sound->pitch, -12.0, 12.0, 0, 0, "Set the pitch of this sound");
xco = xcostart;
yco -= 30;
uiBlockSetCol(block, BUTSALMON);
uiDefButI(block, TOG|BIT|SOUND_FLAGS_LOOP_BIT, B_SOUND_REDRAW, "Loop",
xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between looping on/off");
if (sound->flags & SOUND_FLAGS_LOOP)
{
xco += 100;
uiDefButI(block, TOG|BIT|SOUND_FLAGS_BIDIRECTIONAL_LOOP_BIT, B_SOUND_REDRAW, "Ping Pong",
xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between A->B and A->B->A looping");
#ifdef SOUND_UNDER_DEVELOPMENT
/* uiBlockSetCol(block, REDALERT);
xco += 100;
uiDefButI(block, NUM, B_SOUND_LOOPSTART, "loopstart: ", xco,yco,195,24,
&sound->loopstart, 0, sound->sample->len, 0, 0, "Set the startpoint for the loop of this sound");
xco += 200;
uiDefButI(block, NUM, B_SOUND_LOOPEND, "loopend: ",xco,yco,195,24,
&sound->loopend, 0, sound->sample->len, 0, 0, "Set the endpoint for the loop of this sound");
*/
#endif
}
#ifdef SOUND_UNDER_DEVELOPMENT
xco = xcostart;
yco -= 30;
uiDefButI(block, TOG|BIT|SOUND_FLAGS_PRIORITY_BIT, B_SOUND_REDRAW, "Priority",
xco, yco, 95, 24, &sound->flags, 0.0, 0.0, 0, 0,"Toggle between high and low priority");
#endif
/* 2D & 3D settings ------------------------------------------------------------------ */
uiBlockSetCol(block, BUTGREY);
if (sound->sample->channels == 1)
{
xco = xcostart;
yco -= 30;
uiDefButI(block, TOG|BIT|SOUND_FLAGS_3D_BIT, B_SOUND_REDRAW, "3D Sound",
xco, yco, 95, 24, &sound->flags, 0, 0, 0, 0, "Turns 3D sound on");
if (sound->flags & SOUND_FLAGS_3D)
{
xco = xcostart;
yco -= 30;
uiBlockSetCol(block, BUTGREY);
uiDefBut(block, LABEL, 0, "3D surround settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
xco,(short)(yco-=30),195,24,&sound->attenuation, 0.0, 5.0, 1.0, 0, "Sets the world-scaling factor for this sound");
/*
xco += 200;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Distance: ",
xco,yco,195,20,&sound->distance, 0.0, 100.0, 1.0, 0, "Reference distance: sets the distance at which the listener will experience gain");
xco -= 200;
yco -= 30;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Minvol: ",
xco,yco,195,20,&sound->min_gain, 0.0, 1.0, 1.0, 0, "Minimal volume: sets the lower threshold for the gain of this sound");
xco += 200;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Maxvol: ",
xco,yco,195,20,&sound->max_gain, 0.0, 10.0, 1.0, 0, "Maximal volume: sets the upper threshold for the gain of this sound");
*/
}
}
/* listener settings ------------------------------------------------------------------ */
draw_buttons_edge(curarea->win, 740);
xco = xcostart + 750;
yco = 195;
uiBlockSetCol(block, BUTGREY);
mixrate = sound_get_mixrate();
sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
yco -= 30;
uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
/*
yco -= 30;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
xco,yco,195,20,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Doppler scaling: sets the scaling factor for doppler effect");
*/
yco -= 30;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
xco,yco,195,24,&G.listener->dopplervelocity, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
/*
if (sound->channels != SOUND_CHANNELS_STEREO || sample->channels == 1)
{
uiBlockSetCol(block, BUTGREEN);
uiDefButI(block, TOGN|BIT|SOUND_FLAGS_FIXED_PANNING_BIT, B_SOUND_REDRAW, "3D pan",
xco, yco, 95, 20, &sound->flags, 0, 0, 0, 0, "");
uiBlockSetCol(block, BUTSALMON);
xco += 100;
uiDefButI(block, TOG|BIT|SOUND_FLAGS_FIXED_PANNING_BIT, B_SOUND_REDRAW, "Fixed",
xco, yco, 95, 20, &sound->flags, 0, 0, 0, 0, "");
uiBlockSetCol(block, BUTGREY);
if (sound->flags & SOUND_FLAGS_FIXED_PANNING)
{
xco += 100;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pann: ",
xco,yco,195,20,&sound->panning, -1.0, 1.0, 0, 0, "");
}
}
*/
uiDrawBlock(block);
}
/* audio sequence engine settings ------------------------------------------------------------------ */
draw_buttons_edge(curarea->win, 1000);
xco = xcostart + 1010;
yco = 195;
uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 25;
sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 25;
uiBlockSetCol(block, BUTGREY);
uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz", xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz");
uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz", xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz");
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc", xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
yco -= 25;
uiBlockSetCol(block, BUTGREEN);
uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync", xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
uiDefButS(block, TOG|BIT|2, B_SOUND_CHANGED, "Scrub", xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames");
yco -= 25;
uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 25;
uiBlockSetCol(block, BUTGREY);
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
yco -= 25;
uiDefButS(block, TOG|BIT|0, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");
yco -= 35;
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN", xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio");
uiDrawBlock(block);
}
/* **************************** VIEW ************************ */
static void view3d_change_bgpic_ima(View3D *v3d, Image *newima) {
@ -929,490 +448,3 @@ static void scene_change_set(Scene *sc, Scene *set) {
}
/* ********************* CONSTRAINT ***************************** */
static void activate_constraint_ipo_func (void *arg1v, void *unused)
{
bConstraint *con = arg1v;
bConstraintChannel *chan;
ListBase *conbase;
get_constraint_client(NULL, NULL, NULL);
conbase = get_constraint_client_channels(1);
if (!conbase)
return;
/* See if this list already has an appropriate channel */
chan = find_constraint_channel(conbase, con->name);
if (!chan){
/* Add a new constraint channel */
chan = add_new_constraint_channel(con->name);
BLI_addtail(conbase, chan);
}
/* Ensure there is an ipo to display */
if (!chan->ipo){
chan->ipo = add_ipo(con->name, IPO_CO);
}
/* Make this the active channel */
OBACT->activecon = chan;
allqueue(REDRAWIPO, 0);
allqueue(REDRAWNLA, 0);
}
static void del_constraint_func (void *arg1v, void *arg2v)
{
bConstraint *con= arg1v;
Object *ob;
ListBase *lb= arg2v;
ob=OBACT;
if (ob->activecon && !strcmp(ob->activecon->name, con->name))
ob->activecon = NULL;
free_constraint_data (con);
BLI_freelinkN(lb, con);
allqueue(REDRAWBUTSCONSTRAINT, 0);
allqueue(REDRAWIPO, 0);
}
static void verify_constraint_name_func (void *data, void *data2_unused)
{
ListBase *conlist;
bConstraint *con;
char ownerstr[64];
short type;
con = (bConstraint*) data;
if (!con)
return;
conlist = get_constraint_client(ownerstr, &type, NULL);
unique_constraint_name (con, conlist);
}
static void constraint_changed_func (void *data, void *data2_unused)
{
bConstraint *con = (bConstraint*) data;
if (con->type == con->otype)
return;
free_constraint_data (con);
con->data = new_constraint_data(con->type);
}
static void move_constraint_func (void *datav, void *data2_unused)
{
bConstraint *constraint_to_move= datav;
int val;
ListBase *conlist;
char ownerstr[64];
short type;
bConstraint *curCon, *con, *neighbour;
val= pupmenu("Move up%x1|Move down %x2");
con = constraint_to_move;
if(val>0) {
conlist = get_constraint_client(ownerstr, &type, NULL);
for (curCon = conlist->first; curCon; curCon = curCon->next){
if (curCon == con){
/* Move up */
if (val == 1 && con->prev){
neighbour = con->prev;
BLI_remlink(conlist, neighbour);
BLI_insertlink(conlist, con, neighbour);
}
/* Move down */
else if (val == 2 && con->next){
neighbour = con->next;
BLI_remlink (conlist, con);
BLI_insertlink(conlist, neighbour, con);
}
break;
}
}
}
}
static void get_constraint_typestring (char *str, bConstraint *con)
{
switch (con->type){
case CONSTRAINT_TYPE_CHILDOF:
strcpy (str, "Child Of");
return;
case CONSTRAINT_TYPE_NULL:
strcpy (str, "Null");
return;
case CONSTRAINT_TYPE_TRACKTO:
strcpy (str, "Track To");
return;
case CONSTRAINT_TYPE_KINEMATIC:
strcpy (str, "IK Solver");
return;
case CONSTRAINT_TYPE_ROTLIKE:
strcpy (str, "Copy Rotation");
return;
case CONSTRAINT_TYPE_LOCLIKE:
strcpy (str, "Copy Location");
return;
case CONSTRAINT_TYPE_ACTION:
strcpy (str, "Action");
return;
default:
strcpy (str, "Unknown");
return;
}
}
static BIFColorID get_constraint_col(bConstraint *con)
{
switch (con->type) {
case CONSTRAINT_TYPE_NULL:
return BUTWHITE;
case CONSTRAINT_TYPE_KINEMATIC:
return BUTPURPLE;
case CONSTRAINT_TYPE_TRACKTO:
return BUTGREEN;
case CONSTRAINT_TYPE_ROTLIKE:
return BUTBLUE;
case CONSTRAINT_TYPE_LOCLIKE:
return BUTYELLOW;
case CONSTRAINT_TYPE_ACTION:
return BUTPINK;
default:
return REDALERT;
}
}
static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco, short type)
{
uiBut *but;
char typestr[64];
short height, width = 268;
BIFColorID curCol;
uiBlockSetEmboss(block, UI_EMBOSSW);
get_constraint_typestring (typestr, con);
curCol = get_constraint_col(con);
/* Draw constraint header */
uiBlockSetCol(block, BUTSALMON);
but = uiDefIconBut(block, BUT, B_CONSTRAINT_REDRAW, ICON_X, *xco, *yco, 20, 20, list, 0.0, 0.0, 0.0, 0.0, "Delete constraint");
uiButSetFunc(but, del_constraint_func, con, list);
if (con->flag & CONSTRAINT_EXPAND){
uiBlockSetCol(block, BUTYELLOW);
if (con->flag & CONSTRAINT_DISABLE)
uiBlockSetCol(block, REDALERT);
if (type==TARGET_BONE)
but = uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Bone Constraint%t|Track To%x2|IK Solver%x3|Copy Rotation%x8|Copy Location%x9|Action%x12|Null%x0", *xco+20, *yco, 100, 20, &con->type, 0.0, 0.0, 0.0, 0.0, "Constraint type");
else
but = uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Object Constraint%t|Track To%x2|Copy Rotation%x8|Copy Location%x9|Null%x0", *xco+20, *yco, 100, 20, &con->type, 0.0, 0.0, 0.0, 0.0, "Constraint type");
uiButSetFunc(but, constraint_changed_func, con, NULL);
con->otype = con->type;
but = uiDefBut(block, TEX, B_CONSTRAINT_REDRAW, "", *xco+120, *yco, 128, 20, con->name, 0.0, 32.0, 0.0, 0.0, "Constraint name");
uiButSetFunc(but, verify_constraint_name_func, con, NULL);
}
else{
uiBlockSetEmboss(block, UI_EMBOSSP);
uiBlockSetCol(block, BUTGREY);
if (con->flag & CONSTRAINT_DISABLE){
uiBlockSetCol(block, REDALERT);
BIF_set_color(REDALERT, COLORSHADE_MEDIUM);
}
else
BIF_set_color(curCol, COLORSHADE_MEDIUM);
glRects(*xco+20, *yco, *xco+248, *yco+20);
but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+20, *yco, 100, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(but, move_constraint_func, con, NULL);
but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco, 128, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(but, move_constraint_func, con, NULL);
}
uiBlockSetCol(block, BUTGREY);
uiBlockSetEmboss(block, UI_EMBOSSW);
uiDefIconButS(block, ICONTOG|BIT|CONSTRAINT_EXPAND_BIT, B_CONSTRAINT_REDRAW, ICON_RIGHTARROW, *xco+248, *yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse");
/* Draw constraint data*/
#ifdef __CON_IPO
if (con->type!=CONSTRAINT_TYPE_NULL)
{
uiDefBut(block, NUMSLI|FLO, B_CONSTRAINT_REDRAW, "Influence:", *xco+280, *yco, 196, 20, &con->enforce, 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Edit Ipo", *xco+480, *yco, 64, 20, 0, 0.0, 1.0, 0.0, 0.0, "Show this constraint's ipo in the object's Ipo window");
/* If this is on an object, add the constraint to the object */
uiButSetFunc (but, activate_constraint_ipo_func, con, NULL);
/* If this is on a bone, add the constraint to the action (if any) */
}
#endif
if (!(con->flag & CONSTRAINT_EXPAND)){
(*yco)-=21;
return;
}
switch (con->type){
case CONSTRAINT_TYPE_ACTION:
{
bActionConstraint *data = con->data;
bArmature *arm;
height = 86;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
/* Draw target parameters */
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
/* Draw action button */
uiDefIDPoinBut(block, test_actionpoin_but, B_CONSTRAINT_CHANGETARGET, "AC:", *xco+((width/2)-120), *yco-60, 80, 18, &data->act, "Action containing the keyed motion for this bone");
uiDefButS(block, NUM, B_CONSTRAINT_CHANGETARGET, "Start:", *xco+((width/2)-40), *yco-60, 80, 18, &data->start, 1, 18000, 0.0, 0.0, "Starting frame of the keyed motion");
uiDefButS(block, NUM, B_CONSTRAINT_CHANGETARGET, "End:", *xco+((width/2)+40), *yco-60, 80, 18, &data->end, 1, 18000, 0.0, 0.0, "Ending frame of the keyed motion");
/* Draw XYZ toggles */
uiDefButI(block, MENU, B_CONSTRAINT_REDRAW, "Key on%t|X Rot%x0|Y Rot%x1|Z Rot%x2", *xco+((width/2)-120), *yco-80, 80, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action");
uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Min:", *xco+((width/2)-40), *yco-80, 80, 18, &data->min, -180, 180, 0, 0, "Minimum value for target channel range");
uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Max:", *xco+((width/2)+40), *yco-80, 80, 18, &data->max, -180, 180, 0, 0, "Maximum value for target channel range");
}
break;
case CONSTRAINT_TYPE_LOCLIKE:
{
bLocateLikeConstraint *data = con->data;
bArmature *arm;
height = 66;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
/* Draw target parameters */
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
/* Draw XYZ toggles */
but=uiDefButI(block, TOG|BIT|0, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-60, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
but=uiDefButI(block, TOG|BIT|1, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-60, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
but=uiDefButI(block, TOG|BIT|2, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-60, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
}
break;
case CONSTRAINT_TYPE_ROTLIKE:
{
bRotateLikeConstraint *data = con->data;
bArmature *arm;
height = 46;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
}
break;
case CONSTRAINT_TYPE_KINEMATIC:
{
bKinematicConstraint *data = con->data;
bArmature *arm;
height = 66;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Tolerance:", *xco+((width/2)-96), *yco-20, 96, 18, &data->tolerance, 0.0001, 1.0, 0.0, 0.0, "Maximum distance to target after solving");
uiDefButI(block, NUM, B_CONSTRAINT_REDRAW, "Iterations:", *xco+((width/2)), *yco-20, 96, 18, &data->iterations, 1, 10000, 0.0, 0.0, "Maximum number of solving iterations");
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-40, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-60,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
}
break;
case CONSTRAINT_TYPE_NULL:
{
height = 20;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
}
break;
case CONSTRAINT_TYPE_TRACKTO:
{
bTrackToConstraint *data = con->data;
bArmature *arm;
height = 46;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
}
break;
default:
height = 0;
break;
}
(*yco)-=(24+height);
}
static void constraintbuts(void)
{
short xco, yco, type;
uiBlock *block;
char str[32];
ListBase *conlist;
char ownerstr[64];
bConstraint *curcon;
xco = 320;
yco = 195;
sprintf(str, "buttonswin %d", curarea->win);
block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win);
conlist = get_constraint_client(ownerstr, &type, NULL);
if (conlist){
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_CONSTRAINT_ADD, "Add", xco, yco, 95, 20, 0, 0.0, 0, 0, 0,"Add new constraint");
/* Go through the list of constraints and draw them */
xco = 465;
yco = 195;
for (curcon = conlist->first; curcon; curcon=curcon->next)
{
/* Draw default constraint header */
draw_constraint(block, conlist, curcon, &xco, &yco, type);
}
}
uiDrawBlock(block);
}
static void do_constraintbuts(unsigned short event)
{
ListBase *list;
short type;
switch(event) {
case B_CONSTRAINT_CHANGENAME:
break;
case B_CONSTRAINT_TEST:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSCONSTRAINT, 0);
break;
case B_CONSTRAINT_REDRAW:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSCONSTRAINT, 0);
break;
case B_CONSTRAINT_CHANGETARGET:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSCONSTRAINT, 0);
break;
case B_CONSTRAINT_CHANGETYPE:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSCONSTRAINT, 0);
break;
case B_CONSTRAINT_ADD:
{
bConstraint *con;
// ListBase *chanbase;
// bConstraintChannel *chan;
// Object *ob = OBACT;
list = get_constraint_client(NULL, &type, NULL);
// chanbase= get_constraint_client_channels(0);
if (list){
con = add_new_constraint();
unique_constraint_name(con, list);
// chan = add_new_constraint_channel(con->name);
// ob->activecon = chan;
// BLI_addtail(chanbase, chan);
BLI_addtail(list, con);
}
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSCONSTRAINT, 0);
}
break;
case B_CONSTRAINT_DEL:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSCONSTRAINT, 0);
break;
default:
break;
}
}

View File

@ -1755,13 +1755,63 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me)
static void editing_panel_materials(Object *ob)
{
uiBlock *block;
int *poin;
ID *id, *idfrom;
int *poin, xco=143;
float min;
Material *ma;
char str[64];
block= uiNewBlock(&curarea->uiblocks, "editing_panel_materials", UI_EMBOSSX, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Materials", "Editing", 0, 0, 318, 204)==0) return;
if(uiNewPanel(curarea, block, "Link and Materials", "Editing", 0, 0, 318, 204)==0) return;
buttons_active_id(&id, &idfrom);
if(id) {
int alone= 0;
int local= 0;
int browse= B_EDITBROWSE;
if(ob->type==OB_MESH) {
browse= B_MESHBROWSE;
alone= B_MESHALONE;
local= B_MESHLOCAL;
uiSetButLock(G.obedit!=0, "Unable to perform function in EditMode");
}
else if(ob->type==OB_MBALL) {
alone= B_MBALLALONE;
local= B_MBALLLOCAL;
}
else if ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF) {
alone= B_CURVEALONE;
local= B_CURVELOCAL;
}
else if(ob->type==OB_CAMERA) {
alone= B_CAMERAALONE;
local= B_CAMERALOCAL;
}
else if(ob->type==OB_LAMP) {
alone= B_LAMPALONE;
local= B_LAMPLOCAL;
}
else if (ob->type==OB_ARMATURE){
alone = B_ARMALONE;
local = B_ARMLOCAL;
}
else if(ob->type==OB_LATTICE) {
alone= B_LATTALONE;
local= B_LATTLOCAL;
}
uiBlockSetCol(block, BUTPURPLE);
xco= std_libbuttons(block, 143, 180, 0, NULL, browse, id, idfrom, &(G.buts->menunr), alone, local, 0, 0, B_KEEPDATA);
}
if(ob) {
uiBlockSetCol(block, BUTGREY);
uiBut *but= uiDefBut(block, TEX, B_IDNAME, "OB:", xco, 180, 454-xco, YIC, ob->id.name+2, 0.0, 19.0, 0, 0, "Displays Active Object name. Click to change.");
uiButSetFunc(but, test_idbutton_cb, ob->id.name, NULL);
}
/* to be sure */
if ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL);
@ -1771,7 +1821,7 @@ static void editing_panel_materials(Object *ob)
if(ob->type==OB_MESH) poin= &( ((Mesh *)ob->data)->texflag );
else if(ob->type==OB_MBALL) poin= &( ((MetaBall *)ob->data)->texflag );
else poin= &( ((Curve *)ob->data)->texflag );
uiDefButI(block, TOG|BIT|0, B_AUTOTEX, "AutoTexSpace", 143,180,130,19, poin, 0, 0, 0, 0, "Adjusts active object's texture space automatically when transforming object");
uiDefButI(block, TOG|BIT|0, B_AUTOTEX, "AutoTexSpace", 143,15,130,19, poin, 0, 0, 0, 0, "Adjusts active object's texture space automatically when transforming object");
sprintf(str,"%d Mat:", ob->totcol);
if(ob->totcol) min= 1.0; else min= 0.0;

View File

@ -125,6 +125,7 @@
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "BIF_editconstraint.h"
#include "BSE_editipo.h"
#include "BDR_editobject.h"
@ -132,13 +133,507 @@
float hspeed=0.1, prspeed=0.0, prlen=0.0;
/* ********************* CONSTRAINT ***************************** */
static void activate_constraint_ipo_func (void *arg1v, void *unused)
{
bConstraint *con = arg1v;
bConstraintChannel *chan;
ListBase *conbase;
get_constraint_client(NULL, NULL, NULL);
conbase = get_constraint_client_channels(1);
if (!conbase)
return;
/* See if this list already has an appropriate channel */
chan = find_constraint_channel(conbase, con->name);
if (!chan){
/* Add a new constraint channel */
chan = add_new_constraint_channel(con->name);
BLI_addtail(conbase, chan);
}
/* Ensure there is an ipo to display */
if (!chan->ipo){
chan->ipo = add_ipo(con->name, IPO_CO);
}
/* Make this the active channel */
OBACT->activecon = chan;
allqueue(REDRAWIPO, 0);
allqueue(REDRAWNLA, 0);
}
static void del_constraint_func (void *arg1v, void *arg2v)
{
bConstraint *con= arg1v;
Object *ob;
ListBase *lb= arg2v;
ob=OBACT;
if (ob->activecon && !strcmp(ob->activecon->name, con->name))
ob->activecon = NULL;
free_constraint_data (con);
BLI_freelinkN(lb, con);
allqueue(REDRAWBUTSOBJECT, 0);
allqueue(REDRAWIPO, 0);
}
static void verify_constraint_name_func (void *data, void *data2_unused)
{
ListBase *conlist;
bConstraint *con;
char ownerstr[64];
short type;
con = (bConstraint*) data;
if (!con)
return;
conlist = get_constraint_client(ownerstr, &type, NULL);
unique_constraint_name (con, conlist);
}
static void constraint_changed_func (void *data, void *data2_unused)
{
bConstraint *con = (bConstraint*) data;
if (con->type == con->otype)
return;
free_constraint_data (con);
con->data = new_constraint_data(con->type);
}
static void move_constraint_func (void *datav, void *data2_unused)
{
bConstraint *constraint_to_move= datav;
int val;
ListBase *conlist;
char ownerstr[64];
short type;
bConstraint *curCon, *con, *neighbour;
val= pupmenu("Move up%x1|Move down %x2");
con = constraint_to_move;
if(val>0) {
conlist = get_constraint_client(ownerstr, &type, NULL);
for (curCon = conlist->first; curCon; curCon = curCon->next){
if (curCon == con){
/* Move up */
if (val == 1 && con->prev){
neighbour = con->prev;
BLI_remlink(conlist, neighbour);
BLI_insertlink(conlist, con, neighbour);
}
/* Move down */
else if (val == 2 && con->next){
neighbour = con->next;
BLI_remlink (conlist, con);
BLI_insertlink(conlist, neighbour, con);
}
break;
}
}
}
}
static void get_constraint_typestring (char *str, bConstraint *con)
{
switch (con->type){
case CONSTRAINT_TYPE_CHILDOF:
strcpy (str, "Child Of");
return;
case CONSTRAINT_TYPE_NULL:
strcpy (str, "Null");
return;
case CONSTRAINT_TYPE_TRACKTO:
strcpy (str, "Track To");
return;
case CONSTRAINT_TYPE_KINEMATIC:
strcpy (str, "IK Solver");
return;
case CONSTRAINT_TYPE_ROTLIKE:
strcpy (str, "Copy Rotation");
return;
case CONSTRAINT_TYPE_LOCLIKE:
strcpy (str, "Copy Location");
return;
case CONSTRAINT_TYPE_ACTION:
strcpy (str, "Action");
return;
default:
strcpy (str, "Unknown");
return;
}
}
static BIFColorID get_constraint_col(bConstraint *con)
{
switch (con->type) {
case CONSTRAINT_TYPE_NULL:
return BUTWHITE;
case CONSTRAINT_TYPE_KINEMATIC:
return BUTPURPLE;
case CONSTRAINT_TYPE_TRACKTO:
return BUTGREEN;
case CONSTRAINT_TYPE_ROTLIKE:
return BUTBLUE;
case CONSTRAINT_TYPE_LOCLIKE:
return BUTYELLOW;
case CONSTRAINT_TYPE_ACTION:
return BUTPINK;
default:
return REDALERT;
}
}
static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco, short type)
{
uiBut *but;
char typestr[64];
short height, width = 268;
BIFColorID curCol;
uiBlockSetEmboss(block, UI_EMBOSSW);
get_constraint_typestring (typestr, con);
curCol = get_constraint_col(con);
/* Draw constraint header */
uiBlockSetCol(block, BUTSALMON);
but = uiDefIconBut(block, BUT, B_CONSTRAINT_REDRAW, ICON_X, *xco, *yco, 20, 20, list, 0.0, 0.0, 0.0, 0.0, "Delete constraint");
uiButSetFunc(but, del_constraint_func, con, list);
if (con->flag & CONSTRAINT_EXPAND) {
uiBlockSetCol(block, BUTYELLOW);
if (con->flag & CONSTRAINT_DISABLE)
uiBlockSetCol(block, REDALERT);
if (type==TARGET_BONE)
but = uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Bone Constraint%t|Track To%x2|IK Solver%x3|Copy Rotation%x8|Copy Location%x9|Action%x12|Null%x0", *xco+20, *yco, 100, 20, &con->type, 0.0, 0.0, 0.0, 0.0, "Constraint type");
else
but = uiDefButC(block, MENU, B_CONSTRAINT_TEST, "Object Constraint%t|Track To%x2|Copy Rotation%x8|Copy Location%x9|Null%x0", *xco+20, *yco, 100, 20, &con->type, 0.0, 0.0, 0.0, 0.0, "Constraint type");
uiButSetFunc(but, constraint_changed_func, con, NULL);
con->otype = con->type;
but = uiDefBut(block, TEX, B_CONSTRAINT_REDRAW, "", *xco+120, *yco, 128, 20, con->name, 0.0, 32.0, 0.0, 0.0, "Constraint name");
uiButSetFunc(but, verify_constraint_name_func, con, NULL);
}
else{
uiBlockSetEmboss(block, UI_EMBOSSP);
uiBlockSetCol(block, BUTGREY);
if (con->flag & CONSTRAINT_DISABLE) {
uiBlockSetCol(block, REDALERT);
BIF_set_color(REDALERT, COLORSHADE_MEDIUM);
}
else
BIF_set_color(curCol, COLORSHADE_MEDIUM);
glRects(*xco+20, *yco, *xco+248, *yco+20);
but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, *xco+20, *yco, 100, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(but, move_constraint_func, con, NULL);
but = uiDefBut(block, LABEL, B_CONSTRAINT_TEST, con->name, *xco+120, *yco, 128, 20, NULL, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(but, move_constraint_func, con, NULL);
}
uiBlockSetCol(block, BUTGREY);
uiBlockSetEmboss(block, UI_EMBOSSW);
uiDefIconButS(block, ICONTOG|BIT|CONSTRAINT_EXPAND_BIT, B_CONSTRAINT_REDRAW, ICON_RIGHTARROW, *xco+248, *yco, 20, 20, &con->flag, 0.0, 0.0, 0.0, 0.0, "Collapse");
if (!(con->flag & CONSTRAINT_EXPAND)) {
(*yco)-=21;
return;
}
if (con->type!=CONSTRAINT_TYPE_NULL) {
uiDefBut(block, NUMSLI|FLO, B_CONSTRAINT_REDRAW, "Influence:", *xco, *yco-20, 196, 20, &con->enforce, 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
but = uiDefBut(block, BUT, B_CONSTRAINT_REDRAW, "Edit Ipo", *xco+200, *yco-20, 64, 20, 0, 0.0, 1.0, 0.0, 0.0, "Show this constraint's ipo in the object's Ipo window");
/* If this is on an object, add the constraint to the object */
uiButSetFunc (but, activate_constraint_ipo_func, con, NULL);
/* If this is on a bone, add the constraint to the action (if any) */
(*yco)-=21;
}
/* Draw constraint data*/
switch (con->type){
case CONSTRAINT_TYPE_ACTION:
{
bActionConstraint *data = con->data;
bArmature *arm;
height = 86;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
/* Draw target parameters */
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
/* Draw action button */
uiDefIDPoinBut(block, test_actionpoin_but, B_CONSTRAINT_CHANGETARGET, "AC:", *xco+((width/2)-120), *yco-60, 80, 18, &data->act, "Action containing the keyed motion for this bone");
uiDefButS(block, NUM, B_CONSTRAINT_CHANGETARGET, "Start:", *xco+((width/2)-40), *yco-60, 80, 18, &data->start, 1, 18000, 0.0, 0.0, "Starting frame of the keyed motion");
uiDefButS(block, NUM, B_CONSTRAINT_CHANGETARGET, "End:", *xco+((width/2)+40), *yco-60, 80, 18, &data->end, 1, 18000, 0.0, 0.0, "Ending frame of the keyed motion");
/* Draw XYZ toggles */
uiDefButI(block, MENU, B_CONSTRAINT_REDRAW, "Key on%t|X Rot%x0|Y Rot%x1|Z Rot%x2", *xco+((width/2)-120), *yco-80, 80, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action");
uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Min:", *xco+((width/2)-40), *yco-80, 80, 18, &data->min, -180, 180, 0, 0, "Minimum value for target channel range");
uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Max:", *xco+((width/2)+40), *yco-80, 80, 18, &data->max, -180, 180, 0, 0, "Maximum value for target channel range");
}
break;
case CONSTRAINT_TYPE_LOCLIKE:
{
bLocateLikeConstraint *data = con->data;
bArmature *arm;
height = 66;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
/* Draw target parameters */
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
/* Draw XYZ toggles */
but=uiDefButI(block, TOG|BIT|0, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-60, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component");
but=uiDefButI(block, TOG|BIT|1, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-60, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
but=uiDefButI(block, TOG|BIT|2, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-60, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component");
}
break;
case CONSTRAINT_TYPE_ROTLIKE:
{
bRotateLikeConstraint *data = con->data;
bArmature *arm;
height = 46;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
}
break;
case CONSTRAINT_TYPE_KINEMATIC:
{
bKinematicConstraint *data = con->data;
bArmature *arm;
height = 66;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
uiDefButF(block, NUM, B_CONSTRAINT_REDRAW, "Tolerance:", *xco+((width/2)-96), *yco-20, 96, 18, &data->tolerance, 0.0001, 1.0, 0.0, 0.0, "Maximum distance to target after solving");
uiDefButI(block, NUM, B_CONSTRAINT_REDRAW, "Iterations:", *xco+((width/2)), *yco-20, 96, 18, &data->iterations, 1, 10000, 0.0, 0.0, "Maximum number of solving iterations");
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-40, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-60,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
}
break;
case CONSTRAINT_TYPE_NULL:
{
height = 20;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
}
break;
case CONSTRAINT_TYPE_TRACKTO:
{
bTrackToConstraint *data = con->data;
bArmature *arm;
height = 46;
BIF_set_color(curCol, COLORSHADE_GREY);
glRects(*xco, *yco-height, *xco+width, *yco);
uiEmboss((float)*xco, (float)*yco-height, (float)*xco+width, (float)*yco, 1);
uiDefIDPoinBut(block, test_obpoin_but, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+((width/2)-48), *yco-20, 96, 18, &data->tar, "Target Object");
arm = get_armature(data->tar);
if (arm){
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+((width/2)-48), *yco-40,96,18, &data->subtarget, 0, 24, 0, 0, "Bone");
}
else
strcpy (data->subtarget, "");
}
break;
default:
height = 0;
break;
}
(*yco)-=(24+height);
}
void do_constraintbuts(unsigned short event)
{
ListBase *list;
short type;
switch(event) {
case B_CONSTRAINT_CHANGENAME:
break;
case B_CONSTRAINT_TEST:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
break;
case B_CONSTRAINT_REDRAW:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
break;
case B_CONSTRAINT_CHANGETARGET:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
break;
case B_CONSTRAINT_CHANGETYPE:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
break;
case B_CONSTRAINT_ADD:
{
bConstraint *con;
// ListBase *chanbase;
// bConstraintChannel *chan;
// Object *ob = OBACT;
list = get_constraint_client(NULL, &type, NULL);
// chanbase= get_constraint_client_channels(0);
if (list){
con = add_new_constraint();
unique_constraint_name(con, list);
// chan = add_new_constraint_channel(con->name);
// ob->activecon = chan;
// BLI_addtail(chanbase, chan);
BLI_addtail(list, con);
}
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
}
break;
case B_CONSTRAINT_DEL:
test_scene_constraints();
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
break;
default:
break;
}
}
static void object_panel_constraint(void)
{
uiBlock *block;
ListBase *conlist;
bConstraint *curcon;
short xco, yco, type;
char ownerstr[64];
block= uiNewBlock(&curarea->uiblocks, "object_panel_constraint", UI_EMBOSSX, UI_HELV, curarea->win);
uiNewPanelTabbed("Effects", "Object");
if(uiNewPanel(curarea, block, "Constraints", "Object", 10, 640, 318, 204)==0) return;
/* this is a variable height panel, newpanel doesnt force new size on existing panels */
/* so first we make it default height */
uiNewPanelHeight(block, 204);
conlist = get_constraint_client(ownerstr, &type, NULL);
if (conlist) {
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_CONSTRAINT_ADD, "Add", 10, 190, 95, 20, 0, 0.0, 0, 0, 0,"Add new constraint");
/* Go through the list of constraints and draw them */
xco = 10;
yco = 160;
// local panel coords
uiPanelPush(block);
for (curcon = conlist->first; curcon; curcon=curcon->next) {
/* Draw default constraint header */
draw_constraint(block, conlist, curcon, &xco, &yco, type);
}
uiPanelPop(block);
if(yco < 0) uiNewPanelHeight(block, 204-yco);
}
}
/* *************** */
#include "BLI_editVert.h"
extern ListBase editNurb;
void do_common_editbuts(unsigned short event) // old name
void do_common_editbuts(unsigned short event) // old name, is a mix of object and editing events....
{
EditVlak *evl;
Base *base;
@ -886,8 +1381,8 @@ void object_panels()
if(ob) {
object_panel_anim(ob);
object_panel_draw(ob);
if(ob->type==OB_MESH)
object_panel_effects(ob);
if(ob->type==OB_MESH) object_panel_effects(ob);
object_panel_constraint();
}
}

View File

@ -47,10 +47,16 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_scene_types.h"
#include "DNA_sound_types.h"
#include "DNA_userdef_types.h"
#include "DNA_packedFile_types.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_library.h"
#include "BKE_sound.h"
#include "BKE_packedFile.h"
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
@ -83,7 +89,9 @@
#include "BIF_renderwin.h"
#include "BIF_writeimage.h"
#include "BIF_writeavicodec.h"
#include "BIF_editsound.h"
#include "BSE_seqaudio.h"
#include "BSE_headerbuttons.h"
#include "butspace.h" // own module
#ifdef WITH_QUICKTIME
@ -98,7 +106,340 @@
*/
/* ************************ SOUND *************************** */
static void load_new_sample(char *str) /* called from fileselect */
{
char name[FILE_MAXDIR+FILE_MAXFILE];
bSound *sound;
bSample *sample, *newsample;
sound = G.buts->lockpoin;
if (sound) {
// save values
sample = sound->sample;
strcpy(name, sound->sample->name);
strcpy(sound->name, str);
sound_set_sample(sound, NULL);
sound_initialize_sample(sound);
if (sound->sample->type == SAMPLE_INVALID) {
error("Not a valid sample: %s", str);
newsample = sound->sample;
// restore values
strcpy(sound->name, name);
sound_set_sample(sound, sample);
// remove invalid sample
sound_free_sample(newsample);
BLI_remlink(samples, newsample);
MEM_freeN(newsample);
}
}
allqueue(REDRAWBUTSSCENE, 0);
}
void do_soundbuts(unsigned short event)
{
char name[FILE_MAXDIR+FILE_MAXFILE];
bSound *sound;
bSample *sample;
bSound* tempsound;
ID *id;
sound = G.buts->lockpoin;
switch(event) {
case B_SOUND_REDRAW:
allqueue(REDRAWBUTSSCENE, 0);
break;
case B_SOUND_LOAD_SAMPLE:
if (sound) strcpy(name, sound->name);
else strcpy(name, U.sounddir);
activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
break;
case B_SOUND_PLAY_SAMPLE:
if (sound) {
if (sound->sample->type != SAMPLE_INVALID) {
sound_play_sound(sound);
allqueue(REDRAWBUTSSCENE, 0);
}
}
break;
case B_SOUND_MENU_SAMPLE:
if (G.buts->menunr == -2) {
if (sound) {
activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts);
}
} else if (G.buts->menunr > 0) {
sample = BLI_findlink(samples, G.buts->menunr - 1);
if (sample && sound) {
BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
sound_set_sample(sound, sample);
do_soundbuts(B_SOUND_REDRAW);
}
}
break;
case B_SOUND_NAME_SAMPLE:
load_new_sample(sound->name);
break;
case B_SOUND_UNPACK_SAMPLE:
if(sound && sound->sample) {
sample = sound->sample;
if (sample->packedfile) {
if (G.fileflags & G_AUTOPACK) {
if (okee("Disable AutoPack ?")) {
G.fileflags &= ~G_AUTOPACK;
}
}
if ((G.fileflags & G_AUTOPACK) == 0) {
unpackSample(sample, PF_ASK);
}
} else {
sound_set_packedfile(sample, newPackedFile(sample->name));
}
allqueue(REDRAWHEADERS, 0);
do_soundbuts(B_SOUND_REDRAW);
}
break;
case B_SOUND_COPY_SOUND:
if (sound) {
tempsound = sound_make_copy(sound);
sound = tempsound;
id = &sound->id;
G.buts->lockpoin = (bSound*)id;
do_soundbuts(B_SOUND_REDRAW);
}
break;
case B_SOUND_RECALC:
waitcursor(1);
sound = G.main->sound.first;
while (sound) {
MEM_freeN(sound->stream);
sound->stream = 0;
audio_makestream(sound);
sound = (bSound *) sound->id.next;
}
waitcursor(0);
allqueue(REDRAWSEQ, 0);
break;
case B_SOUND_RATECHANGED:
allqueue(REDRAWBUTSSCENE, 0);
allqueue(REDRAWSEQ, 0);
break;
case B_SOUND_MIXDOWN:
audio_mixdown();
break;
default:
if (G.f & G_DEBUG) {
printf("do_soundbuts: unhandled event %d\n", event);
}
}
}
static void sound_panel_listener()
{
uiBlock *block;
int xco= 100, yco=100, mixrate;
char mixrateinfo[256];
block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSSX, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return;
uiBlockSetCol(block, BUTGREY);
mixrate = sound_get_mixrate();
sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
yco -= 30;
uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
yco -= 30;
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
xco,yco,195,24,&G.listener->dopplervelocity, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
}
static void sound_panel_sequencer()
{
uiBlock *block;
short xco, yco;
char mixrateinfo[256];
block= uiNewBlock(&curarea->uiblocks, "sound_panel_sequencer", UI_EMBOSSX, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Sequencer", "Sound", 640, 0, 318, 204)==0) return;
/* audio sequence engine settings ------------------------------------------------------------------ */
xco = 1010;
yco = 195;
uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 25;
sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 25;
uiBlockSetCol(block, BUTGREY);
uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz", xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz");
uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz", xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz");
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc", xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
yco -= 25;
uiBlockSetCol(block, BUTGREEN);
uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync", xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
uiDefButS(block, TOG|BIT|2, B_SOUND_CHANGED, "Scrub", xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames");
yco -= 25;
uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
yco -= 25;
uiBlockSetCol(block, BUTGREY);
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
yco -= 25;
uiDefButS(block, TOG|BIT|0, 0, "Mute", xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");
yco -= 35;
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN", xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio");
}
static void sound_panel_sound(bSound *sound)
{
static int packdummy=0;
ID *id, *idfrom;
uiBlock *block;
bSample *sample;
char *strp, str[32], ch[256];
block= uiNewBlock(&curarea->uiblocks, "sound_panel_sound", UI_EMBOSSX, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Sound", "Sound", 0, 0, 318, 204)==0) return;
uiDefBut(block, LABEL, 0, "Blender Sound block",10,180,195,20, 0, 0, 0, 0, 0, "");
// warning: abuse of texnr here! (ton didnt code!)
buttons_active_id(&id, &idfrom);
std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", 220,160,90,20, 0, 0, 0, 0, 0, "Make another copy (duplicate) of the current sound");
if (sound) {
uiSetButLock(sound->id.lib!=0, "Can't edit library data");
sound_initialize_sample(sound);
sample = sound->sample;
/* info string */
if (sound->sample && sound->sample->len) {
if (sound->sample->channels == 1) strcpy(ch, "Mono");
else if (sound->sample->channels == 2) strcpy(ch, "Stereo");
else strcpy(ch, "Unknown");
sprintf(ch, "Sample: %s, %d bit, %d Hz, %d samples", ch, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels));
uiDefBut(block, LABEL, 0, ch, 35,140,225,20, 0, 0, 0, 0, 0, "");
}
else {
uiDefBut(block, LABEL, 0, "Sample: No sample info available.",35,140,225,20, 0, 0, 0, 0, 0, "");
}
/* sample browse buttons */
id= (ID *)sound->sample;
IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr));
if (strp[0]) uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp, 10,120,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
MEM_freeN(strp);
uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "", 35,120,225,20, sound->name, 0.0, 79.0, 0, 0, "The sample file used by this Sound");
sprintf(str, "%d", sample->id.us);
uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str, 260,120,25,20, 0, 0, 0, 0, 0, "The number of users");
if (sound->sample->packedfile) packdummy = 1;
else packdummy = 0;
uiDefIconButI(block, TOG|BIT|0, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
285, 120,25,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
uiBlockSetCol(block, BUTSALMON);
uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", 10, 95,150,24, 0, 0, 0, 0, 0, "Load a different sample file");
uiBlockSetCol(block, BUTPURPLE);
uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play", 160, 95, 150, 24, 0, 0.0, 0, 0, 0, "Playback sample using settings below");
uiBlockSetCol(block, BUTGREY);
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
10,70,150,20, &sound->volume, 0.0, 1.0, 0, 0, "Set the volume of this sound");
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
160,70,150,20, &sound->pitch, -12.0, 12.0, 0, 0, "Set the pitch of this sound");
/* looping */
uiBlockSetCol(block, BUTGREEN);
uiDefButI(block, TOG|BIT|SOUND_FLAGS_LOOP_BIT, B_SOUND_REDRAW, "Loop",
10, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Toggle between looping on/off");
if (sound->flags & SOUND_FLAGS_LOOP) {
uiDefButI(block, TOG|BIT|SOUND_FLAGS_BIDIRECTIONAL_LOOP_BIT, B_SOUND_REDRAW, "Ping Pong",
105, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Toggle between A->B and A->B->A looping");
}
/* 3D settings ------------------------------------------------------------------ */
if (sound->sample->channels == 1) {
uiBlockSetCol(block, BUTGREEN);
uiDefButI(block, TOG|BIT|SOUND_FLAGS_3D_BIT, B_SOUND_REDRAW, "3D Sound",
10, 10, 90, 20, &sound->flags, 0, 0, 0, 0, "Turns 3D sound on");
if (sound->flags & SOUND_FLAGS_3D) {
uiBlockSetCol(block, BUTGREY);
uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
100,10,210,20, &sound->attenuation, 0.0, 5.0, 1.0, 0, "Sets the surround scaling factor for this sound");
}
}
}
}
/* ************************* SCENE *********************** */
static void output_pic(char *name)
@ -929,9 +1270,14 @@ void anim_panels()
void sound_panels()
{
bSound *sound;
sound = G.buts->lockpoin;
if ((sound) && (sound->flags & SOUND_FLAGS_SEQUENCE)) sound = NULL;
sound_panel_sound(sound);
sound_panel_listener();
sound_panel_sequencer();
}

View File

@ -291,7 +291,7 @@ void areawinset(short win)
}
#define SCR_BACK 0.55
#define SCR_ROUND 9
#define SCR_ROUND 12
void headerbox(ScrArea *area)
{
@ -306,11 +306,11 @@ void headerbox(ScrArea *area)
/* weird values here... is because of window matrix that centres buttons */
if(area->headertype==HEADERTOP) {
uiSetRoundBox(3);
uiRoundBoxEmboss(-0.5+area->headbutofs, -10.0, width-1.5+area->headbutofs, HEADERY-1, SCR_ROUND);
uiRoundBoxEmboss(-0.5+area->headbutofs, -10.0, width-1.5+area->headbutofs, HEADERY-2.0, SCR_ROUND);
}
else {
uiSetRoundBox(12);
uiRoundBoxEmboss(-0.5+area->headbutofs, -2.0, width-1.5+area->headbutofs, HEADERY+10, SCR_ROUND);
uiRoundBoxEmboss(-0.5+area->headbutofs, -3.5, width-1.5+area->headbutofs, HEADERY+10, SCR_ROUND);
}
uiSetRoundBox(15);
@ -356,9 +356,9 @@ void scrarea_do_headchange(ScrArea *area)
float ofs= area->headbutofs;
if (area->headertype==HEADERDOWN) {
bwin_ortho2(area->headwin, -0.5+ofs, area->headrct.xmax-area->headrct.xmin-0.5+ofs, -2.5, area->headrct.ymax-area->headrct.ymin-2.5);
bwin_ortho2(area->headwin, -0.5+ofs, area->headrct.xmax-area->headrct.xmin-0.5+ofs, -3.5, area->headrct.ymax-area->headrct.ymin-3.5);
} else if (area->headertype==HEADERTOP) {
bwin_ortho2(area->headwin, -0.5+ofs, area->headrct.xmax-area->headrct.xmin-0.5+ofs, -1.5, area->headrct.ymax-area->headrct.ymin-1.5);
bwin_ortho2(area->headwin, -0.5+ofs, area->headrct.xmax-area->headrct.xmin-0.5+ofs, -2.5, area->headrct.ymax-area->headrct.ymin-2.5);
}
}

View File

@ -191,8 +191,32 @@ void buttons_active_id(ID **id, ID **idfrom)
*idfrom= (ID *)ob;
if(G.buts->mainb==CONTEXT_SCENE) {
*id= (ID *)G.scene;
int tab= G.buts->tab[CONTEXT_SCENE];
if(tab==TAB_SCENE_RENDER) *id= (ID *)G.scene;
else if(tab==TAB_SCENE_SOUND) {
ID *search;
// validate lockpoin, maybe its not a sound
if (G.buts->lockpoin) {
search = G.main->sound.first;
while (search) {
if (search == G.buts->lockpoin) {
break;
}
search = search->next;
}
if (search == NULL) {
*id = G.main->sound.first;
} else {
*id = search;
}
}
else {
*id = G.main->sound.first;
}
}
}
else if(G.buts->mainb==CONTEXT_SHADING) {
int tab= G.buts->tab[CONTEXT_SHADING];
@ -261,29 +285,6 @@ void buttons_active_id(ID **id, ID **idfrom)
*id= ob->data;
}
}
else if (G.buts->mainb == BUTS_SOUND) {
#if 0
ID * search;
if (G.buts->lockpoin) {
search = G.main->sound.first;
while (search) {
if (search == G.buts->lockpoin) {
break;
}
search = search->next;
}
if (search == NULL) {
*id = G.main->sound.first;
} else {
*id = search;
}
} else {
*id = G.main->sound.first;
}
// printf("id: %d\n\n", *id);
#endif
}
}
static void validate_bonebutton(void *bonev, void *data2_unused){
@ -380,7 +381,6 @@ void buts_buttons(void)
uiBlock *block;
uiBut *but;
short xco, t_base= -2;
int alone, local, browse;
char naam[20];
sprintf(naam, "header %d", curarea->headwin);
@ -403,15 +403,25 @@ void buts_buttons(void)
/* mainb menu */
/* (this could be done later with a dynamic tree and branches, also for python) */
uiBlockSetCol(block, MIDGREY);
uiBlockSetEmboss(block, UI_EMBOSSMB); // menu but
// uiBlockSetEmboss(block, UI_EMBOSSMB); // menu but
{
char mainbname[8][12]= {" Scene", " Object", " Types", " Shading", " Editing", " Script", " Logic"};
char mainbicon[8]= {ICON_SCENE_DEHLT, ICON_OBJECT, ICON_BBOX, ICON_MATERIAL_DEHLT, ICON_EDIT, ICON_SCRIPT, ICON_GAME};
uiBut *but= uiDefIconTextBlockBut(block, sbuts_context_menu, NULL, mainbicon[G.buts->mainb], mainbname[G.buts->mainb], xco, 0, 90, YIC, "Set main context for button panels");
uiButClearFlag(but, UI_ICON_RIGHT); // this type has both flags set, and draws icon right.. uhh
xco+= 90-XIC+10;
}
//{
// char mainbname[8][12]= {" Scene", " Object", " Types", " Shading", " Editing", " Script", " Logic"};
// char mainbicon[8]= {ICON_SCENE_DEHLT, ICON_OBJECT, ICON_BBOX, ICON_MATERIAL_DEHLT, ICON_EDIT, ICON_SCRIPT, ICON_GAME};
// uiBut *but= uiDefIconTextBlockBut(block, sbuts_context_menu, NULL, mainbicon[G.buts->mainb], mainbname[G.buts->mainb], xco, 0, 90, YIC, "Set main context for button panels");
// uiButClearFlag(but, UI_ICON_RIGHT); // this type has both flags set, and draws icon right.. uhh
// xco+= 90-XIC+10;
//}
uiDefIconButS(block, ROW, B_REDR, ICON_GAME, xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_LOGIC, 0, 0, "Logic (F4) ");
uiDefIconButS(block, ROW, B_REDR, ICON_SCRIPT, xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_SCRIPT, 0, 0, "Script ");
uiDefIconButS(block, ROW, B_REDR, ICON_MATERIAL_DEHLT,xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_SHADING, 0, 0, "Shading (F5) ");
uiDefIconButS(block, ROW, B_REDR, ICON_OBJECT, xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_OBJECT, 0, 0, "Object (F7) ");
uiDefIconButS(block, ROW, B_REDR, ICON_EDIT, xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_EDITING, 0, 0, "Editing (F9) ");
uiDefIconButS(block, ROW, B_REDR, ICON_SCENE_DEHLT, xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_SCENE, 0, 0, "Scene (F10) ");
xco+=XIC;
if(curarea->headertype==HEADERTOP) t_base= -3; else t_base= 3;
/* select the context to be drawn, per contex/tab the actual context is tested */
uiBlockSetEmboss(block, UI_EMBOSSX); // normal
@ -452,79 +462,13 @@ void buts_buttons(void)
G.buts->lockpoin= id;
if(G.buts->mainb==CONTEXT_SHADING) {
#if 0
int tab= G.buts->tab[CONTEXT_SHADING];
if(tab==TAB_SHADING_MAT) {
}
else if(tab==TAB_SHADING_TEX) {
}
else if(tab==TAB_SHADING_LAMP) {
if(id) {
xco= std_libbuttons(block, xco, 0, 0, NULL, B_LAMPBROWSE, id, (ID *)ob, &(G.buts->menunr), B_LAMPALONE, B_LAMPLOCAL, 0, 0, 0);
}
}
else if(tab==TAB_SHADING_WORLD) {
xco= std_libbuttons(block, xco, 0, 0, NULL, B_WORLDBROWSE, id, idfrom, &(G.buts->menunr), B_WORLDALONE, B_WORLDLOCAL, B_WORLDDELETE, 0, B_KEEPDATA);
}
#endif
}
else if(G.buts->mainb==CONTEXT_EDITING) {
if(id) {
alone= 0;
local= 0;
browse= B_EDITBROWSE;
xco+= XIC;
if(ob->type==OB_MESH) {
browse= B_MESHBROWSE;
alone= B_MESHALONE;
local= B_MESHLOCAL;
uiSetButLock(G.obedit!=0, "Unable to perform function in EditMode");
}
else if(ob->type==OB_MBALL) {
alone= B_MBALLALONE;
local= B_MBALLLOCAL;
}
else if ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF) {
alone= B_CURVEALONE;
local= B_CURVELOCAL;
}
else if(ob->type==OB_CAMERA) {
alone= B_CAMERAALONE;
local= B_CAMERALOCAL;
}
else if(ob->type==OB_LAMP) {
alone= B_LAMPALONE;
local= B_LAMPLOCAL;
}
else if (ob->type==OB_ARMATURE){
alone = B_ARMALONE;
local = B_ARMLOCAL;
}
else if(ob->type==OB_LATTICE) {
alone= B_LATTALONE;
local= B_LATTLOCAL;
}
xco= std_libbuttons(block, xco, 0, 0, NULL, browse, id, idfrom, &(G.buts->menunr), alone, local, 0, 0, B_KEEPDATA);
xco+= XIC;
}
if(ob) {
but= uiDefBut(block, TEX, B_IDNAME, "OB:", xco, 0, 135, YIC, ob->id.name+2, 0.0, 19.0, 0, 0, "Displays Active Object name. Click to change.");
uiButSetFunc(but, test_idbutton_cb, ob->id.name, NULL);
xco+= 135;
}
}
#if 0
else if (G.buts->mainb==BUTS_SOUND) {
xco= std_libbuttons(block, xco, 0, 0, NULL, B_SOUNDBROWSE2, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
}
else if(G.buts->mainb==BUTS_CONSTRAINT){
if(id) {

View File

@ -153,8 +153,7 @@ void do_sound_buttons(unsigned short event)
if (idtest != id) {
G.buts->lockpoin = (bSound *)idtest;
if(idtest->us==0) idtest->us= 1;
//allqueue(REDRAWBUTSSOUND, 0);
BIF_preview_changed(G.buts);
allqueue(REDRAWBUTSSCENE, 0);
}
}
break;

View File

@ -340,8 +340,10 @@ int std_libbuttons(uiBlock *block, short xco, short yco,
if(parid) uiSetButLock(parid->lib!=0, "Can't edit library data");
uiDefButS(block, MENU, browse, "ADD NEW %x 32767",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
uiClearButLock();
// } else if (G.buts->mainb == BUTS_SOUND) {
// uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
} else if (G.buts->mainb == CONTEXT_SCENE) {
if(G.buts->tab[CONTEXT_SCENE]== TAB_SCENE_SOUND) {
uiDefButS(block, MENU, browse, "OPEN NEW %x 32766",xco,yco,XIC,YIC, menupoin, 0, 0, 0, 0, "Browses Datablock");
}
}
}
else if(curarea->spacetype==SPACE_TEXT) {