[Bf-blender-cvs] [6395212] temp_widgets_files_refactor: Split wm_generic_widgets.c into separate files per widget type
Julian Eisel
noreply at git.blender.org
Mon Feb 8 13:55:37 CET 2016
Commit: 6395212302db00cbc7d5b2cc3c8568716bdf07ea
Author: Julian Eisel
Date: Mon Feb 8 13:38:36 2016 +0100
Branches: temp_widgets_files_refactor
https://developer.blender.org/rB6395212302db00cbc7d5b2cc3c8568716bdf07ea
Split wm_generic_widgets.c into separate files per widget type
New files are now located under windowmanager/widgets/widget_library/xxx_widget.c. Added two headers, wm_widgets_intern.h and widget_library.h (which only contains external declarations and is only used as #include in WM_api.h).
wm_generic_widgets.c is gone now.
===================================================================
M source/blender/windowmanager/CMakeLists.txt
M source/blender/windowmanager/WM_api.h
D source/blender/windowmanager/intern/wm_generic_widgets.c
M source/blender/windowmanager/intern/wm_widgets.c
A source/blender/windowmanager/widgets/widget_library/arrow_widget.c
A source/blender/windowmanager/widgets/widget_library/cage_widget.c
A source/blender/windowmanager/widgets/widget_library/dial_widget.c
A source/blender/windowmanager/widgets/widget_library/facemap_widget.c
M source/blender/windowmanager/widgets/widget_library/geom_arrow_widget.c
M source/blender/windowmanager/widgets/widget_library/geom_cube_widget.c
M source/blender/windowmanager/widgets/widget_library/geom_dial_widget.c
A source/blender/windowmanager/widgets/widget_library/plane_widget.c
A source/blender/windowmanager/widgets/widget_library/widget_library.h
A source/blender/windowmanager/widgets/wm_widget.c
A source/blender/windowmanager/widgets/wm_widgets_intern.h
M source/blender/windowmanager/wm.h
===================================================================
diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt
index 242bb2f..c4c04c6 100644
--- a/source/blender/windowmanager/CMakeLists.txt
+++ b/source/blender/windowmanager/CMakeLists.txt
@@ -68,7 +68,12 @@ set(SRC
intern/wm_window.c
intern/wm_stereo.c
intern/wm_widgets.c
- intern/wm_generic_widgets.c
+ widgets/wm_widget.c
+ widgets/widget_library/arrow_widget.c
+ widgets/widget_library/cage_widget.c
+ widgets/widget_library/dial_widget.c
+ widgets/widget_library/facemap_widget.c
+ widgets/widget_library/plane_widget.c
widgets/widget_library/geom_arrow_widget.c
widgets/widget_library/geom_cube_widget
widgets/widget_library/geom_dial_widget.c
@@ -84,7 +89,9 @@ set(SRC
wm_files.h
wm_subwindow.h
wm_window.h
+ widgets/wm_widgets_intern.h
widgets/widget_library/widget_geometry.h
+ widgets/widget_library/widget_library.h
)
if(WITH_AUDASPACE)
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index da0369a..4f9312d 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -41,6 +41,7 @@
#include "DNA_windowmanager_types.h"
#include "DNA_listBase.h"
#include "WM_keymap.h"
+#include "widgets/widget_library/widget_library.h"
#include "BLI_compiler_attrs.h"
#ifdef __cplusplus
@@ -600,65 +601,6 @@ bool WM_widgetmap_cursor_set(const struct wmWidgetMap *wmap, struct wmWindow *wi
void WM_widgetmaptypes_free(void);
-/* wm_generic_widgets.c */
-
-enum {
- WIDGET_ARROW_STYLE_NORMAL = 1,
- WIDGET_ARROW_STYLE_NO_AXIS = (1 << 1),
- WIDGET_ARROW_STYLE_CROSS = (1 << 2),
- WIDGET_ARROW_STYLE_INVERTED = (1 << 3), /* inverted offset during interaction - if set it also sets constrained below */
- WIDGET_ARROW_STYLE_CONSTRAINED = (1 << 4), /* clamp arrow interaction to property width */
- WIDGET_ARROW_STYLE_BOX = (1 << 5), /* use a box for the arrowhead */
- WIDGET_ARROW_STYLE_CONE = (1 << 6),
-};
-
-enum {
- WIDGET_DIAL_STYLE_RING = 0,
- WIDGET_DIAL_STYLE_RING_CLIPPED = 1,
- WIDGET_DIAL_STYLE_RING_FILLED = 2,
-};
-
-enum {
- WIDGET_RECT_TRANSFORM_STYLE_TRANSLATE = 1, /* widget translates */
- WIDGET_RECT_TRANSFORM_STYLE_ROTATE = (1 << 1), /* widget rotates */
- WIDGET_RECT_TRANSFORM_STYLE_SCALE = (1 << 2), /* widget scales */
- WIDGET_RECT_TRANSFORM_STYLE_SCALE_UNIFORM = (1 << 3), /* widget scales uniformly */
-};
-
-/* slots for properties */
-enum {
- ARROW_SLOT_OFFSET_WORLD_SPACE = 0
-};
-
-enum {
- RECT_TRANSFORM_SLOT_OFFSET = 0,
- RECT_TRANSFORM_SLOT_SCALE = 1
-};
-
-struct wmWidget *WIDGET_arrow_new(struct wmWidgetGroup *wgroup, const char *name, const int style);
-void WIDGET_arrow_set_direction(struct wmWidget *widget, const float direction[3]);
-void WIDGET_arrow_set_up_vector(struct wmWidget *widget, const float direction[3]);
-void WIDGET_arrow_set_line_len(struct wmWidget *widget, const float len);
-void WIDGET_arrow_set_ui_range(struct wmWidget *widget, const float min, const float max);
-void WIDGET_arrow_set_range_fac(struct wmWidget *widget, const float range_fac);
-void WIDGET_arrow_cone_set_aspect(struct wmWidget *widget, const float aspect[2]);
-
-struct wmWidget *WIDGET_dial_new(struct wmWidgetGroup *wgroup, const char *name, const int style);
-void WIDGET_dial_set_up_vector(struct wmWidget *widget, const float direction[3]);
-
-struct wmWidget *WIDGET_plane_new(struct wmWidgetGroup *wgroup, const char *name, const int style);
-void WIDGET_plane_set_direction(struct wmWidget *widget, const float direction[3]);
-void WIDGET_plane_set_up_vector(struct wmWidget *widget, const float direction[3]);
-
-struct wmWidget *WIDGET_rect_transform_new(
- struct wmWidgetGroup *wgroup, const char *name, const int style,
- const float width, const float height);
-
-struct wmWidget *WIDGET_facemap_new(
- struct wmWidgetGroup *wgroup, const char *name, const int style,
- struct Object *ob, const int facemap);
-struct bFaceMap *WIDGET_facemap_get_fmap(struct wmWidget *widget);
-
#ifdef WITH_INPUT_IME
bool WM_event_is_ime_switch(const struct wmEvent *event);
diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c
deleted file mode 100644
index 064bac2..0000000
--- a/source/blender/windowmanager/intern/wm_generic_widgets.c
+++ /dev/null
@@ -1,1651 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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.
- *
- * The Original Code is Copyright (C) 2014 Blender Foundation.
- * All rights reserved.
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/windowmanager/intern/wm_generic_widgets.c
- * \ingroup wm
- *
- * *****************************************************
- * GENERIC WIDGET LIBRARY
- * *****************************************************
- */
-
-#include "RNA_types.h"
-#include "RNA_access.h"
-
-#include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_object_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_windowmanager_types.h"
-#include "DNA_userdef_types.h"
-#include "DNA_widget_types.h"
-
-#include "BLI_listbase.h"
-#include "BLI_utildefines.h"
-#include "BLI_math_matrix.h"
-#include "BLI_math.h"
-#include "BLI_rect.h"
-
-#include "BKE_context.h"
-#include "BKE_depsgraph.h"
-#include "BKE_object.h"
-
-#include "ED_view3d.h"
-#include "ED_screen.h"
-
-#include "WM_types.h"
-#include "WM_api.h"
-
-#include "GL/glew.h"
-#include "GPU_select.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "UI_interface.h"
-
-#include "../widgets/widget_library/widget_geometry.h"
-
-#include "wm.h"
-#include "WM_types.h"
-
-
-/* to use custom arrows exported to arrow_widget.c */
-//#define WIDGET_USE_CUSTOM_ARROWS
-/* to use custom dials exported to dial_widget.c */
-//#define WIDGET_USE_CUSTOM_DIAS
-
-
-/* -------------------------------------------------------------------- */
-/* Widget drawing */
-
-typedef struct WidgetDrawInfo {
- int nverts;
- int ntris;
- float (*verts)[3];
- float (*normals)[3];
- unsigned short *indices;
- bool init;
-} WidgetDrawInfo;
-
-
-#ifdef WIDGET_USE_CUSTOM_ARROWS
-WidgetDrawInfo arrow_head_draw_info = {0};
-#endif
-WidgetDrawInfo cube_draw_info = {0};
-#ifdef WIDGET_USE_CUSTOM_DIAS
-WidgetDrawInfo dial_draw_info = {0};
-#endif
-
-/**
- * Main draw call for WidgetDrawInfo data
- */
-static void widget_draw_intern(WidgetDrawInfo *info, const bool select)
-{
- GLuint buf[3];
-
- const bool use_lighting = !select && ((U.tw_flag & V3D_SHADED_WIDGETS) != 0);
-
- if (use_lighting)
- glGenBuffers(3, buf);
- else
- glGenBuffers(2, buf);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, buf[0]);
- glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * info->nverts, info->verts, GL_STATIC_DRAW);
- glVertexPointer(3, GL_FLOAT, 0, NULL);
-
- if (use_lighting) {
- glEnableClientState(GL_NORMAL_ARRAY);
- glBindBuffer(GL_ARRAY_BUFFER, buf[2]);
- glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * info->nverts, info->normals, GL_STATIC_DRAW);
- glNormalPointer(GL_FLOAT, 0, NULL);
- glShadeModel(GL_SMOOTH);
- }
-
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf[1]);
- glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned short) * (3 * info->ntris), info->indices, GL_STATIC_DRAW);
-
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
-
- glDrawElements(GL_TRIANGLES, info->ntris * 3, GL_UNSIGNED_SHORT, NULL);
-
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
- glDisableClientState(GL_VERTEX_ARRAY);
-
- if (use_lighting) {
- glDisableClientState(GL_NORMAL_ARRAY);
- glShadeModel(GL_FLAT);
- glDeleteBuffers(3, buf);
- }
- else {
- glDeleteBuffers(2, buf);
- }
-}
-
-
-/* -------------------------------------------------------------------- */
-/* Widget defines */
-
-/** \name Arrow Widget
- *
- * 3D Widget
- *
- * \brief Simple arrow widget which is dragged into a certain direction.
- * The arrow head can have varying shapes, e.g. cone, box, etc.
- *
- * \{ */
-
-/* ArrowWidget->flag */
-enum {
- ARROW_UP_VECTOR_SET = (1 << 0),
- ARROW_CUSTOM_RANGE_SET = (1 << 1),
-};
-
-typedef struct ArrowWidget {
- wmWidget widget;
- int style;
- int flag;
-
- float len; /* arrow line length */
- float direction[3];
- float up[3];
- float aspect[2]; /* cone style only */
-
- float range_fac; /* factor for arrow min/max distance */
- float offset;
- /* property range and minimum for constrained arrows */
- float range, min;
-} ArrowWidget;
-
-typedef struct ArrowInteraction {
- float orig_value; /* initial property value */
- float orig_origin[3];
- float orig_mouse[2];
- float orig_offset;
- float orig_scale;
-
- /* offset of last handling step */
- float prev_offset;
- /* Total offset added by precision tweaking.
- * Needed to allow toggling precision on/off without causing jumps */
- float precision_offset;
-} ArrowInteraction;
-
-/* factor for precision tweaking */
-#define ARROW_PRECISION_FAC 0.05f
-
-
-static void widget_arrow_get_final_pos(wmWidget *widget, float r_pos[3])
-{
- ArrowWidget *arrow = (ArrowWidget *)widget;
-
- mul_v3_v3fl(r_pos, arrow->direction, arrow->offset);
- add_v3_v3(r_pos, arrow->widget.origin);
-}
-
-static void arrow_draw_geom(const ArrowWidget *arrow, const bool select)
-{
- if (arrow->style & W
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list