[Bf-blender-cvs] [136ea84d9a3] master: Cleanup: Move interface_handlers.c to C++

Hans Goudey noreply at git.blender.org
Sat Nov 26 17:14:07 CET 2022


Commit: 136ea84d9a3791aafb835802f5a525247af9d362
Author: Hans Goudey
Date:   Fri Nov 25 23:48:33 2022 -0600
Branches: master
https://developer.blender.org/rB136ea84d9a3791aafb835802f5a525247af9d362

Cleanup: Move interface_handlers.c to C++

===================================================================

M	source/blender/blenkernel/BKE_blender_undo.h
M	source/blender/editors/interface/CMakeLists.txt
R093	source/blender/editors/interface/interface_handlers.c	source/blender/editors/interface/interface_handlers.cc
M	source/blender/editors/interface/interface_intern.h

===================================================================

diff --git a/source/blender/blenkernel/BKE_blender_undo.h b/source/blender/blenkernel/BKE_blender_undo.h
index 3003fe2596d..58a57f7618a 100644
--- a/source/blender/blenkernel/BKE_blender_undo.h
+++ b/source/blender/blenkernel/BKE_blender_undo.h
@@ -5,6 +5,8 @@
  * \ingroup bke
  */
 
+#include "BKE_undo_system.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -13,8 +15,6 @@ struct Main;
 struct MemFileUndoData;
 struct bContext;
 
-enum eUndoStepDir;
-
 #define BKE_UNDO_STR_MAX 64
 
 struct MemFileUndoData *BKE_memfile_undo_encode(struct Main *bmain,
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index 4108800c518..3803c11a1db 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -43,7 +43,7 @@ set(SRC
   interface_drag.cc
   interface_draw.cc
   interface_dropboxes.cc
-  interface_handlers.c
+  interface_handlers.cc
   interface_icons.cc
   interface_icons_event.cc
   interface_layout.cc
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.cc
similarity index 93%
rename from source/blender/editors/interface/interface_handlers.c
rename to source/blender/editors/interface/interface_handlers.cc
index ac16d41dabe..a9229983995 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.cc
@@ -5,12 +5,12 @@
  * \ingroup edinterface
  */
 
-#include <ctype.h>
-#include <float.h>
-#include <limits.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cfloat>
+#include <climits>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
 
 #include "MEM_guardedalloc.h"
 
@@ -19,6 +19,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 
+#include "BLI_array.hh"
 #include "BLI_array_utils.h"
 #include "BLI_linklist.h"
 #include "BLI_listbase.h"
@@ -149,31 +150,28 @@
 /** \name Local Prototypes
  * \{ */
 
-static int ui_do_but_EXIT(bContext *C,
-                          uiBut *but,
-                          struct uiHandleButtonData *data,
-                          const wmEvent *event);
+static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event);
 static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b);
-static void ui_textedit_string_set(uiBut *but, struct uiHandleButtonData *data, const char *str);
+static void ui_textedit_string_set(uiBut *but, uiHandleButtonData *data, const char *str);
 static void button_tooltip_timer_reset(bContext *C, uiBut *but);
 
 static void ui_block_interaction_begin_ensure(bContext *C,
                                               uiBlock *block,
-                                              struct uiHandleButtonData *data,
+                                              uiHandleButtonData *data,
                                               const bool is_click);
-static struct uiBlockInteraction_Handle *ui_block_interaction_begin(struct bContext *C,
-                                                                    uiBlock *block,
-                                                                    const bool is_click);
-static void ui_block_interaction_end(struct bContext *C,
+static uiBlockInteraction_Handle *ui_block_interaction_begin(bContext *C,
+                                                             uiBlock *block,
+                                                             const bool is_click);
+static void ui_block_interaction_end(bContext *C,
                                      uiBlockInteraction_CallbackData *callbacks,
-                                     struct uiBlockInteraction_Handle *interaction);
-static void ui_block_interaction_update(struct bContext *C,
+                                     uiBlockInteraction_Handle *interaction);
+static void ui_block_interaction_update(bContext *C,
                                         uiBlockInteraction_CallbackData *callbacks,
-                                        struct uiBlockInteraction_Handle *interaction);
+                                        uiBlockInteraction_Handle *interaction);
 
 #ifdef USE_KEYNAV_LIMIT
-static void ui_mouse_motion_keynav_init(struct uiKeyNavLock *keynav, const wmEvent *event);
-static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEvent *event);
+static void ui_mouse_motion_keynav_init(uiKeyNavLock *keynav, const wmEvent *event);
+static bool ui_mouse_motion_keynav_test(uiKeyNavLock *keynav, const wmEvent *event);
 #endif
 
 /** \} */
@@ -197,15 +195,15 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve
 /** Drag-lock distance threshold (in pixels). */
 #define BUTTON_DRAGLOCK_THRESH 3
 
-typedef enum uiButtonActivateType {
+enum uiButtonActivateType {
   BUTTON_ACTIVATE_OVER,
   BUTTON_ACTIVATE,
   BUTTON_ACTIVATE_APPLY,
   BUTTON_ACTIVATE_TEXT_EDITING,
   BUTTON_ACTIVATE_OPEN,
-} uiButtonActivateType;
+};
 
-typedef enum uiHandleButtonState {
+enum uiHandleButtonState {
   BUTTON_STATE_INIT,
   BUTTON_STATE_HIGHLIGHT,
   BUTTON_STATE_WAIT_FLASH,
@@ -217,17 +215,17 @@ typedef enum uiHandleButtonState {
   BUTTON_STATE_MENU_OPEN,
   BUTTON_STATE_WAIT_DRAG,
   BUTTON_STATE_EXIT,
-} uiHandleButtonState;
+};
 
-typedef enum uiMenuScrollType {
+enum uiMenuScrollType {
   MENU_SCROLL_UP,
   MENU_SCROLL_DOWN,
   MENU_SCROLL_TOP,
   MENU_SCROLL_BOTTOM,
-} uiMenuScrollType;
+};
 
-typedef struct uiBlockInteraction_Handle {
-  struct uiBlockInteraction_Params params;
+struct uiBlockInteraction_Handle {
+  uiBlockInteraction_Params params;
   void *user_data;
   /**
    * This is shared between #uiHandleButtonData and #uiAfterFunc,
@@ -237,7 +235,7 @@ typedef struct uiBlockInteraction_Handle {
    * accepting/canceling the operation.
    */
   int user_count;
-} uiBlockInteraction_Handle;
+};
 
 #ifdef USE_ALLSELECT
 
@@ -245,16 +243,16 @@ typedef struct uiBlockInteraction_Handle {
  * (propagate single clicks on layer buttons to other objects) */
 #  define USE_ALLSELECT_LAYER_HACK
 
-typedef struct uiSelectContextElem {
+struct uiSelectContextElem {
   PointerRNA ptr;
   union {
     bool val_b;
     int val_i;
     float val_f;
   };
-} uiSelectContextElem;
+};
 
-typedef struct uiSelectContextStore {
+struct uiSelectContextStore {
   uiSelectContextElem *elems;
   int elems_len;
   bool do_free;
@@ -264,15 +262,13 @@ typedef struct uiSelectContextStore {
    * - dragging numbers uses delta.
    * - typing in values will assign to all. */
   bool is_copy;
-} uiSelectContextStore;
+};
 
-static bool ui_selectcontext_begin(bContext *C,
-                                   uiBut *but,
-                                   struct uiSelectContextStore *selctx_data);
+static bool ui_selectcontext_begin(bContext *C, uiBut *but, uiSelectContextStore *selctx_data);
 static void ui_selectcontext_end(uiBut *but, uiSelectContextStore *selctx_data);
 static void ui_selectcontext_apply(bContext *C,
                                    uiBut *but,
-                                   struct uiSelectContextStore *selctx_data,
+                                   uiSelectContextStore *selctx_data,
                                    const double value,
                                    const double value_orig);
 
@@ -308,25 +304,25 @@ static void ui_selectcontext_apply(bContext *C,
 #  define DRAG_MULTINUM_THRESHOLD_VERTICAL (0.75f)
 
 /* a simple version of uiHandleButtonData when accessing multiple buttons */
-typedef struct uiButMultiState {
+struct uiButMultiState {
   double origvalue;
   uiBut *but;
 
 #  ifdef USE_ALLSELECT
   uiSelectContextStore select_others;
 #  endif
-} uiButMultiState;
+};
 
-typedef struct uiHandleButtonMulti {
+struct uiHandleButtonMulti {
   enum {
     /** gesture direction unknown, wait until mouse has moved enough... */
-    BUTTON_MULTI_INIT_UNSET = 0,
+    INIT_UNSET = 0,
     /** vertical gesture detected, flag buttons interactively (UI_BUT_DRAG_MULTI) */
-    BUTTON_MULTI_INIT_SETUP,
+    INIT_SETUP,
     /** flag buttons finished, apply horizontal motion to active and flagged */
-    BUTTON_MULTI_INIT_ENABLE,
+    INIT_ENABLE,
     /** vertical gesture _not_ detected, take no further action */
-    BUTTON_MULTI_INIT_DISABLE,
+    INIT_DISABLE,
   } init;
 
   bool has_mbuts; /* any buttons flagged UI_BUT_DRAG_MULTI */
@@ -347,15 +343,14 @@ typedef struct uiHandleButtonMulti {
    * used to detect buttons between the current and initial mouse position */
   int drag_start[2];
 
-  /* store x location once BUTTON_MULTI_INIT_SETUP is set,
-   * moving outside this sets BUTTON_MULTI_INIT_ENABLE */
+  /* store x location once INIT_SETUP is set,
+   * moving outside this sets INIT_ENABLE */
   int drag_lock_x;
-
-} uiHandleButtonMulti;
+};
 
 #endif /* USE_DRAG_MULTINUM */
 
-typedef struct uiHandleButtonData {
+struct uiHandleButtonData {
   wmWindowManager *wm;
   wmWindow *window;
   ScrArea *area;
@@ -437,7 +432,7 @@ typedef struct uiHandleButtonData {
   /* Search box see: #UI_screen_free_active_but_highlight. */
   ARegion *searchbox;
 #ifdef USE_KEYNAV_LIMIT
-  struct uiKeyNavLock searchbox_keynav_state;
+  uiKeyNavLock searchbox_keynav_state;
 #endif
 
 #ifdef USE_DRAG_MULTINUM
@@ -449,18 +444,18 @@ typedef struct uiHandleButtonData {
   uiSelectContextStore select_others;
 #endif
 
-  struct uiBlockInteraction_Handle *custom_interaction_handle;
+  uiBlockInteraction_Handle *custom_interaction_handle;
 
   /* Text field undo. */
-  struct uiUndoStack_Text *undo_stack_text;
+  uiUndoStack_Text *undo_stack_text;
 
   /* post activate */
   uiButtonActivateType posttype;
   uiBut *postbut;
-} uiHandleButtonData;
+};
 
-typedef struct uiAfterFunc {
-  struct uiAfterFunc *next, *prev;
+struct uiAfterFunc {
+  uiAfterFunc *next, *prev;
 
   uiButHandleFunc func;
   void *func_arg1;
@@ -499,7 +494,7 @@ typedef struct uiAfterFunc {
 
   char undostr[BKE_UNDO_STR_MAX];
   char drawstr[UI_MAX_DRAW_STR];
-} uiAfterFunc;
+};
 
 static void button_activate_init(bContext *C,
                                  ARegion *region,
@@ -562,7 +557,7 @@ void ui_pan_to_scroll(const wmEve

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list