Mercurial > dwindows
changeset 2670:e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
Move the window destroy logic into the C code event handler...
That way handling the DW_SIGNAL_DELETE can prevent the window closure.
The application still can't be stopped from closing, but windows can.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 18 Oct 2021 00:09:57 +0000 |
parents | 2ad924c6493d |
children | 0ed61ddb9957 |
files | android/DWindows.kt android/dw.cpp dw.h |
diffstat | 3 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/android/DWindows.kt Sun Oct 17 20:14:51 2021 +0000 +++ b/android/DWindows.kt Mon Oct 18 00:09:57 2021 +0000 @@ -974,8 +974,10 @@ val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter val index = windowLayout!!.currentItem - if (index > 0) { - windowDestroy(adapter.viewList[index]) + // If the current window has a close button... + if (index > 0 && (windowStyles[index] and 1) == 1) { + // Send the DW_SIGNAL_DELETE to the event handler + eventHandlerSimple(adapter.viewList[index], DWEvent.DELETE) } } } @@ -1147,6 +1149,9 @@ if (adapter.viewList.count() == 1) { this.title = title windowLayout!!.setCurrentItem(0, false) + if((windowStyles[0] and 2) != 2) { + supportActionBar?.hide() + } } } } @@ -1424,12 +1429,18 @@ // So using RecyclerView.scrollToPosition() also windowLayout!!.setCurrentItem(index, true) + // Hide or show the actionbar based on the titlebar flag + if((windowStyles[index] and 2) == 2) { + supportActionBar?.show() + } else { + supportActionBar?.hide() + } // If the new view has a default item, focus it if(windowDefault[index] != null) { windowDefault[index]?.requestFocus() } // Add or remove a back button depending on the visible window - if(index > 0) { + if(index > 0 && (windowStyles[index] and 1) == 1) { this.actionBar?.setDisplayHomeAsUpEnabled(true) } else { this.actionBar?.setDisplayHomeAsUpEnabled(false)
--- a/android/dw.cpp Sun Oct 17 20:14:51 2021 +0000 +++ b/android/dw.cpp Mon Oct 18 00:09:57 2021 +0000 @@ -563,7 +563,8 @@ int _dw_event_handler(jobject object, void **params) { - DWSignalHandler *handler = _dw_get_handler(object, DW_POINTER_TO_INT(params[8])); + int messageid = DW_POINTER_TO_INT(params[8]); + DWSignalHandler *handler = _dw_get_handler(object, messageid); if (handler) { @@ -573,7 +574,7 @@ * If it isn't a draw event, either queue the event * or launch a new thread to handle it. */ - if(DW_POINTER_TO_INT(params[8]) != 7) + if(DW_POINTER_TO_INT(params[8]) != _DW_EVENT_EXPOSE) { #ifdef _DW_EVENT_THREADING /* Make a copy of the params so it isn't allocated from the stack */ @@ -589,7 +590,9 @@ else return _dw_event_handler2(params); - } + } /* If we don't have a handler, destroy the window */ + else if(messageid == _DW_EVENT_DELETE) + dw_window_destroy(object); return 0; }
--- a/dw.h Sun Oct 17 20:14:51 2021 +0000 +++ b/dw.h Mon Oct 18 00:09:57 2021 +0000 @@ -812,8 +812,8 @@ #define DW_DT_WORDBREAK 0 #define DW_DT_ERASERECT 0 -#define DW_FCF_CLOSEBUTTON 0 -#define DW_FCF_TITLEBAR 0 +#define DW_FCF_CLOSEBUTTON 1 +#define DW_FCF_TITLEBAR (1 << 1) #define DW_FCF_SYSMENU 0 #define DW_FCF_MENU 0 #define DW_FCF_SIZEBORDER 0