Skip to content

Commit 907f492

Browse files
committed
- Worked on Copilot suggestions
1 parent 0da64e1 commit 907f492

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/wings_status.erl

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626

2727
-behaviour(wx_object).
2828

29+
-define(TEXT_PADDING_X, 3).
30+
-define(TEXT_PADDING_Y, 2).
31+
-define(GRIP_DOT_SIZE, 2).
32+
-define(GRIP_DOT_SPACING, 3).
33+
-define(GRIP_ROWS, 3).
34+
2935
start_link() ->
3036
Status = wx_object:start_link({local,?MODULE}, ?MODULE, [wings_frame:get_top_frame()], []),
3137
{ok, wx_object:get_pid(Status)}.
@@ -109,25 +115,36 @@ custom_draw(#wx{obj=Obj, event=#wxPaint{}}, _) ->
109115
Size = wxWindow:getSize(Obj),
110116
DC = case os:type() of
111117
{win32, _} -> %% Flicker on windows
112-
wx:typeCast(wxBufferedPaintDC:new(Obj), wxPaintDC);
118+
BufferedDC = wxBufferedPaintDC:new(Obj),
119+
wx:typeCast(BufferedDC, wxPaintDC);
113120
_ ->
121+
BufferedDC = none,
114122
wxPaintDC:new(Obj)
115123
end,
124+
SBG = wings_color:rgb4bv(wings_pref:get_value(info_line_bg)),
125+
Brush = wxBrush:new(SBG),
116126
wxDC:setBackgroundMode(DC, ?wxBRUSHSTYLE_SOLID),
127+
wxDC:setBackground(DC, Brush),
117128
wxDC:clear(DC),
118129
case wxStatusBar:getFieldsCount(Obj) of
119130
2 ->
120131
{true,{Xl,Yl,_,_Hl}} = wxStatusBar:getFieldRect(Obj, 0),
121132
{true,{Xr,Yr,_Wr,_Hr}} = wxStatusBar:getFieldRect(Obj, 1),
122-
wxDC:drawText(DC, wxStatusBar:getStatusText(Obj,[{number,0}]), {Xl+3,Yl+2}),
123-
wxDC:drawText(DC, wxStatusBar:getStatusText(Obj,[{number,1}]), {Xr+3,Yr+2});
133+
wxDC:drawText(DC, wxStatusBar:getStatusText(Obj,[{number,0}]), {Xl+?TEXT_PADDING_X,Yl+?TEXT_PADDING_Y}),
134+
wxDC:drawText(DC, wxStatusBar:getStatusText(Obj,[{number,1}]), {Xr+?TEXT_PADDING_X,Yr+?TEXT_PADDING_Y});
124135
_ -> ok
125136
end,
126137
GrpPen = wxPen:new(wxSystemSettings:getColour(?wxSYS_COLOUR_3DSHADOW)),
127138
wxDC:setPen(DC,GrpPen),
128-
draw_grip(DC, Size, 3),
139+
draw_grip(DC, Size, ?GRIP_ROWS),
129140
wxPen:destroy(GrpPen),
130-
wxPaintDC:destroy(DC).
141+
wxBrush:destroy(Brush),
142+
case os:type() of
143+
{win32, _} -> %% Flicker on windows
144+
wxBufferedPaintDC:destroy(BufferedDC);
145+
_ ->
146+
wxPaintDC:destroy(DC)
147+
end.
131148

132149
update_status({value, Prev}, Prev, _SB) ->
133150
Prev;
@@ -160,7 +177,8 @@ set_status(Msgs={Left, Right}, SB) ->
160177

161178
draw_grip(_, _, 0) -> ok;
162179
draw_grip(DC, {W,H}=Size, C) ->
163-
[wxDC:drawRectangle(DC, {W-(3*I)-1, H-(3*(4-C))-1}, {2,2}) || I <- lists:seq(C,1,-1)],
180+
[wxDC:drawRectangle(DC, {W-(?GRIP_DOT_SPACING*I)-1, H-(?GRIP_DOT_SPACING*(4-C))-1},
181+
{?GRIP_DOT_SIZE,?GRIP_DOT_SIZE}) || I <- lists:seq(C,1,-1)],
164182
draw_grip(DC, Size, C-1).
165183

166184
str(undefined, Old) -> Old;

0 commit comments

Comments
 (0)