mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-26 04:58:07 +00:00
Merge branch 'red5/g4' into area/app-1
This commit is contained in:
@@ -266,6 +266,19 @@ impl PdfCraftApp {
|
||||
}
|
||||
|
||||
fn execute_unguarded(&mut self, ctx: &egui::Context, id: &str) -> bool {
|
||||
// Paste is the framework's clipboard command, not a registered one: the pages take what
|
||||
// the clipboard holds (pages in Organize, else objects, a picture or comment text).
|
||||
if id == crate::menus::PASTE {
|
||||
let Some(i) = self.active.filter(|&i| i < self.views.len()) else { return false };
|
||||
if self.views[i].organize {
|
||||
return self.execute_unguarded(ctx, "page.paste");
|
||||
}
|
||||
if self.views[i].session.forms.focus.is_some() {
|
||||
return false;
|
||||
}
|
||||
self.paste_from_clipboard(ctx, i);
|
||||
return true;
|
||||
}
|
||||
let Some(spec) = commands::command(id) else { return false };
|
||||
if !self.command_enabled(spec) {
|
||||
let why = self.disabled_reason(spec);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
//! by earlier versions (`side_panels`, `docking`) are read once by [`migrate`].
|
||||
|
||||
use craft::automation::dock as dock_rpc;
|
||||
use craft::behavior::dock::{Action, Column, DockEdge, DockPlacement, Group, Layout, Location, Node, Permissions, SplitSize, Target, Workspace};
|
||||
use craft::behavior::dock::{
|
||||
Action, Column, DockEdge, DockPlacement, Group, Layout, Location, Node, PanelState, Permissions, SplitSize, Target, Workspace,
|
||||
};
|
||||
use craft::behavior::{Axis, DockSide, IconId};
|
||||
use craft::keymap::CommandRef;
|
||||
use craft::ui::buttons::IconButton;
|
||||
@@ -242,7 +244,10 @@ fn edge_name(edge: Option<DockEdge>) -> &'static str {
|
||||
|
||||
/// The side panel that is open, if any.
|
||||
fn open_side(workspace: &Workspace<PanelId>) -> Option<PanelId> {
|
||||
SIDE.into_iter().find(|panel| workspace.layout.contains(panel))
|
||||
// The side panels share a group: the open one is its front tab. A minimized or collapsed group
|
||||
// shows none in front, and then the first one open stands for it.
|
||||
let layout = &workspace.layout;
|
||||
SIDE.into_iter().find(|panel| layout.panel_state(panel) == PanelState::Front).or_else(|| SIDE.into_iter().find(|panel| layout.contains(panel)))
|
||||
}
|
||||
|
||||
/// The tab label of a side panel: its name, and the count of what it lists where it has one.
|
||||
@@ -473,7 +478,7 @@ fn show_panel(app: &mut PdfCraftApp, panel: PanelId, visible: bool) -> Result<()
|
||||
|
||||
/// The side panel `workspace` has open, `None` when every side panel is closed.
|
||||
pub(crate) fn right_of(workspace: &Workspace<PanelId>) -> Option<RightPanel> {
|
||||
SIDE.iter().find(|panel| workspace.layout.contains(panel)).and_then(|panel| panel.side())
|
||||
open_side(workspace).and_then(PanelId::side)
|
||||
}
|
||||
|
||||
/// Opens or closes `panel`, telling the user when the dock refuses.
|
||||
|
||||
@@ -50,7 +50,8 @@ fn side(h: &mut Harness<'static, PdfCraftApp>, key: &str) -> String {
|
||||
|
||||
/// The side panel the workspace has open, as `ui.state` reports it (`side_panel`).
|
||||
pub(crate) fn right(app: &PdfCraftApp) -> Option<RightPanel> {
|
||||
use pdfcraft_ui_egui::side_panels::PanelId;
|
||||
let state = pdfcraft_ui_egui::side_panels::state(app);
|
||||
let open = state["side_panel"].as_str()?;
|
||||
[
|
||||
RightPanel::Comments,
|
||||
RightPanel::Bookmarks,
|
||||
@@ -65,7 +66,7 @@ pub(crate) fn right(app: &PdfCraftApp) -> Option<RightPanel> {
|
||||
RightPanel::Compare,
|
||||
]
|
||||
.into_iter()
|
||||
.find(|panel| app.dock.layout.contains(&PanelId::from(*panel)))
|
||||
.find(|panel| format!("{panel:?}") == open)
|
||||
}
|
||||
|
||||
/// Runs the command `id` as the app's own command entry does, with the harness's context.
|
||||
|
||||
Reference in New Issue
Block a user