Changeset 12017


Ignore:
Timestamp:
May 8, 2009, 1:39:18 AM (10 years ago)
Author:
rme
Message:

Be a little smarter about placing new editor windows. (ticket:196)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/cocoa-editor.lisp

    r12009 r12017  
    703703  (let* ((newself (#/init self))
    704704         (styles (make-editor-style-map))
    705          (mirror (#/retain (make-instance ns:ns-mutable-attributed-string
     705         (mirror (make-instance ns:ns-mutable-attributed-string
    706706                                   :with-string s
    707                                    :attributes (#/objectAtIndex: styles 0)))))
     707                                   :attributes (#/objectAtIndex: styles 0))))
    708708    (declare (type hemlock-text-storage newself))
    709709    (setf (slot-value newself 'styles) styles)
     
    26532653(def-cocoa-default *initial-editor-x-pos* :float 20.0f0 "X position of upper-left corner of initial editor")
    26542654
    2655 (def-cocoa-default *initial-editor-y-pos* :float -20.0f0 "Y position of upper-left corner of initial editor")
     2655(def-cocoa-default *initial-editor-y-pos* :float 10.0f0 "Y position of upper-left corner of initial editor")
     2656
     2657(defloadvar *editor-cascade-point* nil)
    26562658
    26572659(defloadvar *next-editor-x-pos* nil) ; set after defaults initialized
     
    26972699      (#/addWindowController: self controller)
    26982700      (#/release controller)
    2699       (ns:with-ns-point  (current-point
    2700                           (or *next-editor-x-pos*
    2701                               (x-pos-for-window window *initial-editor-x-pos*))
    2702                           (or *next-editor-y-pos*
    2703                               (y-pos-for-window window *initial-editor-y-pos*)))
    2704         (let* ((new-point (#/cascadeTopLeftFromPoint: window current-point)))
    2705           (setq *next-editor-x-pos* (ns:ns-point-x new-point)
    2706                 *next-editor-y-pos* (ns:ns-point-y new-point))))
     2701      ;; Cascade windows from the top left corner of the topmost editor window.
     2702      ;; If there's no editor window, use the default position.
     2703      (flet ((editor-window-p (w)
     2704               (and (not (eql w window))
     2705                    (eql (#/class (#/windowController w))
     2706                         (find-class 'hemlock-editor-window-controller)))))
     2707        (let* ((editors (remove-if-not #'editor-window-p (windows)))
     2708               (top-editor (car editors)))
     2709          (if top-editor
     2710            (ns:with-ns-point (zp 0 0)
     2711              (setq *editor-cascade-point* (#/cascadeTopLeftFromPoint: top-editor zp)))
     2712            (let* ((screen-frame (#/visibleFrame (#/screen window)))
     2713                   (pt (ns:make-ns-point
     2714                                            *initial-editor-x-pos*
     2715                                            (- (ns:ns-rect-height
     2716                                                screen-frame)
     2717                                               *initial-editor-y-pos*))))
     2718              (setq *editor-cascade-point* pt)))))
     2719      (#/cascadeTopLeftFromPoint: window *editor-cascade-point*)
    27072720      (let ((view (hemlock-view window)))
    27082721        (hi::handle-hemlock-event view #'(lambda ()
Note: See TracChangeset for help on using the changeset viewer.