mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
Fix S-meter top layout
This commit is contained in:
+34
-39
@@ -90,6 +90,10 @@ const
|
||||
MODE_NAMES: array[0..MODE_COUNT-1] of string = (
|
||||
'LSB','USB','DSB','CWL','CWU','FM','AM','SAM');
|
||||
|
||||
SMETER_WIDTH_RATIO = 0.32;
|
||||
SMETER_MARGIN = 3;
|
||||
TOP_SMETER_GAP = 72;
|
||||
|
||||
type
|
||||
TDeviceItem = record
|
||||
Dev: THPSDRDevice;
|
||||
@@ -275,7 +279,6 @@ type
|
||||
BtnVfoACopyB: TFlatButton;
|
||||
BtnVfoBCopyA: TFlatButton;
|
||||
PanelTopVfoB: TPanel;
|
||||
PanelTopVfoSep: TPanel;
|
||||
|
||||
PanelBands: TPanel;
|
||||
BtnBand: array[0..BAND_COUNT-1] of TFlatButton;
|
||||
@@ -1311,12 +1314,6 @@ begin
|
||||
PanelTopVfoB.BevelOuter := bvNone;
|
||||
PanelTopVfoB.Color := CLR_PANEL;
|
||||
|
||||
PanelTopVfoSep := TPanel.Create(Self);
|
||||
PanelTopVfoSep.Parent := Self;
|
||||
PanelTopVfoSep.SetBounds(0, 0, 1, 60);
|
||||
PanelTopVfoSep.BevelOuter := bvNone;
|
||||
PanelTopVfoSep.Color := CLR_TEXTDIM;
|
||||
|
||||
PanelVfoB := TPanel.Create(Self);
|
||||
PanelVfoB.Parent := PanelTopVfoB;
|
||||
PanelVfoB.SetBounds(0, 0, TOP_VFO_W, TOP_VFO_FREQ_H);
|
||||
@@ -1756,14 +1753,10 @@ procedure TMainForm.LayoutTopVfoBlock;
|
||||
const
|
||||
MARGIN = 4;
|
||||
TOP_OFFSET = 2;
|
||||
TOP_VFO_MIN_W = 244;
|
||||
TOP_VFO_BTN_H = 14;
|
||||
TOP_VFO_FREQ_H = 47;
|
||||
SEP_GAP = 4;
|
||||
SEP_W = 1;
|
||||
SEP_TOP_OFFSET = 10;
|
||||
SEP_BOTTOM_OFFSET = 8;
|
||||
S_METER_GAP = SEP_GAP + SEP_W + SEP_GAP + 2;
|
||||
SEP_SHIFT_LEFT = 3;
|
||||
SETTINGS_GAP = 4;
|
||||
BTN_GAP = 4;
|
||||
var
|
||||
@@ -1771,71 +1764,73 @@ var
|
||||
BtnY: Integer;
|
||||
BtnRowW: Integer;
|
||||
BtnX: Integer;
|
||||
SepDrawLeft: Integer;
|
||||
SepLeft: Integer;
|
||||
LeftEdge: Integer;
|
||||
RightW: Integer;
|
||||
SMW: Integer;
|
||||
SMLeft: Integer;
|
||||
TopVfoW: Integer;
|
||||
NeedFreqW: Integer;
|
||||
NeedBtnW: Integer;
|
||||
begin
|
||||
if (PanelToolbar = nil) or (PanelTopVfoB = nil) or (PanelTopVfoSep = nil) then Exit;
|
||||
if (PanelToolbar = nil) or (PanelTopVfoB = nil) then Exit;
|
||||
|
||||
SepLeft := PanelToolbar.ClientWidth - MARGIN - SEP_W;
|
||||
Canvas.Font.Name := FreqDispB.FontName;
|
||||
Canvas.Font.Size := FreqDispB.FontSize;
|
||||
Canvas.Font.Style := [fsBold];
|
||||
NeedFreqW := FreqDispB.Left + Canvas.TextWidth('000.000.000') + 8;
|
||||
NeedBtnW := BtnVfoSwap.Width + BtnVfoACopyB.Width + BtnVfoBCopyA.Width +
|
||||
BTN_GAP * 2 + 8;
|
||||
TopVfoW := Max(TOP_VFO_MIN_W, Max(NeedFreqW, NeedBtnW));
|
||||
|
||||
SepLeft := PanelToolbar.ClientWidth - MARGIN;
|
||||
if PanelLeft <> nil then
|
||||
begin
|
||||
RightW := ClientWidth - PanelLeft.Width;
|
||||
if RightW > 200 then
|
||||
begin
|
||||
SMW := Round(RightW * 0.40);
|
||||
SMLeft := ClientWidth - SMW - 3;
|
||||
SepLeft := Min(SepLeft, SMLeft - SEP_GAP - SEP_W - 2);
|
||||
SMW := Round(RightW * SMETER_WIDTH_RATIO);
|
||||
SMLeft := ClientWidth - SMW - SMETER_MARGIN;
|
||||
SepLeft := Min(SepLeft, SMLeft - TOP_SMETER_GAP);
|
||||
end;
|
||||
end;
|
||||
|
||||
LeftEdge := SepLeft - SEP_GAP - PanelTopVfoB.Width;
|
||||
LeftEdge := SepLeft - SEP_GAP - TopVfoW;
|
||||
if BtnSettings <> nil then
|
||||
LeftEdge := Max(LeftEdge, BtnSettings.Left + BtnSettings.Width + SETTINGS_GAP);
|
||||
|
||||
if LeftEdge + PanelTopVfoB.Width > SepLeft - SEP_GAP then
|
||||
if LeftEdge + TopVfoW > SepLeft - SEP_GAP then
|
||||
begin
|
||||
PanelTopVfoB.Visible := False;
|
||||
PanelTopVfoSep.Visible := False;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
PanelTopVfoB.Visible := True;
|
||||
PanelTopVfoSep.Visible := True;
|
||||
BlockH := PanelToolbar.Height + PanelSpanButtons.Height - (MARGIN * 2);
|
||||
if BlockH < 56 then BlockH := 56;
|
||||
PanelTopVfoB.SetBounds(LeftEdge, TOP_OFFSET, PanelTopVfoB.Width, BlockH);
|
||||
PanelVfoB.SetBounds(0, 0, PanelTopVfoB.Width, TOP_VFO_FREQ_H);
|
||||
PanelTopVfoB.SetBounds(LeftEdge, TOP_OFFSET, TopVfoW, BlockH);
|
||||
PanelVfoB.SetBounds(0, 0, TopVfoW, TOP_VFO_FREQ_H);
|
||||
FreqDispB.SetBounds(FreqDispB.Left, FreqDispB.Top,
|
||||
Max(20, TopVfoW - FreqDispB.Left), TOP_VFO_FREQ_H);
|
||||
BtnTopVfoBSelect.Left := FreqDispB.Left - BtnTopVfoBSelect.Width;
|
||||
BtnTopVfoBTX.Left := FreqDispB.Left - BtnTopVfoBTX.Width;
|
||||
BtnY := PanelTopVfoB.Height - TOP_VFO_BTN_H - 8;
|
||||
if BtnY < 42 then BtnY := 42;
|
||||
PanelVfoButtons.SetBounds(4, BtnY, PanelTopVfoB.Width - 8, TOP_VFO_BTN_H);
|
||||
PanelVfoButtons.SetBounds(4, BtnY, TopVfoW - 8, TOP_VFO_BTN_H);
|
||||
BtnRowW := BtnVfoSwap.Width + BtnVfoACopyB.Width + BtnVfoBCopyA.Width + BTN_GAP * 2;
|
||||
BtnX := FreqDispB.Left + (FreqDispB.Width - BtnRowW) div 2 - PanelVfoButtons.Left;
|
||||
if BtnX < 0 then BtnX := 0;
|
||||
BtnVfoSwap.Left := BtnX;
|
||||
BtnVfoACopyB.Left := BtnVfoSwap.Left + BtnVfoSwap.Width + BTN_GAP;
|
||||
BtnVfoBCopyA.Left := BtnVfoACopyB.Left + BtnVfoACopyB.Width + BTN_GAP;
|
||||
SepDrawLeft := SepLeft - SEP_SHIFT_LEFT;
|
||||
PanelTopVfoSep.SetBounds(SepDrawLeft,
|
||||
TOP_OFFSET + SEP_TOP_OFFSET, SEP_W,
|
||||
PanelTopVfoB.Height - SEP_TOP_OFFSET - SEP_BOTTOM_OFFSET);
|
||||
PanelTopVfoB.BringToFront;
|
||||
PanelTopVfoSep.BringToFront;
|
||||
end;
|
||||
|
||||
procedure TMainForm.ResizeSMeter;
|
||||
// PanelSMeterRight на главной форме (Parent=Self).
|
||||
// По Y: от самого верха формы до низа PanelSpanButtons (Toolbar+Span = 66px).
|
||||
// По X: 40% ширины PanelRight, прижат к правому краю.
|
||||
const
|
||||
MARGIN = 3;
|
||||
var
|
||||
FW, FH: Integer;
|
||||
FW: Integer;
|
||||
RightW: Integer; // ширина PanelRight
|
||||
SMW: Integer; // ширина S-метра
|
||||
SMLeft: Integer;
|
||||
@@ -1852,15 +1847,15 @@ begin
|
||||
RightW := FW - PanelLeft.Width;
|
||||
if RightW < 200 then Exit;
|
||||
|
||||
// Ширина S-метра = 40% от PanelRight
|
||||
SMW := Round(RightW * 0.40);
|
||||
// Ширина S-метра = 32% от PanelRight
|
||||
SMW := Round(RightW * SMETER_WIDTH_RATIO);
|
||||
|
||||
// X: прижат к правому краю формы
|
||||
SMLeft := FW - SMW - MARGIN;
|
||||
SMLeft := FW - SMW - SMETER_MARGIN;
|
||||
|
||||
// Y: от верха формы+margin до низа PanelSpanButtons-margin
|
||||
SMTop := MARGIN;
|
||||
SMBot := PanelToolbar.Height + PanelSpanButtons.Height - MARGIN;
|
||||
SMTop := SMETER_MARGIN;
|
||||
SMBot := PanelToolbar.Height + PanelSpanButtons.Height - SMETER_MARGIN;
|
||||
|
||||
PanelSMeterRight.SetBounds(SMLeft, SMTop, SMW, SMBot - SMTop);
|
||||
PanelSMeterRight.BringToFront;
|
||||
|
||||
Reference in New Issue
Block a user