finalcut icon indicating copy to clipboard operation
finalcut copied to clipboard

Support of expanding text widget (+ / - syntax)

Open siddharth99 opened this issue 3 years ago • 2 comments

I'm printing very simple pre-formatted text in a tabular format; I am tabulating myself using snprintf(..) etc. In below example I have a (X, *) that is the summation of (X, x1) and (X, x2). I am wondering if there's a way to support a expand section / contract section type syntax with some minor effort or reasonably achieve the same thing by placing buttons to the left of each expanding section and clicking on them.

My widget architecture is FDialog -> FScrollView -> FLabel and I just call FLabel::setText(..) to update the text.

    Current Layout
    -------------------------
    | id | mode | A | B | C |
    | X  | *    | 2 | 2 | 2 |
    | X  | x1   | 1 | 1 | 1 |
    | X  | x2   | 1 | 1 | 1 |
    | Y  | *    | 3 | 3 | 3 |
    | Y  | y1   | 1 | 1 | 1 |
    | Y  | y2   | 2 | 2 | 2 |
    -------------------------
    Desired unexpanded layout
    -------------------------
    | id | mode | A | B | C |
    + X  | *    | 2 | 2 | 2 |
    + Y  | *    | 3 | 3 | 3 |
    -------------------------
    Desired expanded layout when both expanded
    -------------------------
    | id | mode | A | B | C |
    - X  | *    | 2 | 2 | 2 |
    | X  | x1   | 1 | 1 | 1 |
    | X  | x2   | 1 | 1 | 1 |
    - Y  | *    | 3 | 3 | 3 |
    | Y  | y1   | 1 | 1 | 1 |
    | Y  | y2   | 2 | 2 | 2 |
    -------------------------

Thanks in advance!

siddharth99 avatar Nov 19 '21 22:11 siddharth99

I think you want to use a FListView widget in tree view mode. You can expand and collapse sub-lines by clicking the triangle, double-clicking a line, or using the +, -, , or keyboard keys.

Here is a small code example:

#include <final/final.h>

using namespace finalcut;


int main (int argc, char* argv[])
{
  FApplication app(argc, argv);

  FDialog dialog ("Expand and collapse data", &app);
  dialog.setGeometry (FPoint(30, 6), FSize(33, 10));

  FListView list (&dialog);
  list.ignorePadding();
  list.setGeometry (FPoint(1, 2), FSize(33, 9));

  // Add columns to the view
  list.addColumn ("id", 5);
  list.addColumn ("mode", 5);
  list.addColumn ("A", 5);
  list.addColumn ("B", 5);
  list.addColumn ("C", 5);

  // Activate tree view
  list.setTreeView();

  auto iter1 = list.insert ({"X", "*", "2", "2", "2"});
  list.insert ({"X", "x1", "1", "1", "1"}, iter1);
  list.insert ({"X", "x2", "1", "1", "1"}, iter1);

  auto iter2 = list.insert ({"Y", "*", "3", "3", "3"});
  list.insert ({"Y", "y1", "1", "1", "1"}, iter2);
  list.insert ({"Y", "y2", "2", "2", "2"}, iter2);

  app.setMainWidget(&dialog);
  dialog.show();
  return app.exec();
}

 

image

image

PS: Removing the ID in the sub-lines would emphasize the togetherness.

gansm avatar Nov 20 '21 16:11 gansm

@siddharth99:

I have not received any further feedback from you. Can I assume that this is a working solution for you?

gansm avatar Jan 03 '22 15:01 gansm

@siddharth99:

Is this a workable solution for you?

gansm avatar Nov 24 '22 22:11 gansm

Based on the absence of feedback, I will be closing this issue.

gansm avatar Mar 16 '23 18:03 gansm