From: binarymaster Date: Tue, 26 Sep 2017 20:18:56 +0000 (+0300) Subject: Main: Fix drawing texture list items X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-editor.git;a=commitdiff_plain;h=b4fac8bc01cf16c033ea0e66c16eabe919c86f86 Main: Fix drawing texture list items --- diff --git a/src/editor/f_main.lfm b/src/editor/f_main.lfm index d359463..e404cfa 100644 --- a/src/editor/f_main.lfm +++ b/src/editor/f_main.lfm @@ -247,6 +247,7 @@ object MainForm: TMainForm Constraints.MinHeight = 70 ItemHeight = 13 OnClick = lbTextureListClick + OnDrawItem = lbTextureListDrawItem Style = lbOwnerDrawFixed TabOrder = 0 end diff --git a/src/editor/f_main.pas b/src/editor/f_main.pas index 9982035..e470131 100644 --- a/src/editor/f_main.pas +++ b/src/editor/f_main.pas @@ -207,6 +207,8 @@ type procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormResize(Sender: TObject); procedure lbTextureListClick(Sender: TObject); + procedure lbTextureListDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); procedure RenderPanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure RenderPanelMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure RenderPanelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); @@ -258,8 +260,6 @@ type procedure OnIdle(Sender: TObject; var Done: Boolean); public procedure RefreshRecentMenu(); - { procedure lbTextureListDrawItem(Control: TWinControl; Index: Integer; - Rect: TRect; State: TOwnerDrawState); } end; const @@ -4377,6 +4377,27 @@ begin end; end; +procedure TMainForm.lbTextureListDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +begin + with Control as TListBox do + begin + if LCLType.odSelected in State then + begin + Canvas.Brush.Color := clHighlight; + Canvas.Font.Color := clHighlightText; + end else + if (Items <> nil) and (Index >= 0) then + if slInvalidTextures.IndexOf(Items[Index]) > -1 then + begin + Canvas.Brush.Color := clRed; + Canvas.Font.Color := clWhite; + end; + Canvas.FillRect(ARect); + Canvas.TextRect(ARect, ARect.Left, ARect.Top, Items[Index]); + end; +end; + procedure TMainForm.vleObjectPropertyGetPickList(Sender: TObject; const KeyName: String; Values: TStrings); begin @@ -6411,26 +6432,4 @@ begin end; end; -{ -procedure TMainForm.lbTextureListDrawItem(Control: TWinControl; Index: Integer; - Rect: TRect; State: LCLType.TOwnerDrawState); -begin - with Control as TListBox do - begin - if LCLType.odSelected in State then - begin - Canvas.Brush.Color := clHighlight; - Canvas.Font.Color := clHighlightText; - end else - if (Items <> nil) and (Index >= 0) then - if slInvalidTextures.IndexOf(Items[Index]) > -1 then - begin - Canvas.Brush.Color := clRed; - Canvas.Font.Color := clWhite; - end; - Canvas.FillRect(Rect); - Canvas.TextRect(Rect, Rect.Left, Rect.Top, Items[Index]); - end; -end; -} end. diff --git a/src/engine/e_graphics.pas b/src/engine/e_graphics.pas index 47bf110..c9a16c2 100644 --- a/src/engine/e_graphics.pas +++ b/src/engine/e_graphics.pas @@ -37,7 +37,7 @@ type X, Y: Double; end; - TRect = record + TRectE = record Left, Top, Right, Bottom: Integer; end; @@ -52,7 +52,7 @@ type PPoint = ^TPoint; PPoint2f = ^TPoint2f; - PRect = ^TRect; + PRect = ^TRectE; PRectWH = ^TRectWH; @@ -126,7 +126,7 @@ procedure e_EndRender(); function _RGB(Red, Green, Blue: Byte): TRGB; function _Point(X, Y: Integer): TPoint2i; function _Rect(X, Y: Integer; Width, Height: Word): TRectWH; -function _TRect(L, T, R, B: LongInt): TRect; +function _TRect(L, T, R, B: LongInt): TRectE; //function e_getTextGLId (ID: DWORD): GLuint; @@ -1522,7 +1522,7 @@ begin Result.Height := Height; end; -function _TRect(L, T, R, B: LongInt): TRect; +function _TRect(L, T, R, B: LongInt): TRectE; begin Result.Top := T; Result.Left := L;