Skip to content

Commit

Permalink
proper hi-dpi support for the project manager
Browse files Browse the repository at this point in the history
  • Loading branch information
mrDIMAS committed Dec 17, 2024
1 parent 8f47588 commit ef10ad5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
15 changes: 15 additions & 0 deletions project-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ fn main() {
format!("Unable to set frame size: {e:?}"),
);
}

let window = &engine.graphics_context.as_initialized_ref().window;

let logical_size = size.to_logical(window.scale_factor());
let ui = engine.user_interfaces.first_mut();
ui.send_message(WidgetMessage::width(
project_manager.root_grid,
MessageDirection::ToWidget,
logical_size.width,
));
ui.send_message(WidgetMessage::height(
project_manager.root_grid,
MessageDirection::ToWidget,
logical_size.height,
));
}
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
let ui = engine.user_interfaces.first_mut();
Expand Down
16 changes: 10 additions & 6 deletions project-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

use crate::settings::MANIFEST_PATH_VAR;
use crate::{
build::BuildWindow,
project::ProjectWizard,
settings::{Project, Settings, SettingsWindow},
settings::{Project, Settings, SettingsWindow, MANIFEST_PATH_VAR},
upgrade::UpgradeTool,
utils::{self, is_production_ready, load_image},
};
use fyrox::gui::utils::make_text_and_image_button_with_tooltip;
use fyrox::{
core::{color::Color, log::Log, pool::Handle, some_or_return},
gui::{
Expand All @@ -44,12 +42,14 @@ use fyrox::{
message::{KeyCode, MessageDirection, UiMessage},
messagebox::{MessageBoxBuilder, MessageBoxButtons, MessageBoxMessage, MessageBoxResult},
navigation::NavigationLayerBuilder,
screen::ScreenBuilder,
searchbar::{SearchBarBuilder, SearchBarMessage},
stack_panel::StackPanelBuilder,
style::{resource::StyleResourceExt, Style},
text::{TextBuilder, TextMessage},
utils::{make_image_button_with_tooltip, make_simple_tooltip},
utils::{
make_image_button_with_tooltip, make_simple_tooltip,
make_text_and_image_button_with_tooltip,
},
widget::{WidgetBuilder, WidgetMessage},
window::{WindowBuilder, WindowMessage, WindowTitle},
BuildContext, HorizontalAlignment, Orientation, Thickness, UiNode, UserInterface,
Expand All @@ -73,6 +73,7 @@ enum Mode {
}

pub struct ProjectManager {
pub root_grid: Handle<UiNode>,
create: Handle<UiNode>,
import: Handle<UiNode>,
projects: Handle<UiNode>,
Expand Down Expand Up @@ -548,9 +549,11 @@ impl ProjectManager {
let navigation_layer =
NavigationLayerBuilder::new(WidgetBuilder::new().with_child(main_content)).build(ctx);

ScreenBuilder::new(WidgetBuilder::new().with_child(
let root_grid = GridBuilder::new(WidgetBuilder::new().with_child(
BorderBuilder::new(WidgetBuilder::new().with_child(navigation_layer)).build(ctx),
))
.add_row(Row::stretch())
.add_column(Column::stretch())
.build(ctx);

ctx.sender()
Expand All @@ -561,6 +564,7 @@ impl ProjectManager {
.unwrap();

Self {
root_grid,
create,
import,
projects,
Expand Down

0 comments on commit ef10ad5

Please sign in to comment.