GithubHelp home page GithubHelp logo

frang75 / nappgui_src Goto Github PK

View Code? Open in Web Editor NEW
462.0 462.0 45.0 6.04 MB

SDK for building cross-platform desktop apps in ANSI-C

Home Page: https://www.nappgui.com

License: MIT License

C 57.75% CMake 2.45% C++ 29.78% Objective-C 10.01%
c cairo cocoa cross-platform cross-platform-app cross-platform-gui gdi-plus gtk3 quartz win32

nappgui_src's People

Contributors

frang75 avatar g8kig avatar glitchedpolygons avatar mrstevns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nappgui_src's Issues

fseek, ftell?

From my point of view it's a very good idea to also include basic features in NAppGUI usually found in the C standard library to avoid compiler/platform dependencies.

But I didn't find fseek nor ftell (or similar functionality), neither in Osbs nor in Core. Can you give me a hint please how I'm supposed to set a file position using NAppGUI?

Build errors with CMake >= 3.21.2

Hello! I'm excited to try this library out, but can't get the demos to build on my macOS system.

I followed the macOS quick start instructions here. First, I get the CMake output as shown in this gist. Looks fine aside from the upfront warning about the CMake version (I'm using the latest 3.21.2).

Then, running xcodebuild, I get the output in this other gist, with the first error shown on line 615.

Error seems to emanate from draw2d_osx.ixx.

Unfortunately, I'm not much of a macOS developer, so I'm not sure how one would even go about correcting this! (I guess I need to learn 😄)

Thanks for any help on this!

Not able to make the Xcode project

Hi there... trying quickly I get this error:

MBP:nappgui_build oldes$ cmake -G "Xcode" ../nappgui_sdk/src
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -- broken
CMake Error at /usr/local/Cellar/cmake/3.9.5/share/cmake/Modules/CMakeTestCXXCompiler.cmake:44 (message):
  The C++ compiler
  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /Users/oldes/GIT/nappgui_build/CMakeFiles/CMakeTmp

  

  Run Build Command:"/usr/bin/xcodebuild" "-project"
  "CMAKE_TRY_COMPILE.xcodeproj" "build" "-target" "cmTC_cb4fb"
  "-configuration" "Debug"

  note: Using new build system

  2021-09-09 23:00:33.422 xcodebuild[33634:1747991] unable to create build
  operation: Error Domain=com.apple.xcbuild Code=1 "unknown error while
  handling message: missingTarget(guid:
  "1aba590e2e5c6a1873bb5978a646d793204a9ea3f8464f305b840440404ef12c")"
  UserInfo={NSLocalizedDescription=unknown error while handling message:
  missingTarget(guid:
  "1aba590e2e5c6a1873bb5978a646d793204a9ea3f8464f305b840440404ef12c")}

  

  ** BUILD FAILED **
MBP:nappgui_build oldes$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
MBP:nappgui_build oldes$ xcodebuild -version
Xcode 11.0
Build version 11A420a

Issues with High Contrast themes on Windows

First of all thank you for your work! I really like your library. Easy API, well documented, and the statically linked size is incredible comparted to some other toolkits! So far i have only two problems.

The first:
There are issues, when windows high contrast mode is used, which some people like to use and some vision-impaired people actually need to use. If apps are started when high contrast mode already activated, some controls like Edit, ListBox, TextView, TableView are not drawn at all. On the other hand, when enabling the high contrast mode after the apps are already running, the controls adapt somehow to the new colors but not fully correct. I'll attach two screenshots with some of the demo apps.

I assume it would be similar with 3th party themes, like WindowBlinds.
I think as an accesibility setting at least the high contrast mode should work.

Screenshot 2023-02-24 091207

Screenshot 2023-02-24 090839

Creating a "flyout" window

I'm using the term "flyout" not really knowing if that's the correct word, but what I mean is a window that usually has no borders and can be closed simply by clicking outside the window bounds. Think of the the dropdown list in a ComboBox, for instance, or a popup context menu. Or if you've used a date or time picker, the picker window pops up, but if you don't want to enter anything, you can just click somewhere else and it will go away.

Is this possible to do, given the current start of NAppGUI?

Usage of window_cursor with user defined images

Hello, I wanted to set an animated cursor during a computation loop. I have set several images that I use to display the cursor. I first set the cursor with the first image and then call osapp_task to manage the computation:

osapp_task (app, 0.5f, loop_start, loop_update, loop_end, App);

I change the cursor image in function loop_update. The first call to window_cursor, before calling osapp_task, works fine: the cursor is changed and the update is applied immediately. Subsequent calls to window_cursor in update function don't work as well: the cursor is changed but I have to move manually the mouse to see the change applied (tested on Windows 10).

Is there anything I can do to force the update? Or is there another way to animate a slider?

organize public headers into a single include directory

First of all, thank you for developing this! I was looking for a lightweight toolkit that I can use instead of Qt and I think I've found it with NAppGUI.

Anyways I'm working on writing some bindings for Nim for this toolkit and I've come across a couple issues doing so with the way the public headers include headers from other libraries.

For example, draw2d/draw2dall.h includes geom2d/geom2dall.h via a simple #include "geom2dall.h", which is doable because src/geom2d is in the search path when compiling. Using this style of includes makes it hard to install this library in the system (you would have to use a flat directory structure), and also when integrating it in other projects.

I would suggest having all public headers be located in a include folder, ie include/nappgui, so that this folder alone can be copied into the system's include directory when installing this library. With this, only that include directory needs to be added to the search path when compiling. Private headers can remain where they are.

That way instead of:

#include "geom2dall.h"

You would use:

#include "nappgui/geom2d/geom2dall.h"
// or even better:
// #include "nappgui/geom2d.h"

This would make things easier when binding to other languages, and being able to use the toolkit as a traditional library would be nice too for package maintainers.

UPDATE: I made a fork and added a commit that just adds a copy of all public headers into a top level include directory.

Dynamically unloading GUI elements

Hello,

I'm working on a application that requires some dynamic UI behavior.
In the context of this application this means adding and removing (not hiding but outright destroying) arbitrary GUI elements to a existing (and visible) window.

Looking at the documentation and going through the examples I haven't found a way to achieve this.

Is this something that is doable?

Thank you!

Compilation success with MSYS2/MinGW

I was able to build the DLL with Rochus Keller's project files with MinGW on 64bit Windows 10 version with some changes:

Probably misspelling in MinGW headers:
+++ b/src/draw2d/win/dctx_win.cpp
-            ctx->lbrush->RotateTransform(ctx->gradient_angle);
+            ctx->lbrush->RotateTranform(ctx->gradient_angle);
Did not find headers:
+++ b/src/draw2d/win/draw2d_win.ixx
-#include <gdiplus.h>
-#include <gdipluspixelformats.h>
+#include <gdiplus/gdiplus.h>
+#include <gdiplus/gdipluspixelformats.h>
Not sure why this failed. Commented out for now:
+++ b/src/draw2d/win/osimage.cpp
-    status = bitmap->Save(stream, &clsid);
+    //status = bitmap->Save(stream, &clsid);
i64 prefix is a Microsoft extension. Replaced with LL:
+++ b/src/osbs/win/btime.c
-#define EPOCHFILETIME (116444736000000000i64)
+#define EPOCHFILETIME (116444736000000000LL)
Error due to encoding:
+++ b/src/osgui/win/osedit.c
-        SendMessage(edit->control.hwnd, EM_SETPASSWORDCHAR, (WPARAM)L'•', (LPARAM)0);
+        SendMessage(edit->control.hwnd, EM_SETPASSWORDCHAR, (WPARAM)L'#', (LPARAM)0);
Not sure why this failed. Edit fixed the problem:
+++ b/src/osgui/win/oswindow.c
-    enum gui_role_t role;
+    gui_role_t role;
Processor type not picked up. Temporary work around:
+++ b/src/sewer/arch.hxx
-        #error Unknown processor
+        #define __x64__
Compiler not supported. Temporary work around:
+++ b/src/sewer/win/bmem_win.c
 #if !defined (_MSC_VER)
-#error Unknow compiler
 #endif

The DLL built fine and worked with the ported Oberon+ examples.
The edits here are minor and it look feasible to to support MinGW in the future.

How to create and build a single new project instead of re-building the whole package

Following the instruction I successfully create my new project and built and ran by running command line "cmake ...." .Great.
However it seems everytime it rebuild the whole package,the libs,the demo apps,the how-to examples,and my small test program.

Is there any plain and simple way to create a new project and then run cmake or vc compiler to just compile and build the specific project(actually just a very small program) I created?

Thanks in advance.

How to working with the third-party static library(Ex: libusb-1.0.lib)

Hello Frang:
I'm new to NAppGUI and CMake. about below question I can't find any answer on Google.
When add new project by command "desktopApp("TestUSB" "Ben/TestUSB" "" NRC_NONE)", and add the "target_link_libraries(TestUSB usb-1.0)" to CMakeLists.txt file on my new project folder , but this file will be updated automatic every time when CMake configure.
How does the best way the NAppGUI working with a third-party library (Example; libusb-1.0.lib libusb-1.0.a ), if I don't want re-compiler the third-party library source code?

Status of HiDPI / Dark theme support?

Does this library support dark theme or HiDPI?
The Linux version is based on GTK+, the support for dark theme and HiDPI should come out of the box.
The Windows version is based on Win32 API, and we know Win32 API does not support those features "out of the box".
Does this library have already do any special work (or hook or hack) to support those features on Windows? If not so, are there any plan on it?

Minor issue on MacOS Apple Silicon - slider mouse tracking incorrect

First of all, I love this project. I ran some of the demo apps on MacOS and the slider control has a bug where the mouse tracking / slider thumb tracking are inverted... You click a slider thumb button, start dragging to the right, the nApp code places the slider value at the opposite value (e.g. say you click on position 0, the start of a slider - the code thinks you clicked at 100 and jumps the slider to 100... then when you slide to position 1, it jumps the tracker to position 99 and so on...). Prob just a simple (neg / pos value calculation bug or something like in the code) fix. When I have time and get the code built on Mac I'll look into it myself.

Unrelated note, I tried to build on Mac (M1 chip) with Xcode installed and Cmake installed and the CMake build spit out "Can't find compiler" type error. I'll open an issue about it some other day. But, once I get that sorted out so I can build run debug code. I'm sure I can pretty quickly find the issue with the slider tracking and offer some insight on it.

Thanks for this project!! It's like reading my entire career history of everything tool/framework I've either tried to use or tried to build myself bc I hated most of the cross platform tools and then I finally found this project... This is EXACTLY what I've been looking for, for years!! BRAVO for great work! Code is super clean... I don't know jack sht about CMake otherwise I could have figured out how to build it. But, I've read a lot of the code and I love it... (old school Win32 API / C developer and recently been learning and doing some Mac coding but with Swift which I hate...)

support golang?

hi, maintainer, are there any plans to support golang?

Have a nice day :-)

Unexpected Asserts on SplitView

This library looks / seems extremely promising... It's very clean and it appears to be very well thought out.

Right now, I'm experimenting with the API to see how well it will work with some rendering related tools. So far, it's looking promising but I've ran into a couple of issues that are triggering unexpected asserts. My test code is below:

MainWindow::MainWindow(Application * application)
{
	auto describePanel_Color = [this](std::string const & title, Pixel::packedRGBA const & color)
	{
		Label * titleLabel = label_create();
		label_text(titleLabel, title.c_str());

		Label * redLabel = label_create();
			label_text(redLabel, "Red:");
		Slider * redSlider = slider_create();
			slider_value(redSlider, .5f);
		//	slider_OnMoved(redSlider, listener(app, i_OnAngle, App));

		Label * greenLabel = label_create();
			label_text(greenLabel, "Green:");
		Slider * greenSlider = slider_create();
			slider_value(greenSlider, .5f);
		//	slider_OnMoved(greenSlider, listener(app, i_OnScale, App));

		Label * blueLabel = label_create();
			label_text(blueLabel, "Blue:");
		Slider * blueSlider = slider_create();
			slider_value(blueSlider, .5f);
		//	slider_OnMoved(blueSlider, listener(app, i_OnScale, App));

		Layout * layout = layout_create(5, 4); // <--- why does ncols need to be >= 5. I'd expect 2 to be valid
			layout_label(layout,  titleLabel,  0, 0);
			layout_label(layout,  redLabel,    0, 1);
			layout_slider(layout, redSlider,   1, 1);
			layout_label(layout,  greenLabel,  0, 2);
			layout_slider(layout, greenSlider, 1, 2);
			layout_label(layout,  blueLabel,   0, 3);
			layout_slider(layout, blueSlider,  1, 3);

			layout_halign(layout, 0, 1, ekRIGHT);
			layout_halign(layout, 0, 2, ekRIGHT);
			layout_halign(layout, 0, 3, ekRIGHT);

			layout_hmargin(layout, 0, 10);
			layout_hmargin(layout, 1, 10);

		Panel * panel = panel_create();
			panel_layout(panel, layout);

		return panel;
	};

	auto describePanel_Main = [&]()
	{
		Label * label = label_create();
			label_text(label, "Hello!, I'm a label");

		Button * button = button_push();
			button_text(button, "Click Me!");
			button_OnClick(button, IListen(this, MainWindow, onButton));

		m_textView = textview_create();

		m_view = view_create();
			view_size(m_view, s2df(1024, 768));
			view_OnDraw(m_view, IListen(this, MainWindow, onDraw));

		Panel * panelColor0 = describePanel_Color("color0", m_color0);
		Panel * panelColor1 = describePanel_Color("color1", m_color1);

		// attempting to chain together multiple SplitView(s) to
		// create 3 resizable columns						<------
		//	||XXXXXX||XXXXXX||XXXXXX||
		//	||XXXXXX||XXXXXX||XXXXXX||
		//	||XXXXXX||XXXXXX||XXXXXX||
		//	||XXXXXX||XXXXXX||XXXXXX||

		SplitView * split1 = splitview_vertical();
			splitview_view( split1,  m_view);
			splitview_panel(split1, panelColor1);
			splitview_size(split1, s2df(800, 480));
			splitview_pos( split1, 0.25f);

		SplitView * split0 = splitview_vertical();
			splitview_panel(split0, panelColor0);
			splitview_split(split0, split1);
			splitview_size(split0, s2df(400, 480));
			splitview_pos( split0, 0.5f);

		Layout * layout = layout_create(1, 1);
			layout_splitview(layout, split0, 0, 0);

		Panel * panel = panel_create();
			panel_layout(panel, layout);

		return panel;
	};

	m_window = window_create(ekWINDOW_STDRES);
		window_panel(m_window, describePanel_Main());
		window_title(m_window, "Hello, C++!");
		window_origin(m_window, v2df(500, 200));
		window_OnClose(m_window, IListen(application, Application, onClose));
		window_show(m_window);
}

the first issue is in describePanel_Color where I'm expecting to be able to use layout_create(2, 4) but instead anything with columns less than 5 causes an assert.

the second issue is when attempting to chain multiple horizontal SplitView(s) together to create 3 resizable columns (data | view/texture | data). Can SplitViews even be combined in this way?

Thanks!

Any Database Support Like SQLite?

Greetings!
I'm kindly asking that does NAPPGUI has any support for common databases like SQLite, MySQL, MSSQL Server and others? If so, how to connect to them and do CRUD?

Thanks

TableView

Hi,

I am looking to port a java application to nappgui, but the main part of the program has a table that has editable elements. I was wondering the status / progress of the TableView code and what all needs done before its functional. I have no problems contributing time and code to make it work either.

Thanks

right Shift + Tab doesnt move focus to previous control

Tested on windows 10,
If I press the left side Shift + Tab the focus does move to previous control but shouldn't right side shift + Tab mimic the same, right now it's just moving to next element like as if right shift isn't pressed at all.

GTK3 Window dimensions with Wayland

The final size of NAppGUI Window in GTK is made in:
https://github.com/frang75/nappgui_src/blob/main/src/osgui/gtk3/oswindow.c line 772, calling to
gtk_widget_set_size_request(window->control.widget, (gint)width, (gint)height);

The width and height values have been calculated by NAppGUI compositor.

With Wayland backend, the window is sized slightly smaller than the width and height values. Specifically, 50 pixels less in width and 89 pixels less in height. With x11 backend the window is sized correctly.

Study the case to determine if anything can be done within the NAppGUI code to make this work correctly in Wayland. Obviously, using width + 50, height + 89 if we detect the Wayland backend seems to solve the problem.

At the moment, NAppGUI forces to use X11 as GDK_BACKEND in hopes of solving this problem.

hello_gtk3

dice_gtk3

drawhello_gtk3

urlimg_gtk3

guihello_gtk3

Modal Window Close Crash.

Hello,

First thing I would like to mention, I really enjoy this library! Imo, easy to grasp and not really bloated like other libraries I've used prior.

I've came across an issue on Windows. Whenever I would close a second window, using the [X] on the title bar, it would crash the whole program. After looking into the debug, it crashes at the strcmp between "bool_t" and an unknown value with "0x3f3f3f3f3f3f3f3f", and looking even more back the event->return_type inside event_result_imp() is also set to "0x3f3f3f3f3f3f3f3f".

The good news, if I were to not use the [X] on the title bar, It wouldn't crash (eg. a push button, set to destroy the modal window).

I have modified the "HelloWorld" main.c files to show you what I've encountered. I made sure that I did a fresh compilation of nappgui before sending this issue (using vs2022):
win32_modal_crash.zip

I also sent two pics (the actual modal window in where it would crash, and the event_result_imp 0x3f3f.)
Hopefully this crash is easily replicated on your end. [Or hopefully this is just my machine and everything is truly ok, that works too lol]

GitHub Sponsors

Could you set up GitHub Sponsors, this project is really cool and I would like to support it.

TreeView

First of all congratulations for your work. It is really very impressive.
The TableView component added in version 1.3 works fine (checked only on Windows).
Do you have any plans to add a TreeView component based on the same concepts?

Adjusting font for all controls on a form

The fonts on all the samples look very small to me & I would love to be able to adjust that. It would be interesting to take the GuiHello sample and add a slider to adjust the font size of all the controls in the window. Is that possible?

Building shared libraries?

This is a great library and there is definitely a need for it; thank you very much for open-sourcing it!

I explored the code and made some experiments with the build system. My approach was to work with the standard features of cmake and build a dynamic library instead of the static ones. However, you seem to have built your own build system with the cmake language, and before I study all the code I wanted to ask first.

Are there provisions to build a shared library on all platforms instead of the static libraries? From an architectural perspective, is there anything against dynamically binding your code to an application?

I also tried to build the libraries without the inet module to get rid of the libcurl dependency; but when deleting the corresponding line in the top level CMakeLists.txt and all exes assumingly depending on it I still get "ERROR- libCURL is required" and "missing: CURL_LIBRARY CURL_INCLUDE_DIR" from cmake.

I was able though to create the attached (quick and dirty) qmake project which generates a shared library without the inet module which I now try to use with my Oberon+ FFI (see https://github.com/rochus-keller/Oberon/); currently it works on Linux i386. But of course it would be more elegant to use your build system.
NAppGUI.pro.gz
../todo/res_assert.h:
res_assert.h.gz

How to fix memory leaks

I run an app on Windows with a simple gui (basically a main window with a menubar, 2 buttons and a textview). At the end of execution I get some memory leaks in the heap memory statistics. The dump shows blocks addresses and data. But i have no ideas where to look to fix those leaks. I use the Nappgui heap functions for only one structure in the gui part of the application. I don't use nappgui functions in the non-gui part of the application. I alse checked the application with Visual Leak Detector, which says No memory leaks detected.

nrc (NAppGUI ressource compiler)

Hi Francisco,

when cloning your SDK we can find many relevant variations of the nrc executables within the folder "prj/script" for linux, macos and windows.
What is the reason that your SDK ships those executables?
Why are they not compiled during the cmake build process by the available sources?
For me as a "beginner" C Programmer and also beginner "cmake" user it seemed at first that they were maybe compiled by yourself and you maybe just have forgotton to clean them out in your publicly available github project, but then I realized that they are not even overwritten by cmake build process either.

Best regards Nejat

How to animate text in a TextView control

hi i am getting issues when i remove the bthread_sleep the uptime in os_task is not effect to delay the update function is my issue or is api issues thanks this is my code .

static uint32_t i_m(App *app)
{
// uint32_t c;
// real32_t ipf;
//
// for(c=0;c <= 100;c++)
// {
// bthread_sleep(5);
// app->i = c;
// for (ipf = .0f; ipf <= .99f; ipf += .1f) {
// // code here
// bthread_sleep(5);
// app->pos = ipf;
//
// }
// }
for(app->i=0;app->i <= str_len_c(app->str->data);app->i++)
{
bthread_sleep(100);
}

return (uint32_t)app->i;

}

static void i_on(App *app)
{

// progress_value(app->spr,app->pos);
// textview_printf(app->text,"update : %d\n",app->i);
// textview_scroll_down(app->text);
if (app->on == TRUE)
{

       textview_printf(app->text,"%c",app->str->data[app->i]);
       if (app->i == str_len_c(app->str->data))
       {
           app->on = FALSE;
           app->i = 0;
           
           
       }
 }

}

static void i_end(App *app,const uint32_t rvalue)
{

if (rvalue == str_len_c(app->str->data)) {
    textview_printf(app->text,"Task completed successfully\n");
}
else {
        textview_printf(app->text,"Task failed with error code %d\n", rvalue);
    }

}
/*
The function inits is called by the runme function, it clears the text view using the textview_clear function and calls the get_ip function to retrieve the IP address and sets app->on to TRUE.
*/
static void inits(App *app,Event *e)
{

//cell_enabled(app->abt, FALSE);
app->on = TRUE;
get_ip(app);
osapp_task(app,.04,i_m,i_on,i_end, App);
unref(e);

}

Applications not sized correctly Ubuntu 18.04.

For example the hello demo app only displays the title bar.
Build from source is successful.
I am surprised the application can not be resized/maximised either.
Otherwise nice job
Screenshot from 2022-04-10 18 57 11
Screenshot from 2022-04-10 18 57 50
!

How to correctly parse a JSON

Screenshot 1401-11-04 at 13 08 48

hi i want to access the field temp_C in json always getting empty value request using the code below :

/*

*/

/* NAppGUI Hello World */

#include "nappgui.h"
#include "inet.h"
#include "httpreq.h"
#include "json.h"

typedef struct _app_t App;
typedef struct _currentCondition_t CurrentCondition;
typedef struct WeatherDesc {
char_t value[20];
} WeatherDesc;

typedef struct WeatherIconUrl {
char_t value[100];
} WeatherIconUrl;

struct _currentCondition_t {
uint32_t FeelsLikeC;
uint32_t FeelsLikeF;
uint32_t cloudcover;
uint32_t humidity;
char_t localObsDateTime[20];
char_t observation_time[20];
real32_t precipInches;
real32_t precipMM;
uint32_t pressure;
real32_t pressureInches;
uint32_t temp_C;
uint32_t temp_F;
uint32_t uvIndex;
uint32_t visibility;
uint32_t visibilityMiles;
uint32_t weatherCode;
WeatherDesc weatherDesc[1];
WeatherIconUrl weatherIconUrl[1];
char_t winddir16Point[5];
uint32_t winddirDegree;
uint32_t windspeedKmph;
uint32_t windspeedMiles;
};

struct _app_t
{
Window *window;
TextView *text;

};
/---------------------------------------------------------------------------/

/---------------------------------------------------------------------------/

static void i_OnButton(App *app, Event *e)
{
Stream *gdata = NULL;
CurrentCondition *json=NULL;

Http *ht = http_secure("wttr.in",443);
if(http_get(ht, "/spain?format=j1", NULL, 0, NULL) == TRUE)
{
    //app->buff = str_printf("%d\n",http_response_status(ht));
    textview_printf(app->text, "%d\n",http_response_status(ht));
    gdata = stm_memory(4096);
    if (http_response_body(ht, gdata, NULL) == FALSE)
        stm_close(&gdata);
}
http_destroy(&ht);
dbind(CurrentCondition, uint32_t, temp_C);
json = json_read(gdata,NULL, CurrentCondition);
textview_printf(app->text,"The temp_c : %d\n",json->temp_C);
json_destroy(&json, CurrentCondition);
unref(e);

}
static Panel *i_panel(App *app)
{
Panel *panel = panel_create();
Layout *layout = layout_create(1, 3);
Label *label = label_create();
Button *button = button_push();
TextView *text = textview_create();
app->text = text;
label_text(label, "Hello!, I'm a label");
button_text(button, "Click Me!");
button_OnClick(button, listener(app, i_OnButton, App));
layout_label(layout, label, 0, 0);
layout_button(layout, button, 0, 1);
layout_textview(layout, text, 0, 2);
layout_hsize(layout, 0, 250);
layout_vsize(layout, 2, 200);
//layout_hsize(layout, 2, 200);
layout_margin(layout, 5);
layout_vmargin(layout, 0, 5);
layout_vmargin(layout, 1, 5);
panel_layout(panel, layout);
return panel;
}

/---------------------------------------------------------------------------/

static void i_OnClose(App *app, Event *e)
{
osapp_finish();
unref(app);
unref(e);
}

/---------------------------------------------------------------------------/

static App *i_create(void)
{
App *app = heap_new0(App);
Panel *panel = i_panel(app);
app->window = window_create(ekWINDOW_STD | ekWINDOW_RESIZE);
window_panel(app->window, panel);
window_title(app->window, "Hello, World!");
//window_size(app->window,s2df(800.0,400.0));
window_origin(app->window, v2df(500, 200));
window_OnClose(app->window, listener(app, i_OnClose, App));
window_show(app->window);
return app;
}

/---------------------------------------------------------------------------/

static void i_destroy(App **app)
{
window_destroy(&(*app)->window);
heap_delete(app, App);
}

/---------------------------------------------------------------------------/

#include "osmain.h"
osmain(i_create, i_destroy, "", App)

Screenshot 1401-11-04 at 23 45 08

curl --silent wttr.in/spain?format=j1 | grep -i -o ""temp_c":.*[0-9]" --color=auto | sed 's/"//g'

I am getting issues compiling my source code on ubuntu 22.X

hi @frang75 I am getting this is on ubuntu how I fix it :
usr/bin/ld: /home/parallels/nappgui_sdk/lib/gcc11_gtk3_x64/Debug/libsewer.a(bmath.cpp.o): undefined reference to symbol 'exp@@GLIBC_2.29'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [demo/hello/CMakeFiles/HelloWorld.dir/build.make:111: demo/hello/Debug/HelloWorld] Error 1
make[1]: *** [CMakeFiles/Makefile2:358: demo/hello/CMakeFiles/HelloWorld.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Screenshot 2022-12-20 at 8 05 08 PM

Build for MacOS

Does anyone know how to correct the following?

What I ran >> cmake -G Xcode -S ./src -B ./build

Output >> -- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:5 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:5 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!

How do I setup Xcode / C compiler on MacOS to build the project? Thanks

Accessing mysql/mariadb server

I could not figure out how to access my mariadb server with the NAppGUI SDK.

[my actual situation]
I already have installed the required mariadb packages (libmariadb-dev and libssl-dev) for my linux distro (Linux Mint 21.1). Therefore mysql.h is located in "/usr/include/mariadb/mysql.h".

[Enhancement maybe? :-) ]
It would be verry nice if I could for example just edit the main "nappgui_src/src/CMakeLists.txt" file to benefit from your excellent super build pattern.

[final roundup question]
What would be your advice as a best practice if I want my napp gui application let access a mysql/mariadb server?

Thank you in advance,
Best regards Nejat

Output unicode (utf8) to console

I try output unicode (utf8) to console like a

const char_t *line = "HI ПРИВЕТ";
String *line_s = str_c(line);
bstd_printf("%s\n", line_s);
// Output
// HI ╨Я╨а╨Ш╨Т╨Х╨в

At the same time, everything is fine (unicode utf8 is OK) in the GUI label
изображение

How correct out unicode to console?
OS Windows 10. Set chcp 65001 in console

Creating a custom control

How would I go about creating a reusable custom control? For instance, if I wanted to take the "IP Address" sample and wrap those 4 textboxes, character filtering, and error checking into a single control that could be added to a window in a single step, how would I do that?

C++ wrapper and some notes

Nice project! I was experimenting with the examples and started writing some C++ wrapper classes, similar to WTL (http://wtl.sourceforge.net/)

I have a fork with my changes and a new hello world C++ example: https://github.com/ragsaq/nappgui_src

My suggestions are:

  • try and refactor the CMakeLists.txt so that the includes use #include <header> instead of #include "header"
  • try and get the library included in vcpkg: https://github.com/microsoft/vcpkg
  • put all includes in a nappgui folder, to avoid conflicts: #include <nappgui/gui.hxx>
  • use editorconfig (https://editorconfig.org/) or clang-format. some of the files have mixed tabs/spaces. it would help to keep it consistent and would help contributors to use the same style.

once the library is included in vcpkg my C++ wrappers would integrate better (right now, I just copied the headers to the same folders)

the hello world example I did compiles to around the same size to the C API. each class just stores a pointer, so it's cheap to copy by value and wrap existing pointers/interface with the C API.

Quick Start on Windows

Hi.
A beautiful effort is being put on this library.
I really appreciate the goal and vision of this project.

Trying to give it a first try, by following the simple-to-read guide: https://nappgui.com/en/start/quick.html
I struggled a bit with it.
It wasn't as straight forward as it first seemed by reading.

While running cmake -S ./src -B ./build, it won't just compile, Unknown compiler and such.
Previous steps were required.

The first thing to learn is the incompatibility with MSYS2/MinGW.
Therefore, I had to download 10Gb of Visual Studio Community, which is over bloated to my taste.
Then cmake for windows as instructed, avoiding the use of msys2 installed one.

The second thing to learn, not being a CMake expert, is that it should be setup with cmake-gui. Picture attached.
Or alternatively, with this command. ref:

cmake -G "Visual Studio 17 2022" -A Win32 -T v143

So the sequence of the guide is missing one step

git clone --depth 1 https://github.com/frang75/nappgui_src.git
cd nappgui_src
cmake -G "Visual Studio 17 2022" -A Win32 -T v143
cmake -S ./src -B ./build
cmake --build ./build --config Debug

Once compiled, I don't get the expected demo/example binaries in the Debug folder.
And I got to this point. Not sure why yet.

I downloaded the example binaries and they look very nice.
I really like how they are barely 400kb.

The third thing to learn, I readed somewhere about a command msbuild NAppGUI.sln which is called from src folder.
When VS was installed it didn't placed anything on the path, so I had to manually add it. C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin, after that, restarted the CMD Console and went back to the folder.

cd src
msbuild NAppGUI.sln

Finally, got the examples binaries in src/Debug/bin/...
Buttttt, they are about 3Mb, not 400kb.
I guess that some deep compiler optimization is required and still missing on the sequence.

Also, I haven't opened the +10Gb of Visual Studio.
Is it really required?

Hope this feedback helps.
Kind regards,

image
image

Binary files in the source code

A lot of effort seems to have put into this project. I looks interesting and I would like to try it out, however when looking at the source code, I found binary files for various operating systems in subdirectories of the directory "prj". E.g. "prj/script/win/x64/nrc.exe", a file which even got 2 warnings when analyzing it via virustotal.com. I admit some false positives are normal. I want to trust the project, however I don't know why those binary files are there nor what they do, and why they need to be there in binary form instead of source code. Could you clarify it? Would it be possible to provide the source code? I am concerned about running binary files of unknown origin. Thanks for understanding.

onwindow_show function does exist

hi i want to make a delay 2 seconds between 1 to 100 and begin to print the numbers on the textview when the window finish to show any idea how ?

TableView scrollbar always visible

And here the second issue i got:

The TableView has the vertical scrollbar always visible.
No matter how big the TableView is or how less entries there are, you can scroll one entry down.
And the vertical scrollbar shows before it should, like if you don't let a gap with the same width as the already visible scrollbar..

And as an enhancement it would be nice if the TableView columns could scale automatically to fit the content and if we could specify one or more columns to automatically expand when the windows gets resized.

Screenshot 2023-02-24 101030

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.