Changeset 10691


Ignore:
Timestamp:
2005-10-05T15:54:53+13:00 (19 years ago)
Author:
kjdon
Message:

fixed up the folder selection highlighting (cue lines) - the lines now disappear if the mouse is dragged off the folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r9755 r10691  
    300300        g2.drawImage(group.image_ghost, AffineTransform.getTranslateInstance(ra_ghost.getX(), ra_ghost.getY()), null);
    301301    }
    302     // Now we highlight the target node if it is a valid drop target. Of course we don't bother if we are still over a node which has already been identified as to whether its a drop target.
     302    // Now we highlight the target node if it is a valid drop target. Of course we don't bother if we are still over a node which has already been identified as to whether its a drop target
    303303    TreePath target_path = this.getPathForLocation(pt.x, pt.y);
     304   
     305    if (target_path == null) {
     306        // the user has moved the mouse into background area - need to remove any existing cue lines
     307        if(upper_cue_line != null && lower_cue_line != null) {
     308        paintImmediately(upper_cue_line.getBounds());
     309        paintImmediately(lower_cue_line.getBounds());
     310        previous_path = null;
     311        }
     312        // don't need to display anything
     313        return;
     314    }
     315   
    304316    if(previous_path == null || target_path != null && !target_path.equals(previous_path)) {
    305317        // Immediately clear the old cue lines.
     
    309321        }
    310322        if(isValidDrop(target_path)) {
    311         ///ystem.err.println("Valid. Painting cues.");
    312323        // Get the drop target's bounding rectangle
    313324        Rectangle raPath = getPathBounds(target_path);
    314325        // Cue line bounds (2 pixels beneath the drop target)
    315         upper_cue_line = new Rectangle(0,  raPath.y + (int)raPath.getHeight(), getWidth(), 2);
    316         lower_cue_line = new Rectangle(0,  raPath.y, getWidth(), 2);
     326        upper_cue_line = new Rectangle(0, raPath.y + (int)raPath.getHeight(), getWidth(), 2);
     327        lower_cue_line = new Rectangle(0, raPath.y, getWidth(), 2);
    317328        g2.setColor(((DefaultTreeCellRenderer)cellRenderer).getBackgroundSelectionColor()); // The cue line color
    318329        g2.fill(upper_cue_line);         // Draw the cue line
     
    644655    private boolean isValidDrop(TreePath target_path) {
    645656    boolean valid = false;
    646     if(target_path != null) {
     657    if(target_path == null) {
     658        previous_path = null;
     659    }
     660    else {
    647661        FileNode target_node = (FileNode) target_path.getLastPathComponent();
    648662        // We can only continue testing if the node is a folder.
     
    673687        previous_path = target_path;
    674688    }
    675     else {
    676         if(target_path == null) {
    677         previous_path = null;
    678         }
    679     }
    680689    return valid;
    681690    }
Note: See TracChangeset for help on using the changeset viewer.