[brailleblaster] push by brandon....@xxxxxxxxx - When item is changed in tree, scrollbar now moves to current selection... on 2014-01-15 19:14 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Wed, 15 Jan 2014 19:14:33 +0000

Revision: cb8412dba3a4
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Wed Jan 15 19:13:09 2014 UTC
Log: When item is changed in tree, scrollbar now moves to current selection if it is not visible in text and braille view
http://code.google.com/p/brailleblaster/source/detail?r=cb8412dba3a4

Modified:
 /src/main/org/brailleblaster/perspectives/braille/Manager.java

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Wed Jan 15 14:26:58 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Wed Jan 15 19:13:09 2014 UTC
@@ -558,7 +558,7 @@

        private void handleSetCurrent(Message message){
                int index;
-       //      list.checkList();
+               list.checkList();
                if(message.getValue("isBraille").equals(true)){
                        index = list.findClosestBraille(message);
                        list.setCurrent(index);
@@ -580,6 +580,27 @@
                        sm.setStyleTableItem(list.getCurrent());
                        resetCursorData();
                }
+
+               if(treeView.getTree().isFocusControl() && 
!currentElementOnScreen()){
+ text.view.setTopIndex(text.view.getLineAtOffset(list.getCurrent().start)); + handleUpdateScrollbar(Message.createUpdateScollbarMessage("tree", list.getCurrent().start));
+               }
+       }
+
+       private boolean currentElementOnScreen(){
+               int viewHeight = text.view.getClientArea().height;
+               int lineHeight = text.view.getLineHeight();
+               int totalLines = viewHeight / lineHeight;
+
+               int currentLine = 
text.view.getLineAtOffset(list.getCurrent().start);
+               int topIndex = text.view.getTopIndex();
+
+ if(currentLine >= topIndex && currentLine <= (topIndex + totalLines - 1)){
+                       return true;
+               }
+               else {
+                       return false;
+               }
        }

        private void handleGetCurrent(Message message){

Other related posts:

  • » [brailleblaster] push by brandon....@xxxxxxxxx - When item is changed in tree, scrollbar now moves to current selection... on 2014-01-15 19:14 GMT - brailleblaster