#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/MarkdownTip.hpp>
|
| static bool | ShowTip (std::string const &tip, std::string const &tooltip, wxPoint pos) |
| static void | ExitTip () |
| static void | Reload () |
| static void | Recreate (wxWindow *parent) |
| static wxWindow * | AttachTo (wxWindow *parent) |
| static wxWindow * | DetachFrom (wxWindow *parent) |
◆ MarkdownTip()
| Slic3r::GUI::MarkdownTip::MarkdownTip |
( |
| ) |
|
|
private |
87 : wxPopupTransientWindow(wxGetApp().mainframe, wxBORDER_NONE)
88{
89 wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
90
92 topsizer->Add(
_tipView, wxSizerFlags().Expand().Proportion(1));
93
94 SetSizer(topsizer);
95 SetSize({400, 300});
96
98
101}
wxWebView * CreateTipView(wxWindow *parent)
Definition MarkdownTip.cpp:240
void LoadStyle()
Definition MarkdownTip.cpp:105
void OnTimer(wxTimerEvent &event)
Definition MarkdownTip.cpp:285
wxTimer * _timer
Definition MarkdownTip.hpp:67
wxWebView * _tipView
Definition MarkdownTip.hpp:61
References _timer, _tipView, CreateTipView(), LoadStyle(), and OnTimer().
Referenced by AttachTo(), DetachFrom(), and markdownTip().
◆ ~MarkdownTip()
| Slic3r::GUI::MarkdownTip::~MarkdownTip |
( |
| ) |
|
|
private |
◆ AttachTo()
| wxWindow * Slic3r::GUI::MarkdownTip::AttachTo |
( |
wxWindow * | parent | ) |
|
|
static |
339{
341 tip._tipView = tip.CreateTipView(parent);
342 tip._pendingScript = " ";
343 return tip._tipView;
344}
MarkdownTip()
Definition MarkdownTip.cpp:86
static MarkdownTip * markdownTip(bool create=true)
Definition MarkdownTip.cpp:302
References MarkdownTip(), _pendingScript, _tipView, CreateTipView(), and markdownTip().
◆ CreateTipView()
| wxWebView * Slic3r::GUI::MarkdownTip::CreateTipView |
( |
wxWindow * | parent | ) |
|
|
private |
241{
246 return tipView;
247}
void OnTitleChanged(wxWebViewEvent &event)
Definition MarkdownTip.cpp:253
void OnLoaded(wxWebViewEvent &event)
Definition MarkdownTip.cpp:249
void OnError(wxWebViewEvent &event)
Definition MarkdownTip.cpp:281
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313
References WebView::CreateWebView(), OnError(), OnLoaded(), and OnTitleChanged().
Referenced by MarkdownTip(), and AttachTo().
◆ DetachFrom()
| wxWindow * Slic3r::GUI::MarkdownTip::DetachFrom |
( |
wxWindow * | parent | ) |
|
|
static |
◆ ExitTip()
| void Slic3r::GUI::MarkdownTip::ExitTip |
( |
| ) |
|
|
static |
◆ LoadStyle()
| void Slic3r::GUI::MarkdownTip::LoadStyle |
( |
| ) |
|
|
private |
106{
109 ph /= "resources/tooltip/common/styled.html";
111 if (!fs::exists(ph)) {
113 ph /= "tooltip/styled.html";
115 }
118}
std::string _language
Definition MarkdownTip.hpp:64
bool _data_dir
Definition MarkdownTip.hpp:69
std::string _lastTip
Definition MarkdownTip.hpp:62
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
const std::string & data_dir()
Definition utils.cpp:365
const std::string & resources_dir()
Definition utils.cpp:296
References _data_dir, _language, _lastTip, _tipView, Slic3r::data_dir(), Slic3r::GUI::file_url_from_path(), Slic3r::GUI::into_u8(), and Slic3r::resources_dir().
Referenced by MarkdownTip().
◆ LoadTip()
| std::string Slic3r::GUI::MarkdownTip::LoadTip |
( |
std::string const & | tip, |
|
|
std::string const & | tooltip ) |
|
private |
173{
174 fs::path ph;
175 wxString file;
180 ph /=
"resources/tooltip/" +
_language +
"/" + tip +
".md";
182 if (wxFile::Exists(file) &&
f.Open(file)) {
183 std::string content(
f.Length(), 0);
184 f.Read(&content[0], content.size());
185 return content;
186 }
187 }
189 ph /= "resources/tooltip/common/" + tip + ".md";
191 if (wxFile::Exists(file) &&
f.Open(file)) {
192 std::string content(
f.Length(), 0);
193 f.Read(&content[0], content.size());
194 return content;
195 }
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
216 ph /=
"tooltip/" +
_language +
"/" + tip +
".md";
218 if (wxFile::Exists(file) &&
f.Open(file)) {
219 std::string content(
f.Length(), 0);
220 f.Read(&content[0], content.size());
221 return content;
222 }
224 ph /= "tooltip/" + tip + ".md";
226 if (wxFile::Exists(file) &&
f.Open(file)) {
227 std::string content(
f.Length(), 0);
228 f.Read(&content[0], content.size());
229 return content;
230 }
231 if (!tooltip.empty())
return "#### " +
_utf8(tip) +
"\n" + tooltip;
232 return (
_tipView->GetParent() ==
this && tip.empty()) ?
"" :
LoadTip(
"",
"");
233}
std::string LoadTip(std::string const &tip, std::string const &tooltip)
Definition MarkdownTip.cpp:172
wxString from_u8(const std::string &str)
Definition GUI.cpp:544
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
#define _utf8(s)
Definition I18N.hpp:10
References _data_dir, _language, _tipView, _utf8, Slic3r::data_dir(), Slic3r::f(), Slic3r::GUI::from_u8(), LoadTip(), and Slic3r::resources_dir().
Referenced by LoadTip(), and ShowTip().
◆ markdownTip()
| MarkdownTip * Slic3r::GUI::MarkdownTip::markdownTip |
( |
bool | create = true | ) |
|
|
staticprivate |
◆ OnError()
| void Slic3r::GUI::MarkdownTip::OnError |
( |
wxWebViewEvent & | event | ) |
|
|
private |
◆ OnLoaded()
| void Slic3r::GUI::MarkdownTip::OnLoaded |
( |
wxWebViewEvent & | event | ) |
|
|
private |
◆ OnTimer()
| void Slic3r::GUI::MarkdownTip::OnTimer |
( |
wxTimerEvent & | event | ) |
|
|
private |
286{
288 wxPoint
pos = ScreenToClient(wxGetMousePosition());
289 if (GetClientRect().Contains(pos)) {
290 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::OnTimer: restart hide timer...";
292 return;
293 }
294 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::OnTimer: hide.";
295 this->Hide();
296 } else {
297 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::OnTimer: show.";
298 this->Show();
299 }
300}
bool _hide
Definition MarkdownTip.hpp:68
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
References _hide, and _timer.
Referenced by MarkdownTip().
◆ OnTitleChanged()
| void Slic3r::GUI::MarkdownTip::OnTitleChanged |
( |
wxWebViewEvent & | event | ) |
|
|
private |
254{
258 return;
259 }
260#ifdef __linux__
261 wxString str = "0";
262#else
263 wxString str = event.GetString();
264#endif
266 if (str.ToDouble(&height)) {
268 return;
271 wxSize size = wxDisplay(this).GetClientArea().GetSize();
272 if (height > size.y)
275 if (
pos.y + height > size.y)
277 this->SetSize({ 400, (int)height });
278 this->SetPosition(pos);
279 }
280}
void RunScript(std::string const &script)
Definition MarkdownTip.cpp:235
wxPoint _requestPos
Definition MarkdownTip.hpp:65
std::string _pendingScript
Definition MarkdownTip.hpp:63
double _lastHeight
Definition MarkdownTip.hpp:66
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
References _lastHeight, _pendingScript, _requestPos, and RunScript().
Referenced by CreateTipView().
◆ Recreate()
| void Slic3r::GUI::MarkdownTip::Recreate |
( |
wxWindow * | parent | ) |
|
|
static |
331{
333 tip->Reparent(parent);
334 tip->LoadStyle();
335 }
336}
References markdownTip().
◆ Reload()
| void Slic3r::GUI::MarkdownTip::Reload |
( |
| ) |
|
|
static |
◆ RunScript()
| void Slic3r::GUI::MarkdownTip::RunScript |
( |
std::string const & | script | ) |
|
|
private |
◆ ShowTip() [1/2]
| bool Slic3r::GUI::MarkdownTip::ShowTip |
( |
std::string const & | tip, |
|
|
std::string const & | tooltip, |
|
|
wxPoint | pos ) |
|
static |
◆ ShowTip() [2/2]
| bool Slic3r::GUI::MarkdownTip::ShowTip |
( |
wxPoint | pos, |
|
|
std::string const & | tip, |
|
|
std::string const & | tooltip ) |
|
private |
121{
122 if (tip.empty()) {
124 return false;
127 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::ShowTip: hide soon on empty tip.";
128 this->Hide();
129 }
132 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::ShowTip: start hide timer (300)...";
134 }
135 return false;
136 }
138 if (tipChanged) {
139 auto content =
LoadTip(tip, tooltip);
140 if (content.empty()) {
142 this->Hide();
143 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::ShowTip: hide soon on empty content.";
144 return false;
145 }
146 auto script =
"window.showMarkdown('" +
url_encode(content) +
"', true);";
149 }
150 else {
152 }
155 this->Hide();
156 }
157 if (
_tipView->GetParent() ==
this) {
158 wxSize size = wxDisplay(this).GetClientArea().GetSize();
160 if (
pos.y + this->GetSize().y > size.y)
161 pos.y = size.y - this->GetSize().y;
162 this->SetPosition(pos);
163 if (tipChanged ||
_hide) {
165 BOOST_LOG_TRIVIAL(info) << "MarkdownTip::ShowTip: start show timer (500)...";
167 }
168 }
169 return true;
170}
static std::string url_encode(const std::string &value)
Definition MarkdownTip.cpp:33
References _hide, _lastTip, _pendingScript, _requestPos, _timer, _tipView, LoadTip(), RunScript(), and Slic3r::GUI::url_encode().
◆ _data_dir
| bool Slic3r::GUI::MarkdownTip::_data_dir = false |
|
private |
◆ _hide
| bool Slic3r::GUI::MarkdownTip::_hide = false |
|
private |
◆ _language
| std::string Slic3r::GUI::MarkdownTip::_language |
|
private |
◆ _lastHeight
| double Slic3r::GUI::MarkdownTip::_lastHeight = 0 |
|
private |
◆ _lastTip
| std::string Slic3r::GUI::MarkdownTip::_lastTip |
|
private |
◆ _pendingScript
| std::string Slic3r::GUI::MarkdownTip::_pendingScript = " " |
|
private |
◆ _requestPos
| wxPoint Slic3r::GUI::MarkdownTip::_requestPos |
|
private |
◆ _timer
| wxTimer* Slic3r::GUI::MarkdownTip::_timer = nullptr |
|
private |
◆ _tipView
| wxWebView* Slic3r::GUI::MarkdownTip::_tipView = nullptr |
|
private |
The documentation for this class was generated from the following files: