ide, RichText: Fixed numerous issues with Topic++ and SlideShow

git-svn-id: svn://ultimatepp.org/upp/trunk@12826 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2019-03-11 09:35:47 +00:00
parent 62e0584846
commit 5f15a14ff3
8 changed files with 55 additions and 37 deletions

View file

@ -156,7 +156,6 @@ Speller *sGetSpeller(int lang)
#ifdef PLATFORM_POSIX
pp << "/usr/local/share/upp/speller;/usr/local/share/upp;/usr/share/upp/speller;/usr/share/upp";
#endif
RDUMP(pp);
String path = GetFileOnPath(ToLower(LNGAsText(lang)) + ".udc", pp);
if(IsNull(path))
return NULL;

View file

@ -43,6 +43,7 @@ private:
void RefreshSel();
void RefreshRange(int a, int b);
WString GetSelText() const;
int TopY() const;
protected:
enum {
@ -63,7 +64,7 @@ public:
int GetWidth() const { return text.GetWidth(); }
int GetHeight(int cx) const { return text.GetHeight(Zoom(1, 1), cx); }
int GetHeight() const { return text.GetHeight(GetZoom(), GetSize().cx); }
int GetHeight() const;
int GetSb() const { return sb; }
void SetSb(int i) { sb = i; }

View file

@ -4,11 +4,40 @@ namespace Upp {
#define LLOG(x) // LOG(x)
Zoom RichTextView::GetZoom() const
{
int szcx = GetSize().cx;
if(!sb.IsShown() && sb.IsAutoHide())
szcx -= ScrollBarSize();
return IsNull(zoom) ? Zoom(szcx - margin.left - margin.right, cx) : zoom;
}
int RichTextView::GetPageCx(bool reduced) const
{
int szcx = GetSize().cx;
if(reduced && !sb.IsShown() && sb.IsAutoHide())
szcx -= ScrollBarSize();
return IsNull(zoom) ? cx : (szcx - margin.left - margin.right) / zoom;
}
Rect RichTextView::GetPage() const
{
return Rect(0, 0, GetPageCx(), INT_MAX);
}
int RichTextView::GetHeight() const
{
return text.GetHeight(GetPage()).y;
}
int RichTextView::TopY() const
{
if(vcenter && sb.GetTotal() < sb.GetPage())
return (sb.GetPage() - sb.GetTotal()) / 2;
return 0;
}
void RichTextView::Paint(Draw& w)
{
Size sz = GetSize();
@ -38,34 +67,15 @@ void RichTextView::Paint(Draw& w)
pi.shrink_oversized_objects = shrink_oversized_objects;
pi.darktheme = Grayscale(SColorPaper()) < 100;
Rect pg = GetPage();
if(vcenter && sb.GetTotal() < sb.GetPage())
pg.top = (sb.GetPage() - sb.GetTotal()) / 2;
pg.top = TopY();
text.Paint(pw, pg, pi);
w.End();
w.End();
}
Zoom RichTextView::GetZoom() const
{
int szcx = GetSize().cx;
if(!sb.IsShown() && sb.IsAutoHide())
szcx -= ScrollBarSize();
return IsNull(zoom) ? Zoom(szcx - margin.left - margin.right, cx) : zoom;
}
int RichTextView::GetPageCx(bool reduced) const
{
int szcx = GetSize().cx;
if(reduced && !sb.IsShown() && sb.IsAutoHide())
szcx -= ScrollBarSize();
return IsNull(zoom) ? cx : (szcx - margin.left - margin.right) / zoom;
}
void RichTextView::SetSb()
{
Rect page(0, 0, GetPageCx(true), INT_MAX);
PageY py = text.GetHeight(page);
sb.SetTotal(py.y);
sb.SetTotal(GetHeight());
sb.SetPage((GetSize().cy - margin.top - margin.bottom) / GetZoom());
}
@ -132,7 +142,7 @@ Point RichTextView::GetTextPoint(Point p) const
p -= margin.TopLeft();
Zoom zoom = GetZoom();
p.y += sb * zoom;
return Point(p.x / zoom, p.y / zoom);
return Point(p.x / zoom, p.y / zoom - TopY());
}
int RichTextView::GetPointPos(Point p) const
@ -172,7 +182,7 @@ void RichTextView::RefreshRange(int a, int b)
Rect r1 = text.GetCaret(l, GetPage()) + margin.TopLeft();
Rect r2 = text.GetCaret(h, GetPage()) + margin.TopLeft();
Zoom zoom = GetZoom();
Refresh(Rect(0, zoom * (r1.top - sb), GetSize().cx, zoom * (r2.bottom - sb + zoom.d - 1)));
Refresh(Rect(0, zoom * (r1.top - sb + TopY()), GetSize().cx, zoom * (r2.bottom - sb + zoom.d - 1) + TopY()));
}
void RichTextView::RefreshSel()

View file

@ -8,7 +8,7 @@ int CharFilterID(int c)
bool ParseTopicFileName(const String& fn, String& topic, int& lang)
{
String q = GetFileTitle(fn);
int w = q.Find('_');
int w = q.ReverseFind('_');
if(w < 0)
return false;
topic = q.Mid(0, w);

View file

@ -64,7 +64,7 @@ void TopicEditor::MoveTopic()
if(dlg.Run() != IDOK)
return;
String np = AppendFileName(SourcePath(~dlg.package, (String)~dlg.group + ".tpp"),
(String)~dlg.topic + "@" + ToLower(LNGAsText(~dlg.lang)) + ".tpp");
(String)~dlg.topic + "_" + ToLower(LNGAsText(~dlg.lang)) + ".tpp");
if(FindFile(np)) {
if(!PromptYesNo("Target file aready exists!&Do you want to overwrite it?"))
return;

View file

@ -1,7 +1,7 @@
#include "Browser.h"
ArrayMap<String, TopicEditor::FileInfo> TopicEditor::editstate;
VectorMap<String, String> TopicEditor::grouptopic;
VectorMap<String, String> TopicEditor::grouptopic; // the last topic edited in group
String TopicEditor::lasttemplate;
int TopicEditor::lastlang;
@ -19,11 +19,15 @@ bool LoadTopics(Vector<String>& topics, const String& grouppath)
bool renamed = false;
for(int pass = 0; pass < 2; pass++) {
topics.Clear();
FindFile ff(AppendFileName(grouppath, "*.*"));
for(; ff; ff.Next()) {
if(ff.IsFile() && GetFileExt(ff.GetName()) == ".tppi") {
String n = ff.GetName();
int q = n.ReverseFind('$');
if(q < 0)
q = n.ReverseFind('@');
if(q >= 0 && q > n.GetLength() - 12) {
String nn = n;
n.Set(q, '_');
@ -57,16 +61,17 @@ void FillTopicsList(FileList& list, const Vector<String>& topics)
{
list.Clear();
for (const auto& topic : topics) {
for (const auto& topic : topics)
list.Add(topic, TopicImg::Topic());
}
list.Sort(ListOrder());
list.Enable();
}
void TopicEditor::Open(const String& group_path)
{
topics_search.Clear();
grouppath = group_path;
@ -74,7 +79,6 @@ void TopicEditor::Open(const String& group_path)
DeleteFile(grouppath);
DirectoryCreate(grouppath);
topics.Clear();
if(LoadTopics(topics, grouppath))
SaveInc();
FillTopicsList(topics_list, topics);

View file

@ -384,7 +384,7 @@ void TopicEditor::SaveAsTemplate()
d.nest.GoBegin();
if(d.Execute() != IDOK || IsNull(~d.nest))
return;
SaveFile(AppendFileName(AppendFileName(~d.nest, "$.tpp"), d.GetName()),
SaveFile(AppendFileName(AppendFileName(~d.nest, "_.tpp"), d.GetName()),
WriteTopic((String)~title, editor.Get()));
}

View file

@ -55,8 +55,8 @@ SlideShowSettingsDlg::SlideShowSettingsDlg()
zoom_minus.WhenRepeat = zoom_minus ^= [=] { slideshow->Key(K_CTRL|K_SUBTRACT, 1); };
margin_plus.WhenRepeat = margin_plus ^= [=] { slideshow->Key(K_ALT|K_ADD, 1); };
margin_minus.WhenRepeat = margin_minus ^= [=] { slideshow->Key(K_ALT|K_SUBTRACT, 1); };
title_plus.WhenRepeat = title_plus ^= [=] { slideshow->Key(K_SHIFT|K_ALT|K_ADD, 1); };
title_minus.WhenRepeat = title_minus ^= [=] { slideshow->Key(K_SHIFT|K_ALT|K_SUBTRACT, 1); };
title_plus.WhenRepeat = title_plus ^= [=] { slideshow->Key(K_CTRL|K_ALT|K_ADD, 1); };
title_minus.WhenRepeat = title_minus ^= [=] { slideshow->Key(K_CTRL|K_ALT|K_SUBTRACT, 1); };
}
void SlideShow::Serialize(Stream& s)
@ -88,6 +88,7 @@ SlideShow::SlideShow()
title.NoSb();
Add(title);
title.SetFrame(NullFrame());
title.SizePos();
LoadFromGlobal(*this, "SlideShow");
}
@ -131,6 +132,9 @@ bool SlideShow::Key(dword key, int count)
case K_ESCAPE:
Break();
return true;
case K_HOME:
page = 0;
break;
case K_LEFT:
case K_PAGEUP:
case K_SPACE:
@ -180,11 +184,11 @@ void SlideShow::SetPage()
if(page >= 0)
t = ReadTopic(LoadFile(path[page]));
if(settings.title) {
title <<= "{{1@C~ [*R+" + AsString(titleh) + " " + t.title + "}}";
title <<= "{{1@C~ [*R+" + AsString(titleh) + " \1" + t.title + "\1}}";
title.HMargins(DPI(8) * margins);
title.VMargins(0);
int cy = min(title.GetHeight() + DPI(20), GetSize().cx / 2);
title.HSizePos().TopPos(0, cy);
int cy = min(title.GetHeight() + DPI(20), GetSize().cy / 2);
title.TopPos(0, cy);
text.VSizePos(cy, 0);
title.Show();
}