~victored/slingshot/app-launcher-dbus

« back to all changes in this revision

Viewing changes to src/SlingshotView.vala

  • Committer: Andrea Basso
  • Date: 2012-06-20 22:35:59 UTC
  • Revision ID: voluntatefaber@gmail.com-20120620223559-swfj3989jewszkl1
Slightly changed order of code

Show diffs side-by-side

added added

removed removed

Lines of Context:
555
555
            return true;
556
556
 
557
557
        }
558
 
        
559
 
        private void category_move_focus (int delta_column, int delta_row) {
560
 
            var new_focus = category_view.app_view.get_child_at (category_column_focus + delta_column, category_row_focus + delta_row);
561
 
            if (new_focus == null) {
562
 
                if (delta_row < 0 && category_view.category_switcher.selected != 0) {
563
 
                    category_view.category_switcher.selected--;
564
 
                    top_left_focus ();
565
 
                    return;
566
 
                }
567
 
                else if (delta_row > 0 && category_view.category_switcher.selected != category_view.category_switcher.cat_size - 1) {
568
 
                    category_view.category_switcher.selected++;
569
 
                    top_left_focus ();
570
 
                    return;
571
 
                }
572
 
                else if (delta_column > 0 && (category_column_focus + delta_column) % category_view.app_view.get_page_columns () == 0
573
 
                          && category_view.switcher.active + 1 != category_view.app_view.get_n_pages ()) {
574
 
                    category_view.switcher.set_active (category_view.switcher.active + 1);
575
 
                    top_left_focus ();
576
 
                    return;
577
 
                }
578
 
                else if (category_column_focus == 0 && delta_column < 0) {
579
 
                    searchbar.grab_focus ();
580
 
                    category_column_focus = 0;
581
 
                    category_row_focus = 0;
582
 
                    return;
583
 
                }
584
 
                else
585
 
                    return;
586
 
            }
587
 
            category_column_focus += delta_column;
588
 
            category_row_focus += delta_row;
589
 
            if (delta_column > 0 && category_column_focus % category_view.app_view.get_page_columns () == 0 ) { // check if we need to change page
590
 
                category_view.switcher.set_active (category_view.switcher.active + 1);
591
 
            }
592
 
            else if (delta_column < 0 && (category_column_focus + 1) % category_view.app_view.get_page_columns () == 0) {
593
 
                // check if we need to change page
594
 
                category_view.switcher.set_active (category_view.switcher.active - 1);
595
 
            }
596
 
            new_focus.grab_focus ();
597
 
        }
598
 
        
599
 
        // this method moves focus to the first AppEntry in the top left corner of the current page. Works in CategoryView only
600
 
        private void top_left_focus () {
601
 
            // this is the first column of the current page
602
 
            int first_column = category_view.switcher.active * category_view.app_view.get_page_columns ();
603
 
            category_view.app_view.get_child_at (first_column, 0).grab_focus ();
604
 
            category_column_focus = first_column;
605
 
            category_row_focus = 0;
606
 
        }
607
558
 
608
559
        public override bool scroll_event (EventScroll event) {
609
560
 
885
836
            }
886
837
        }
887
838
        
 
839
        private void category_move_focus (int delta_column, int delta_row) {
 
840
            var new_focus = category_view.app_view.get_child_at (category_column_focus + delta_column, category_row_focus + delta_row);
 
841
            if (new_focus == null) {
 
842
                if (delta_row < 0 && category_view.category_switcher.selected != 0) {
 
843
                    category_view.category_switcher.selected--;
 
844
                    top_left_focus ();
 
845
                    return;
 
846
                }
 
847
                else if (delta_row > 0 && category_view.category_switcher.selected != category_view.category_switcher.cat_size - 1) {
 
848
                    category_view.category_switcher.selected++;
 
849
                    top_left_focus ();
 
850
                    return;
 
851
                }
 
852
                else if (delta_column > 0 && (category_column_focus + delta_column) % category_view.app_view.get_page_columns () == 0
 
853
                          && category_view.switcher.active + 1 != category_view.app_view.get_n_pages ()) {
 
854
                    category_view.switcher.set_active (category_view.switcher.active + 1);
 
855
                    top_left_focus ();
 
856
                    return;
 
857
                }
 
858
                else if (category_column_focus == 0 && delta_column < 0) {
 
859
                    searchbar.grab_focus ();
 
860
                    category_column_focus = 0;
 
861
                    category_row_focus = 0;
 
862
                    return;
 
863
                }
 
864
                else
 
865
                    return;
 
866
            }
 
867
            category_column_focus += delta_column;
 
868
            category_row_focus += delta_row;
 
869
            if (delta_column > 0 && category_column_focus % category_view.app_view.get_page_columns () == 0 ) { // check if we need to change page
 
870
                category_view.switcher.set_active (category_view.switcher.active + 1);
 
871
            }
 
872
            else if (delta_column < 0 && (category_column_focus + 1) % category_view.app_view.get_page_columns () == 0) {
 
873
                // check if we need to change page
 
874
                category_view.switcher.set_active (category_view.switcher.active - 1);
 
875
            }
 
876
            new_focus.grab_focus ();
 
877
        }
 
878
        
 
879
        // this method moves focus to the first AppEntry in the top left corner of the current page. Works in CategoryView only
 
880
        private void top_left_focus () {
 
881
            // this is the first column of the current page
 
882
            int first_column = category_view.switcher.active * category_view.app_view.get_page_columns ();
 
883
            category_view.app_view.get_child_at (first_column, 0).grab_focus ();
 
884
            category_column_focus = first_column;
 
885
            category_row_focus = 0;
 
886
        }
 
887
        
888
888
        public void reset_category_focus () {
889
889
            category_column_focus = 0;
890
890
            category_row_focus = 0;