-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugging issue with colour picker (#2422)
- Loading branch information
Showing
9 changed files
with
40 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* ct_actions_format.cc | ||
* | ||
* Copyright 2009-2023 | ||
* Copyright 2009-2024 | ||
* Giuseppe Penone <[email protected]> | ||
* Evgenii Gurianov <https://github.com/txe> | ||
* | ||
|
@@ -365,19 +365,17 @@ void CtActions::apply_tag(const Glib::ustring& tag_property, | |
property_value = _links_entries_post_dialog(_link_entry); | ||
} | ||
else { | ||
gchar color_for = tag_property[0] == 'f' ? 'f' : 'b'; | ||
Gdk::RGBA ret_color = Gdk::RGBA(_pCtConfig->currColors.at(color_for)); | ||
Glib::ustring title = tag_property[0] == 'f' ? _("Pick a Foreground Color") : _("Pick a Background Color"); | ||
auto res = CtDialogs::color_pick_dialog(_pCtMainWin, title, ret_color, true); | ||
Glib::ustring& ret_colour = 'f' == tag_property[0] ? _pCtConfig->currColour_fg : _pCtConfig->currColour_bg; | ||
const Glib::ustring title = 'f' == tag_property[0] ? _("Pick a Foreground Color") : _("Pick a Background Color"); | ||
const CtDialogs::CtPickDlgState res = CtDialogs::colour_pick_dialog(_pCtMainWin, title, ret_colour, true/*allow_remove_colour*/); | ||
if (res == CtDialogs::CtPickDlgState::CANCEL) { | ||
return; | ||
} | ||
else if (res == CtDialogs::CtPickDlgState::REMOVE_COLOR) { | ||
if (res == CtDialogs::CtPickDlgState::REMOVE_COLOR) { | ||
property_value = "-"; // don't use empty because `apply prev tag` command brings a color dialog again | ||
} | ||
else { | ||
_pCtConfig->currColors[color_for] = CtRgbUtil::rgb_to_string(ret_color); | ||
property_value = CtRgbUtil::rgb_to_string(ret_color); | ||
property_value = ret_colour; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* ct_dialogs.h | ||
* | ||
* Copyright 2009-2023 | ||
* Copyright 2009-2024 | ||
* Giuseppe Penone <[email protected]> | ||
* Evgenii Gurianov <https://github.com/txe> | ||
* | ||
|
@@ -168,8 +168,8 @@ CtExporting selnode_selnodeandsub_alltree_dialog(Gtk::Window& parent, | |
|
||
// Dialog to select a color, featuring a palette | ||
enum class CtPickDlgState {SELECTED, CANCEL, REMOVE_COLOR }; | ||
CtPickDlgState color_pick_dialog(CtMainWin* pCtMainWin, const Glib::ustring& title, | ||
Gdk::RGBA& color, bool allow_remove_color); | ||
CtPickDlgState colour_pick_dialog(CtMainWin* pCtMainWin, const Glib::ustring& title, | ||
Glib::ustring& colour, bool allow_remove_colour); | ||
|
||
// The Question dialog, returns True if the user presses OK | ||
bool question_dialog(const Glib::ustring& message, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* ct_dialogs_tree.cc | ||
* | ||
* Copyright 2009-2023 | ||
* Copyright 2009-2024 | ||
* Giuseppe Penone <[email protected]> | ||
* Evgenii Gurianov <https://github.com/txe> | ||
* | ||
|
@@ -52,7 +52,7 @@ bool CtDialogs::node_prop_dialog(const Glib::ustring &title, | |
|
||
Gtk::CheckButton fg_checkbutton{_("Use Selected Color")}; | ||
fg_checkbutton.set_active(not nodeData.foregroundRgb24.empty()); | ||
Glib::ustring real_fg = not nodeData.foregroundRgb24.empty() ? nodeData.foregroundRgb24 : (not pCtConfig->currColors.at('n').empty() ? pCtConfig->currColors.at('n').c_str() : "red"); | ||
Glib::ustring real_fg = not nodeData.foregroundRgb24.empty() ? nodeData.foregroundRgb24 : (not pCtConfig->currColour_nn.empty() ? pCtConfig->currColour_nn.c_str() : "red"); | ||
Gtk::ColorButton fg_colorbutton{Gdk::RGBA{real_fg}}; | ||
fg_colorbutton.set_sensitive(not nodeData.foregroundRgb24.empty()); | ||
|
||
|
@@ -197,9 +197,9 @@ bool CtDialogs::node_prop_dialog(const Glib::ustring &title, | |
fg_colorbutton.set_sensitive(fg_checkbutton.get_active()); | ||
}); | ||
fg_colorbutton.signal_pressed().connect([&pCtMainWin, &fg_colorbutton](){ | ||
Gdk::RGBA ret_color = fg_colorbutton.get_rgba(); | ||
if (CtDialogs::color_pick_dialog(pCtMainWin, _("Pick a Color"), ret_color, false) == CtPickDlgState::SELECTED) { | ||
fg_colorbutton.set_rgba(ret_color); | ||
Glib::ustring ret_colour = fg_colorbutton.get_rgba().to_string(); | ||
if (CtDialogs::colour_pick_dialog(pCtMainWin, _("Pick a Color"), ret_colour, false) == CtPickDlgState::SELECTED) { | ||
fg_colorbutton.set_rgba(Gdk::RGBA(ret_colour)); | ||
} | ||
}); | ||
c_icon_checkbutton.signal_toggled().connect([&c_icon_checkbutton, &c_icon_button, &nodeData, &currCustomIconId](){ | ||
|
@@ -285,7 +285,7 @@ bool CtDialogs::node_prop_dialog(const Glib::ustring &title, | |
nodeData.isBold = is_bold_checkbutton.get_active(); | ||
if (fg_checkbutton.get_active()) { | ||
nodeData.foregroundRgb24 = CtRgbUtil::get_rgb24str_from_str_any(fg_colorbutton.get_color().to_string()); | ||
pCtConfig->currColors['n'] = nodeData.foregroundRgb24; | ||
pCtConfig->currColour_nn = nodeData.foregroundRgb24; | ||
} | ||
else { | ||
nodeData.foregroundRgb24.clear(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* ct_misc_utils.cc | ||
* | ||
* Copyright 2009-2023 | ||
* Copyright 2009-2024 | ||
* Giuseppe Penone <[email protected]> | ||
* Evgenii Gurianov <https://github.com/txe> | ||
* | ||
|
@@ -956,14 +956,14 @@ guint32 CtRgbUtil::get_rgb24int_from_str_any(const char* rgbStrAny) | |
return get_rgb24int_from_rgb24str(rgb24Str); | ||
} | ||
|
||
std::string CtRgbUtil::rgb_to_string(Gdk::RGBA color) | ||
std::string CtRgbUtil::rgb_to_string(const Gdk::RGBA& color) | ||
{ | ||
char rgbStrOut[16]; | ||
sprintf(rgbStrOut, "#%.4x%.4x%.4x", color.get_red_u(), color.get_green_u(), color.get_blue_u()); | ||
return rgbStrOut; | ||
} | ||
|
||
std::string CtRgbUtil::rgb_any_to_24(Gdk::RGBA color) | ||
std::string CtRgbUtil::rgb_any_to_24(const Gdk::RGBA& color) | ||
{ | ||
char rgb24StrOut[16]; | ||
set_rgb24str_from_str_any(CtRgbUtil::rgb_to_string(color).c_str(), rgb24StrOut); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* ct_misc_utils.h | ||
* | ||
* Copyright 2009-2023 | ||
* Copyright 2009-2024 | ||
* Giuseppe Penone <[email protected]> | ||
* Evgenii Gurianov <https://github.com/txe> | ||
* | ||
|
@@ -281,9 +281,9 @@ std::string get_rgb24str_from_str_any(const std::string& rgbStrAny); | |
|
||
guint32 get_rgb24int_from_str_any(const char* rgbStrAny); | ||
|
||
std::string rgb_to_string(Gdk::RGBA color); | ||
std::string rgb_to_string(const Gdk::RGBA& color); | ||
|
||
std::string rgb_any_to_24(Gdk::RGBA color); | ||
std::string rgb_any_to_24(const Gdk::RGBA& color); | ||
|
||
} // namespace CtRgbUtil | ||
|
||
|