CudaText
CudaText copied to clipboard
CudaText with dark theme: white rectangle blinks on startup (Windows-specific?)
I really like dark themes for CudaText - such as "zeus", "darkwolf", "monokai-alt". However I mostly use either "green" or "default" theme. And here is why:
- Activate any dark theme you like
- Maximize CudaText's window (or just make it very big)
- Close CudaText
- Start CudaText and carefully look at its window while CudaText is starting. Under Windows, I clearly see a big white rectangle that appears on the dark background during a fraction of a second. You see, it really irritate the eyes.
I do not observe such visual effect (or defect) under Mac OS, because Mac OS seems to postpone the painting of the application's window until the window is fully initialized. (Frankly, it creates an impression that all applications start faster under Windows than under Mac OS, because under Windows you see the applications' user interface faster). I don't know whether the white rectangle on startup is visible under Linux or not because I don't have Linux.
That's why I've been mostly using the "green" or "default" theme - because the white rectangle during startup is not so visible on the light-grey background of these themes.
To fix this white rectangle, we first need to understand: is it caused by the editing window (ATSynEdit component) or is it white part of the application's background? Then, after it is identified, I think what could be done is to apply the background color of the active theme to the window in question (either ATSynEdit or part of the application's background) at the moment of creation of this window. Just to make this rectangle to have a dark color similar to the dark theme rather than the pure white that creates high contrast with the dark background.
Don't know if this is related, when switching to full-screen or distraction-free, and especially when coming back from distraction-free, there is a bright flash before the other screen comes on.
When I fill the Windows desktop with black, or put a black full-screen image underneath Cuda, the flash is not bright, and it looks more like a screen flicker, but still has a different color from my Cud-theme.
It is only visible for a brief moment, as if the old screen were destroyed right away, but the new screen not quite created yet.
On Linux it';s not visible.
I tried to apply black (or red) background color to different TPanel's of Cud (panels underlying the actual UI) but it din't give the effect. Didn't try to change the back of ATSynEdit.
how I changed code: let's take one of TPanel's, e.g. PanelEditors (exists in fmMain). i added PanelEditors.OnPaint handler, in which i did
begin
Canvas.Brush.Color:= clRed;
Canvas.FillRect(ClientRect); //or fixed rect - Rect(0, 0, 1300, 1200)
end;
On Win10, tried now on
- TATSynEdit.Paint - did not help (e.g. red color is visible but white blink is here)
- TfmMain.Paint - did not help
for ppl who will investigate: Lazarus have 2 funcs which may give the flickering
fmMain.DisableAutoSizing;
....
//do some resizing of controls
fmMain.EnableAutoSizing;
What is the component that contains all the TATSynEdit controls and the corresponding tabs? Probably the same component also contains the vertical toolbar (or whatever its name is - it's where the Code Tree button, Search button, Console button, Output button are located). I'm asking because I very carefully inspected the moment of CudaText startup with a dark theme and noticed the following:
- The borders of the main window, its main menu and status bar are initially dark, so they are OK;
- The inner background of the Console (when it is initially visible) and of the Code tree (when it is initially visible) are initially dark, so they are OK;
- The vertical tool bar is initially white - not good;
- The part of the screen where the TATSynEdit controls and the corresponding tabs will be located is initially white - not good;
- When the Console and the Code tree are not initially visible, then only the borders of the main window, its main menu and status bar are initially dark, whereas everything in the middle (the vertical toolbar, the place where the TATSynEdit controls and the corresponding tabs will be located) is all white.
What is the component that contains all the TATSynEdit controls
TEditorFrame is the parent. all 'frames' are parented by TATPages (max 6 pages are visible when you call =
top menu). parent of TATPages is TATGroups (Groups
object).
and the corresponding tabs?
parent of TATTabs is TATPages.
constructor TATPages.Create(AOwner: TComponent);
begin
...
FTabs:= TATTabs.Create(Self);
parent of TATPages:
constructor TATGroups.Create(AOwner: TComponent);
...
Pages1:= TATPages.Create(Self);
Pages2:= TATPages.Create(Self);
Pages3:= TATPages.Create(Self);
Pages4:= TATPages.Create(Self);
Pages5:= TATPages.Create(Self);
Pages6:= TATPages.Create(Self);
Correction. TATSynEdit parent is not TEditorFrame, it is TFormDummy:
procedure TEditorFrame.InitEditor(var ed: TATSynEdit; const AName: string);
begin
ed:= TATSynEdit.Create(FFormDummy);
...
ed.Parent:= FFormDummy;
I should say I still can't catch the moment when the main window is initially shown.
The method TfmMain.FormShow
, despite of its name, actually does not show the main window (*) - it will be shown later, and I still can't find what method is responsible for that.
(*) Actually, I've identified exactly one case when TfmMain.FormShow
does show the main window. It happens only when the main window is maximized on startup, and the window is shown as the result of calling the method _Init_WindowMaximized
. When we look into _Init_WindowMaximized
, it does not seem to contain any explicit instruction that should lead to showing of the window - however, it happens. Looks like WindowState:= wsMaximized;
calls ShowWindow
, and it leads to showing the window. And when it is shown, it blinks with the white rectangle.
(Additional interesting observation: the tab control has different style before calling DoApplyUiOps
: the tabs initially have trapezium-like form, whereas after DoApplyUiOps
they become rectangle-like).
So, what happens under the hood of ShowWindow
? Is there some callback method of TfmMain
that is called as the result of calling ShowWindow
?
ShowWindow is the Lazarus wrapper for original ShowWindow Win32 Api. In the ide, you can right click any id and call “go to definition” (or smth like that, I write by memory).