-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JF002/develop
Version 0.2.0
- Loading branch information
Showing
21 changed files
with
1,005 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
# cfGUI | ||
A simple GUI library for M5Stack (ESP32) | ||
|
||
This library is intended to run on M5Stack development board (http://www.m5stack.com/). However, it should be easy to port it to any other board. | ||
This library is intended to run on M5Stack development board (http://www.m5stack.com/), base on ESP32. | ||
|
||
However, it should be easy to port it to any other board with an LCD screen and 3 physical buttons. | ||
|
||
It's composed of a simple hierarchy of graphical widget that can be drawn on screen. | ||
The following widgets have been created so far: | ||
- Screen | ||
- Screen and AppScreen (screen with a top bar and a bottom bar) | ||
- Bar | ||
- StatusBar (with uptime, current time and wifi signal) | ||
- Button | ||
- Mosaic of widge | ||
|
||
![Example picture of cfGUI running on a M5Stack board](https://mastodon.codingfield.com/media/oXYl3M6SVqcpn2iefrs) | ||
- StatusBar (Bar with uptime, clock and Wifi signal) | ||
- ButtonInfoBar (display the function of the physical button) | ||
- Button, UpDownButton | ||
- Mosaic of widgets | ||
|
||
![Example picture of cfGUI running on a M5Stack board](https://mastodon.codingfield.com/system/media_attachments/files/000/207/740/original/dbacf24f45561e5c.jpg) | ||
|
||
# How To (Platform.io) | ||
To use this library with your platform.io project, simply clone or download the library into the directory 'lib' of your project. | ||
Then, you just need to include the headers (e.g. #include <Screen.h>) and write some code. | ||
|
||
Look at examples if you need some inspiration ;-) | ||
|
||
# Todo | ||
- Remove hard-coded values to make the lib more flexible | ||
- <s>Remove hard-coded values to make the lib more flexible</s> | ||
- Add new widgets | ||
- Better 'focus' management | ||
|
||
# Changelog | ||
## 0.2.0 | ||
- Change default font (looks better) | ||
- New widgets (AppScreen, StatusBar, ButtonInfoBar, UpDownButton) | ||
- Improved mosaic (the size and position of the widget is not hard-coded anymore) | ||
- Global improvements | ||
|
||
## 0.1.0 | ||
- First version of the library, with basic functionalities | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=cfGUI | ||
version=0.1 | ||
version=0.2.0 | ||
author=Jean-François Milants <[email protected]> | ||
maintainer=Jean-François Milants <[email protected]> | ||
sentence=cfGUI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "AppScreen.h" | ||
#include <Bar.h> | ||
|
||
using namespace Codingfield::UI; | ||
|
||
AppScreen::AppScreen(Size size, Color color) : Screen(size, color) { | ||
|
||
} | ||
|
||
AppScreen::AppScreen(Size size, Color color, Bar* topBar, Bar* bottomBar, Widget* centreWidget) : Screen(size, color), topBar{topBar}, bottomBar{bottomBar}, centreWidget{centreWidget} { | ||
if(topBar != nullptr) { | ||
topBar->SetParent(this); | ||
topBar->SetPosition(Point(0,0)); | ||
topBar->SetSize(Size(this->GetSize().width, barHeight)); | ||
AddChild(topBar); | ||
} | ||
|
||
if(bottomBar != nullptr) { | ||
bottomBar->SetParent(this); | ||
bottomBar->SetPosition(Point(0, this->GetSize().height-barHeight)); | ||
bottomBar->SetSize(Size(this->GetSize().width, barHeight)); | ||
AddChild(bottomBar); | ||
} | ||
|
||
if(centreWidget != nullptr) { | ||
Point centerPosition; | ||
centerPosition.y = position.y + ((topBar != nullptr) ? topBar->GetSize().height : 0) + padding; | ||
centerPosition.x = position.x + padding; | ||
|
||
Size centerSize; | ||
centerSize.height = size.height - (((bottomBar != nullptr) ? bottomBar->GetSize().height : 0) + ((topBar != nullptr) ? topBar->GetSize().height : 0) + padding); | ||
centerSize.width = size.width; | ||
|
||
centreWidget->SetParent(this); | ||
centreWidget->SetPosition(centerPosition); | ||
centreWidget->SetSize(centerSize); | ||
AddChild(centreWidget); | ||
} | ||
} | ||
|
||
void AppScreen::OnButtonAPressed() { | ||
if(centreWidget != nullptr) | ||
centreWidget->OnButtonAPressed(); | ||
} | ||
|
||
void AppScreen::OnButtonBPressed() { | ||
if(centreWidget != nullptr) | ||
centreWidget->OnButtonBPressed(); | ||
} | ||
|
||
void AppScreen::OnButtonBLongPush() { | ||
if(centreWidget != nullptr) | ||
centreWidget->OnButtonBLongPush(); | ||
} | ||
|
||
void AppScreen::OnButtonCPressed() { | ||
if(centreWidget != nullptr) | ||
centreWidget->OnButtonCPressed(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <Screen.h> | ||
|
||
namespace Codingfield { | ||
namespace UI { | ||
class Bar; | ||
class AppScreen : public Screen { | ||
public: | ||
AppScreen(Size size, Color color); | ||
AppScreen(Size size, Color color, Bar* topBar, Bar* bottomBar, Widget* centreWidget); | ||
|
||
virtual void OnButtonAPressed() override; | ||
virtual void OnButtonBPressed() override; | ||
virtual void OnButtonBLongPush() override; | ||
virtual void OnButtonCPressed() override; | ||
|
||
private: | ||
Bar* topBar = nullptr; | ||
Bar* bottomBar = nullptr; | ||
Widget* centreWidget = nullptr; | ||
int32_t padding = 5; | ||
int32_t barHeight = 25; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.