Changed blend mode listing names, and removed useless blend modes
This commit is contained in:
parent
3795b43dca
commit
5be677483a
4 changed files with 36 additions and 21 deletions
|
|
@ -296,7 +296,8 @@ void DrawingProgramLayerManagerGUI::setup_list_gui(const char* id, bool& hoverin
|
|||
if(tempPtr) {
|
||||
nameToEdit = tempPtr->get_name();
|
||||
alphaValToEdit = tempPtr->get_alpha();
|
||||
blendModeValToEdit = static_cast<size_t>(tempPtr->get_blend_mode());
|
||||
auto it = std::find(get_blend_mode_useful_list().begin(), get_blend_mode_useful_list().end(), tempPtr->get_blend_mode());
|
||||
blendModeValToEdit = (it == get_blend_mode_useful_list().end()) ? 0 : (it - get_blend_mode_useful_list().begin());
|
||||
}
|
||||
else {
|
||||
nameToEdit.clear();
|
||||
|
|
@ -341,12 +342,12 @@ void DrawingProgramLayerManagerGUI::setup_list_gui(const char* id, bool& hoverin
|
|||
tempPtr->set_alpha(layerMan, alphaValToEdit);
|
||||
gui.left_to_right_line_layout([&]() {
|
||||
gui.text_label("Blend Mode");
|
||||
gui.dropdown_select("input blend mode", &blendModeValToEdit, get_blend_mode_name_list(), 200.0f, [&hoveringOverDropdown]() {
|
||||
gui.dropdown_select("input blend mode", &blendModeValToEdit, get_blend_mode_useful_name_list(), 240.0f, [&hoveringOverDropdown]() {
|
||||
if(Clay_Hovered())
|
||||
hoveringOverDropdown = true;
|
||||
});
|
||||
});
|
||||
tempPtr->set_blend_mode(layerMan, static_cast<SerializedBlendMode>(blendModeValToEdit));
|
||||
tempPtr->set_blend_mode(layerMan, get_blend_mode_useful_list()[blendModeValToEdit]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,28 @@
|
|||
#include "SerializedBlendMode.hpp"
|
||||
#include <unordered_set>
|
||||
|
||||
SkBlendMode serialized_blend_mode_to_sk_blend_mode(SerializedBlendMode serializedBlendMode) {
|
||||
int skBlendModeStartVal = static_cast<int>(SkBlendMode::kClear);
|
||||
return static_cast<SkBlendMode>(skBlendModeStartVal + static_cast<uint8_t>(serializedBlendMode));
|
||||
}
|
||||
|
||||
const std::vector<std::string>& get_blend_mode_name_list() {
|
||||
static std::vector<std::string> blendModeList;
|
||||
const std::vector<SerializedBlendMode>& get_blend_mode_useful_list() {
|
||||
static std::vector<SerializedBlendMode> blendModeList;
|
||||
if(blendModeList.empty()) {
|
||||
for(uint8_t i = 0; i < static_cast<uint8_t>(SerializedBlendMode::LAST_MODE); i++)
|
||||
blendModeList.emplace_back(nlohmann::json(static_cast<SerializedBlendMode>(i)));
|
||||
std::unordered_set<SerializedBlendMode> exclusionList = {SerializedBlendMode::CLEAR, SerializedBlendMode::SRC, SerializedBlendMode::DST};
|
||||
for(uint8_t i = 0; i < static_cast<uint8_t>(SerializedBlendMode::LAST_MODE); i++) {
|
||||
if(!exclusionList.contains(static_cast<SerializedBlendMode>(i)))
|
||||
blendModeList.emplace_back(static_cast<SerializedBlendMode>(i));
|
||||
}
|
||||
}
|
||||
return blendModeList;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& get_blend_mode_useful_name_list() {
|
||||
static std::vector<std::string> blendModeNameList;
|
||||
if(blendModeNameList.empty()) {
|
||||
for(SerializedBlendMode i : get_blend_mode_useful_list())
|
||||
blendModeNameList.emplace_back(nlohmann::json(static_cast<SerializedBlendMode>(i)));
|
||||
}
|
||||
return blendModeNameList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,16 +38,16 @@ enum class SerializedBlendMode : uint8_t {
|
|||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(SerializedBlendMode, {
|
||||
{SerializedBlendMode::CLEAR, "Clear"},
|
||||
{SerializedBlendMode::SRC, "Src"},
|
||||
{SerializedBlendMode::DST, "Dst"},
|
||||
{SerializedBlendMode::SRC_OVER, "Src Over"},
|
||||
{SerializedBlendMode::DST_OVER, "Dst Over"},
|
||||
{SerializedBlendMode::SRC_IN, "Src In"},
|
||||
{SerializedBlendMode::DST_IN, "Dst In"},
|
||||
{SerializedBlendMode::SRC_OUT, "Src Out"},
|
||||
{SerializedBlendMode::DST_OUT, "Dst Out"},
|
||||
{SerializedBlendMode::SRC_A_TOP, "Src A Top"},
|
||||
{SerializedBlendMode::DST_A_TOP, "Dst A Top"},
|
||||
{SerializedBlendMode::SRC, "Source"},
|
||||
{SerializedBlendMode::DST, "Destination"},
|
||||
{SerializedBlendMode::SRC_OVER, "Source Over"},
|
||||
{SerializedBlendMode::DST_OVER, "Destination Over"},
|
||||
{SerializedBlendMode::SRC_IN, "Source In"},
|
||||
{SerializedBlendMode::DST_IN, "Destination In"},
|
||||
{SerializedBlendMode::SRC_OUT, "Source Out"},
|
||||
{SerializedBlendMode::DST_OUT, "Destination Out"},
|
||||
{SerializedBlendMode::SRC_A_TOP, "Source Alpha Top"},
|
||||
{SerializedBlendMode::DST_A_TOP, "Destination Alpha Top"},
|
||||
{SerializedBlendMode::XOR, "XOR"},
|
||||
{SerializedBlendMode::PLUS, "Plus"},
|
||||
{SerializedBlendMode::MODULATE, "Modulate"},
|
||||
|
|
@ -69,4 +69,5 @@ NLOHMANN_JSON_SERIALIZE_ENUM(SerializedBlendMode, {
|
|||
})
|
||||
|
||||
SkBlendMode serialized_blend_mode_to_sk_blend_mode(SerializedBlendMode serializedBlendMode);
|
||||
const std::vector<std::string>& get_blend_mode_name_list();
|
||||
const std::vector<SerializedBlendMode>& get_blend_mode_useful_list();
|
||||
const std::vector<std::string>& get_blend_mode_useful_name_list();
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ void Toolbar::grid_menu(bool justOpened) {
|
|||
gui.push_id("grid menu");
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0, 600) },
|
||||
.sizing = {.width = CLAY_SIZING_FIT(350), .height = CLAY_SIZING_FIT(0, 600) },
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
|
|
@ -808,7 +808,7 @@ void Toolbar::bookmark_menu(bool justOpened) {
|
|||
gui.push_id("bookmark menu");
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0, 600) },
|
||||
.sizing = {.width = CLAY_SIZING_FIT(350), .height = CLAY_SIZING_FIT(0, 600) },
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
|
|
@ -833,7 +833,7 @@ void Toolbar::layer_menu(bool justOpened) {
|
|||
gui.push_id("layer menu");
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(300), .height = CLAY_SIZING_FIT(0, 600) },
|
||||
.sizing = {.width = CLAY_SIZING_FIT(350), .height = CLAY_SIZING_FIT(0, 600) },
|
||||
.padding = CLAY_PADDING_ALL(io->theme->padding1),
|
||||
.childGap = io->theme->childGap1,
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue