Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of expanding text widget (+ / - syntax) #96

Closed
siddharth99 opened this issue Nov 19, 2021 · 4 comments
Closed

Support of expanding text widget (+ / - syntax) #96

siddharth99 opened this issue Nov 19, 2021 · 4 comments

Comments

@siddharth99
Copy link

siddharth99 commented Nov 19, 2021

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!

@gansm
Copy link
Owner

gansm commented Nov 20, 2021

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
Copy link
Owner

gansm commented Jan 3, 2022

@siddharth99:

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

@gansm
Copy link
Owner

gansm commented Nov 24, 2022

@siddharth99:

Is this a workable solution for you?

@gansm
Copy link
Owner

gansm commented Mar 16, 2023

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

@gansm gansm closed this as completed Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants