malisipi / mui

A Cross-Platform UI Library
https://malisipi.github.io/mui/
Apache License 2.0
95 stars 9 forks source link

mui.v and some examples makes this notice/error #38

Closed max00217 closed 3 months ago

max00217 commented 5 months ago
~/.vmodules/mui/mui.v:306:50: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe`
  304 | 
  305 | pub fn (mut app Window) set_viewarea (x int, y int) {
  306 |     app.get_object_by_id("@scrollbar:horizontal")[0]["vlMax"].num=x+app.x_offset+app.xn_offset
      |                                                     ~~~~~~~~~
  307 |     app.get_object_by_id("@scrollbar:vertical")[0]["vlMax"].num=y+app.y_offset+app.yn_offset
  308 | }
~/.vmodules/mui/mui.v:307:48: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe`
  305 | pub fn (mut app Window) set_viewarea (x int, y int) {
  306 |     app.get_object_by_id("@scrollbar:horizontal")[0]["vlMax"].num=x+app.x_offset+app.xn_offset
  307 |     app.get_object_by_id("@scrollbar:vertical")[0]["vlMax"].num=y+app.y_offset+app.yn_offset
      |                                                   ~~~~~~~~~
  308 | }
notepad.v:69:36: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe`
   67 | mut app:=m.create(m.WindowConfig{ title:"Notepad - MUI Examples", width:400, height: 300, menubar:menubar, file_handler:load_file, ask_quit:true, app_data:&AppData{}, toolbar:25, statusbar:25, draw_mode:.system_native })
   68 | 
   69 | app.get_object_by_id("@toolbar")[0]["bg"].clr = app.color_scheme[0]
      |                                    ~~~~~~
   70 | app.get_object_by_id("@statusbar")[0]["bg"].clr = app.color_scheme[0]
   71 |
notepad.v:70:38: notice: accessing map value that contain pointers requires an `or {}` block outside `unsafe`
   68 | 
   69 | app.get_object_by_id("@toolbar")[0]["bg"].clr = app.color_scheme[0]
   70 | app.get_object_by_id("@statusbar")[0]["bg"].clr = app.color_scheme[0]
      |                                      ~~~~~~
   71 | 
   72 | app.button(id:"open", x:0, y:0 width:25, height:25, text:open_file_emoji, onclick:load_file, icon:true, frame:"@toolbar")
~/.vmodules/mui/types.v:184:43: error: cannot copy map: call `clone` method (or use a reference)
  182 |     click_events    bool            = true                                        //sclke
  183 |     z_index            int            //= 0                                        //z_ind
  184 |     connected_widget    map[string]WindowData    = null_object                                    //cnObj
      |                                                    ~~~~~~~~~~~
  185 |     row_height        int            = -1                                        //row_h
  186 |     view_area        []int            = [-1,-1]                                    //viewA

I tried to test this module, but the following warnings and errors occurred. What steps should be taken to resolve this? (Also, I'm not very familiar with Vlang.)

malisipi commented 5 months ago

Latest V updates was broken the library. However don't worry, I updated the library with latest commit 2ad95f11b476bf968949b5865ec70038445be060. I hope this, fix your issue. If not please let me know. Also I thank you for reporting the issue.

max00217 commented 5 months ago

Thanks! It works without problem in Linux environment. However, when Irun/compile the code in a Windows environment, it returns a warning and doesn't run.

~/.vmodules/mui/native_windows.c.v:9:92: warning: unknown type `C.MENUITEMINFO` (all virtual C types must be defined, this will be an error soon)
    7 | fn C.InsertMenuItem(hmenu C.HMENU, id int, idk_wtd bool, item &C.MENUITEMINFO)
    8 | fn C.TrackPopupMenu(hmenu C.HMENU, int, int, int, int, voidptr, int) int
    9 | fn C.mui_popup_menu_MENUITEMINFO(id int, def bool, disabled bool, checked bool, text &u16) C.MENUITEMINFO
      |                                                                                            ~~~~~~~~~~~~~~
   10 | fn C.DestroyMenu(hmenu C.HMENU)
   11 | fn C.mui_update_window_pos(hwnd voidptr)
malisipi commented 5 months ago

I made a fix about this warning with the latest commit 1c414e421842acb15a840a9b994db98c09ff3fbe. It should be fix the issue. Also if you're trying to use TCC, you should use full WinAPI since V doesn't bundle tose APIs that required by MUI. Not using full API, can trigger the compile error. You can find more details on FAQ section of the library https://github.com/malisipi/mui#faq.

max00217 commented 5 months ago

image Thanks, it works. But, when compiling on Windows, no error occurs, but neither gcc nor tcc creates a binary (.exe) file. Projects other than MUI compile without problems. Full winapi is also installed, and there are no environment variable problems. Is there perhaps something else I can do?

And there is a problem in line 7 of mui/native/windows_core_helper.h where #include <TlHelp32.h> does not actually refer to tlhelp32.h. It appears to be an uppercase/lowercase issue.

malisipi commented 5 months ago

When you change it to lowercase, does it work?

max00217 commented 5 months ago

It works on Linux, but still doesn't work on Windows

malisipi commented 5 months ago

This is a little weird. Some GCC versions can be incompatible with V. Maybe GCC is not working due incompatibly. Also I'm not sure about why TCC is not working.

Can you try the GCC version that is recommended by V?

https://github.com/vlang/v/wiki/Installing-a-C-compiler-on-Windows#mingw

max00217 commented 5 months ago

I was originally thinking of trying it on another computer, but I think it might be a GCC version issue. I will try it and comment again. Thanks as always for your help

malisipi commented 5 months ago

Also I thank you for trying the library.

max00217 commented 5 months ago

I re-downloaded GCC to the latest version... I used GCC 13.2.0 (with POSIX threads) + LLVM/Clang/LLD/LLDB 17.0.6 + MinGW-w64 11.0.1 (UCRT) - release 4: Win64

GCC:

>v -cc gcc main.v
==================
      |                                                                              ^
C:\Users\USER\AppData\Local\Temp\v_0\main.01HMGRY58HDSCG9B6XNV78KJ5N.tmp.c:91714:85: error: incompatible pointer to integer conversion passing 'voidptr' (aka 'void *') to parameter of type 'intptr_t' (aka 'long long') [-Wint-conversion]
 91714 |                 if (!(!atomic_compare_exchange_weak_ptr(((voidptr*)(&ch->adr_written)), &nulladr, ((voidptr)(-1))))) break;
       |                                                                                                   ^~~~~~~~~~~~~~~
C:\Users\USER\AppData\Local\Temp\v_0\main.01HMGRY58HDSCG9B6XNV78KJ5N.tmp.c:1368:42: note: expanded from macro 'atomic_compare_exchange_weak_ptr'
 1368 | #define atomic_compare_exchange_weak_ptr atomic_compare_exchange_weak
      |                                          ^
C:\Users\USER\AppData\Local\Temp\v_0\main.01HMGRY58HDSCG9B6XNV78KJ5N.tmp.c:1326:54: note: expanded from macro 'atomic_compare_exchange_weak'
 1326 |     atomic_compare_exchange_strong(object, expected, desired)
      |                                                      ^~~~~~~
C:\Users\USER\AppData\Local\Temp\v_0\main.01HMGRY58HDSCG9B6XNV78KJ5N.tmp.c:1314:59: note: passing argument to parameter 'desired' here
 1314 |                                                  intptr_t desired)
...
==================
(Use `v -cg` to print the entire error message)

builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

TCC:

> v gcc tcc main.v
v: unknown command `gcc`
Run  v help  for usage.

C:\Users\USER\Downloads\proj>v -cg -cc tcc main.v
C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:721: warning: WINVER redefined
In file included from C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1112:
C:/Program Files/v/thirdparty/sokol/sokol_app.h:7787: warning: implicit declaration of function 'freopen_s'
C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1289: warning: InterlockedIncrement64 redefined
In file included from C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1688:
c:/program files/v/thirdparty/tcc/include/winapi/synchapi.h:13: warning: CreateEvent redefined
In file included from C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1688:
c:/program files/v/thirdparty/tcc/include/winapi/synchapi.h:117: warning: OpenEvent redefined
In file included from C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1688:
c:/program files/v/thirdparty/tcc/include/winapi/synchapi.h:167: warning: CreateMutex redefined
In file included from C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1855:
C:/Program Files/v/thirdparty/vschannel/vschannel.c:284: warning: implicit declaration of function 'WSAConnectByNameW'
In file included from C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:1855:
C:/Program Files/v/thirdparty/vschannel/vschannel.c:300: warning: assignment from incompatible pointer type
C:/Users/USER/AppData/Local/Temp/v_0/main.01HMGS6TZ2N3DX7C04P0839DB9.tmp.c:4622: error: ';' expected (got "CONDITION_VARIABLE")
builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

It says it's a compiler issue. But it(Native and Cross compile) works on Linux lmao

Ah, and the cross-compiled .exe file creates a cmd window in the background. Are there any other options related to this?

malisipi commented 5 months ago

To hide console windows on cross compiled, you can pass -cflags "-mwindows" flag to v. (For example v -os windows -cflags "-mwindows" notepad.v) Also gcc error looks like internal issue in V. I can not recognize the issue. Are you using latest version of V?

max00217 commented 5 months ago

Thanks for the flag explanation And the version of V installed on my PC(Windows/Linux both) is obviously the latest

And are you planning to implement features like mouse dragging or shift + arrow keys to select text, copy/paste or other text editing shortcuts at cursor/selected area in textarea widget? Or do I have to implement it myself?

malisipi commented 5 months ago

I want to do this features however I do not have much time to develop and improve the library since I have a university entrance exam after five months. So in the near future, I cannot; however if you are faced with an issue, I can still help.

max00217 commented 5 months ago

It's okay, I understand your situation Thank you for your help, and I hope you get the results you want

max00217 commented 5 months ago

Sorry if you're busy, but is it possible to assign a key other than ctrl to the keybindings function? Also, can I assign keys like ctrl|shift|s? I used alt and it doesn't seem to work.

malisipi commented 5 months ago

I was not implemented the feature before. However last commit (99b4eba3505c7388cf1627fb25a50e6e4adc7c4a) is bringing the support for all key combinations (of ctrl, shift and alt keys). A example is below. https://github.com/malisipi/mui/blob/99b4eba3505c7388cf1627fb25a50e6e4adc7c4a/examples/keybindings.v#L1-L43

max00217 commented 5 months ago

Thank you for continuing to update us even though you are busy. I've been keep using the Mui module lately, and I think it's quite interesting.

max00217 commented 5 months ago

It seems like another issue has occurred. Shortcuts not working on windows. All the existing(ctrl + something) shortcuts don’t work either.

malisipi commented 5 months ago

It's caused by weird behaviour of Windows. In Linux (and probably *nix) char_fn is enough to handle all shortcuts. However Windows, char_fn is only used to send Shift+(key) key combinations. keydown_fn is other shortcuts including Shift+(key). This is ridiculus at all.

In end, i got fully working shortcut handler. However i will test it in other OSs before merge it. Can you test the branch, does it solve your issue. #39

max00217 commented 5 months ago

Hmm... Shift key combination doesn't seem to work either (I compiled keybindings.v in the example directly from Windows) No keyboard shortcuts are working Or is this just my problem?

malisipi commented 5 months ago

I cannot reproduce the bug after #39 . Also i was merged it to main branch.

Maybe you forget update the library? Sometimes v doesn't update the library due a weird issue.

Also if you're using latest version of the library, Which version you are using of Windows? Maybe some Windows versions has different behavior.

max00217 commented 5 months ago

🤔All tests were performed on Windows 10/11. And the module updates are also up to date. Maybe I should find another way

Thank you for your help every time

max00217 commented 4 months ago

Formatted PC and reinstalled all components. Compilation issues, keyboard shortcuts have all been fixed. Thank you.

But compiling from Windows to GCC takes a very long time, for what reason?

Wajinn commented 4 months ago

As a 3rd person reading this and following along, it appears that malisipi has solved a few of these issues, but max00217 is bringing up new unrelated issues.

max00217, maybe break these out as separate issues, and for the ones that are solved, allowed them to be closed.

As to the last issue as to how long GCC takes to compile something on Windows, that doesn't look like anything for malisipi, but something to take up on the GCC boards.

Lastly, malisipi you have been doing a great job, look forward to when you have more time and good luck with your exams.

malisipi commented 3 months ago

I was missed the last comments (GitHub not notified me about it). I saw the update while surfing in GitHub.

GCC is designed for *nix and as I remember, it not using CPU with all performance in Windows while compiling. Like Wajinn said, maybe GCC devs can help about it.

After all, i am happy to hear that fixed your issues after format.

I will close the issue since it was went to unrelated topics than main issue. If you still encounter a issue that placed in there, please open a new issue.

Lastly Wajinn, I am thank you for your wishes. Good luck in your life.

Thank you for all about your interest. Have a good day!