]> git.mxchange.org Git - flightgear.git/commitdiff
first stab at label box pointers. <option>top</option> on a <label> makes
authormfranz <mfranz>
Mon, 24 Jul 2006 17:09:03 +0000 (17:09 +0000)
committermfranz <mfranz>
Mon, 24 Jul 2006 17:09:03 +0000 (17:09 +0000)
such a box:

    _____/\_____
    |   Booo   |
    |__________|

likewise with options bottom, left, right. The size can be set via option
<marker-offset> (analogous to <tape> offsets), which describes the distance
from the base to the peak. Default: 8 px

src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/HUD/HUD_label.cxx

index b43f1c5e1f93a1f872b2b95237f60db3ee4bce71..8c544ac270b84bbef827d7f1a9a057ddd37afdf8 100644 (file)
@@ -439,6 +439,7 @@ private:
     int     _blink;
     bool    _box;
     float   _text_y;
+    float   _marker_offset;
 
     SGCondition *_blink_condition;
     double  _blink_interval;
index 6a00c05da9f2166937e589ffceeeff207ea7bf8b..71d032da9b5c1771e2e0e5bb556226a4d01acb4e 100644 (file)
@@ -32,6 +32,7 @@ HUD::Label::Label(HUD *hud, const SGPropertyNode *n, float x, float y) :
     _input(n->getNode("input", false)),
     _fontsize(fgGetInt("/sim/startup/xsize") > 1000 ? FONT_LARGE : FONT_SMALL),                // FIXME
     _box(n->getBoolValue("box", false)),
+    _marker_offset(n->getFloatValue("marker-offset", 8)),
     _blink_condition(0),
     _blink_interval(n->getFloatValue("blinking/interval", -1.0f)),
     _blink_target(0.0),
@@ -84,10 +85,51 @@ void HUD::Label::draw(void)
         return;
 
     if (_box) {
-        draw_line(_x, _y, _x + _w, _y);
-        draw_line(_x + _w, _y, _x + _w, _y + _h);
-        draw_line(_x + _w, _y + _h, _x, _y + _h);
-        draw_line(_x, _y + _h, _x, _y);
+        const float tan30 = 0.57735;
+        float base = _marker_offset * tan30;
+        float l, r, p;
+
+        l = _center_x - base;
+        r = _center_x + base;
+
+        if (option_bottom()) {
+            p = _y - _marker_offset;
+            draw_line(_x, _y, l, _y);
+            draw_line(l, _y, _center_x, p);
+            draw_line(_center_x, p, r, _y);
+            draw_line(r, _y, _x + _w, _y);
+        } else
+            draw_line(_x, _y, _x + _w, _y);
+
+        if (option_top()) {
+            p = _y + _h + _marker_offset;
+            draw_line(_x, _y + _h, l, _y + _h);
+            draw_line(l, _y + _h, _center_x, p);
+            draw_line(_center_x, p, r, _y + _h);
+            draw_line(r, _y + _h, _x + _w, _y + _h);
+        } else
+            draw_line(_x + _w, _y + _h, _x, _y + _h);
+
+        l = _center_y - base;
+        r = _center_y + base;
+
+        if (option_left()) {
+            p = _x - _marker_offset;
+            draw_line(_x, _y, _x, l);
+            draw_line(_x, l, p, _center_y);
+            draw_line(p, _center_y, _x, r);
+            draw_line(_x, r, _x, _y + _h);
+        } else
+            draw_line(_x, _y + _h, _x, _y);
+
+        if (option_right()) {
+            p = _x + _w + _marker_offset;
+            draw_line(_x + _w, _y, _x + _w, l);
+            draw_line(_x + _w, l, p, _center_y);
+            draw_line(p, _center_y, _x + _w, r);
+            draw_line(_x + _w, r, _x + _w, _y + _h);
+        } else
+            draw_line(_x + _w, _y, _x + _w, _y + _h);
     }
 
     const int BUFSIZE = 256;