Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added capability of specifying a size of the label #1468

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions src/grandorgue/gui/GOGUILabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ static const wxString WX_BITMAP_LABEL_FMT = wxT(GOBitmapPrefix "label%02d");
void GOGUILabel::InitBackgroundBitmap(
unsigned x,
unsigned y,
unsigned w,
unsigned h,
wxString imageFileName,
unsigned imageNum,
const wxString &imageMaskFilename) {
Expand All @@ -74,16 +76,17 @@ void GOGUILabel::InitBackgroundBitmap(
m_PBackgroundBitmap
= new GOBitmap(m_panel->LoadBitmap(imageFileName, imageMaskFilename));

unsigned backgroundWidth
= m_PBackgroundBitmap ? m_PBackgroundBitmap->GetWidth() : 80;
unsigned backgroundHeight
= m_PBackgroundBitmap ? m_PBackgroundBitmap->GetHeight() : 25;
// take the size from the bitmap if it is not specified
if (!w)
w = m_PBackgroundBitmap ? m_PBackgroundBitmap->GetWidth() : 80;
if (!h)
h = m_PBackgroundBitmap ? m_PBackgroundBitmap->GetHeight() : 25;
unsigned textX = 1;
unsigned textY = 1;
unsigned textWidth = backgroundWidth - textX;
unsigned textHeigth = backgroundHeight - textY;
unsigned textWidth = w - textX;
unsigned textHeigth = h - textY;

m_BoundingRect = wxRect(x, y, backgroundWidth, backgroundHeight);
m_BoundingRect = wxRect(x, y, w, h);
m_TextRect = wxRect(textX, textY, textWidth, textHeigth);
m_TextWidth = textWidth;
m_TileOffsetX = 0;
Expand All @@ -102,14 +105,16 @@ void GOGUILabel::Init(
unsigned x_pos,
unsigned y_pos,
wxString name,
unsigned DispImageNum) {
unsigned DispImageNum,
unsigned w,
unsigned h) {
GOGUIControl::Init(cfg, group);

m_TextColor = wxColour(0x00, 0x00, 0x00);
m_Text = name;

InitBackgroundBitmap(
x_pos, y_pos, wxEmptyString, DispImageNum, wxEmptyString);
x_pos, y_pos, w, h, wxEmptyString, DispImageNum, wxEmptyString);
InitFont(wxEmptyString, 7);
}

Expand Down Expand Up @@ -202,35 +207,31 @@ void GOGUILabel::Load(GOConfigReader &cfg, wxString group) {
InitBackgroundBitmap(
x,
y,
cfg.ReadInteger(
ODFSetting,
group,
wxT("Width"),
1,
m_metrics->GetScreenWidth(),
false,
0),
cfg.ReadInteger(
ODFSetting,
group,
wxT("Height"),
1,
m_metrics->GetScreenHeight(),
false,
0),
cfg.ReadStringTrim(ODFSetting, group, WX_IMAGE, false),
cfg.ReadInteger(ODFSetting, group, WX_DISP_IMAGE_NUM, 0, 12, false, 1),
cfg.ReadInteger(ODFSetting, group, WX_DISP_IMAGE_NUM, 0, 15, false, 1),
cfg.ReadStringTrim(ODFSetting, group, WX_MASK, false));
InitFont(
cfg.ReadStringTrim(
ODFSetting, group, wxT("DispLabelFontName"), false, wxEmptyString),
cfg.ReadFontSize(
ODFSetting, group, wxT("DispLabelFontSize"), false, wxT("normal")));

int w, h;

w = cfg.ReadInteger(
ODFSetting,
group,
wxT("Width"),
1,
m_metrics->GetScreenWidth(),
false,
m_BoundingRect.width);
h = cfg.ReadInteger(
ODFSetting,
group,
wxT("Height"),
1,
m_metrics->GetScreenHeight(),
false,
m_BoundingRect.height);
m_BoundingRect = wxRect(x, y, w, h);

m_TileOffsetX = cfg.ReadInteger(
ODFSetting,
group,
Expand Down Expand Up @@ -264,15 +265,16 @@ void GOGUILabel::Load(GOConfigReader &cfg, wxString group) {
m_BoundingRect.height - 1,
false,
m_TextRect.y);
w = cfg.ReadInteger(

unsigned w = cfg.ReadInteger(
ODFSetting,
group,
wxT("TextRectWidth"),
1,
m_BoundingRect.width - x,
false,
m_BoundingRect.width - x);
h = cfg.ReadInteger(
unsigned h = cfg.ReadInteger(
ODFSetting,
group,
wxT("TextRectHeight"),
Expand Down
6 changes: 5 additions & 1 deletion src/grandorgue/gui/GOGUILabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class GOGUILabel : public GOGUIControl {
void InitBackgroundBitmap(
unsigned x,
unsigned y,
unsigned w,
unsigned h,
wxString imageFileName,
unsigned imageNum,
const wxString &imageMaskFileneme);
Expand All @@ -57,7 +59,9 @@ class GOGUILabel : public GOGUIControl {
unsigned x_pos = 0,
unsigned y_pos = 0,
wxString name = wxT(""),
unsigned imageno = 1);
unsigned imageno = 1,
unsigned w = 0,
unsigned h = 0);
void Load(GOConfigReader &cfg, wxString group);
void Layout();

Expand Down