Starting work on real UI
This commit is contained in:
		
							parent
							
								
									e9a07b15da
								
							
						
					
					
						commit
						a68b76fed6
					
				
					 2 changed files with 17 additions and 2 deletions
				
			
		
							
								
								
									
										13
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								src/main.cpp
									
										
									
									
									
								
							|  | @ -136,6 +136,12 @@ std::vector<std::string> GetMprisServices() { | ||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | float ScaleToFit(Vector2 src, Vector2 dst) { | ||||||
|  |     float ratio = std::min(dst.x/src.x, dst.y/src.y); | ||||||
|  |     return ratio; | ||||||
|  |     //return Vector2Scale(src, ratio);
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||||
|     // Initialization
 |     // Initialization
 | ||||||
|     //--------------------------------------------------------------------------------------
 |     //--------------------------------------------------------------------------------------
 | ||||||
|  | @ -145,7 +151,7 @@ int main(int argc, char *argv[]) { | ||||||
|     // SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
 |     // SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
 | ||||||
|     SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); |     SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT | FLAG_WINDOW_RESIZABLE); | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking"); |     InitWindow(screenWidth, screenHeight, "raylib-Extras [ImGui] example - Docking"); | ||||||
|     SetTargetFPS(120); |     SetTargetFPS(244); | ||||||
|     rlImGuiSetup(true); |     rlImGuiSetup(true); | ||||||
|     ImGui::GetStyle().AntiAliasedLinesUseTex = false; |     ImGui::GetStyle().AntiAliasedLinesUseTex = false; | ||||||
| 
 | 
 | ||||||
|  | @ -197,7 +203,6 @@ int main(int argc, char *argv[]) { | ||||||
|     while (!WindowShouldClose() && |     while (!WindowShouldClose() && | ||||||
|            run) // Detect window close button or ESC key, or a quit from the menu
 |            run) // Detect window close button or ESC key, or a quit from the menu
 | ||||||
|     { |     { | ||||||
| 
 |  | ||||||
|         if (GetTime() > lasttime+3 ) { |         if (GetTime() > lasttime+3 ) { | ||||||
|             lasttime = GetTime(); |             lasttime = GetTime(); | ||||||
|             current_player.Refresh(); |             current_player.Refresh(); | ||||||
|  | @ -206,6 +211,10 @@ int main(int argc, char *argv[]) { | ||||||
|         BeginDrawing(); |         BeginDrawing(); | ||||||
|         ClearBackground(DARKGRAY); |         ClearBackground(DARKGRAY); | ||||||
| 
 | 
 | ||||||
|  |         Vector2 winwidth = (Vector2) {(float) GetScreenWidth(), (float) GetScreenHeight()}; | ||||||
|  |         Vector2 imagesize = (Vector2) {(float) current_player.tex.tex.width, (float) current_player.tex.tex.height}; | ||||||
|  |         DrawTextureEx(current_player.tex.tex, (Vector2) {0,0}, 0,  ScaleToFit(imagesize, winwidth), WHITE); | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|         // start ImGui content
 |         // start ImGui content
 | ||||||
|         rlImGuiBegin(); |         rlImGuiBegin(); | ||||||
|  |  | ||||||
|  | @ -128,18 +128,24 @@ void MprisPlayer::UpdateTexture() { | ||||||
| 
 | 
 | ||||||
|  RayTexture::RayTexture() { |  RayTexture::RayTexture() { | ||||||
|     tex = LoadTexture(ASSET_DIR "/null.png" ); |     tex = LoadTexture(ASSET_DIR "/null.png" ); | ||||||
|  |     GenTextureMipmaps(&tex); | ||||||
|  |     SetTextureFilter(tex, TEXTURE_FILTER_BILINEAR); | ||||||
|     path = ASSET_DIR "/null.png"; |     path = ASSET_DIR "/null.png"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  RayTexture::RayTexture(Image img) { |  RayTexture::RayTexture(Image img) { | ||||||
|     path = "NOPATH"; |     path = "NOPATH"; | ||||||
|     tex = LoadTextureFromImage(img); |     tex = LoadTextureFromImage(img); | ||||||
|  |     GenTextureMipmaps(&tex); | ||||||
|  |     SetTextureFilter(tex, TEXTURE_FILTER_BILINEAR); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  RayTexture::RayTexture(const RayTexture &other) { |  RayTexture::RayTexture(const RayTexture &other) { | ||||||
|     path = other.path; |     path = other.path; | ||||||
|     auto img = LoadImageFromTexture(other.tex); |     auto img = LoadImageFromTexture(other.tex); | ||||||
|     tex = LoadTextureFromImage(img); |     tex = LoadTextureFromImage(img); | ||||||
|  |     GenTextureMipmaps(&tex); | ||||||
|  |     SetTextureFilter(tex, TEXTURE_FILTER_BILINEAR); | ||||||
|     UnloadImage(img); |     UnloadImage(img); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue