[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Displaying table grids

From: Norbert Nemec
Subject: Re: [Texmacs-dev] Displaying table grids
Date: Mon, 14 Dec 2009 21:39:09 +0000
User-agent: Thunderbird (X11/20090817)

Dear Joris,

in fact, I had initially intended to make the lines 1px wide just as you describe. After some fiddling I found that it always ended up looking strangely asymmetric. The problem is that the cyan environment frames are always 1px-wide lines outside the box, defining the box boundaries to sit exactly between pixels. A 1px wide line can therefore only sit either to the left or to the right of the box boundary. Any way you choose this, it looks crooked. The only solution to allow good-looking 1px-wide grids would be to shift the cyan box guides as well as the red selection markers.

Ultimately, though, I found that 2px lines actually have the advantage that they can be displayed in fainter gray while still giving the same visual impact. This should reduce the visual clutter with the black page content.

As for the eqnarray* grids - indeed that look takes some getting used to. After using it for some time, I actually began to like it. I am not quite sure how to change this cleanly. Currently, the whole code is really simple, drawing a rectangle around each cell individually. Trying to find adjacent cells and then determining the line between is certainly much more messy and may be quite tricky to get correct for cell spans etc.

Actually, do you have an idea what the mechanism is that causes the space between the lines in eqnarray* ? I never managed to cause the same effect in a table.

Currently, my own major grievance with the table grid code is that cell borders are hidden *behind* the grid. I tried to put the visual hints behind the text, but this did not work nicely with overlays (which I use heavily in one special layout). As I said, alpha-channel rastering would be the perfect solution for this...


Joris van der Hoeven wrote:
Dear Norbert,

Thanks for your patch. I support the idea of it, but still find
the rendering suboptimal: I think that the width of the table hints
should always be 1ln, whereas the width is currently 2ln for interior cells.
Also, the rendering of eqnarray* environments is ugly; one should try to
use the mean y-values of successive rows.

I agree that this will be some more work, but do you think that you
can fix these issues? Don't forget that some cells may have
non trivial spans...

Best wishes, --Joris

On Tue, Dec 08, 2009 at 10:07:52AM +0000, Norbert Nemec wrote:
Hi there,

attached is a patch implementing an idea that I had for a long time:

Currently, when the cursor is inside a table, only the outer border of the whole table is displayed as a cyan rectangle. This patch displays the whole grid of a table as very faint gray lines.

I hope that this feature will help greatly if you do intense layout with complex tables and especially nested tables.

The patch also slightly changes the color of outline rectangles from intense cyan to fainter gray-cyan. This is mostly a matter of taste. I always found the intense color a bit "loud" on the eye. The intense red for selections is fine, but the outline should be a mere hint to guide the eye and seems a bit more elegant in a fainter tone.

This whole patch is probably not the final form of this feature, but more a basis of discussion.


>From 1092fa3a4e3e6ce5703aeee82b868802e433357e Mon Sep 17 00:00:00 2001
From: Norbert Nemec <address@hidden>
Date: Mon, 7 Dec 2009 12:11:43 +0000
Subject: [PATCH] Display table grid (very faint gray). Also change color of 
environment boxes from intense cyan to faint gray cyan and put them behind the 
displayed content.

 src/src/Edit/Interface/edit_interface.cpp |   30 ++++++++++++++++++++++------
 src/src/Edit/Interface/edit_interface.hpp |    3 +-
 src/src/Edit/Interface/edit_repaint.cpp   |   10 +++++++-
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/src/src/Edit/Interface/edit_interface.cpp 
index a035b5a..9443cc0 100644
--- a/src/src/Edit/Interface/edit_interface.cpp
+++ b/src/src/Edit/Interface/edit_interface.cpp
@@ -261,26 +261,36 @@ is_graphical (tree t) {
-edit_interface_rep::compute_env_rects (path p, rectangles& rs, bool recurse) {
+edit_interface_rep::compute_env_rects (path p,
+    rectangles& rs, rectangles& tcrs, bool recurse) {
   p= path_up (p);
   if (p == rp) return;
   tree st= subtree (et, p);
-  if (is_atomic (st) ||
+  if(is_func(st,TABLE)) {
+    rectangles r;
+    for(int i=0;i<N(st);i++)
+        if(is_func(st[i],ROW))
+            for(int j=0;j<N(st[i]);j++) {
+                selection sel= eb->find_check_selection (p*i*j*0,p*i*j*1);
+                r << sel->rs - ::correct(thicken(sel->rs,-pixel,-pixel));
+            }
+    tcrs << simplify(r);
+    compute_env_rects (p, rs, tcrs, recurse);
+  } else if (is_atomic (st) ||
       drd->is_child_enforcing (st) ||
       //is_document (st) || is_concat (st) ||
-      is_func (st, TABLE) || is_func (st, SUBTABLE) ||
+      is_func (st, SUBTABLE) ||
       is_func (st, ROW) || is_func (st, TFORMAT) ||
       is_graphical (st) ||
       (is_func (st, WITH) && is_graphical (st[N(st)-1])) ||
       (is_func (st, WITH) && is_func (st[N(st)-1], TEXT_AT)) ||
       (is_compound (st, "math", 1) &&
        is_compound (subtree (et, path_up (p)), "input")))
-    compute_env_rects (p, rs, recurse);
+    compute_env_rects (p, rs, tcrs, recurse);
   else {
     int new_mode= DRD_ACCESS_NORMAL;
     if (get_init_string (MODE) == "src") new_mode= DRD_ACCESS_SOURCE;
     int old_mode= set_access_mode (new_mode);
-    tree st= subtree (et, p);
     if (is_accessible_cursor (et, p * right_index (st)) || in_source ()) {
       bool right;
       path p1= p * 0, p2= p * 1, q1, q2;
@@ -294,7 +304,7 @@ edit_interface_rep::compute_env_rects (path p, rectangles& 
rs, bool recurse) {
       rs << outline (sel->rs, pixel);
     set_access_mode (old_mode);
-    if (recurse) compute_env_rects (p, rs, recurse);
+    if (recurse) compute_env_rects (p, rs, tcrs, recurse);
@@ -457,8 +467,14 @@ edit_interface_rep::apply_changes () {
     oc= copy (cu);
rectangles old_rects= env_rects;
+    rectangles old_tc_rects= tblcell_rects;
     env_rects= rectangles ();
-    compute_env_rects (path_up (tp), env_rects, true);
+    tblcell_rects= rectangles ();
+    compute_env_rects (path_up (tp), env_rects, tblcell_rects, true);
+    if (tblcell_rects != old_tc_rects) {
+      invalidate (old_tc_rects);
+      invalidate (tblcell_rects);
+    }
     if (env_rects != old_rects) {
       invalidate (old_rects);
       invalidate (env_rects);
diff --git a/src/src/Edit/Interface/edit_interface.hpp 
index 05cf7d8..dbf5c85 100644
--- a/src/src/Edit/Interface/edit_interface.hpp
+++ b/src/src/Edit/Interface/edit_interface.hpp
@@ -55,6 +55,7 @@ protected:
   bool          table_selection;
   rectangles    selection_rects;
   rectangles    env_rects;
+  rectangles    tblcell_rects;
   cursor        oc;
   bool          temp_invalid_cursor;
   array<string> completions;
@@ -110,7 +111,7 @@ public:
   void animate ();
/* miscellaneous */
-  void compute_env_rects (path p, rectangles& rs, bool recurse);
+  void compute_env_rects (path p, rectangles& rs, rectangles& trs, bool 
   void cursor_visible ();
   void selection_visible ();
   void full_screen_mode (bool flag);
diff --git a/src/src/Edit/Interface/edit_repaint.cpp 
index 69a1efd..08a2a6b 100644
--- a/src/src/Edit/Interface/edit_repaint.cpp
+++ b/src/src/Edit/Interface/edit_repaint.cpp
@@ -35,9 +35,15 @@ edit_interface_rep::draw_text (renderer ren, rectangles& l) {
 edit_interface_rep::draw_env (renderer ren) {
   if (!full_screen) {
-    rectangles rs= env_rects;
+    rectangles rs= tblcell_rects;
     while (!is_nil (rs)) {
-      ren->set_color (rgb_color (0, 255, 255));
+      ren->set_color (rgb_color (224, 224, 224));
+      ren->fill (rs->item->x1, rs->item->y1, rs->item->x2, rs->item->y2);
+      rs= rs->next;
+    }
+    rs= env_rects;
+    while (!is_nil (rs)) {
+      ren->set_color (rgb_color (162, 224, 224));
       ren->fill (rs->item->x1, rs->item->y1, rs->item->x2, rs->item->y2);
       rs= rs->next;

Texmacs-dev mailing list

Texmacs-dev mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]