void WidgetTable::draw_cell(TableContext context, int R, int C, int X, int Y, int W, int H) { switch (context) { case CONTEXT_STARTPAGE: fl_font(FL_HELVETICA, 12); // font used by all headers col_width_all(50); // sets the width of the columns break; case CONTEXT_RC_RESIZE: { int X, Y, W, H; int index = 0; for (int r = 0; r<rows(); r++) { for (int c = 0; c<cols(); c++) { if (index >= children()) break; find_cell(CONTEXT_TABLE, r, c, X, Y, W, H); child(index++)->resize(X, Y, W, H); } } init_sizes(); // tell group children resized return; } case CONTEXT_ROW_HEADER: fl_push_clip(X, Y, W, H); { static char s[40]; sprintf(s, "Row %d", R); fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, row_header_color()); fl_color(FL_BLACK); fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER); } fl_pop_clip(); return; case CONTEXT_COL_HEADER: fl_push_clip(X, Y, W, H); { static char s[40]; sprintf(s, "Column %d", C); fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color()); fl_color(FL_BLACK); fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER); } fl_pop_clip(); return; case CONTEXT_CELL: return; // fltk handles drawing the widgets default: return; } }
void gLiquidScroll::resize(int X, int Y, int W, int H) { int nc = children()-2; // skip hscrollbar and vscrollbar for ( int t=0; t<nc; t++) { // tell children to resize to our new width Fl_Widget *c = child(t); c->resize(c->x(), c->y(), W-24, c->h()); // W-24: leave room for scrollbar } init_sizes(); // tell scroll children changed in size Fl_Scroll::resize(X,Y,W,H); }
MonsterGenerator::MonsterGenerator() { mon_templates["mon_null"] = new mtype(); mon_species["spec_null"] = new species_type(); //ctor init_phases(); init_attack(); init_death(); init_flags(); init_trigger(); init_sizes(); }
static void *aac_create(obs_data_t settings, obs_encoder_t encoder) { struct aac_encoder *enc; int bitrate = (int)obs_data_getint(settings, "bitrate"); audio_t audio = obs_encoder_audio(encoder); if (!bitrate) { aac_warn("aac_create", "Invalid bitrate specified"); return NULL; } avcodec_register_all(); enc = bzalloc(sizeof(struct aac_encoder)); enc->encoder = encoder; enc->aac = avcodec_find_encoder(AV_CODEC_ID_AAC); if (!enc->aac) { aac_warn("aac_create", "Couldn't find encoder"); goto fail; } blog(LOG_INFO, "Using ffmpeg \"%s\" aac encoder", enc->aac->name); enc->context = avcodec_alloc_context3(enc->aac); if (!enc->context) { aac_warn("aac_create", "Failed to create codec context"); goto fail; } enc->context->bit_rate = bitrate * 1000; enc->context->channels = (int)audio_output_channels(audio); enc->context->sample_rate = audio_output_samplerate(audio); enc->context->sample_fmt = enc->aac->sample_fmts ? enc->aac->sample_fmts[0] : AV_SAMPLE_FMT_FLTP; init_sizes(enc, audio); /* enable experimental FFmpeg encoder if the only one available */ enc->context->strict_std_compliance = -2; enc->context->flags = CODEC_FLAG_GLOBAL_HEADER; if (initialize_codec(enc)) return enc; fail: aac_destroy(enc); return NULL; }
void Controller_Module::maybe_create_panner ( void ) { if ( _type != SPATIALIZATION ) { clear(); Panner *o = new Panner( 0,0, 92,92 ); o->box(FL_FLAT_BOX); o->color(FL_GRAY0); o->selection_color(FL_BACKGROUND_COLOR); o->labeltype(FL_NORMAL_LABEL); o->labelfont(0); o->labelcolor(FL_FOREGROUND_COLOR); o->align(FL_ALIGN_TOP); o->when(FL_WHEN_CHANGED); label( "Spatialization" ); o->align(FL_ALIGN_TOP); o->labelsize( 10 ); // o->callback( cb_panner_value_handle, new callback_data( this, azimuth_port_number, elevation_port_number ) ); o->callback( cb_spatializer_handle, this ); control = (Fl_Valuator*)o; if ( _pad ) { Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o ); flg->position( x(), y() ); flg->set_visible_focus(); size( flg->w(), flg->h() ); add( flg ); } else { // o->clear_visible_focus(); o->resize( x(), y(), w(), h() ); add( o ); resizable( o ); init_sizes(); } _type = SPATIALIZATION; } }
int main(int argc, char *argv[]) { char config_path[MAX_PATH]; memset(config_path,0,MAX_PATH); /* Setup all the initial function pointers */ my_ops.getattr = do_getattr; my_ops.read = do_read; my_ops.write = do_write; my_ops.readdir = do_readdir; my_ops.truncate = do_truncate; my_ops.mknod = do_mknod; my_ops.unlink = do_unlink; my_ops.rename = do_rename; my_ops.symlink = do_symlink; my_ops.readlink = do_readlink; my_ops.mkdir = do_mkdir; my_ops.rmdir = do_rmdir; my_ops.open = do_open; my_ops.release = do_release; my_ops.utime = do_utime; my_ops.chmod = do_chmod; my_ops.link = do_link; my_ops.flush = do_flush; my_ops.access = do_access; my_ops.destroy = do_destroy; #ifdef HAVE_SETXATTR my_ops.setxattr = do_setxattr; my_ops.getxattr = do_getxattr; my_ops.listxattr = do_listxattr; my_ops.removexattr = do_removexattr; #endif /* Check with corefs_op_init if we need to replace any of the pointers */ client_op_init(&my_ops); /* Call the upper layer's init function */ if(up_client_init(&my_ops) != PROCEED){ fprintf(stderr, "ERROR: up_client_init failed, proceeding to load corefs...\n"); } /* set the local path to $HOME/.corefs */ local_path = calloc(LOCALSIZE,1); sprintf(local_path, "%s/.corefs",getenv("HOME")); /* See if the local path exists and if there is a mnt directory in it. Create, if there isn't */ struct stat st; char dir_path[MAXPATH+LOCALSIZE]; int stret = stat(local_path, &st); if (stret < 0) { if (mkdir(local_path, 0700)) { perror("Failed to create local .corefs directory"); exit(1); } } memset(dir_path, 0, MAXPATH+LOCALSIZE); sprintf(dir_path, "%s/mnt", local_path); stret = stat(dir_path, &st); if (stret < 0) { if (mkdir(dir_path, 0700)) { perror("Failed to create local .corefs/mnt directory"); exit(1); } } init_list_head(&head); /* Parse the command line args */ parse_arguments(argc, argv, config_path); init_sizes(); if(corefs_main(fuse_argc, fuse_argv, &my_ops) != 0){ usage(argv[0]); return -1; } return 0; }
/** attempt to transform this controller into a spatialization controller and connect to the given module's spatialization control inputs. Returns true on success, false if given module does not accept spatialization inputs. */ bool Controller_Module::connect_spatializer_to ( Module *m ) { /* these are for detecting related parameter groups which can be better represented by a single control */ Port *azimuth_port = NULL; float azimuth_value = 0.0f; Port *elevation_port = NULL; float elevation_value = 0.0f; for ( unsigned int i = 0; i < m->control_input.size(); ++i ) { Port *p = &m->control_input[i]; if ( !strcasecmp( "Azimuth", p->name() ) && 180.0f == p->hints.maximum && -180.0f == p->hints.minimum ) { azimuth_port = p; azimuth_value = p->control_value(); continue; } else if ( !strcasecmp( "Elevation", p->name() ) && 90.0f == p->hints.maximum && -90.0f == p->hints.minimum ) { elevation_port = p; elevation_value = p->control_value(); continue; } } if ( ! ( azimuth_port && elevation_port ) ) return false; control_output.clear(); add_port( Port( this, Port::OUTPUT, Port::CONTROL ) ); add_port( Port( this, Port::OUTPUT, Port::CONTROL ) ); control_output[0].connect_to( azimuth_port ); control_output[1].connect_to( elevation_port ); { clear(); Panner *o = new Panner( 0,0, 100, 100 ); o->box(FL_THIN_UP_BOX); o->color(FL_GRAY0); o->selection_color(FL_BACKGROUND_COLOR); o->labeltype(FL_NORMAL_LABEL); o->labelfont(0); o->labelcolor(FL_FOREGROUND_COLOR); o->align(FL_ALIGN_TOP); o->when(FL_WHEN_CHANGED); label( "Spatialization" ); o->align(FL_ALIGN_TOP); o->labelsize( 10 ); // o->callback( cb_panner_value_handle, new callback_data( this, azimuth_port_number, elevation_port_number ) ); o->point( 0 )->azimuth( azimuth_value ); o->point( 0 )->elevation( elevation_value ); o->callback( cb_spatializer_handle, this ); control = (Fl_Valuator*)o; if ( _pad ) { Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o ); flg->position( x(), y() ); flg->set_visible_focus(); size( flg->w(), flg->h() ); add( flg ); } else { o->resize( x(), y(), w(), h() ); add( o ); resizable( o ); init_sizes(); } _type = SPATIALIZATION; return true; } }
void Controller_Module::connect_to ( Port *p ) { control_output[0].connect_to( p ); clear(); Fl_Widget *w; if ( p->hints.type == Module::Port::Hints::BOOLEAN ) { Fl_Button *o = new Fl_Button( 0, 0, 40, 40, p->name() ); w = o; o->type( FL_TOGGLE_BUTTON ); o->value( p->control_value() ); o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) ); _type = TOGGLE; /* FIXME: hack */ control = (Fl_Valuator*)o; } else if ( p->hints.type == Module::Port::Hints::INTEGER ) { Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() ); control = o; w = o; o->type(1); o->step(1); if ( p->hints.ranged ) { o->minimum( p->hints.minimum ); o->maximum( p->hints.maximum ); } _type = SPINNER; o->value( p->control_value() ); } // else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC ) else { Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() ); control = o; w = o; if ( ! _horizontal ) { o->size( 30, 250 ); o->type(FL_VERT_NICE_SLIDER); } else { o->size(250,20); o->type(FL_HOR_NICE_SLIDER); } // o->type(4); o->color( FL_BACKGROUND2_COLOR ); o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) ); o->minimum(1.5); o->maximum(0); o->value(1); // o->textsize(9); if ( p->hints.ranged ) { if ( ! _horizontal ) { o->minimum( p->hints.maximum ); o->maximum( p->hints.minimum ); } else { o->minimum( p->hints.minimum ); o->maximum( p->hints.maximum ); } } o->precision(2); o->value( p->control_value() ); _type = SLIDER; } /* else */ /* { */ /* { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() ); */ /* w = o; */ /* control = o; */ /* if ( p->hints.ranged ) */ /* { */ /* DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum ); */ /* o->minimum( p->hints.minimum ); */ /* o->maximum( p->hints.maximum ); */ /* } */ /* o->color( fl_darker( FL_GRAY ) ); */ /* o->selection_color( FL_WHITE ); */ /* o->value( p->control_value() ); */ /* } */ /* _type = KNOB; */ /* } */ control_value = p->control_value(); w->clear_visible_focus(); w->align(FL_ALIGN_TOP); w->labelsize( 10 ); w->callback( cb_handle, this ); if ( _pad ) { Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w ); flg->set_visible_focus(); size( flg->w(), flg->h() ); flg->position( x(), y() ); add( flg ); resizable(flg); // init_sizes(); } else { /* HACK: hide label */ if ( _type == TOGGLE ) { w->align( FL_ALIGN_INSIDE ); } else { w->labeltype( FL_NO_LABEL ); } w->resize( x(), y(), this->w(), h() ); add( w ); resizable( w ); init_sizes(); } }
static void *aac_create(obs_data_t *settings, obs_encoder_t *encoder) { struct aac_encoder *enc; int bitrate = (int)obs_data_get_int(settings, "bitrate"); audio_t *audio = obs_encoder_audio(encoder); avcodec_register_all(); enc = bzalloc(sizeof(struct aac_encoder)); enc->encoder = encoder; enc->aac = avcodec_find_encoder(AV_CODEC_ID_AAC); blog(LOG_INFO, "---------------------------------"); if (!enc->aac) { warn("Couldn't find encoder"); goto fail; } if (!bitrate) { warn("Invalid bitrate specified"); return NULL; } enc->context = avcodec_alloc_context3(enc->aac); if (!enc->context) { warn("Failed to create codec context"); goto fail; } enc->context->bit_rate = bitrate * 1000; enc->context->channels = (int)audio_output_get_channels(audio); enc->context->sample_rate = audio_output_get_sample_rate(audio); enc->context->sample_fmt = enc->aac->sample_fmts ? enc->aac->sample_fmts[0] : AV_SAMPLE_FMT_FLTP; /* if using FFmpeg's AAC encoder, at least set a cutoff value * (recommended by konverter) */ if (strcmp(enc->aac->name, "aac") == 0) { int cutoff1 = 4000 + (int)enc->context->bit_rate / 8; int cutoff2 = 12000 + (int)enc->context->bit_rate / 8; int cutoff3 = enc->context->sample_rate / 2; int cutoff; cutoff = MIN(cutoff1, cutoff2); cutoff = MIN(cutoff, cutoff3); enc->context->cutoff = cutoff; } info("bitrate: %" PRId64 ", channels: %d", enc->context->bit_rate / 1000, enc->context->channels); init_sizes(enc, audio); /* enable experimental FFmpeg encoder if the only one available */ enc->context->strict_std_compliance = -2; enc->context->flags = CODEC_FLAG_GLOBAL_HEADER; if (initialize_codec(enc)) return enc; fail: aac_destroy(enc); return NULL; }
void Fl_Align_Group::layout() { Fl_Widget::layout(); if(!children()) return; int i; int n_lines = n_to_break() ? (children() / n_to_break() + (children() % n_to_break()?1:0)) : 1; bool variable_is_y = (align() & (FL_ALIGN_TOP|FL_ALIGN_BOTTOM)) != 0; int nx = vertical() ? n_lines : n_to_break() ? n_to_break() : children(); int ny = vertical() ? n_to_break() ? n_to_break() : children() : n_lines; int n_variable = variable_is_y ? ny : nx; uchar label_space[256]; memset(label_space,0,n_variable*sizeof(uchar)); int u=0, v=0; int total_label_space=0; int numchildren = children(); if (align()) { for (i = 0; i < numchildren; i++) { Fl_Widget* o = child(i); fl_font(o->label_font(), o->label_size()); int w = this->w()-o->w(),h = this->h()-o->h(); fl_measure(o->label().c_str() ,w,h,o->flags()); if (variable_is_y) w = h; int which = (variable_is_y == vertical()) ? u : v; if (label_space[which] < w) label_space[which] = w; if (++u == n_to_break()) {u = 0; v++;} } for (i = 0; i<n_variable; i++) total_label_space+=label_space[i]; } int W = (w() - (variable_is_y ? 0:total_label_space) - (nx + 1)*dw()) / nx; int H = (h() - (variable_is_y ? total_label_space:0) - (ny + 1)*dh()) / ny; int cx = dw(), cy = dh(); int icx = cx, icy = cy; u = v = 0; for (i = 0; i < numchildren; i++) { Fl_Widget* o = child(i); int which = (variable_is_y == vertical()) ? u : v; int X = cx, Y = cy; if (align() & FL_ALIGN_TOP) Y += label_space[which]; else if (!variable_is_y && align() & FL_ALIGN_LEFT) X += label_space[which]; o->resize(X,Y,W,H); o->align(align()); o->layout(); if (++u == n_to_break()) { u = 0; v++; if (vertical()) { cx += W+dw(); cy = icy; if (!variable_is_y) cx += label_space[which]; } else { cy += H+dh(); cx = icx; if (variable_is_y) cy += label_space[which]; } } else { if (vertical()) { cy += H+dh(); if (variable_is_y) cy += label_space[which]; } else { cx += W+dw(); if (!variable_is_y) cx += label_space[which]; } } } init_sizes(); }
static void *enc_create(obs_data_t *settings, obs_encoder_t *encoder, const char *type, const char *alt) { struct enc_encoder *enc; int bitrate = (int)obs_data_get_int(settings, "bitrate"); audio_t *audio = obs_encoder_audio(encoder); avcodec_register_all(); enc = bzalloc(sizeof(struct enc_encoder)); enc->encoder = encoder; enc->codec = avcodec_find_encoder_by_name(type); enc->type = type; if (!enc->codec && alt) { enc->codec = avcodec_find_encoder_by_name(alt); enc->type = alt; } blog(LOG_INFO, "---------------------------------"); if (!enc->codec) { warn("Couldn't find encoder"); goto fail; } if (!bitrate) { warn("Invalid bitrate specified"); return NULL; } enc->context = avcodec_alloc_context3(enc->codec); if (!enc->context) { warn("Failed to create codec context"); goto fail; } enc->context->bit_rate = bitrate * 1000; enc->context->channels = (int)audio_output_get_channels(audio); enc->context->sample_rate = audio_output_get_sample_rate(audio); enc->context->sample_fmt = enc->codec->sample_fmts ? enc->codec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP; /* check to make sure sample rate is supported */ if (enc->codec->supported_samplerates) { const int *rate = enc->codec->supported_samplerates; int cur_rate = enc->context->sample_rate; int closest = 0; while (*rate) { int dist = abs(cur_rate - *rate); int closest_dist = abs(cur_rate - closest); if (dist < closest_dist) closest = *rate; rate++; } if (closest) enc->context->sample_rate = closest; } /* if using FFmpeg's AAC encoder, at least set a cutoff value * (recommended by konverter) */ if (strcmp(enc->codec->name, "aac") == 0) { int cutoff1 = 4000 + (int)enc->context->bit_rate / 8; int cutoff2 = 12000 + (int)enc->context->bit_rate / 8; int cutoff3 = enc->context->sample_rate / 2; int cutoff; cutoff = MIN(cutoff1, cutoff2); cutoff = MIN(cutoff, cutoff3); enc->context->cutoff = cutoff; } info("bitrate: %" PRId64 ", channels: %d", enc->context->bit_rate / 1000, enc->context->channels); init_sizes(enc, audio); /* enable experimental FFmpeg encoder if the only one available */ enc->context->strict_std_compliance = -2; enc->context->flags = CODEC_FLAG_GLOBAL_HEADER; if (initialize_codec(enc)) return enc; fail: enc_destroy(enc); return NULL; }
static int parser_init(struct parser_state *state, const struct config_parser *parser, void *input) { struct parser_sizes szs; size_t group_alloc; size_t input_alloc; void **next_input_slot; struct group *group; /* Allocate and initialize group structures */ init_sizes(&szs); calc_sizes(parser, &szs); group_alloc = sizeof(*state->groups) * szs.num_groups; input_alloc = sizeof(*state->child_inputs) * szs.num_child_inputs; state->storage = malloc(group_alloc + input_alloc); if (!state->storage) return ENOMEM; state->groups = state->storage; state->egroup = state->groups + szs.num_groups; if (szs.num_child_inputs > 0) { state->child_inputs = (void *) ((char *) state->storage + group_alloc); memset(state->child_inputs, 0, input_alloc); } else state->child_inputs = NULL; group = state->groups; next_input_slot = state->child_inputs; convert_options(parser, NULL, 0, &group, &next_input_slot); assert(group == state->egroup); assert(next_input_slot == state->child_inputs + szs.num_child_inputs); /* Call with CONFIG_KEY_INIT, for propagation of child inputs */ state->groups[0].state.input = input; for (group = state->groups; group < state->egroup; group++) { int err; if (group->parent) group->state.input = group->parent->state.child_inputs[group->parent_index]; err = group->parser->handler(CONFIG_PARSE_KEY_INIT, 0, NULL, &group->state); if (err && err != EINVAL) { /* Abort initialization */ free(state->storage); state->storage = NULL; return err; } } return 0; }
void ChannelChatTab::setSplitPos(int x) { init_sizes(); position(userList_->x(), 0, x, 0); }