src/Tools/jEdit/src/pretty_tooltip.scala
author wenzelm
Mon, 01 Jul 2013 13:32:26 +0200
changeset 52492 0f0f80e41581
parent 52491 d435febab327
child 52493 ee7218d28159
permissions -rw-r--r--
tighten tooltip size;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49702
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     1
/*  Title:      Tools/jEdit/src/pretty_tooltip.scala
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     3
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     4
Enhanced tooltip window based on Pretty_Text_Area.
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     5
*/
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     6
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     7
package isabelle.jedit
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     8
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
     9
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    10
import isabelle._
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    11
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    12
import java.awt.{Color, Point, BorderLayout, Dimension}
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    13
import java.awt.event.{FocusAdapter, FocusEvent}
52483
478ef4fa3d5a more direct use of screen location: avoid misplacement if parent component has already disappeared asynchronously;
wenzelm
parents: 52481
diff changeset
    14
import javax.swing.{JWindow, JPanel, JComponent, PopupFactory}
49702
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    15
import javax.swing.border.LineBorder
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    16
49725
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
    17
import scala.swing.{FlowPanel, Label}
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
    18
import scala.swing.event.MouseClicked
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
    19
49702
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    20
import org.gjt.sp.jedit.View
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    21
import org.gjt.sp.jedit.textarea.TextArea
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    22
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
    23
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    24
object Pretty_Tooltip
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    25
{
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    26
  /* tooltip hierarchy */
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    27
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    28
  // owned by Swing thread
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    29
  private var stack: List[Pretty_Tooltip] = Nil
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    30
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    31
  private def hierarchy(tip: Pretty_Tooltip): Option[(List[Pretty_Tooltip], List[Pretty_Tooltip])] =
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    32
  {
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    33
    Swing_Thread.require()
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    34
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    35
    if (stack.contains(tip)) Some(stack.span(_ != tip))
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    36
    else None
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    37
  }
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    38
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    39
  def apply(
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    40
    view: View,
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    41
    parent: JComponent,
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    42
    rendering: Rendering,
52483
478ef4fa3d5a more direct use of screen location: avoid misplacement if parent component has already disappeared asynchronously;
wenzelm
parents: 52481
diff changeset
    43
    screen_point: Point,
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    44
    results: Command.Results,
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    45
    body: XML.Body): Pretty_Tooltip =
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    46
  {
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    47
    Swing_Thread.require()
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    48
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    49
    val (old, rest) =
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    50
      JEdit_Lib.ancestors(parent).collectFirst({ case x: Pretty_Tooltip => x }) match {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    51
        case Some(tip) => hierarchy(tip).getOrElse((stack, Nil))
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    52
        case None => (stack, Nil)
51458
67542078fa21 prefer ownerless window, to avoid question of potentially changing parent view;
wenzelm
parents: 51457
diff changeset
    53
      }
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    54
    old.foreach(_.hide_popup)
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    55
52483
478ef4fa3d5a more direct use of screen location: avoid misplacement if parent component has already disappeared asynchronously;
wenzelm
parents: 52481
diff changeset
    56
    val tip = new Pretty_Tooltip(view, rendering, parent, screen_point, results, body)
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    57
    stack = tip :: rest
52484
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
    58
    tip.show_popup
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    59
    tip
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
    60
  }
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    61
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    62
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    63
  /* dismiss -- with global delay */
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    64
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    65
  // owned by Swing thread
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    66
  private var active = true
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    67
  def is_active: Boolean = Swing_Thread.required { active }
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    68
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    69
  // owned by Swing thread
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    70
  private lazy val reactivate_delay =
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    71
    Swing_Thread.delay_last(PIDE.options.seconds("jedit_tooltip_delay")) {
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    72
      active = true
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    73
    }
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    74
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    75
  private def dismissing()
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    76
  {
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    77
    Swing_Thread.require()
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    78
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    79
    active = false
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    80
    reactivate_delay.invoke()
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    81
  }
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    82
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    83
  def dismiss(tip: Pretty_Tooltip)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    84
  {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    85
    dismissing()
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    86
    hierarchy(tip) match {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    87
      case Some((old, _ :: rest)) =>
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    88
        old.foreach(_.hide_popup)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    89
        tip.hide_popup
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    90
        stack = rest
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    91
      case _ =>
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    92
    }
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    93
  }
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    94
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    95
  def dismiss_all()
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
    96
  {
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    97
    dismissing()
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    98
    stack.foreach(_.hide_popup)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
    99
    stack = Nil
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   100
  }
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   101
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   102
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   103
  /* auxiliary geometry measurement */
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   104
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   105
  private lazy val dummy_window = new JWindow
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   106
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   107
  private def decoration_size(tip: Pretty_Tooltip): (Int, Int) =
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   108
  {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   109
    val old_content = dummy_window.getContentPane
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   110
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   111
    dummy_window.setContentPane(tip)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   112
    dummy_window.pack
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   113
    dummy_window.revalidate
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   114
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   115
    val painter = tip.pretty_text_area.getPainter
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   116
    val w = dummy_window.getWidth - painter.getWidth
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   117
    val h = dummy_window.getHeight - painter.getHeight
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   118
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   119
    dummy_window.setContentPane(old_content)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   120
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   121
    (w, h)
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
   122
  }
51449
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
   123
}
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
   124
8d6e478934dc explicit handling of tooltip window stack -- avoid memory leak due to not-so-weak references to disposed windows (via event handlers and other aux. components);
wenzelm
parents: 51440
diff changeset
   125
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   126
class Pretty_Tooltip private(
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   127
  view: View,
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   128
  rendering: Rendering,
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   129
  parent: JComponent,
52483
478ef4fa3d5a more direct use of screen location: avoid misplacement if parent component has already disappeared asynchronously;
wenzelm
parents: 52481
diff changeset
   130
  screen_point: Point,
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   131
  results: Command.Results,
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   132
  body: XML.Body) extends JPanel(new BorderLayout)
49702
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
   133
{
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   134
  tip =>
49705
036c9a028dbd close tooltip window on escape;
wenzelm
parents: 49703
diff changeset
   135
49725
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
   136
  Swing_Thread.require()
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
   137
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
   138
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
   139
  /* controls */
f8eeff667076 explicit close button;
wenzelm
parents: 49712
diff changeset
   140
49727
2fe56b600698 make buttons closer to original mouse position;
wenzelm
parents: 49726
diff changeset
   141
  private val close = new Label {
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   142
    icon = rendering.tooltip_close_icon
49727
2fe56b600698 make buttons closer to original mouse position;
wenzelm
parents: 49726
diff changeset
   143
    tooltip = "Close tooltip window"
2fe56b600698 make buttons closer to original mouse position;
wenzelm
parents: 49726
diff changeset
   144
    listenTo(mouse.clicks)
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   145
    reactions += { case _: MouseClicked => Pretty_Tooltip.dismiss(tip) }
49727
2fe56b600698 make buttons closer to original mouse position;
wenzelm
parents: 49726
diff changeset
   146
  }
2fe56b600698 make buttons closer to original mouse position;
wenzelm
parents: 49726
diff changeset
   147
49726
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   148
  private val detach = new Label {
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   149
    icon = rendering.tooltip_detach_icon
49726
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   150
    tooltip = "Detach tooltip window"
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   151
    listenTo(mouse.clicks)
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   152
    reactions += {
50501
6f41f1646617 more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents: 50206
diff changeset
   153
      case _: MouseClicked =>
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   154
        Info_Dockable(view, rendering.snapshot, results, body)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   155
        Pretty_Tooltip.dismiss(tip)
49726
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   156
    }
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   157
  }
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
   158
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   159
  private val controls = new FlowPanel(FlowPanel.Alignment.Left)(close, detach) {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   160
    background = rendering.tooltip_color
49709
3062937b45b3 tuned window position to fit on screen;
wenzelm
parents: 49708
diff changeset
   161
  }
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
   162
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
   163
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   164
  /* text area */
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   165
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   166
  val pretty_text_area =
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   167
    new Pretty_Text_Area(view, () => Pretty_Tooltip.dismiss(tip), true) {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   168
      override def get_background() = Some(rendering.tooltip_color)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   169
    }
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   170
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   171
  pretty_text_area.addFocusListener(new FocusAdapter {
52491
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   172
    override def focusGained(e: FocusEvent)
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   173
    {
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   174
      tip_border(3)
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   175
    }
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   176
    override def focusLost(e: FocusEvent)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   177
    {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   178
      Pretty_Tooltip.hierarchy(tip) match {
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   179
        case Some((Nil, _)) => Pretty_Tooltip.dismiss(tip)
52491
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   180
        case _ => tip_border(1)
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   181
      }
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   182
    }
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   183
  })
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
   184
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   185
  pretty_text_area.resize(Rendering.font_family(),
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   186
    Rendering.font_size("jedit_tooltip_font_scale").round)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   187
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   188
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   189
  /* main content */
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   190
52491
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   191
  def tip_border(thickness: Int = 1)
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   192
  {
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   193
    tip.setBorder(new LineBorder(Color.BLACK, thickness))
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   194
    tip.repaint()
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   195
  }
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   196
  tip_border(1)
d435febab327 visually explicit focus (behaviour dependent on platform and look-and-feel);
wenzelm
parents: 52484
diff changeset
   197
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   198
  override def getFocusTraversalKeysEnabled = false
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   199
  tip.setBackground(rendering.tooltip_color)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   200
  tip.add(controls.peer, BorderLayout.NORTH)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   201
  tip.add(pretty_text_area)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   202
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   203
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   204
  /* popup */
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   205
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   206
  private val popup =
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
   207
  {
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   208
    val screen_bounds = JEdit_Lib.screen_bounds(screen_point)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   209
52492
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   210
    val (w, h) =
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   211
    {
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   212
      val painter = pretty_text_area.getPainter
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   213
      val metric = JEdit_Lib.pretty_metric(painter)
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   214
      val margin = rendering.tooltip_margin * metric.average
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   215
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   216
      val formatted = Pretty.formatted(body, margin, metric)
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   217
      val lines =
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   218
        XML.traverse_text(formatted)(0)(
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   219
          (n: Int, s: String) => n + s.iterator.filter(_ == '\n').length)
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   220
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   221
      val (deco_width, deco_height) = Pretty_Tooltip.decoration_size(tip)
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   222
      val bounds = rendering.tooltip_bounds
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   223
52492
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   224
      val h1 = painter.getFontMetrics.getHeight * (lines + 1) + deco_height
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   225
      val h2 = (screen_bounds.height * bounds).toInt
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   226
      val h = h1 min h2
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   227
52492
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   228
      val margin1 =
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   229
        if (h1 <= h2)
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   230
          (0.0 /: split_lines(XML.content(formatted)))({ case (m, line) => m max metric(line) })
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   231
        else margin
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   232
      val w =
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   233
        ((metric.unit * (margin1 + metric.average)).round.toInt + deco_width) min
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   234
        (screen_bounds.width * bounds).toInt
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   235
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   236
      (w, h)
0f0f80e41581 tighten tooltip size;
wenzelm
parents: 52491
diff changeset
   237
    }
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   238
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   239
    tip.setSize(new Dimension(w, h))
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   240
    tip.setPreferredSize(new Dimension(w, h))
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   241
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   242
    val x = screen_point.x min (screen_bounds.x + screen_bounds.width - tip.getWidth)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   243
    val y = screen_point.y min (screen_bounds.y + screen_bounds.height - tip.getHeight)
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   244
    PopupFactory.getSharedInstance.getPopup(parent, tip, x, y)
51452
14e6d761ba1c extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents: 51451
diff changeset
   245
  }
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   246
52484
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
   247
  private def show_popup
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
   248
  {
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
   249
    popup.show
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
   250
    pretty_text_area.requestFocus
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
   251
    pretty_text_area.update(rendering.snapshot, results, body)
23a09c639700 avoid potential race condition of focusLost/dismiss vs. popup.show;
wenzelm
parents: 52483
diff changeset
   252
  }
52478
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   253
0a1db0d02628 manage popup windows via PopupFactory, which prefers light-weight JComponent, but might fall back on JWindow (despite JPanel of 0f88591478e6);
wenzelm
parents: 52472
diff changeset
   254
  private def hide_popup: Unit = popup.hide
49702
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
   255
}
696e91c0bc80 separate module Pretty_Tooltip;
wenzelm
parents:
diff changeset
   256