2008-12-20 10:02:00 +00:00
|
|
|
/*
|
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-20 10:02:00 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2011-10-20 09:47:05 +00:00
|
|
|
*/
|
2008-12-20 10:02:00 +00:00
|
|
|
|
|
|
|
#ifndef BLI_STRING_H
|
|
|
|
#define BLI_STRING_H
|
|
|
|
|
2011-02-18 13:58:08 +00:00
|
|
|
/** \file BLI_string.h
|
|
|
|
* \ingroup bli
|
|
|
|
*/
|
|
|
|
|
2008-12-20 10:02:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplicates the cstring @a str into a newly mallocN'd
|
|
|
|
* string and returns it.
|
|
|
|
*
|
|
|
|
* @param str The string to be duplicated
|
|
|
|
* @retval Returns the duplicated string
|
|
|
|
*/
|
|
|
|
char *BLI_strdup(const char *str);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duplicates the first @a len bytes of cstring @a str
|
|
|
|
* into a newly mallocN'd string and returns it. @a str
|
|
|
|
* is assumed to be at least len bytes long.
|
|
|
|
*
|
|
|
|
* @param str The string to be duplicated
|
|
|
|
* @param len The number of bytes to duplicate
|
|
|
|
* @retval Returns the duplicated string
|
|
|
|
*/
|
2011-03-25 13:40:44 +00:00
|
|
|
char *BLI_strdupn(const char *str, const size_t len);
|
2008-12-20 10:02:00 +00:00
|
|
|
|
|
|
|
/**
|
2010-11-29 14:29:30 +00:00
|
|
|
* Appends the two strings, and returns new mallocN'ed string
|
|
|
|
* @param str1 first string for copy
|
|
|
|
* @param str2 second string for append
|
|
|
|
* @retval Returns dst
|
|
|
|
*/
|
|
|
|
char *BLI_strdupcat(const char *str1, const char *str2);
|
|
|
|
|
|
|
|
/**
|
2008-12-20 10:02:00 +00:00
|
|
|
* Like strncpy but ensures dst is always
|
|
|
|
* '\0' terminated.
|
|
|
|
*
|
|
|
|
* @param dst Destination for copy
|
|
|
|
* @param src Source string to copy
|
|
|
|
* @param maxncpy Maximum number of characters to copy (generally
|
|
|
|
* the size of dst)
|
|
|
|
* @retval Returns dst
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
*/
|
2011-03-25 13:40:44 +00:00
|
|
|
char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
|
2008-12-20 10:02:00 +00:00
|
|
|
|
2009-10-12 11:27:34 +00:00
|
|
|
/* Makes a copy of the text within the "" that appear after some text 'blahblah'
|
|
|
|
* i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
|
|
|
|
*
|
|
|
|
* - str: is the entire string to chop
|
|
|
|
* - prefix: is the part of the string to leave out
|
|
|
|
*
|
|
|
|
* Assume that the strings returned must be freed afterwards, and that the inputs will contain
|
|
|
|
* data we want...
|
|
|
|
*/
|
|
|
|
char *BLI_getQuotedStr(const char *str, const char *prefix);
|
|
|
|
|
2009-10-09 12:18:32 +00:00
|
|
|
/**
|
|
|
|
* Returns a copy of the cstring @a str into a newly mallocN'd
|
|
|
|
* string with all instances of oldText replaced with newText,
|
|
|
|
* and returns it.
|
|
|
|
*
|
|
|
|
* @param str The string to replace occurances of oldText in
|
|
|
|
* @param oldText The text in the string to find and replace
|
|
|
|
* @param newText The text in the string to find and replace
|
|
|
|
* @retval Returns the duplicated string
|
|
|
|
*/
|
|
|
|
char *BLI_replacestr(char *str, const char *oldText, const char *newText);
|
|
|
|
|
2008-12-20 10:02:00 +00:00
|
|
|
/*
|
|
|
|
* Replacement for snprintf
|
|
|
|
*/
|
2011-03-25 13:40:44 +00:00
|
|
|
size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
|
2010-12-04 11:44:56 +00:00
|
|
|
#ifdef __GNUC__
|
2011-02-27 08:31:10 +00:00
|
|
|
__attribute__ ((format (printf, 3, 4)))
|
2010-12-04 11:44:56 +00:00
|
|
|
#endif
|
|
|
|
;
|
2008-12-20 10:02:00 +00:00
|
|
|
|
2009-03-25 20:29:01 +00:00
|
|
|
/*
|
|
|
|
* Print formatted string into a newly mallocN'd string
|
|
|
|
* and return it.
|
|
|
|
*/
|
2010-12-04 11:44:56 +00:00
|
|
|
char *BLI_sprintfN(const char *format, ...)
|
|
|
|
#ifdef __GNUC__
|
2011-02-27 08:31:10 +00:00
|
|
|
__attribute__ ((format (printf, 1, 2)))
|
2010-12-04 11:44:56 +00:00
|
|
|
#endif
|
|
|
|
;
|
2009-03-25 20:29:01 +00:00
|
|
|
|
2011-08-23 15:08:54 +00:00
|
|
|
size_t BLI_strescape(char *dst, const char *src, const size_t maxlen);
|
|
|
|
|
2008-12-20 10:02:00 +00:00
|
|
|
/**
|
|
|
|
* Compare two strings without regard to case.
|
|
|
|
*
|
|
|
|
* @retval True if the strings are equal, false otherwise.
|
|
|
|
*/
|
2.5
More cleanup!
- removed old UI font completely, including from uiBeginBlock
- emboss hints for uiBlock only have three types now;
Regular, Pulldown, or "Nothing" (only icon/text)
- removed old font path from Userdef
- removed all old button theme hinting
- removed old "auto block" to merge buttons in groups
(was only in use for radiosity buttons)
And went over all warnings. One hooray for make giving clean output :)
Well, we need uniform definitions for warnings, so people at least fix
them... here's the real bad bugs I found:
- in mesh code, a call to editmesh mixed *em and *me
- in armature, ED_util.h was not included, so no warnings for wrong call
to ED_undo_push()
- The extern Py api .h was not included in the bpy_interface.c, showing
a several calls using different args.
Further just added the missing includes, and removed unused vars.
2009-04-14 15:59:52 +00:00
|
|
|
int BLI_strcaseeq(const char *a, const char *b);
|
2008-12-20 10:02:00 +00:00
|
|
|
|
|
|
|
char *BLI_strcasestr(const char *s, const char *find);
|
|
|
|
int BLI_strcasecmp(const char *s1, const char *s2);
|
2011-03-25 13:40:44 +00:00
|
|
|
int BLI_strncasecmp(const char *s1, const char *s2, size_t len);
|
2009-06-08 20:08:19 +00:00
|
|
|
int BLI_natstrcmp(const char *s1, const char *s2);
|
2010-05-08 15:37:29 +00:00
|
|
|
size_t BLI_strnlen(const char *str, size_t maxlen);
|
2008-12-20 10:02:00 +00:00
|
|
|
void BLI_timestr(double _time, char *str); /* time var is global */
|
|
|
|
|
2011-05-26 09:58:22 +00:00
|
|
|
void BLI_ascii_strtolower(char *str, int len);
|
|
|
|
void BLI_ascii_strtoupper(char *str, int len);
|
|
|
|
|
2008-12-20 10:02:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|