void ClipEditWindow::create_objects() { lock_window("ClipEditWindow::create_objects"); this->create_it = thread->create_it; int x = 10, y = 10; int x1 = x; BC_TextBox *textbox; BC_TextBox *titlebox; BC_Title *title; add_subwindow(title = new BC_Title(x1, y, _("Title:"))); y += title->get_h() + 5; add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2)); y += titlebox->get_h() + 10; add_subwindow(title = new BC_Title(x1, y, _("Comments:"))); y += title->get_h() + 5; add_subwindow(textbox = new ClipEditComments(this, x1, y, get_w() - x1 * 2, BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - 10 - BC_OKButton::calculate_h() - y))); add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); show_window(); titlebox->activate(); unlock_window(); }
void button::draw() { color old_fg = get_foreground(); color old_bg = get_background(); if (down_tick) { if ((SDL_GetTicks() - down_tick) < 100) { get_foreground() = old_bg; get_background() = old_fg; } else { down_tick = 0; } } textbox::draw(); // border display::scoped_color fg(get_screen(), get_foreground()); get_screen().draw_line_2d(0, 0, get_w(), 0); get_screen().draw_line_2d(get_w(), 0, get_w(), get_h()); get_screen().draw_line_2d(get_w(), get_h(), 0, get_h()); get_screen().draw_line_2d(0, get_h(), 0, 0); if (down_tick) { get_foreground() = old_fg; get_background() = old_bg; } } // button::draw()
void ChannelEditPictureWindow::create_objects() { int x = 10, y = 10; int widget_border = ((Theme*)channel_picker->get_theme())->widget_border; int x1 = get_w() - BC_Pot::calculate_w() * 2 - widget_border * 2; int x2 = get_w() - BC_Pot::calculate_w() - widget_border; int pad = BC_Pot::calculate_h(); #define SWAP_X x1 ^= x2; x2 ^= x1; x1 ^= x2; PictureConfig *picture_usage = channel_picker->get_picture_usage(); // Only used for Video4Linux 1 if(!picture_usage || (!picture_usage->use_brightness && !picture_usage->use_contrast && !picture_usage->use_color && !picture_usage->use_hue && !picture_usage->use_whiteness && !channel_picker->get_controls())) { add_subwindow(new BC_Title(x, y, "Device has no picture controls.")); y += 50; } // Only used for Video4Linux 1 if(picture_usage && picture_usage->use_brightness) { add_subwindow(new BC_Title(x, y + 10, _("Brightness:"))); add_subwindow(new ChannelEditBright(x1, y, channel_picker, channel_picker->get_brightness())); y += pad; SWAP_X }
void rfft(int n, FFT_COMPLEX * in, FFT_COMPLEX * out) { FFT_COMPLEX * in_t0; FFT_COMPLEX * in_t1; FFT_COMPLEX * out_t0; FFT_COMPLEX * out_t1; FFT_COMPLEX z; FFT_COMPLEX w; FFT_COMPLEX t; int i; int n2; n2 = n >> 1; if(n == 1){ *out = *in; return; } complex_array_print(n, in); w = get_w(1, n); z = get_w(0, n); in_t0 = (FFT_COMPLEX *)malloc(n2 * sizeof(FFT_COMPLEX)); in_t1 = (FFT_COMPLEX *)malloc(n2 * sizeof(FFT_COMPLEX)); out_t0 = (FFT_COMPLEX *)malloc(n2 * sizeof(FFT_COMPLEX)); out_t1 = (FFT_COMPLEX *)malloc(n2 * sizeof(FFT_COMPLEX)); for(i = 0; i < n; i++){ if((i & 1) == 0){ in_t0[i>>1] = in[i]; }else{
int init() { llen = 0; slen = (int)strlen(in_str); int k = 0; for(int i = 0; i<= slen - 1; i++) { if(isalpha(in_str[i])) letters[llen][k++] = in_str[i]; else { if(k > 0) { letters[llen++][k] = '\0'; w[llen - 1] = get_w(letters[llen - 1]); } k = 0; } } if(k > 0) { letters[llen++][k] = '\0'; w[llen - 1] = get_w(letters[llen - 1]); } wlen = llen; return 0; }
void Hormiga::GoHome(void) { int rowMove; int colMove; int newRow; int newCol; if (x<Hm->get_x()) colMove=1; else if (x>Hm->get_x()) colMove=-1; else colMove=0; if (y<Hm->get_y()) rowMove=1; else if (y>Hm->get_y()) rowMove=-1; else rowMove=0; newRow=y+rowMove*size; newCol=x+colMove*size; if (newRow<0) newRow = 0; if (newCol<0) newCol = 0; if (newRow>Game::gfx_h-get_h()) newRow = Game::gfx_h-get_h(); if (newCol>Game::gfx_w-get_w()) newCol = Game::gfx_w-get_w(); y = newRow; x = newCol; }
void ScopeHistogram::draw_mode(int mode, int color, int y, int h) { // Highest of all bins int normalize = 0; for(int i = 0; i < TOTAL_BINS; i++) { if(gui->bins[mode][i] > normalize) normalize = gui->bins[mode][i]; } set_color(color); for(int i = 0; i < get_w(); i++) { int accum_start = (int)(i * TOTAL_BINS / get_w()); int accum_end = (int)((i + 1) * TOTAL_BINS / get_w()); CLAMP(accum_start, 0, TOTAL_BINS); CLAMP(accum_end, 0, TOTAL_BINS); int max = 0; for(int k = accum_start; k < accum_end; k++) { max = MAX(gui->bins[mode][k], max); } // max = max * h / normalize; max = (int)(log(max) / log(normalize) * h); draw_line(i, y + h - max, i, y + h); } }
//--------------------------------------------------------------------------- void uv_image::draw(vector<GLuint> * clist) { if(!get_visible()) return; if(retranslate) { glNewList(stranslation, GL_COMPILE); glTranslatef(get_x(), get_y(), 0); glEndList(); glNewList(etranslation, GL_COMPILE); glTranslatef(-1*get_x(), -1*get_y(), 0); glEndList(); retranslate = false; } if(redraw) { glNewList(drawing, GL_COMPILE); glColor3f(1, 1, 1); if(picx == -1) draw_size(0, 0, get_w(), get_h()); else draw_size(0, 0, get_w(), get_h(), picx, picy, picw, pich); glEndList(); redraw = false; } clist->push_back(stranslation); clist->push_back(drawing); clist->push_back(etranslation); };
void MonospacedLabel::draw (ecl::GC &gc, const ecl::Rect &) { Font *f = m_font; int w, h; naturalsize (w, h); int x = get_x(), y=get_y(); switch (m_halign) { case HALIGN_LEFT: break; case HALIGN_RIGHT: x += get_w() - w; break; case HALIGN_CENTER: x += (get_w()-w)/2; break; } switch (m_valign) { case VALIGN_TOP: break; case VALIGN_BOTTOM: y += get_h() - h; break; case VALIGN_CENTER: y += (get_h()-h)/2; break; } // translate if not an empty string const char * translation = _(m_text.c_str()); int len = strlen(translation); int monoWidth = m_font->get_width(sampleChar); char c[] = " "; for (int i = 0; i<len; i++) { c[0] = translation[i]; if (monoChars.empty() || monoChars.find_first_of(c[0]) != std::string::npos) { int charWidth = m_font->get_width(c[0]); // centere char into monoWodth f->render (gc, x + (monoWidth-charWidth)/2, y, c); x += monoWidth; } else { f->render (gc, x, y, c); x += m_font->get_width(c); } } }
void ResourcePixmap::resize(int w, int h) { int new_w = (w > get_w()) ? w : get_w(); int new_h = (h > get_h()) ? h : get_h(); BC_Pixmap::resize(new_w, new_h); }
int BC_ProgressBar::draw(int force, int flush) { char string[32]; int new_pixel; new_pixel = (int)(((float)position / length) * get_w()); if(new_pixel != pixel || force) { pixel = new_pixel; // Clear background draw_top_background(parent_window, 0, 0, get_w(), get_h()); draw_3segmenth(0, 0, pixel, 0, get_w(), images[PROGRESS_HI]); draw_3segmenth(pixel, 0, get_w() - pixel, 0, get_w(), images[PROGRESS_UP]); if(do_text) { set_font(MEDIUMFONT); set_color(get_resources()->progress_text); // draw decimal percentage sprintf(string, "%d%%", (int)(100 * (float)position / length + 0.5 / w)); draw_center_text(w / 2, h / 2 + get_text_ascent(MEDIUMFONT) / 2, string); } flash(flush); } return 0; }
void VFrame::screen_to_texture(int x, int y, int w, int h) { #ifdef HAVE_GL // Create texture BC_Texture::new_texture(&texture, get_w(), get_h(), get_color_model()); if(pbuffer) { glEnable(GL_TEXTURE_2D); // Read canvas into texture // According to the man page, it must be GL_BACK for the onscreen buffer // and GL_FRONT for a single buffered PBuffer. In reality it must be // GL_BACK for a single buffered PBuffer if the PBuffer has alpha and using // GL_FRONT captures the onscreen front buffer. // glReadBuffer(BC_WindowBase::get_synchronous()->is_pbuffer ? // GL_FRONT : GL_BACK); glReadBuffer(GL_BACK); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, x >= 0 ? x : 0, y >= 0 ? y : 0, w >= 0 ? w : get_w(), h >= 0 ? h : get_h()); } #endif }
uint16_t ti89_get_word(uint32_t adr) { // RAM access if(IN_BOUNDS(0x000000, adr, 0x1fffff)) { return get_w(tihw.ram, adr, RAM_SIZE_TI89 - 1); } // FLASH access else if(IN_BOUNDS(0x200000, adr, 0x5fffff)) { return get_w(tihw.rom, adr, ROM_SIZE_TI89 - 1) | wsm.ret_or; } // memory-mapped I/O else if(IN_BOUNDS(0x600000, adr, 0x6fffff)) { return io_get_word(adr); } // memory-mapped I/O (hw2) else if(IN_RANGE(adr, 0x700000, IO2_SIZE_TI89)) { return io2_get_word(adr); } return 0x1414; }
void TimeBar::draw_range() { int x1 = 0, x2 = get_w(); //printf("TimeBar::draw_range %d %p\n", __LINE__, get_edl()); if(get_edl()) { // get_preview_pixels(x1, x2); // // //printf("TimeBar::draw_range %f %d %d\n", edl_length, x1, x2); // draw_3segmenth(0, 0, x1, mwindow->theme->timebar_view_data); draw_top_background(get_parent(), x1, 0, x2 - x1, get_h()); // draw_3segmenth(x2, 0, get_w() - x2, mwindow->theme->timebar_view_data); // // set_color(BLACK); // draw_line(x1, 0, x1, get_h()); // draw_line(x2, 0, x2, get_h()); // // EDL *edl = get_edl(); // if(edl) // { // int64_t pixel = position_to_pixel( // edl->local_session->get_selectionstart(1)); // // Draw insertion point position if this timebar belongs to a window which // // has something other than the master EDL. // set_color(mwindow->theme->timebar_cursor_color); // draw_line(pixel, 0, pixel, get_h()); // } } else draw_top_background(get_parent(), 0, 0, get_w(), get_h()); }
void VFrame::to_ram() { #ifdef HAVE_GL switch(opengl_state) { // Only pbuffer is supported since this is only called after the // overlay operation onto the pbuffer. case VFrame::SCREEN: if(pbuffer) { enable_opengl(); printf("VFrame::to_ram %d %d\n", get_w(), get_h()); glReadPixels(0, 0, get_w(), get_h(), GL_RGB, GL_UNSIGNED_BYTE, get_rows()[0]); flip_vert(); } opengl_state = VFrame::RAM; return; } #endif }
void TimeBar::update(int flush) { draw_time(); // Need to redo these when range is drawn to get the background updated. update_labels(); update_points(); EDL *edl = get_edl(); int64_t pixel = -1; // Draw highlight position if(edl && (highlighted || current_operation == TIMEBAR_DRAG) && get_cursor_x() >= 0 && get_cursor_y() < get_w()) { //printf("TimeBar::update %d %d\n", __LINE__, get_cursor_x()); double position = pixel_to_position(get_cursor_x()); position = get_edl()->align_to_frame(position, 0); pixel = position_to_pixel(position); update_clock(position); } if(pixel < 0) { double position = test_highlight(); if(position >= 0) pixel = position_to_pixel(position); } if(pixel >= 0 && pixel < get_w()) { set_color(mwindow->theme->timebar_cursor_color); set_line_dashes(1); //printf("TimeBar::update %d pane=%d pixel=%jd\n", __LINE__, pane->number, pixel); draw_line(pixel, 0, pixel, get_h()); set_line_dashes(0); } if(edl) { int64_t pixel = position_to_pixel( edl->local_session->get_selectionstart(1)); // Draw insertion point position. set_color(mwindow->theme->timebar_cursor_color); draw_line(pixel, 0, pixel, get_h()); } update_highlights(); // Get the labels to show show_window(0); flash(flush); //printf("TimeBar::update %d this=%p %d\n", __LINE__, this, current_operation); }
void CreateDVD_GUI::create_objects() { lock_window("CreateDVD_GUI::create_objects"); int pady = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1) + 5; int padx = BC_Title::calculate_w(this, (char*)"X", MEDIUMFONT); int x = padx/2, y = pady/2; BC_Title *title = new BC_Title(x, y, "Title:", MEDIUMFONT, YELLOW); add_subwindow(title); at_x = x + title->get_w(); at_y = y; asset_title = new CreateDVD_AssetTitle(this, at_x, at_y, get_w()-at_x-10); add_subwindow(asset_title); y += title->get_h() + pady/2; title = new BC_Title(x, y, "tmp path:", MEDIUMFONT, YELLOW); add_subwindow(title); tmp_x = x + title->get_w(); tmp_y = y; tmp_path = new CreateDVD_TmpPath(this, tmp_x, tmp_y, get_w()-tmp_x-10); add_subwindow(tmp_path); y += title->get_h() + pady/2; disk_space = new CreateDVD_DiskSpace(this, x, y); add_subwindow(disk_space); disk_space->update(); y += disk_space->get_h() + pady/2; need_deinterlace = new CreateDVD_Deinterlace(this, x, y); add_subwindow(need_deinterlace); int x1 = x + 150, x2 = x1 + 150; need_inverse_telecine = new CreateDVD_InverseTelecine(this, x1, y); add_subwindow(need_inverse_telecine); need_use_ffmpeg = new CreateDVD_UseFFMpeg(this, x2, y); add_subwindow(need_use_ffmpeg); y += need_deinterlace->get_h() + pady/2; need_scale = new CreateDVD_Scale(this, x, y); add_subwindow(need_scale); need_wide_audio = new CreateDVD_WideAudio(this, x1, y); add_subwindow(need_wide_audio); need_resize_tracks = new CreateDVD_ResizeTracks(this, x2, y); add_subwindow(need_resize_tracks); y += need_scale->get_h() + pady/2; need_histogram = new CreateDVD_Histogram(this, x, y); add_subwindow(need_histogram); need_wide_aspect = new CreateDVD_WideAspect(this, x1, y); add_subwindow(need_wide_aspect); need_label_chapters = new CreateDVD_LabelChapters(this, x2, y); add_subwindow(need_label_chapters); ok_w = BC_OKButton::calculate_w(); ok_h = BC_OKButton::calculate_h(); ok_x = 10; ok_y = get_h() - ok_h - 10; ok = new CreateDVD_OK(this, ok_x, ok_y); add_subwindow(ok); cancel_w = BC_CancelButton::calculate_w(); cancel_h = BC_CancelButton::calculate_h(); cancel_x = get_w() - cancel_w - 10, cancel_y = get_h() - cancel_h - 10; cancel = new CreateDVD_Cancel(this, cancel_x, cancel_y); add_subwindow(cancel); show_window(); unlock_window(); }
void TimeAvgWindow::create_objects() { int x = 10, y = 10; BC_Bar *bar; BC_Title *title; add_tool(title = new BC_Title(x, y, _("Frame count:"))); y += title->get_h() + 5; add_tool(total_frames = new TimeAvgSlider(client, x, y)); y += 30; add_tool(paranoid = new TimeAvgParanoid(client, x, y)); y += 30; add_tool(no_subtract = new TimeAvgNoSubtract(client, x, y)); y += 30; add_tool(bar = new BC_Bar(x, y, get_w() - x * 2)); y += bar->get_h() + 5; add_tool(avg = new TimeAvgAvg(client, this, x, y)); y += 30; add_tool(accum = new TimeAvgAccum(client, this, x, y)); y += 30; add_tool(bar = new BC_Bar(x, y, get_w() - x * 2)); y += bar->get_h() + 5; add_tool(replace = new TimeAvgReplace(client, this, x, y)); y += 30; add_tool(new BC_Title(x, y, _("Threshold:"))); y += title->get_h() + 5; add_tool(threshold = new TimeThresholdSlider(client, x, y)); y += 30; add_tool(new BC_Title(x, y, _("Border:"))); y += title->get_h() + 5; add_tool(border = new TimeBorderSlider(client, x, y)); y += 30; add_tool(bar = new BC_Bar(x, y, get_w() - x * 2)); y += bar->get_h() + 5; add_tool(greater = new TimeAvgGreater(client, this, x, y)); y += 30; add_tool(less = new TimeAvgLess(client, this, x, y)); y += 30; update_toggles(); show_window(); flush(); }
int CreateDVD_GUI::resize_event(int w, int h) { asset_title->reposition_window(at_x, at_y, get_w()-at_x-10); tmp_path->reposition_window(tmp_x, tmp_y, get_w()-tmp_x-10); ok_y = h - ok_h - 10; ok->reposition_window(ok_x, ok_y); cancel_x = w - cancel_w - 10, cancel_y = h - cancel_h - 10; cancel->reposition_window(cancel_x, cancel_y); return 0; }
int QuestionWindow::create_objects(char *string, int use_cancel) { int x = 10, y = 10; add_subwindow(new BC_Title(10, 10, string)); y += 30; add_subwindow(new QuestionYesButton(mwindow, this, x, y)); x += get_w() / 2; add_subwindow(new QuestionNoButton(mwindow, this, x, y)); x = get_w() - 100; if(use_cancel) add_subwindow(new BC_CancelButton(x, y)); return 0; }
void VFrame::draw_texture(int flip_y) { draw_texture(0, 0, get_w(), get_h(), 0, 0, get_w(), get_h(), flip_y); }
void BC_Pan::draw(int flash, int flush) { draw_top_background(parent_window, 0, 0, w, h); draw_pixmap(images[highlighted ? PAN_HI : PAN_UP]); get_channel_positions(value_x, value_y, value_positions, virtual_r, total_values); // draw channels int x1, y1; float scale = (float)(get_w() - PICON_W) / (virtual_r * 2); set_color(RED); for(int i = 0; i < total_values; i++) { // printf("BC_Pan::draw 1 %d %d %d %d\n", // i, // value_positions[i], // value_x[i], // value_y[i]); x1 = (int)(value_x[i] * scale); y1 = (int)(value_y[i] * scale); //printf("BC_Pan::draw 2 %d %d\n", x1, y1); CLAMP(x1, 0, get_w() - PICON_W); CLAMP(y1, 0, get_h() - PICON_H); draw_pixmap(images[PAN_CHANNEL_SMALL], x1, y1); // draw_box(x1, y1, PICON_W, PICON_H); } // draw stick set_color(GREEN); x1 = (int)(stick_x * scale); y1 = (int)(stick_y * scale); //printf("BC_Pan::draw 2 %d %d\n", x1, y1); CLAMP(x1, 0, get_w() - PICON_W); CLAMP(y1, 0, get_h() - PICON_H); draw_pixmap(images[PAN_STICK_SMALL], x1, y1); // x2 = x1 + PICON_W; // y2 = y1 + PICON_H; // draw_line(x1, y1, x2, y2); // draw_line(x2, y1, x1, y2); if(flash) this->flash(0); if(flush) this->flush(); }
void ScopeWaveform::update_point(int x, int y) { draw_point(); drag_x = x; drag_y = y; int frame_x = x * gui->frame_w / get_w(); if(gui->use_wave_parade) { if(x > get_w() / 3 * 2) frame_x = (x - get_w() / 3 * 2) * gui->frame_w / (get_w() / 3); else if(x > get_w() / 3) frame_x = (x - get_w() / 3) * gui->frame_w / (get_w() / 3); else frame_x = x * gui->frame_w / (get_w() / 3); } float value = ((float)get_h() - y) / get_h() * (FLOAT_MAX - FLOAT_MIN) + FLOAT_MIN; char string[BCTEXTLEN]; sprintf(string, "X: %d Value: %.3f", frame_x, value); gui->value_text->update(string, 0); draw_point(); flash(1); }
void Paleta::do_action (ControllableObject::action_t act, int magnitude) { switch (act) { case LEFT: x -= 3; break; case RIGHT: x += 3; break; } if (x < 0) x = 0; if (x > SCREEN_W -get_w ()) x = SCREEN_W - get_w (); };
void ScrollView::update() { if ((display_view->get_w() < w_init && display_view->get_w() > get_w()) || (display_view->get_h() < h_init && display_view->get_h() > get_h())) { resize(min(display_view->get_w(), w_init), min(display_view->get_h(), h_init)); } if (scroll_y_vel == 0) { return; } if (!scrolling) { if (scroll_y_vel != 0) { scroll_y_vel -= 0.5 * (scroll_y_vel < 0 ? -1 : 1); } } // const double display_scroll_range = display_view->get_h() - get_h(); // const double scroll_bar_range = scroll_bar_bottom - scroll_bar_top - scroll_bar.get_h(); scroll_y += scroll_y_vel; move_display_to(VGPoint(0,scroll_y)); }
void BolsaDinero::hit(Actor *who, int damage) { switch (who->get_team()) { case TEAM_OSO: am->del(this); break; case TEAM_COMIDA: case TEAM_AGUA: case TEAM_VENENO: case TEAM_HORMIGAS_ROJAS: case TEAM_HORMIGAS_VERDES: case TEAM_RANA: case TEAM_SCORE: case TEAM_BOLSA_DINERO: case TEAM_HORMIGUERO: set_x(Game::rnd(0,Game::gfx_w-get_w())); set_y(Game::rnd(0,Game::gfx_h-get_h())); break; default: break; } }
int BC_PixmapSW::draw() { draw_top_background(parent_window, 0, 0, get_w(), get_h()); draw_pixmap(thepixmap); flash(); return 0; }
double TimeBar::get_edl_length() { edl_length = 0; if(get_edl()) { //printf("TimeBar::get_edl_length 1 %f\n", get_edl()->tracks->total_playable_length()); edl_length = get_edl()->tracks->total_playable_length(); } //printf("TimeBar::get_edl_length 2\n"); if(!EQUIV(edl_length, 0)) { //printf("TimeBar::get_edl_length 3\n"); time_per_pixel = edl_length / get_w(); //printf("TimeBar::get_edl_length 4\n"); } else { time_per_pixel = 0; } //printf("TimeBar::get_edl_length 5\n"); return edl_length; }
void Loro::hit (Actor* who, int damage) { switch (who->getCodigo()) { case Nombres::ladrillo: switch (estado) { case VOLANDO_DER: case FLOTANDO_DER: x = who->get_x() - get_w() - 3; set_actor_graphic (giro_der); break; case VOLANDO_IZQ: case FLOTANDO_IZQ: x = who->get_x() + who->get_w() + 3; set_actor_graphic (giro_izq); break; } tiempo_estado = 50; estado = TROPEZANDO; break; default: break; }; };
uint16_t ti89_get_word(uint32_t adr) { // RAM access if(IN_BOUNDS(0x000000, adr, 0x1fffff)) { return get_w(ram, adr, RAM_SIZE_TI89 - 1); } // FLASH access else if(IN_BOUNDS(0x200000, adr, 0x5fffff)) { return get_w(rom, adr, ROM_SIZE_TI89 - 1); } return 0x1414; }