Grease Pencil: Datablock bugfixes
authorJoshua Leung <aligorith@gmail.com>
Thu, 3 Sep 2009 05:12:34 +0000 (05:12 +0000)
committerJoshua Leung <aligorith@gmail.com>
Thu, 3 Sep 2009 05:12:34 +0000 (05:12 +0000)
* Grease Pencil datablocks can now be properly browsed/added/unlinked from the UI panels

* Made Grease Pencil use the brush icon for now. A proper icon for this would be nice ;)

source/blender/editors/gpencil/gpencil_buttons.c
source/blender/makesrna/intern/rna_ID.c
source/blender/makesrna/intern/rna_gpencil.c

index c3f779b59b89780ee3c0efeb55f5cdc0e309ac0c..0d7cd26324579dadb21fe0cc94ff6a21bc414bf2 100644 (file)
@@ -238,12 +238,15 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
        col= uiLayoutColumn(layout, 0);
                /* current Grease Pencil block */
                // TODO: show some info about who owns this?
-               //uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_new", "GPENCIL_OT_data_unlink"); // XXX not working
-               uiItemR(col, NULL, 0, ctx_ptr, "grease_pencil", 0); // XXX this will have to do for now...
+               uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", "GPENCIL_OT_data_unlink"); 
                
-               /* add new layer button */
+               /* add new layer button - can be used even when no data, since it can add a new block too */
                uiItemO(col, NULL, 0, "GPENCIL_OT_layer_add");
        
+       /* sanity checks... */
+       if (gpd == NULL)
+               return;
+       
        /* draw each layer --------------------------------------------- */
        for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
                col= uiLayoutColumn(layout, 1);
@@ -271,7 +274,7 @@ void gpencil_panel_standard(const bContext *C, Panel *pa)
        /* get pointer to Grease Pencil Data */
        gpd_ptr= gpencil_data_get_pointers((bContext *)C, &ptr);
        
-       if (gpd_ptr && *gpd_ptr)
+       if (gpd_ptr)
                draw_gpencil_panel((bContext *)C, pa->layout, *gpd_ptr, &ptr);
 }
 
index dd26391b11ee0a7c2e85acf97b95db137f06b05a..f5c6063e8924c31d9dab09ddc36c5a2e128ab86d 100644 (file)
@@ -65,6 +65,7 @@ short RNA_type_to_ID_code(StructRNA *type)
        if(RNA_struct_is_a(type, &RNA_Brush)) return ID_BR;
        if(RNA_struct_is_a(type, &RNA_Camera)) return ID_CA;
        if(RNA_struct_is_a(type, &RNA_Curve)) return ID_CU;
+       if(RNA_struct_is_a(type, &RNA_GreasePencil)) return ID_GD;
        if(RNA_struct_is_a(type, &RNA_Group)) return ID_GR;
        if(RNA_struct_is_a(type, &RNA_Image)) return ID_IM;
        if(RNA_struct_is_a(type, &RNA_Key)) return ID_KE;
index df0e5ae67032fa7a452e06656bd25c55b53cc334..5caa868fd2e05c84bdc8e19bda0fbafa38a90df8 100644 (file)
@@ -223,7 +223,7 @@ void rna_def_gpencil_data(BlenderRNA *brna)
        srna= RNA_def_struct(brna, "GreasePencil", "ID");
        RNA_def_struct_sdna(srna, "bGPdata");
        RNA_def_struct_ui_text(srna, "Grease Pencil", "Freehand annotation sketchbook.");
-       //RNA_def_struct_ui_icon(srna, ICON_GPENCIL);
+       RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); // XXX: ICON_GPENCIL!!!
        
        /* Layers */
        prop= RNA_def_property(srna, "layers", PROP_COLLECTION, PROP_NONE);