Commit 5958e597 authored by Chris Ball's avatar Chris Ball
Browse files

Fixed a subtle rendering bug. Added support for <group label="character">.

parent d5dd7d6a
......@@ -500,6 +500,7 @@ void CAlphIO::XML_StartElement(void *userData, const XML_Char *name, const XML_C
if (strcmp(name, "group")==0) {
AlphInfo::group NewGroup;
NewGroup.Colour=-1;
NewGroup.Label="";
Me->InputInfo.Groups.push_back(NewGroup);
while (*atts!=0) {
if (strcmp(*atts, "name")==0) {
......@@ -512,6 +513,11 @@ void CAlphIO::XML_StartElement(void *userData, const XML_Char *name, const XML_C
Me->InputInfo.Groups.back().Colour = atoi(*atts);
atts--;
}
if (strcmp(*atts, "label")==0) {
atts++;
Me->InputInfo.Groups.back().Label = *atts;
atts--;
}
atts += 2;
}
return;
......
......@@ -53,6 +53,7 @@ public:
std::string Description;
std::vector< character > Characters;
int Colour;
std::string Label;
};
std::vector< group > Groups;
character ParagraphCharacter; // display and edit text of paragraph character. Use ("", "") if no paragraph character.
......
......@@ -116,9 +116,10 @@ void CAlphabet::DelChar(symbol Symbol) {
m_Group.erase(m_Group.begin()+Symbol);
}
void CAlphabet::StartNewGroup(int colour)
void CAlphabet::StartNewGroup(int colour, std::string label)
{
m_GroupColour.push_back(colour);
m_GroupLabel.push_back(label);
m_Groups++;
}
......
......@@ -42,6 +42,7 @@ public:
const std::string& GetText(symbol i) const {return m_Characters[i];} // return string for i'th symbol
int GetColour(symbol i) const {return m_Colours[i];} // return the colour for i'th symbol
int GetGroupColour(int i) const {return m_GroupColour[i];} // return the colour for i'th group
std::string GetGroupLabel(int i) const {return m_GroupLabel[i];}
int GetTextColour(symbol i); // return the foreground colour for i'th symbol
const std::string& GetForeground(symbol i) const {return m_Foreground[i];} // return the foreground colour for i'th symbol
int get_group(symbol i) const {return m_Group[i];} // return group membership of i'th symbol
......@@ -65,7 +66,7 @@ protected:
void AddChar(const std::string NewCharacter, const std::string Display, int Colour, const std::string Foreground); // add single char to the alphabet
// Delete a character
void DelChar(symbol Symbol);
void StartNewGroup(int colour=-1);
void StartNewGroup(int colour=-1,std::string label="");
// Alphabet language parameters
void SetParagraphSymbol() {m_ParagraphSymbol=m_Characters.size()-1;}
......@@ -93,7 +94,8 @@ private:
std::vector<std::string> m_Foreground; // stores the colour of the character foreground
std::vector<int> m_Group; // stores the group indicators - e.g. caps, numbers, punctuation
std::vector<int> m_GroupColour; // stores the colour of the group
int m_Groups; // number of groups
std::vector<std::string> m_GroupLabel;
int m_Groups; // number of groups
alphabet_map TextMap;
};
......
......@@ -27,7 +27,7 @@ CCustomAlphabet::CCustomAlphabet(const CAlphIO::AlphInfo& AlphInfo)
for (unsigned int j=0; j<AlphInfo.Groups[i].Characters.size(); j++) { // loop characters
AddChar(AlphInfo.Groups[i].Characters[j].Text, AlphInfo.Groups[i].Characters[j].Display, AlphInfo.Groups[i].Characters[j].Colour, AlphInfo.Groups[i].Characters[j].Foreground);
}
StartNewGroup(AlphInfo.Groups[i].Colour);
StartNewGroup(AlphInfo.Groups[i].Colour, AlphInfo.Groups[i].Label);
}
// Set Space character if requested
......
......@@ -62,6 +62,7 @@ public:
Opts::ColorSchemes Cscheme() const {return m_ColorScheme;}
int Colour() const {return m_iColour;}
int GroupColour(int group) const {return m_languagemodel->GetGroupColour(group);}
std::string GroupLabel(int group) const {return m_languagemodel->GetGroupLabel(group);}
CDasherNode* Parent() const {return m_parent;}
CDasherNode* const Get_node_under(int,myint y1,myint y2,myint smousex,myint smousey); // find node under given co-ords
......
......@@ -91,6 +91,8 @@ void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool tex
int current=0;
int lower=0;
int upper=0;
std::string Label="";
myint range=y2-y1;
for (unsigned int i=1; i<Render->Chars(); i++) {
int g=Children[i]->Group();
......@@ -106,14 +108,16 @@ void CDasherView::RenderGroups(CDasherNode* Render, myint y1, myint y2, bool tex
int mostleft;
bool force;
if (ColourMode==true) {
std::string Label = Render->GroupLabel(current);
int Colour = Render->GroupColour(current);
if (Colour!=-1) {
RenderNode(0,Render->GroupColour(current),Opts::Groups,newy1,newy2,mostleft,force,text,"");
if (Colour!=-1) {
RenderNode(0,Render->GroupColour(current),Opts::Groups,newy1,newy2,mostleft,force,text,Label);
} else {
RenderNode(0,(current%3)+110,Opts::Groups,newy1,newy2,mostleft,force,text,"");
RenderNode(0,(current%3)+110,Opts::Groups,newy1,newy2,mostleft,force,text,Label);
}
} else {
RenderNode(0,current-1,Opts::Groups,newy1,newy2,mostleft,force,text,"");
RenderNode(0,current-1,Opts::Groups,newy1,newy2,mostleft,force,text,Label);
}
}
current=g;
......
......@@ -126,7 +126,7 @@ int CDasherViewSquare::RenderNode(const symbol Character, const int Color, Opts:
int newbottom2 = (height+FontHeight)/2 + top;
MapScreen(&newleft2, &newtop2);
MapScreen(&newright2, &newbottom2);
newleft = min(newleft2, newright2);
//newleft = min(newleft2, newright2);
newtop = min(newtop2, newbottom2);
if(displaytext!="") {
......
......@@ -118,6 +118,11 @@ int CLanguageModel::GetGroupColour(int group)
return m_Alphabet->GetGroupColour(group);
}
std::string CLanguageModel::GetGroupLabel(int group)
{
return m_Alphabet->GetGroupLabel(group);
}
bool CLanguageModel::isRealSymbol( symbol _s ) {
if( _s == 0 )
return false;
......
......@@ -60,7 +60,7 @@ public:
int GetColour(int character);
int GetGroupColour(int group);
std::string GetGroupLabel(int group);
void NewControlTree(ControlTree *tree) { controltree=tree; }
ControlTree* GetControlTree() { return controltree; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment