Including <iostream> or similar headers is quite expensive, since it also pulls in things like <locale> and so on. In many BLI headers, iostreams are only used to implement some sort of "debug print", or an operator<< for ostream. Change some of the commonly used places to instead include <iosfwd>, which is the standard way of forward-declaring iostreams related classes, and move the actual debug-print / operator<< implementations into .cc files. This is not done for templated classes though (it would be possible to provide explicit operator<< instantiations somewhere in the source file, but that would lead to hard-to-figure-out linker error whenever someone would add a different template type). There, where possible, I changed from full <iostream> include to only the needed <ostream> part. For Span<T>, I just removed print_as_lines since it's not used by anything. It could be moved into a .cc file using a similar approach as above if needed. Doing full blender build changes include counts this way: - <iostream> 1986 -> 978 - <sstream> 2880 -> 925 It does not affect the total build time much though, mostly because towards the end of it there's just several CPU cores finishing compiling OpenVDB related source files. Pull Request: https://projects.blender.org/blender/blender/pulls/111046
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup edinterface
|
|
*/
|
|
|
|
#include "UI_interface.hh"
|
|
|
|
#include "BLI_string.h"
|
|
|
|
namespace blender::ui {
|
|
|
|
DragInfo::DragInfo(const wmDrag &drag, const wmEvent &event, const DropLocation drop_location)
|
|
: drag_data(drag), event(event), drop_location(drop_location)
|
|
{
|
|
}
|
|
|
|
std::optional<DropLocation> DropTargetInterface::choose_drop_location(
|
|
const ARegion & /*region*/, const wmEvent & /*event*/) const
|
|
{
|
|
return DropLocation::Into;
|
|
}
|
|
|
|
bool drop_target_apply_drop(bContext &C,
|
|
const ARegion ®ion,
|
|
const wmEvent &event,
|
|
const DropTargetInterface &drop_target,
|
|
const ListBase &drags)
|
|
{
|
|
const char *disabled_hint_dummy = nullptr;
|
|
LISTBASE_FOREACH (const wmDrag *, drag, &drags) {
|
|
if (!drop_target.can_drop(*drag, &disabled_hint_dummy)) {
|
|
return false;
|
|
}
|
|
|
|
const std::optional<DropLocation> drop_location = drop_target.choose_drop_location(region,
|
|
event);
|
|
if (!drop_location) {
|
|
return false;
|
|
}
|
|
|
|
const DragInfo drag_info{*drag, event, *drop_location};
|
|
return drop_target.on_drop(&C, drag_info);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
char *drop_target_tooltip(const ARegion ®ion,
|
|
const DropTargetInterface &drop_target,
|
|
const wmDrag &drag,
|
|
const wmEvent &event)
|
|
{
|
|
const char *disabled_hint_dummy = nullptr;
|
|
if (!drop_target.can_drop(drag, &disabled_hint_dummy)) {
|
|
return nullptr;
|
|
}
|
|
|
|
const std::optional<DropLocation> drop_location = drop_target.choose_drop_location(region,
|
|
event);
|
|
if (!drop_location) {
|
|
return nullptr;
|
|
}
|
|
|
|
const DragInfo drag_info{drag, event, *drop_location};
|
|
const std::string tooltip = drop_target.drop_tooltip(drag_info);
|
|
return tooltip.empty() ? nullptr : BLI_strdup(tooltip.c_str());
|
|
}
|
|
|
|
} // namespace blender::ui
|