Skip to content

Commit

Permalink
Reorganize the data structure of FOptiAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Oct 22, 2023
1 parent fbb7309 commit 8732f50
Show file tree
Hide file tree
Showing 23 changed files with 476 additions and 401 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2023-10-23 Markus Gans <guru.mail@muenster.de>
* Reorganize the data structure of FOptiAttr

2023-10-14 Markus Gans <guru.mail@muenster.de>
* Switch to a readers-writer lock for the timer list

Expand Down
8 changes: 5 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ AC_CHECK_HEADERS( \

# Checks for library functions.
AC_CHECK_FUNCS( \
getuid \
geteuid \
getttynam \
getuid \
pthread_rwlock_wrlock \
select \
sigaction \
strdup \
Expand All @@ -54,15 +55,16 @@ AC_CHECK_FUNCS( \
timer_settime \
vsnprintf \
wcwidth )

# Checks for 'tgetent'
AC_SEARCH_LIBS([tgetent], [terminfo mytinfo termlib termcap tinfo ncurses curses])
# Checks for 'tparm'
AC_SEARCH_LIBS([tparm], [terminfo mytinfo termlib termcap tinfo ncurses curses])
# Checks for 'timer_create'
AC_SEARCH_LIBS([timer_create], [rt])
# Checks for 'timer_create'
# Checks for 'timer_settime'
AC_SEARCH_LIBS([timer_settime], [rt])
# Checks for 'pthread_rwlock_wrlock'
AC_SEARCH_LIBS([pthread_rwlock_wrlock], [pthread])

AC_SUBST([FINAL_LIBS])
AC_SUBST([TERMCAP_LIB])
Expand Down
2 changes: 1 addition & 1 deletion final/fapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ inline void FApplication::findKeyboardWidget() const
}

//----------------------------------------------------------------------
inline auto FApplication::isKeyPressed(uInt64 ms) const -> bool
inline auto FApplication::isKeyPressed (uInt64 ms) const -> bool
{
static auto& mouse = FMouseControl::getInstance();
static auto& keyboard = FKeyboard::getInstance();
Expand Down
2 changes: 1 addition & 1 deletion final/fapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class FApplication : public FWidget
static void showParameterUsage();
void destroyLog();
void findKeyboardWidget() const;
auto isKeyPressed(uInt64 = 0U) const -> bool;
auto isKeyPressed (uInt64 = 0U) const -> bool;
void keyPressed();
void keyReleased() const;
void escapeKeyPressed() const;
Expand Down
111 changes: 91 additions & 20 deletions final/fconfig.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _FINAL_FCONFIG_H
#define _FINAL_FCONFIG_H 1

/* final/fconfig.h. Generated automatically at end of configure. */
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
Expand Down Expand Up @@ -70,9 +70,12 @@
/* Define to 1 if you have the <map> header file. */
/* #undef HAVE_MAP */

/* Define to 1 if you have the <memory.h> header file. */
#ifndef F_HAVE_MEMORY_H
#define F_HAVE_MEMORY_H 1
/* Define to 1 if you have the <minix/config.h> header file. */
/* #undef HAVE_MINIX_CONFIG_H */

/* Define to 1 if you have the `pthread_rwlock_wrlock' function. */
#ifndef F_HAVE_PTHREAD_RWLOCK_WRLOCK
#define F_HAVE_PTHREAD_RWLOCK_WRLOCK 1
#endif

/* Define to 1 if you have the <queue> header file. */
Expand All @@ -93,6 +96,11 @@
#define F_HAVE_STDINT_H 1
#endif

/* Define to 1 if you have the <stdio.h> header file. */
#ifndef F_HAVE_STDIO_H
#define F_HAVE_STDIO_H 1
#endif

/* Define to 1 if you have the <stdlib.h> header file. */
#ifndef F_HAVE_STDLIB_H
#define F_HAVE_STDLIB_H 1
Expand Down Expand Up @@ -181,6 +189,11 @@
#define F_HAVE_VSNPRINTF 1
#endif

/* Define to 1 if you have the <wchar.h> header file. */
#ifndef F_HAVE_WCHAR_H
#define F_HAVE_WCHAR_H 1
#endif

/* Define to 1 if you have the `wcwidth' function. */
#ifndef F_HAVE_WCWIDTH
#define F_HAVE_WCWIDTH 1
Expand Down Expand Up @@ -226,7 +239,9 @@
#define F_PACKAGE_VERSION "0.9.0"
#endif

/* Define to 1 if you have the ANSI C header files. */
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#ifndef F_STDC_HEADERS
#define F_STDC_HEADERS 1
#endif
Expand All @@ -235,38 +250,94 @@
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# define _DARWIN_C_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
/* Enable X/Open compliant socket functions that do not require linking
with -lxnet on HP-UX 11.11. */
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
# define _HPUX_ALT_XOPEN_SOCKET_API 1
#endif
/* Identify the host operating system as Minix.
This macro does not affect the system headers' behavior.
A future release of Autoconf may stop defining this macro. */
#ifndef _MINIX
/* # undef _MINIX */
#endif
/* Enable general extensions on NetBSD.
Enable NetBSD compatibility extensions on Minix. */
#ifndef _NETBSD_SOURCE
# define _NETBSD_SOURCE 1
#endif
/* Enable OpenBSD compatibility extensions on NetBSD.
Oddly enough, this does nothing on OpenBSD. */
#ifndef _OPENBSD_SOURCE
# define _OPENBSD_SOURCE 1
#endif
/* Define to 1 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_SOURCE
/* # undef _POSIX_SOURCE */
#endif
/* Define to 2 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_1_SOURCE
/* # undef _POSIX_1_SOURCE */
#endif
/* Enable POSIX-compatible threading on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
# define __STDC_WANT_IEC_60559_BFP_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
#endif
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
#ifndef __STDC_WANT_LIB_EXT2__
# define __STDC_WANT_LIB_EXT2__ 1
#endif
/* Enable extensions specified by ISO/IEC 24747:2009. */
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
# define __STDC_WANT_MATH_SPEC_FUNCS__ 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
/* Enable X/Open extensions. Define to 500 only if necessary
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
/* # undef _XOPEN_SOURCE */
#endif


/* Version number of package */
#ifndef F_VERSION
#define F_VERSION "0.9.0"
#endif

/* Define to 1 if on MINIX. */
/* #undef _MINIX */

/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */

/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */


/* once: _FINAL_FCONFIG_H */
#endif
4 changes: 2 additions & 2 deletions final/fobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ inline auto FObject::isInstanceOf (const FString& classname) const -> bool
{ return classname == getClassName(); }

//----------------------------------------------------------------------
inline void FObject::setWidgetProperty (bool property)
{ widget_object = property; }
inline void FObject::setWidgetProperty (bool is_widget)
{ widget_object = is_widget; }

} // namespace finalcut

Expand Down
8 changes: 4 additions & 4 deletions final/menu/fdialoglistmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,27 @@ void FDialogListMenu::init()
"last-dialog-closed",
this,
&FDialogListMenu::cb_switchState,
false
Enable::No
);

fapp->addCallback
(
"first-dialog-opened",
this,
&FDialogListMenu::cb_switchState,
true
Enable::Yes
);
}

//----------------------------------------------------------------------
void FDialogListMenu::cb_switchState (bool enable)
void FDialogListMenu::cb_switchState (Enable enable)
{
auto m_item = getItem();

if ( ! m_item )
return;

m_item->setFlags().feature.active = enable;
m_item->setFlags().feature.active = enable == Enable::Yes ? true : false;
auto super = m_item->getSuperMenu();

if ( ! super )
Expand Down
7 changes: 5 additions & 2 deletions final/menu/fdialoglistmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2016-2022 Markus Gans *
* Copyright 2016-2023 Markus Gans *
* *
* FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
Expand Down Expand Up @@ -81,11 +81,14 @@ class FDialogListMenu : public FMenu
auto getClassName() const -> FString override;

private:
// Enumeration
enum class Enable { No, Yes };

// Method
void init();

// Callback method
void cb_switchState (bool);
void cb_switchState (Enable);
};


Expand Down
16 changes: 8 additions & 8 deletions final/menu/fmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
redraw();

// Open the sub menu to be opened
openSubMenu (shown_sub_menu);
openSubMenu (shown_sub_menu, SelectItem::No);
}

//----------------------------------------------------------------------
Expand Down Expand Up @@ -287,7 +287,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( shown_sub_menu )
{
closeOpenedSubMenu();
openSubMenu (shown_sub_menu);
openSubMenu (shown_sub_menu, SelectItem::No);
}
else if ( ms.hide_sub_menu )
{
Expand Down Expand Up @@ -550,14 +550,14 @@ auto FMenu::adjustX (int x_pos) const -> int
}

//----------------------------------------------------------------------
void FMenu::openSubMenu (FMenu* sub_menu, bool select)
void FMenu::openSubMenu (FMenu* sub_menu, SelectItem select)
{
// open sub menu

if ( ! sub_menu || sub_menu->isShown() )
return;

if ( select )
if ( select == SelectItem::Yes )
{
sub_menu->selectFirstItem();

Expand Down Expand Up @@ -728,7 +728,7 @@ auto FMenu::mouseUpOverList (const FPoint& mouse_pos) -> bool
auto sub_menu = sel_item->getMenu();

if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM);
openSubMenu (sub_menu, SelectItem::Yes);
else if ( opened_sub_menu )
{
opened_sub_menu->selectFirstItem();
Expand Down Expand Up @@ -953,7 +953,7 @@ auto FMenu::hotkeyMenu (FKeyEvent* ev) -> bool
auto try_to_open_submenu = [this] (const auto& sub_menu)
{
if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM);
openSubMenu (sub_menu, SelectItem::Yes);

sub_menu->redraw();
};
Expand Down Expand Up @@ -1331,7 +1331,7 @@ inline void FMenu::selectNextMenu (FKeyEvent* ev)
auto sub_menu = getSelectedItem()->getMenu();

if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM);
openSubMenu (sub_menu, SelectItem::Yes);
else
keypressMenuBar(ev); // select next menu
}
Expand All @@ -1348,7 +1348,7 @@ inline void FMenu::acceptSelection()
auto sel_item = getSelectedItem();

if ( sel_item->hasMenu() )
openSubMenu (sel_item->getMenu(), SELECT_ITEM);
openSubMenu (sel_item->getMenu(), SelectItem::Yes);
else
{
unselectItem();
Expand Down
6 changes: 4 additions & 2 deletions final/menu/fmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ class FMenu : public FWindow
void cb_menuitemToggled (const FMenuItem*) const;

private:
// Enumeration
enum class SelectItem { No, Yes };

struct MouseStates
{
uChar focus_changed : 1;
Expand All @@ -159,7 +162,6 @@ class FMenu : public FWindow

// Constants
static constexpr auto NOT_SET = static_cast<std::size_t>(-1);
static constexpr bool SELECT_ITEM = true;

// Accessors
auto getSuperMenu() const -> FWidget*;
Expand All @@ -185,7 +187,7 @@ class FMenu : public FWindow
void calculateDimensions();
void adjustItems() const;
auto adjustX(int) const -> int;
void openSubMenu (FMenu*, bool = false);
void openSubMenu (FMenu*, SelectItem);
void closeOpenedSubMenu();
void hideSubMenus();
void hideSuperMenus() const;
Expand Down
Loading

0 comments on commit 8732f50

Please sign in to comment.