[Bf-blender-cvs] [c637290a6e2] master: Cleanup: remove unused value2d gizmo

Campbell Barton noreply at git.blender.org
Thu Nov 21 13:01:41 CET 2019


Commit: c637290a6e2894c6f3f22e42f5632ff319a623c8
Author: Campbell Barton
Date:   Thu Nov 21 22:57:01 2019 +1100
Branches: master
https://developer.blender.org/rBc637290a6e2894c6f3f22e42f5632ff319a623c8

Cleanup: remove unused value2d gizmo

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

M	source/blender/editors/gizmo_library/CMakeLists.txt
D	source/blender/editors/gizmo_library/gizmo_group_types/value2d_gizmo_group.c
D	source/blender/editors/gizmo_library/gizmo_types/value2d_gizmo.c
M	source/blender/editors/include/ED_gizmo_library.h
M	source/blender/editors/space_api/spacetypes.c

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

diff --git a/source/blender/editors/gizmo_library/CMakeLists.txt b/source/blender/editors/gizmo_library/CMakeLists.txt
index d9503c4e759..4fbe901c1ca 100644
--- a/source/blender/editors/gizmo_library/CMakeLists.txt
+++ b/source/blender/editors/gizmo_library/CMakeLists.txt
@@ -45,7 +45,6 @@ set(SRC
   geometry/geom_arrow_gizmo.c
   geometry/geom_cube_gizmo.c
   geometry/geom_dial_gizmo.c
-  gizmo_group_types/value2d_gizmo_group.c
   gizmo_types/arrow2d_gizmo.c
   gizmo_types/arrow3d_gizmo.c
   gizmo_types/blank3d_gizmo.c
@@ -55,7 +54,6 @@ set(SRC
   gizmo_types/dial3d_gizmo.c
   gizmo_types/move3d_gizmo.c
   gizmo_types/primitive3d_gizmo.c
-  gizmo_types/value2d_gizmo.c
 )
 
 set(LIB
diff --git a/source/blender/editors/gizmo_library/gizmo_group_types/value2d_gizmo_group.c b/source/blender/editors/gizmo_library/gizmo_group_types/value2d_gizmo_group.c
deleted file mode 100644
index a1b01ed8d15..00000000000
--- a/source/blender/editors/gizmo_library/gizmo_group_types/value2d_gizmo_group.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup edgizmolib
- *
- * \name 2D Value Gizmo
- *
- * \brief Gizmo that edits a value for operator redo.
- */
-
-#include "BLI_utildefines.h"
-
-#include "BKE_context.h"
-
-#include "ED_undo.h"
-#include "ED_screen.h"
-#include "ED_gizmo_library.h"
-
-#include "UI_resources.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_access.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-/* -------------------------------------------------------------------- */
-/** \name Value Gizmo
- * \{ */
-
-struct ValueOpRedoGroup {
-  wmGizmo *gizmo;
-  struct {
-    const bContext *context; /* needed for redo. */
-    wmOperator *op;
-  } state;
-};
-
-static void gizmo_op_redo_exec(struct ValueOpRedoGroup *igzgroup)
-{
-  wmOperator *op = igzgroup->state.op;
-  if (op == WM_operator_last_redo((bContext *)igzgroup->state.context)) {
-    ED_undo_operator_repeat((bContext *)igzgroup->state.context, op);
-  }
-}
-
-/* translate callbacks */
-static void gizmo_value_operator_redo_value_get(const wmGizmo *gz,
-                                                wmGizmoProperty *gz_prop,
-                                                void *value_p)
-{
-  float *value = value_p;
-  BLI_assert(gz_prop->type->array_length == 1);
-  UNUSED_VARS_NDEBUG(gz_prop);
-
-  struct ValueOpRedoGroup *igzgroup = gz->parent_gzgroup->customdata;
-  wmOperator *op = igzgroup->state.op;
-  *value = RNA_property_float_get(op->ptr, op->type->prop);
-}
-
-static void gizmo_value_operator_redo_value_set(const wmGizmo *gz,
-                                                wmGizmoProperty *gz_prop,
-                                                const void *value_p)
-{
-  const float *value = value_p;
-  BLI_assert(gz_prop->type->array_length == 1);
-  UNUSED_VARS_NDEBUG(gz_prop);
-
-  struct ValueOpRedoGroup *igzgroup = gz->parent_gzgroup->customdata;
-  wmOperator *op = igzgroup->state.op;
-  RNA_property_float_set(op->ptr, op->type->prop, *value);
-  gizmo_op_redo_exec(igzgroup);
-}
-
-static void WIDGETGROUP_value_operator_redo_modal_from_setup(const bContext *C,
-                                                             wmGizmoGroup *gzgroup)
-{
-  /* Start off dragging. */
-  wmWindow *win = CTX_wm_window(C);
-  wmGizmo *gz = gzgroup->gizmos.first;
-  wmGizmoMap *gzmap = gzgroup->parent_gzmap;
-  WM_gizmo_modal_set_from_setup(gzmap, (bContext *)C, gz, 0, win->eventstate);
-}
-
-static void WIDGETGROUP_value_operator_redo_setup(const bContext *C, wmGizmoGroup *gzgroup)
-{
-  struct ValueOpRedoGroup *igzgroup = MEM_mallocN(sizeof(struct ValueOpRedoGroup), __func__);
-
-  igzgroup->gizmo = WM_gizmo_new("GIZMO_GT_value_2d", gzgroup, NULL);
-  wmGizmo *gz = igzgroup->gizmo;
-
-  igzgroup->state.context = C;
-  igzgroup->state.op = WM_operator_last_redo(C);
-
-  gzgroup->customdata = igzgroup;
-
-  UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
-  UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
-
-  WM_gizmo_target_property_def_func(gz,
-                                    "offset",
-                                    &(const struct wmGizmoPropertyFnParams){
-                                        .value_get_fn = gizmo_value_operator_redo_value_get,
-                                        .value_set_fn = gizmo_value_operator_redo_value_set,
-                                        .range_get_fn = NULL,
-                                        .user_data = igzgroup,
-                                    });
-
-  /* Become modal as soon as it's started. */
-  WIDGETGROUP_value_operator_redo_modal_from_setup(C, gzgroup);
-}
-
-static void WIDGETGROUP_value_operator_redo_refresh(const bContext *UNUSED(C),
-                                                    wmGizmoGroup *gzgroup)
-{
-  struct ValueOpRedoGroup *igzgroup = gzgroup->customdata;
-  wmGizmo *gz = igzgroup->gizmo;
-  wmOperator *op = WM_operator_last_redo((bContext *)igzgroup->state.context);
-  wmGizmoMap *gzmap = gzgroup->parent_gzmap;
-
-  /* FIXME */
-  extern struct wmGizmo *wm_gizmomap_modal_get(struct wmGizmoMap * gzmap);
-  if ((op != igzgroup->state.op) || (wm_gizmomap_modal_get(gzmap) != gz)) {
-    WM_gizmo_group_type_unlink_delayed_ptr(gzgroup->type);
-  }
-}
-
-static void WM_GGT_value_operator_redo(wmGizmoGroupType *gzgt)
-{
-  gzgt->name = "Value Operator Redo";
-  gzgt->idname = "WM_GGT_value_operator_redo";
-
-  /* FIXME, allow multiple. */
-  gzgt->flag = WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_TOOL_INIT;
-
-  gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
-  gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
-
-  gzgt->setup = WIDGETGROUP_value_operator_redo_setup;
-  gzgt->setup_keymap = WM_gizmogroup_setup_keymap_generic_maybe_drag;
-  gzgt->refresh = WIDGETGROUP_value_operator_redo_refresh;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Public API
- * \{ */
-
-void ED_gizmogrouptypes_value_2d(void)
-{
-  WM_gizmogrouptype_append(WM_GGT_value_operator_redo);
-}
-
-/** \} */
diff --git a/source/blender/editors/gizmo_library/gizmo_types/value2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/value2d_gizmo.c
deleted file mode 100644
index 059d3acbd9c..00000000000
--- a/source/blender/editors/gizmo_library/gizmo_types/value2d_gizmo.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/** \file
- * \ingroup edgizmolib
- *
- * \name Value Gizmo
- *
- * \brief Gizmo that can be used to click and drag a value.
- *
- * Use this in cases where it may be useful to have a tool,
- * but the tool doesn't relate to an on-screen handle.
- * eg: smooth or randomize.
- *
- * Exactly how this maps X/Y axis, and draws - may change.
- * The purpose here is to avoid having to write custom modal handlers for each operator.
- *
- * So we can use a single gizmo to make redoing an operator seem modal.
- */
-
-#include <float.h>
-#include <math.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BKE_context.h"
-#include "BLI_string.h"
-
-#include "ED_screen.h"
-#include "ED_gizmo_library.h"
-
-#include "WM_types.h"
-#include "WM_api.h"
-
-/* own includes */
-#include "../gizmo_geometry.h"
-#include "../gizmo_library_intern.h"
-
-/* -------------------------------------------------------------------- */
-/** \name Value Gizmo
- *
- * \{ */
-
-typedef struct ValueInteraction {
-  struct {
-    float mval[2];
-    float prop_value;
-  } init;
-  struct {
-    float prop_value;
-    eWM_GizmoFlagTweak tweak_flag;
-  } prev;
-  float range[2];
-} ValueInteraction;
-
-static void gizmo_value_draw(const bContext *UNUSED(C), wmGizmo *UNUSED(gz))
-{
-  /* pass */
-}
-
-static int gizmo_value_modal(bContext *C,
-                             wmGizmo *gz,
-                             const wmEvent *event,
-                             eWM_GizmoFlagTweak tweak_flag)
-{
-  ValueInteraction *inter = gz->interaction_data;
-  if ((event->type != MOUSEMOVE) && (inter->prev.tweak_flag == tweak_flag)) {
-    return OPERATOR_RUNNING_MODAL;
-  }
-  ARegion *ar = CTX_wm_region(C);
-  const float value_scale = 4.0f; /* Could be option. */
-  const float value_range = inter->range[1] - inter->range[0];
-  float value_delta = (inter->init.prop_value +
-                       (((event->mval[0] - inter->init.mval[0]) / ar->winx) * value_range)) *
-                      value_scale;
-
-  if (tweak_flag & WM_GIZMO_TWEAK_SNAP) {
-    const double snap = 0.1;
-    value_delta = (float)roundf((double)value_delta / snap) * snap;
-  }
-  if (tweak_flag & WM_GIZMO_TWEAK_PRECISE) {
-    value_delta *= 0.1f;
-  }
-  const float value_final = inter->init.prop_value + value_delta;
-
-  if (value_final != inter->prev.prop_value) {
-    /* set the property for the operator and call its modal function */
-    wmGizmoProperty *gz_prop = WM_gizmo_t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list