gansm / finalcut

A text-based widget toolkit
https://github.com/gansm/finalcut/wiki/First-steps#first-steps-with-the-final-cut-widget-toolkit
GNU Lesser General Public License v3.0
981 stars 52 forks source link

show windows on frame buffer #135

Closed mahdi2001h closed 7 months ago

mahdi2001h commented 8 months ago

I want to show finalcut windows output on frame buffer in linux Do you have any suggestions on how to do it?

i tested with FRAMEBUFFER_CONSOLE but it not good and sometime is not compatible.

gansm commented 8 months ago

Thank you for your inquiry and your interest in FINAL CUT. Unfortunately, I can't get enough information from your request to understand your problem. The Linux framebuffer console works fine with FINAL CUT if the TERM environment variable is set to "linux".

fb

finalcut-window

Here is a small C program to test the Linux framebuffer:

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mman.h>

#include <linux/fb.h>

#include <unistd.h>
#include <fcntl.h>

#include <stdio.h>

int main()
{
   struct fb_var_screeninfo screen_info;
   struct fb_fix_screeninfo fixed_info;
   char *buffer = NULL;
   size_t buflen;
   int fd = -1;
   int r = 1;
   int x,y;

   fd = open("/dev/fb0", O_RDWR);

   if ( fd >= 0 )
   {
      if ( ! ioctl(fd, FBIOGET_VSCREENINFO, &screen_info)
        && ! ioctl(fd, FBIOGET_FSCREENINFO, &fixed_info) )
      {
         buflen = screen_info.yres_virtual * fixed_info.line_length;
         buffer = mmap(NULL,
                       buflen,
                       PROT_READ|PROT_WRITE,
                       MAP_SHARED,
                       fd,
                       0);

         if ( buffer != MAP_FAILED )
         {
             printf ("Framebuffer works on this pc!\n");
             printf ("     Name : %s\n", fixed_info.id);
             printf ("  Address : %ld\n", fixed_info.smem_start);
             printf ("     Size : %d\n", fixed_info.smem_len);
             printf ("     xres : %d\n", screen_info.xres);
             printf ("     yres : %d\n", screen_info.yres);
             printf ("      bpp : %d\n", screen_info.bits_per_pixel);

             for (x=0; x < screen_info.xres; x++)
             {
               /* white line */
               *(buffer + (x * screen_info.bits_per_pixel/8) ) = 0xff;    /* blue */
               *(buffer + (x * screen_info.bits_per_pixel/8) + 1) = 0xff; /* green */
               *(buffer + (x * screen_info.bits_per_pixel/8) + 2) = 0xff; /* red */

               *(buffer + (x * screen_info.bits_per_pixel/8) + fixed_info.line_length * (screen_info.yres-1) ) = 0xff; /* blue */
             }
             for (y=0; y < screen_info.yres; y++)
             {
               *(buffer + (y * screen_info.xres) * (screen_info.bits_per_pixel/8) + 1) = 0xff; /* green */
               *(buffer + (y * screen_info.xres + screen_info.xres-1) * (screen_info.bits_per_pixel/8) + 2) = 0xff; /* red */
             }
             r = 0;   /* Indicate success */
         }
         else
         {
            perror("mmap");
         }
      }
      else
      {
         perror("ioctl");
      }
   }
   else
   {
      perror("open");
   }

   /*
    * Clean up
    */
   if (buffer && buffer != MAP_FAILED)
     munmap(buffer, buflen);

   if (fd >= 0)
     close(fd);

   return r;
}

/*  gcc framebuffer-check.c -o framebuffer-check */

Unfortunately, I don't know what kind of hardware, CPU architecture, and distribution you are developing. If you could give me more details or specific scenarios about the problems, I might be able to help you.

mahdi2001h commented 8 months ago

thank for your help

i'm using allwinner v3s chip with sinux v3 board

the value of TERM variable is linux and this is output of commands photo_2024-01-01_18-49-27

this is my program output in this display photo_2024-01-01_18-49-13 and this is output in other screen (with bigger size!) photo_2024-01-01_18-49-32

also I have a FFileDialog that i want to open on top of the main windows what i should to do for this ?

dialog on bigger screen image

i think the problem is screen resolution Do you have any suggestions to fix this problem?

gansm commented 8 months ago

That looks like an interesting project. Let me see how I can help you.

In the first photo, I can see that you are running your display at a resolution of 320×240 pixels. The used font should be a standard CGA font with a character size of 8×8 pixels. That should give you a text mode with 40 columns and 30 lines.

The "cam viewer" window in the second photo is cut off on the right side, so you probably have a window size of more than 40 characters. Should your window be exactly 40 characters wide, you only need to move the window one character to the left.

In the third image, now with a character size of 9×18 pixels, I have difficulty following your execution. What am I seeing here? What is the other screen? Has the display been replaced? Is there a second output device on your evaluation board? Or is the screenshot from a completely different device?

When you open the file-open-chooser, it appears in the center of your terminal screen. This means that, if your main window is in the center of the screen, the FFileDialog widget will be displayed over the main window.

For example:

auto filename = finalcut::FFileDialog::fileOpenChooser (this, directory, filter);

if ( ! filename.isEmpty() )
{
  // open filename...
}

If you require a different positioning behavior, please create a class derived from FFileDialog and overload the FFileDialog::adjustSize() method with your own code.

It is difficult for me to find a more precise solution without seeing your code and more information about your application.

I hope I was able to help you.

mahdi2001h commented 7 months ago

Thanks a lot My problem solved with use FFileDialog::adjustSize() method