📄 arrange.cpp
字号:
void LinearArrangement::goto_down(void){ if (current_row != (n_rows - 1)) current_row++; else return; if (y_trans_mv.at_destination()) { y_trans_mv.init (&Y_Trans, Y_Trans, Y_Trans + (face_height + between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { y_trans_mv.init (&Y_Trans, Y_Trans, y_trans_mv.destination() + (face_height + between), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); }}float LinearArrangement::goto_face (desktop_coords_t dest){ signed int nummove; if (//dest.column == current_col || dest.column < 0 || dest.column >= n_columns) return 0; nummove = dest.column - current_col; current_col = dest.column; if (x_trans_mv.at_destination()) { x_trans_mv.init (&X_Trans, X_Trans, X_Trans - ((float)nummove * (face_width + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { x_trans_mv.init (&X_Trans, X_Trans, x_trans_mv.destination() - ((float)nummove * (face_width + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } if (//dest.row == current_row || dest.row < 0 || dest.row >= n_rows) return 0; nummove = dest.row - current_row; current_row = dest.row; if (y_trans_mv.at_destination()) { y_trans_mv.init (&Y_Trans, Y_Trans, Y_Trans + ((float)nummove * (face_height + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { y_trans_mv.init (&Y_Trans, Y_Trans, y_trans_mv.destination() + ((float)nummove * (face_height + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } return cfg->options->face_change_steps; }#if 0float LinearArrangement::goto_column(int column) { signed int nummove; if (column == current_col || column < 0 || column >= n_columns) return 0; nummove = column - current_col; current_col = column; if (x_trans_mv.at_destination()) { x_trans_mv.init (&X_Trans, X_Trans, X_Trans - ((float)nummove * (face_width + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { x_trans_mv.init (&X_Trans, X_Trans, x_trans_mv.destination() - ((float)nummove * (face_width + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } return cfg->options->face_change_steps;}float LinearArrangement::goto_row(int row) { signed int nummove; if (row == current_row || row < 0 || row >= n_rows) return 0; nummove = row - current_row; current_row = row; if (y_trans_mv.at_destination()) { y_trans_mv.init (&Y_Trans, Y_Trans, Y_Trans - ((float)nummove * (face_width + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } else { y_trans_mv.init (&Y_Trans, Y_Trans, y_trans_mv.destination() - ((float)nummove * (face_width + between)), cfg->options->face_change_steps, LINEAR_MOVE_TYPE); } return cfg->options->face_change_steps;}#endif // if 0void LinearArrangement::do_position_GL(void) { //if (spin_z_rot) // glRotatef(spin_z_rot,0.0f,0.0f,1.0f); glTranslatef(0.0f,0.0f, z_offset); glTranslatef(X_Trans, 0.0f, 0.0f); glTranslatef(0.0f, Y_Trans, 0.0f);}void LinearArrangement::do_movement(void) { if (!x_trans_mv.at_destination()) { x_trans_mv.change_a_bit(); } if (!y_trans_mv.at_destination()) { y_trans_mv.change_a_bit(); }}void LinearArrangement::entry_exit_move(void) { //spin_mv.change_a_bit(); Arrangement::entry_exit_move();}void LinearArrangement::exit_movement_start(void) { //spin_mv.init (&spin_z_rot, // 0.0, 360.0, // cfg->options->zoom_steps, // Movement::MOVE_TYPE_WACK); Arrangement::exit_movement_start();}void LinearArrangement::exit_movement_cancel(void) { //spin_mv.init (&spin_z_rot, // spin_z_rot, 0.0, // cfg->options->zoom_steps, // Movement::MOVE_TYPE_WACK); Arrangement::exit_movement_cancel();}// ==============================================================// FlipArrangement// ==============================================================// override so as to prevent "spin" from getting short circuitedint FlipArrangement::in_goto (void){ return !goto_face_mv.at_destination() || !spin_mv.at_destination();}int FlipArrangement::cant_exit_in_goto(void){ return 1; // this is always true}// Faces in FaceSet aren't rendered at all, we render our ownvoid FlipArrangement::render(){ face_A->render(); face_B->render();}// display list not utilized for this onevoid FlipArrangement::make_display_list(void){ }FlipArrangement::FlipArrangement(VDesktops & vdesks, float fw, float fh, FaceSet *fs, Config *c) : Arrangement (fs, c){ face_width = fw; face_height = fh; face_A = new Face (0); if (!face_A) { msgout(ERROR, "out of memory\n"); exit (-1); } face_B = new Face (0); if (!face_B) { msgout(ERROR, "out of memory\n"); exit (-1); } showing_face = NULL; calculate_faces(vdesks); goto_face_val = 0; goto_face_mv.disable(); spin_mv.disable(); spin_val = 0;}FlipArrangement::~FlipArrangement () { delete face_A; delete face_B;}int FlipArrangement::get_type(){ return FACE_TYPE_FLIP;}void FlipArrangement::calculate_faces(VDesktops & vdesks){ vdesks.get_vdesktop_info (¤t_col, ¤t_row, &n_columns, &n_rows); //msgout (DEBUG, "at %d x %d (%d, %d)\n", current_row, current_col, n_rows, n_columns); // current_face becomes the unrolled current face current_face = current_col + (current_row * n_columns); // n_faces becomes the total number of desktops n_faces = n_columns * n_rows; z_offset_distance = 10.0; per_face_change = 180; float my_angle = ((FOV / 2.0) * PI) / 180.0; z_offset_close = z_offset = -(float)((face_height/2.0) / tan(my_angle) + get_base_z_offset()); Point tl, tr, bl, br; float half_face_height = face_height / 2.0; float half_face_width = face_width / 2.0; tl.set (-half_face_width, half_face_height, .1); tr.set ( half_face_width, half_face_height, .1); bl.set (-half_face_width, -half_face_height, .1); br.set ( half_face_width, -half_face_height, .1); face_A->set_corners(tl, tr, bl, br); tl.set ( half_face_width, half_face_height, -.1); tr.set (-half_face_width, half_face_height, -.1); bl.set ( half_face_width, -half_face_height, -.1); br.set (-half_face_width, -half_face_height, -.1); face_B->set_corners(tl, tr, bl, br); if (!showing_face) showing_face = face_A; msgout (DEBUG, "set tid = %d\n", face_set->get_texture_id(current_face)); showing_face->set_texture_id(face_set->get_texture_id(current_face));}// there is no entry exit for flipsvoid FlipArrangement::entry_movement_start(void){ msgout (DEBUG, "----------4 set tid = %d\n", face_set->get_texture_id(current_face)); showing_face->set_texture_id(face_set->get_texture_id(current_face));}void FlipArrangement::exit_movement_start(void){}void FlipArrangement::exit_movement_cancel(void){}void FlipArrangement::entry_exit_move(void){}int FlipArrangement::is_entry_movement_done(void){ return 1; }int FlipArrangement::is_exit_movement_done(void){ return 1; }void FlipArrangement::set_current_face (int c, int r) { current_face = c + (r * n_columns); current_col = c; current_row = r; msgout (DEBUG, "---------- set tid = %d\n", face_set->get_texture_id(current_face)); showing_face->set_texture_id(face_set->get_texture_id(current_face)); goto_face_val = goto_face_mv.destination(); goto_face_mv.disable();}float FlipArrangement::get_distant_z_offset(void){ return -(z_offset_distance);}float FlipArrangement::get_base_z_offset(void){ return 0.1;}void FlipArrangement::do_position_GL(void) { glTranslatef(0.0f,0.0f, z_offset); glRotatef(goto_face_val, 0.0f, 1.0f, 0.0f); if (spin_val) { glRotatef(spin_val, 1.0f, 1.0f, 1.0f); }}void FlipArrangement::do_movement(void) { if (!goto_face_mv.at_destination()) goto_face_mv.change_a_bit(); else clamp_degrees (&goto_face_val); if (!spin_mv.at_destination()) spin_mv.change_a_bit(); else clamp_degrees (&spin_val);}float FlipArrangement::goto_face (desktop_coords_t dest) { if ((dest.column == current_col && dest.row == current_row) || dest.column < 0 || dest.column >= n_columns || dest.row < 0 || dest.row >= n_rows) { return 0; } int newface = dest.column + (dest.row * n_columns); if (goto_face_mv.at_destination()) goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val + per_face_change, cfg->options->face_change_steps, move_type); else goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() + per_face_change, cfg->options->face_change_steps, move_type); current_face = newface; current_col = dest.column; current_row = dest.row; // swap faces if (showing_face == face_A) { showing_face = face_B; } else { showing_face = face_A; } msgout (DEBUG, "---------1 set tid = %d\n", face_set->get_texture_id(current_face)); showing_face->set_texture_id(face_set->get_texture_id(current_face)); return cfg->options->face_change_steps;}void FlipArrangement::goto_up(void){ if (spin_mv.at_destination()) spin_mv.init(&spin_val, 0.0, 360.0, 2*cfg->options->face_change_steps, move_type); else spin_mv.init(&spin_val, spin_val, spin_mv.destination() + 360.0, 2*cfg->options->face_change_steps, move_type);}void FlipArrangement::goto_down(void){ }// this has to by overridden because of the 'current_face' variable// which is private to this classvoid FlipArrangement::goto_random_face(void){ int which_one; do { which_one = get_randomi (0, (n_columns * n_rows) - 1); } while (which_one == (current_col + (current_row * n_rows))); current_face = which_one; Arrangement::goto_face (which_one);}void FlipArrangement::goto_right(void) { current_face++; if (current_face == n_faces) current_face = 0; // cycle around // we are "unrolling" rows and columns so map the linear // "current_face" back to rows and columns current_col = current_face % n_columns; current_row = current_face / n_columns; if (goto_face_mv.at_destination()) { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val - per_face_change, cfg->options->face_change_steps, move_type); } else { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() - per_face_change, cfg->options->face_change_steps, move_type); } // swap faces if (showing_face == face_A) { showing_face = face_B; } else { showing_face = face_A; } msgout (DEBUG, "----------2 set tid = %d\n", face_set->get_texture_id(current_face)); showing_face->set_texture_id(face_set->get_texture_id(current_face));}void FlipArrangement::goto_left(void) { if (current_face == 0) current_face = n_faces - 1; // cycle around else current_face--; // we are "unrolling" rows and columns so map the linear // "current_face" back to rows and columns current_col = current_face % n_columns; current_row = current_face / n_columns; if (goto_face_mv.at_destination()) { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_val + per_face_change, cfg->options->face_change_steps, move_type); } else { goto_face_mv.init (&goto_face_val, goto_face_val, goto_face_mv.destination() + per_face_change, cfg->options->face_change_steps, move_type); } // swap faces if (showing_face == face_A) { showing_face = face_B; } else { showing_face = face_A; } msgout (DEBUG, "----------3 set tid = %d\n", face_set->get_texture_id(current_face)); showing_face->set_texture_id(face_set->get_texture_id(current_face));}#endif // if !defined ONE_ARRANGEMENT_ONLY
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -