1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
Rhaoma 0a7f6a6331
Add option to align title text in window (#1953)
* Add option to align title text in window 

I found that i really needed a basic way to align the title text in a window, and therefore i did a bit of tinkering and came up with this solution. Mind you that I'm very new to this so it might not be the most optimal way. I have tested a bit and it pretty looked promising,
I have of course written the alignments as I felt was most suitable, but I shouldn't be the judge of that.
Current alignment:

LV_TXT_FLAG_CENTER makes the text align in the center of the header but ensures it can’t overextend into to header button area;

LV_TXT_FLAG_RIGHT makes the text align at the right side, but takes the right side header buttons into account

LV_TXT_FLAG_FIT & LV_TXT_FLAG_EXPAND I wasn’t too sure about what to do so as of now it just aligns them as normal

LV_TXT_FLAG_NONE Is equal to no flag set by the user and therefore I have just set it to the default coords, like normal. The text then align at the left side.

* Update lv_win.h

* Added functions

Added function to set and get alignment of the header title as requested

* Added functions

Added setter and getter functions for the header title alignment as requested
2020-12-11 16:37:20 +01:00
2020-11-02 13:13:01 +01:00
2020-12-01 12:19:45 +01:00
2020-12-01 15:04:20 +01:00
2020-10-02 13:12:41 +02:00
2020-10-21 14:06:48 +02:00
2020-12-01 15:13:30 +01:00
2020-12-01 15:13:30 +01:00
2020-05-31 23:03:38 +02:00
2020-12-09 14:11:14 +01:00
2020-04-16 16:12:35 +02:00
2020-11-21 15:45:11 -05:00

LVGL - Light and Versatile Graphics Library

LVGL provides everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint.

Website · Online demo · Nightly demos · Docs · Forum


Features

  • Powerful building blocks: buttons, charts, lists, sliders, images, etc.
  • Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling
  • Use various input devices: touchscreen, mouse, keyboard, encoder, buttons, etc.
  • Use multiple displays: e.g. monochrome and color display
  • Hardware independent to use with any microcontroller or display
  • Scalable to operate with little memory (64 kB Flash, 10 kB RAM)
  • Multi-language support with UTF-8 handling, Bidirectional and Arabic script support
  • Fully customizable graphical elements via CSS-like styles
  • OS, External memory and GPU are supported but not required
  • Smooth rendering even with a single frame buffer
  • Written in C for maximal compatibility (C++ compatible)
  • Micropython Binding exposes LVGL API in Micropython
  • Simulator to develop on PC without embedded hardware
  • Examples and tutorials for rapid development
  • Documentation and API references

Requirements

Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are:

Name Minimal Recommended
Architecture 16, 32 or 64 bit microcontroller or processor
Clock > 16 MHz > 48 MHz
Flash/ROM > 64 kB > 180 kB
Static RAM > 2 kB > 4 kB
Stack > 2 kB > 8 kB
Heap > 2 kB > 8 kB
Display buffer > 1 × hor. res. pixels > 10 × hor. res. pixels
Compiler C99 or newer

Note that the memory usage might vary depending on the architecture, compiler and build options.

Just to mention some platforms:

Get started

This list shows the recommended way of learning the library:

  1. Check the Online demos to see LVGL in action (3 minutes)
  2. Read the Introduction page of the documentation (5 minutes)
  3. Get familiar with the basics on the Quick overview page (15 minutes)
  4. Set up a Simulator (10 minutes)
  5. Try out some Examples
  6. Port LVGL to a board. See the Porting guide or check the ready to use Projects
  7. Read the Overview page to get a better understanding of the library (2-3 hours)
  8. Check the documentation of the Widgets to see their features and usage
  9. If you have questions go to the Forum
  10. Read the Contributing guide to see how you can help to improve LVGL (15 minutes)

Examples

For more examples see the lv_examples repository.

Button with label

lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL);     /*Add a button to the current screen*/
lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/
lv_obj_set_size(btn, 100, 50);                          /*Set its size*/
lv_obj_set_event_cb(btn, btn_event_cb);                 /*Assign a callback to the button*/

lv_obj_t * label = lv_label_create(btn, NULL);          /*Add a label to the button*/
lv_label_set_text(label, "Button");                     /*Set the labels text*/

...

void btn_event_cb(lv_obj_t * btn, lv_event_t event)
{
    if(event == LV_EVENT_CLICKED) {
        printf("Clicked\n");
    }
}

LVGL button with label example

LVGL from Micropython

Learn more about Micropython.

# Create a Button and a Label
scr = lv.obj()
btn = lv.btn(scr)
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
label = lv.label(btn)
label.set_text("Button")

# Load the screen
lv.scr_load(scr)

Contributing

LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosing your own project under in LVGL.

For a detailed description of contribution opportunities visit the Contributing section of the documentation.

Languages
C 90.2%
C++ 8.2%
Python 1.1%
Assembly 0.2%
CMake 0.1%