Commit: 998a9a0322887575b2422421d846d8dbfe61979f
Author: Antonio Vazquez
Date:   Sat Jul 14 12:46:21 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB998a9a0322887575b2422421d846d8dbfe61979f

Remove Grease Pencil Color Picker

This operator has been replaced by the new preview system.

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

M       source/blender/editors/gpencil/CMakeLists.txt
D       source/blender/editors/gpencil/gpencil_colorpick.c
M       source/blender/editors/gpencil/gpencil_intern.h
M       source/blender/editors/gpencil/gpencil_ops.c

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

diff --git a/source/blender/editors/gpencil/CMakeLists.txt 
b/source/blender/editors/gpencil/CMakeLists.txt
index af35be50f0c..f9f196f6634 100644
--- a/source/blender/editors/gpencil/CMakeLists.txt
+++ b/source/blender/editors/gpencil/CMakeLists.txt
@@ -53,7 +53,6 @@ set(SRC
        gpencil_ops.c
        gpencil_paint.c
        gpencil_fill.c
-       gpencil_colorpick.c
        gpencil_select.c
        gpencil_undo.c
        gpencil_utils.c
diff --git a/source/blender/editors/gpencil/gpencil_colorpick.c 
b/source/blender/editors/gpencil/gpencil_colorpick.c
deleted file mode 100644
index d52deeb93ec..00000000000
--- a/source/blender/editors/gpencil/gpencil_colorpick.c
+++ /dev/null
@@ -1,584 +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) 2017, Blender Foundation, Joshua Leung
- * This is a new part of Blender
- *
- * Contributor(s): Antonio Vazquez
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/gpencil/gpencil_colorpick.c
- *  \ingroup edgpencil
- */
-
-#include <stdio.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_rect.h"
-#include "BLI_stack.h"
-
-#include "BLT_translation.h"
-
-#include "DNA_object_types.h"
-#include "DNA_brush_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_windowmanager_types.h"
-#include "DNA_userdef_types.h"
-
-#include "BKE_main.h"
-#include "BKE_brush.h"
-#include "BKE_image.h"
-#include "BKE_gpencil.h"
-#include "BKE_context.h"
-#include "BKE_screen.h"
-#include "BKE_material.h"
-#include "BKE_paint.h"
-#include "BKE_report.h"
-
-#include "ED_gpencil.h"
-#include "ED_screen.h"
-#include "ED_space_api.h"
-#include "ED_view3d.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "IMB_imbuf.h"
-#include "IMB_imbuf_types.h"
-
-#include "GPU_immediate.h"
-#include "GPU_draw.h"
-#include "GPU_matrix.h"
-#include "GPU_framebuffer.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "gpencil_intern.h"
-
-#define GP_BOX_SIZE (32 * U.ui_scale)
-#define GP_BOX_GAP (24 * U.ui_scale)
-#define GP_PICK_NAME_HEIGHT ((GP_BOX_GAP / 2) - (3 * U.ui_scale))
-
-/* Representation of a color displayed in the picker */
-typedef struct tGPDpickColor {
-       struct Material *mat; /* material */
-       rcti full_rect;  /* full size of region occupied by color box (for 
event/highlight handling) */
-       rcti rect;       /* box position */
-       int index;       /* index of color */
-       float rgba[4];   /* stroke color */
-       float fill[4];   /* fill color */
-} tGPDpickColor;
-
-/* Temporary color picker operation data (op->customdata) */
-typedef struct tGPDpick {
-       struct wmWindow *win;               /* window */
-       struct Scene *scene;                /* current scene from context */
-       struct ToolSettings *ts;            /* current toolsettings from 
context */
-       struct Object *ob;                  /* current active gp object */
-       struct ScrArea *sa;                 /* area where painting originated */
-       struct ARegion *ar;                 /* region where painting originated 
*/
-       struct Material *mat;               /* current material */
-       struct Brush *brush;                /* current brush */
-       short bflag;                        /* previous brush flag */
-
-       int center[2];                      /* mouse center position */
-       rcti rect;                          /* visible area */
-       rcti panel;                         /* panel area */
-       int row, col;                       /* number of rows and columns */
-       int boxsize[2];                     /* size of each box color */
-
-       int totcolor;                       /* number of colors */
-       int curindex;                       /* index of color under cursor */
-       tGPDpickColor *colors;              /* colors */
-
-       void *draw_handle_3d;               /* handle for drawing strokes while 
operator is running */
-} tGPDpick;
-
-
-/* draw color name using default font */
-static void gp_draw_color_name(tGPDpick *tgpk, tGPDpickColor *col, const 
uiFontStyle *fstyle, bool focus)
-{
-       bTheme *btheme = UI_GetTheme();
-       uiWidgetColors menuBack = btheme->tui.wcol_menu_back;
-
-       Material *ma = col->mat;
-       char drawstr[UI_MAX_DRAW_STR];
-       const float okwidth = tgpk->boxsize[0];
-       const size_t max_len = sizeof(drawstr);
-       const float minwidth = (float)(UI_DPI_ICON_SIZE);
-
-       uchar text_col[4];
-       if (focus) {
-               copy_v4_v4_char((char *)text_col, menuBack.text_sel);
-       }
-       else {
-               copy_v4_v4_char((char *)text_col, menuBack.text);
-       }
-
-       /* color name */
-       BLI_strncpy(drawstr, ma->id.name + 2, sizeof(drawstr));
-       UI_text_clip_middle_ex((uiFontStyle *)fstyle, drawstr, okwidth, 
minwidth, max_len, '\0');
-       UI_fontstyle_draw_simple(fstyle, col->rect.xmin, col->rect.ymin - 
GP_PICK_NAME_HEIGHT,
-                                                        drawstr, text_col);
-}
-
-/* draw a pattern for alpha display */
-static void gp_draw_pattern_box(int xmin, int ymin, int xmax, int ymax)
-{
-       uint position;
-
-       Gwn_VertFormat *format = immVertexFormat();
-       position = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, 
GWN_FETCH_FLOAT);
-       immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
-
-       /* Drawing the checkerboard. */
-       immUniform4f("color1", UI_ALPHA_CHECKER_DARK / 255.0f, 
UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_DARK / 255.0f, 1.0f);
-       immUniform4f("color2", UI_ALPHA_CHECKER_LIGHT / 255.0f, 
UI_ALPHA_CHECKER_LIGHT / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 1.0f);
-       immUniform1i("size", 8);
-       immRectf(position, xmin, ymin, xmax, ymax);
-       immUnbindProgram();
-}
-
-/* draw a toolbar with all colors of the object */
-static void gpencil_draw_color_table(const bContext *C, tGPDpick *tgpk)
-{
-       if (!tgpk->mat) {
-               return;
-       }
-
-       /* draw only in the region that originated operator. This is required 
for multiwindow */
-       ARegion *ar = CTX_wm_region(C);
-       if (ar != tgpk->ar) {
-               return;
-       }
-
-       const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
-       float background[4];
-       float line[4];
-       float selcolor[4];
-       float wcolor[4] = { 0.9f, 0.9f, 0.9f, 0.8f };
-       float radius = (0.2f * U.widget_unit);
-
-       /* boxes for stroke and fill color */
-       rcti sbox;
-       rcti fbox;
-
-       bTheme *btheme = UI_GetTheme();
-       uiWidgetColors menuBack = btheme->tui.wcol_menu_back;
-       uiWidgetColors menuItem = btheme->tui.wcol_menu_item;
-
-       rgba_uchar_to_float(line, (const uchar *)menuBack.outline);
-       rgba_uchar_to_float(background, (const uchar *)menuBack.inner);
-       rgba_uchar_to_float(selcolor, (const uchar *)menuItem.inner_sel);
-
-       /* draw panel background */
-       /* TODO: Draw soft drop shadow behind this (like standard menus)? */
-       glEnable(GL_BLEND);
-       UI_draw_roundbox_corner_set(UI_CNR_ALL);
-       UI_draw_roundbox_4fv(true, tgpk->panel.xmin, tgpk->panel.ymin,
-               tgpk->panel.xmax, tgpk->panel.ymax,
-               radius, background);
-       glDisable(GL_BLEND);
-
-       /* draw color boxes */
-       tGPDpickColor *col = tgpk->colors;
-       glLineWidth(1.0);
-       for (int i = 0; i < tgpk->totcolor; i++, col++) {
-               const bool focus = (tgpk->curindex == i);
-
-               const int scalex = (col->rect.xmax - col->rect.xmin) / 3;
-               const int scaley = (col->rect.ymax - col->rect.ymin) / 3;
-
-               sbox.xmin = col->rect.xmin;
-               sbox.ymin = col->rect.ymin + scaley;
-               sbox.xmax = col->rect.xmax - scalex;
-               sbox.ymax = col->rect.ymax;
-
-               fbox.xmin = col->rect.xmin + scalex;
-               fbox.ymin = col->rect.ymin;
-               fbox.xmax = col->rect.xmax;
-               fbox.ymax = col->rect.ymax - scaley;
-
-               glEnable(GL_BLEND);
-               glEnable(GL_LINE_SMOOTH);
-
-
-               /* highlight background of item under mouse */
-               if (i == tgpk->curindex) {
-                       /* TODO: How to get the menu gradient shading? */
-                       rcti *cbox = &col->full_rect;
-                       UI_draw_roundbox_4fv(true,
-                               cbox->xmin, cbox->ymin - GP_PICK_NAME_HEIGHT,
-                               cbox->xmax, cbox->ymax,
-                               0, selcolor);
-               }
-
-               /* fill box */
-               UI_draw_roundbox_4fv(true, fbox.xmin, fbox.ymin, fbox.xmax, 
fbox.ymax, radius, wcolor);
-               gp_draw_pattern_box(fbox.xmin + 2, fbox.ymin + 2, fbox.xmax - 
2, fbox.ymax - 2);
-               UI_draw_roundbox_4fv(true, fbox.xmin, fbox.ymin, fbox.xmax, 
fbox.ymax,
-                       radius, col->fill);
-               UI_draw_roundbox_4fv(false, fbox.xmin, fbox.ymin, fbox.xmax, 
fbox.ymax,
-                       radius, line);
-
-               /* stroke box */
-               UI_draw_roundbox_4fv(true, sbox.xmin, sbox.ymin, sbox.xmax, 
sbox.ymax, radius, wcolor);
-               gp_draw_pattern_box(sbox.xmin + 2, sbox.ymin + 2, sbox.xmax - 
2, sbox.ymax - 2);
-               UI_draw_roundbox_4fv(true, sbox.xmin, sbox.ymin, sbox.xmax, 
sbox.ymax,
-                       radius, col->rgba);
-               UI_draw_roundbox_4fv(false, sbox.xmin, sbox.ymin, sbox.xmax, 
sbox.ymax,
-                       radius, line);
-
-               glDisable(GL_BLEND);
-               glDisable(GL_LINE_SMOOTH);
-
-               /* draw color name */
-               gp_draw_color_name(tgpk, col, fstyle, focus);
-       }
-}
-
-/* Drawing callback for modal operator in 3d mode */
-static void gpencil_colorpick_draw_3d(const bContext *C, ARegion *UNUSED(ar), 
void *arg)
-{
-       tGPDpick *tgpk = (tGPDpick *)arg;
-
-       gpencil_draw_color_table(C, tgpk);
-}
-
-/* check if context is suitable */
-static bool gpencil_colorpick_poll(bContext *C)
-{
-       if (ED_operator_regionactive(C)) {
-               ScrArea *sa = CTX_wm_area(C);
-               if (sa->spacetype == SPACE_VIEW3D) {
-                       return 1;
-               }
-               else {
-                       CTX_wm_operator_poll_msg_set(C, "Operator only works in 
the 3D view");
-                       return 0;
-               }
-       }
-       else {
-               CTX_wm_operator_poll_msg_set(C, "Active region not set");
-               return 0;
-       }
-}
-
-/* Allocate memory and initialize values */
-static tGPDpick *gpencil_colorpick_init(bContext *C, wmOperator *op, const 
wmEvent *event)
-{
-       Main *bmain = CTX_data_main(C);
-       tGPDpick *tgpk = MEM_callocN(

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to